diff options
author | lloyd <[email protected]> | 2015-03-04 02:08:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-03-04 02:08:57 +0000 |
commit | fddc2c80dea8f7ad03f85203d818fcc0eb4bcfa7 (patch) | |
tree | ac44fab5b3c5cd4ff85c73aa69a1741829f1159b | |
parent | 3c47ac00c06505fc9748c9f70d9e8456aabc50da (diff) |
When comparing algorithm identifiers consider NULL and empty
parameters as equivalent. Based on a patch sent to the mailing
list by Uri Blumenthal.
-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); } /* |