diff options
author | Nuno Goncalves <[email protected]> | 2017-03-05 11:18:27 +0100 |
---|---|---|
committer | Nuno Goncalves <[email protected]> | 2017-04-03 22:39:11 +0200 |
commit | 8e272045fbf58223be5d8cffa2f1592380dd79a7 (patch) | |
tree | b7879adc8c59e12c51a70a703d0bf69be8832c74 /src/lib/x509 | |
parent | b1de0a91c2205349beefa205b36cc89a5ebb274b (diff) |
Refactor find_cert_by_pubkey_sha1 to reuse hash object
Signed-off-by: Nuno Goncalves <[email protected]>
Diffstat (limited to 'src/lib/x509')
-rw-r--r-- | src/lib/x509/certstor.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/x509/certstor.cpp b/src/lib/x509/certstor.cpp index e068baa18..63a5cd645 100644 --- a/src/lib/x509/certstor.cpp +++ b/src/lib/x509/certstor.cpp @@ -71,9 +71,13 @@ Certificate_Store_In_Memory::find_cert_by_pubkey_sha1(const std::vector<uint8_t> if(key_hash.size() != 20) throw Invalid_Argument("Certificate_Store_In_Memory::find_cert_by_pubkey_sha1 invalid hash"); - for(const auto& cert : m_certs) - if(key_hash == cert->subject_public_key_bitstring_sha1()) + std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-1")); + + for(const auto& cert : m_certs){ + hash->update(cert->subject_public_key_bitstring()); + if(key_hash == hash->final_stdvec()) //final_stdvec also clears the hash to initial state return cert; + } return nullptr; } |