Skip to content

Commit

Permalink
Bug 1114703: Remove mozilla::pkix's polyfill for std::bind, r=mmc
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 11457f210c7f7534db2e6ebe1a8328985ff6d8b0
  • Loading branch information
briansmith committed Jan 21, 2015
1 parent c592607 commit 578dcf1
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 338 deletions.
231 changes: 0 additions & 231 deletions lib/mozpkix/include/pkix/bind.h

This file was deleted.

38 changes: 0 additions & 38 deletions lib/mozpkix/lib/pkixbind.cpp

This file was deleted.

14 changes: 7 additions & 7 deletions lib/mozpkix/lib/pkixcert.cpp
Expand Up @@ -22,7 +22,6 @@
* limitations under the License.
*/

#include "pkix/bind.h"
#include "pkixutil.h"

namespace mozilla { namespace pkix {
Expand Down Expand Up @@ -140,9 +139,12 @@ BackCert::Init()
}
}

rv = der::OptionalExtensions(tbsCertificate, CSC | 3,
bind(&BackCert::RememberExtension, *this, _1,
_2, _3, _4));
rv = der::OptionalExtensions(
tbsCertificate, CSC | 3,
[this](Reader& extnID, const Input& extnValue, bool critical,
/*out*/ bool& understood) {
return RememberExtension(extnID, extnValue, critical, understood);
});
if (rv != Success) {
return rv;
}
Expand Down Expand Up @@ -178,10 +180,8 @@ BackCert::Init()
return der::End(tbsCertificate);
}

// XXX: The second value is of type |const Input&| instead of type |Input| due
// to limitations in our std::bind polyfill.
Result
BackCert::RememberExtension(Reader& extnID, const Input& extnValue,
BackCert::RememberExtension(Reader& extnID, Input extnValue,
bool critical, /*out*/ bool& understood)
{
understood = false;
Expand Down
44 changes: 18 additions & 26 deletions lib/mozpkix/lib/pkixcheck.cpp
Expand Up @@ -24,7 +24,6 @@

#include "pkixcheck.h"

#include "pkix/bind.h"
#include "pkixder.h"
#include "pkixutil.h"

Expand Down Expand Up @@ -296,24 +295,6 @@ static const long UNLIMITED_PATH_LEN = -1; // must be less than zero
// BasicConstraints ::= SEQUENCE {
// cA BOOLEAN DEFAULT FALSE,
// pathLenConstraint INTEGER (0..MAX) OPTIONAL }
static Result
DecodeBasicConstraints(Reader& input, /*out*/ bool& isCA,
/*out*/ long& pathLenConstraint)
{
if (der::OptionalBoolean(input, isCA) != Success) {
return Result::ERROR_EXTENSION_VALUE_INVALID;
}

// TODO(bug 985025): If isCA is false, pathLenConstraint MUST NOT
// be included (as per RFC 5280 section 4.2.1.9), but for compatibility
// reasons, we don't check this for now.
if (der::OptionalInteger(input, UNLIMITED_PATH_LEN, pathLenConstraint)
!= Success) {
return Result::ERROR_EXTENSION_VALUE_INVALID;
}

return Success;
}

// RFC5280 4.2.1.9. Basic Constraints (id-ce-basicConstraints)
Result
Expand All @@ -327,9 +308,19 @@ CheckBasicConstraints(EndEntityOrCA endEntityOrCA,

if (encodedBasicConstraints) {
Reader input(*encodedBasicConstraints);
if (der::Nested(input, der::SEQUENCE,
bind(DecodeBasicConstraints, _1, ref(isCA),
ref(pathLenConstraint))) != Success) {
Result rv = der::Nested(input, der::SEQUENCE,
[&isCA, &pathLenConstraint](Reader& r) {
Result rv = der::OptionalBoolean(r, isCA);
if (rv != Success) {
return rv;
}
// TODO(bug 985025): If isCA is false, pathLenConstraint
// MUST NOT be included (as per RFC 5280 section
// 4.2.1.9), but for compatibility reasons, we don't
// check this.
return der::OptionalInteger(r, UNLIMITED_PATH_LEN, pathLenConstraint);
});
if (rv != Success) {
return Result::ERROR_EXTENSION_VALUE_INVALID;
}
if (der::End(input) != Success) {
Expand Down Expand Up @@ -488,10 +479,11 @@ CheckExtendedKeyUsage(EndEntityOrCA endEntityOrCA,
bool found = requiredEKU == KeyPurposeId::anyExtendedKeyUsage;

Reader input(*encodedExtendedKeyUsage);
if (der::NestedOf(input, der::SEQUENCE, der::OIDTag, der::EmptyAllowed::No,
bind(MatchEKU, _1, requiredEKU, endEntityOrCA,
ref(found), ref(foundOCSPSigning)))
!= Success) {
Result rv = der::NestedOf(input, der::SEQUENCE, der::OIDTag,
der::EmptyAllowed::No, [&](Reader& r) {
return MatchEKU(r, requiredEKU, endEntityOrCA, found, foundOCSPSigning);
});
if (rv != Success) {
return Result::ERROR_INADEQUATE_CERT_TYPE;
}
if (der::End(input) != Success) {
Expand Down
1 change: 0 additions & 1 deletion lib/mozpkix/lib/pkixder.cpp
Expand Up @@ -24,7 +24,6 @@

#include "pkixder.h"

#include "pkix/bind.h"
#include "pkixutil.h"

namespace mozilla { namespace pkix { namespace der {
Expand Down

0 comments on commit 578dcf1

Please sign in to comment.