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 /src/lib/asn1/alg_id.cpp | |
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.
Diffstat (limited to 'src/lib/asn1/alg_id.cpp')
-rw-r--r-- | src/lib/asn1/alg_id.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
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); } /* |