Skip to content

Commit

Permalink
use HMAC for initialization vectors, for dedupe possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobgorm committed Sep 4, 2018
1 parent 703ccbd commit 015b27a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions block-swap/dubtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,15 @@ int dubtree_insert(DubTree *t, int num_keys, uint64_t* keys,
const uint8_t *v = values;
for (i = 0; i < num_keys; ++i, hash += CRYPTO_TAG_SIZE) {
int size = sizes[i];
RAND_bytes(enc, CRYPTO_IV_SIZE);
#if 0
//RAND_bytes(enc, CRYPTO_IV_SIZE);
//SHA512(v, size, tmp); // XXX use key to make this HMAC
#if 1
uint8_t tmp[512 / 8];
SHA512(v, size, tmp); // XXX use key to make this HMAC
SHA512_CTX ctx;
SHA512_Init(&ctx);
SHA512_Update(&ctx, crypto.key, CRYPTO_KEY_SIZE);
SHA512_Update(&ctx, v, size);
SHA512_Final(tmp, &ctx);
memcpy(enc, tmp, CRYPTO_IV_SIZE);
#endif
sizes[i] = CRYPTO_IV_SIZE + encrypt256(&crypto, enc + CRYPTO_IV_SIZE,
Expand Down

0 comments on commit 015b27a

Please sign in to comment.