MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / mixDigest

Function mixDigest

src/debug.cpp:126–134  ·  view source on GitHub ↗

This function instead of just computing the SHA1 and xoring it * against digest, also perform the digest of "digest" itself and * replace the old value with the new one. * * So the final digest will be: * * digest = SHA1(digest xor SHA1(data)) * * This function is used every time we want to preserve the order so * that digest(a,b,c,d) will be different than digest(b,c,d,a) * * Also note

Source from the content-addressed store, hash-verified

124 * will lead to a different digest compared to "fo", "obar".
125 */
126void mixDigest(unsigned char *digest, const void *ptr, size_t len) {
127 SHA1_CTX ctx;
128 const char *s = (const char*)ptr;
129
130 xorDigest(digest,s,len);
131 SHA1Init(&ctx);
132 SHA1Update(&ctx,digest,20);
133 SHA1Final(digest,&ctx);
134}
135
136void mixStringObjectDigest(unsigned char *digest, robj_roptr o) {
137 o = getDecodedObject(o);

Callers 5

mixStringObjectDigestFunction · 0.85
xorObjectDigestFunction · 0.85
computeDatasetDigestFunction · 0.85
RM_DigestAddStringBufferFunction · 0.85
RM_DigestAddLongLongFunction · 0.85

Calls 4

xorDigestFunction · 0.85
SHA1InitFunction · 0.85
SHA1UpdateFunction · 0.85
SHA1FinalFunction · 0.85

Tested by

no test coverage detected