aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pk_keys.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-14 15:45:55 -0500
committerJack Lloyd <[email protected]>2017-12-14 16:07:53 -0500
commit1b6c50860a1cf7776de448f24814f01a700ef2e9 (patch)
tree84ac7840e2bf5fe94d0816cccbfcd7130aec0e6e /src/lib/pubkey/pk_keys.h
parent5c7f3b45198655bd0fae435c428b1f9256610ac5 (diff)
Add ability to fingerprint public keys
Diffstat (limited to 'src/lib/pubkey/pk_keys.h')
-rw-r--r--src/lib/pubkey/pk_keys.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lib/pubkey/pk_keys.h b/src/lib/pubkey/pk_keys.h
index f513cea6c..79254ea29 100644
--- a/src/lib/pubkey/pk_keys.h
+++ b/src/lib/pubkey/pk_keys.h
@@ -85,6 +85,11 @@ class BOTAN_PUBLIC_API(2,0) Public_Key
*/
std::vector<uint8_t> subject_public_key() const;
+ /**
+ * @return Hash of the subject public key
+ */
+ std::string fingerprint_public(const std::string& alg = "SHA-256") const;
+
// Internal or non-public declarations follow
/**
@@ -192,7 +197,13 @@ class BOTAN_PUBLIC_API(2,0) Private_Key : public virtual Public_Key
/**
* @return Hash of the PKCS #8 encoding for this key object
*/
- std::string fingerprint(const std::string& alg = "SHA") const;
+ std::string fingerprint_private(const std::string& alg) const;
+
+ BOTAN_DEPRECATED("Use fingerprint_private or fingerprint_public")
+ inline std::string fingerprint(const std::string& alg) const
+ {
+ return fingerprint_private(alg); // match behavior in previous versions
+ }
/**
* This is an internal library function exposed on key types.
@@ -289,6 +300,18 @@ typedef PK_Key_Agreement_Key PK_KA_Key;
typedef Public_Key X509_PublicKey;
typedef Private_Key PKCS8_PrivateKey;
+std::string BOTAN_PUBLIC_API(2,4)
+ create_hex_fingerprint(const uint8_t bits[], size_t len,
+ const std::string& hash_name);
+
+template<typename Alloc>
+std::string create_hex_fingerprint(const std::vector<uint8_t, Alloc>& vec,
+ const std::string& hash_name)
+ {
+ return create_hex_fingerprint(vec.data(), vec.size(), hash_name);
+ }
+
+
}
#endif