1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-29 18:33:10 +00:00

keyring: use cubehash for KeyID

This creates incompatible keyrings, so keyring identifiers now have a
version string appended to them.
This commit is contained in:
Mirek Kratochvil 2013-09-30 11:48:04 +02:00
parent 04bbfb49ce
commit 1488927e73

@ -29,7 +29,7 @@ void keyring::clear()
* simple fingerprint. * simple fingerprint.
*/ */
#include <crypto++/sha.h> #include "cube_hash.h"
#include <inttypes.h> #include <inttypes.h>
std::string keyring::get_keyid (const std::string&pubkey) 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"; static const char hex[] = "0123456789abcdef";
std::string r; std::string r;
std::vector<byte> tmp;
tmp.resize (CryptoPP::SHA256::DIGESTSIZE, 0); cube256hash hf;
CryptoPP::SHA256().CalculateDigest ( & (tmp[0]), std::vector<byte> tmp =
(const byte*) & (pubkey[0]), hf (std::vector<byte>
pubkey.length() ); (&pubkey[0],
&pubkey[pubkey.length()]) );
r.resize (tmp.size() * 2, ' '); r.resize (tmp.size() * 2, ' ');
for (size_t i = 0; i < tmp.size(); ++i) { for (size_t i = 0; i < tmp.size(); ++i) {
r[2 * i] = hex[ (tmp[i] >> 4) & 0xf]; r[2 * i] = hex[ (tmp[i] >> 4) & 0xf];
@ -93,8 +94,8 @@ std::string keyring::get_keyid (const std::string&pubkey)
* Serialization stuff first. * Serialization stuff first.
*/ */
#define KEYPAIRS_ID "CCR-KEYPAIRS" #define KEYPAIRS_ID "CCR-KEYPAIRS-v2"
#define PUBKEYS_ID "CCR-PUBKEYS" #define PUBKEYS_ID "CCR-PUBKEYS-v2"
void keyring::clear_keypairs (keypair_storage&pairs) void keyring::clear_keypairs (keypair_storage&pairs)
{ {