diff options
-rw-r--r-- | doc/relnotes/1_11_15.rst | 4 | ||||
-rw-r--r-- | src/lib/asn1/alg_id.cpp | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/doc/relnotes/1_11_15.rst b/doc/relnotes/1_11_15.rst index 4c47785df..a0937deb2 100644 --- a/doc/relnotes/1_11_15.rst +++ b/doc/relnotes/1_11_15.rst @@ -3,3 +3,7 @@ Version 1.11.15, Not Yet Released * A bug in ffi.cpp meant Python could only encrypt. Github issue 53. +* When comparing two ASN.1 algorithm identifiers, consider empty and + NULL parameters the same. + +* Fix compilation problem on OS X diff --git a/src/lib/asn1/alg_id.cpp b/src/lib/asn1/alg_id.cpp index 8e6651d52..7d476a225 100644 --- a/src/lib/asn1/alg_id.cpp +++ b/src/lib/asn1/alg_id.cpp @@ -63,13 +63,27 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, /* * Compare two AlgorithmIdentifiers */ +namespace { + +bool param_null_or_empty(const std::vector<byte>& p) + { + if(p.size() == 2 && (p[0] == 0x05) && (p[1] == 0x00)) + return true; + return p.empty(); + } + +} + bool operator==(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2) { if(a1.oid != a2.oid) return false; - if(a1.parameters != a2.parameters) - return false; - return true; + + if(param_null_or_empty(a1.parameters) && + param_null_or_empty(a2.parameters)) + return true; + + return (a1.parameters == a2.parameters); } /* |