From 1488927e731e46de1bfb783cfa4f8d65d90daa42 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Mon, 30 Sep 2013 11:48:04 +0200 Subject: [PATCH] keyring: use cubehash for KeyID This creates incompatible keyrings, so keyring identifiers now have a version string appended to them. --- src/keyring.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/keyring.cpp b/src/keyring.cpp index 0081960..b087232 100644 --- a/src/keyring.cpp +++ b/src/keyring.cpp @@ -29,7 +29,7 @@ void keyring::clear() * simple fingerprint. */ -#include +#include "cube_hash.h" #include std::string keyring::get_keyid (const std::string&pubkey) @@ -37,12 +37,13 @@ std::string keyring::get_keyid (const std::string&pubkey) static const char hex[] = "0123456789abcdef"; std::string r; - std::vector tmp; - tmp.resize (CryptoPP::SHA256::DIGESTSIZE, 0); - CryptoPP::SHA256().CalculateDigest ( & (tmp[0]), - (const byte*) & (pubkey[0]), - pubkey.length() ); + cube256hash hf; + std::vector tmp = + hf (std::vector + (&pubkey[0], + &pubkey[pubkey.length()]) ); + r.resize (tmp.size() * 2, ' '); for (size_t i = 0; i < tmp.size(); ++i) { r[2 * i] = hex[ (tmp[i] >> 4) & 0xf]; @@ -93,8 +94,8 @@ std::string keyring::get_keyid (const std::string&pubkey) * Serialization stuff first. */ -#define KEYPAIRS_ID "CCR-KEYPAIRS" -#define PUBKEYS_ID "CCR-PUBKEYS" +#define KEYPAIRS_ID "CCR-KEYPAIRS-v2" +#define PUBKEYS_ID "CCR-PUBKEYS-v2" void keyring::clear_keypairs (keypair_storage&pairs) {