Compute the sha1 of string at 's' with 'len' bytes long. * The SHA1 is then xored against the string pointed by digest. * Since xor is commutative, this operation is used in order to * "add" digests relative to unordered elements. * * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */
| 90 | * |
| 91 | * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */ |
| 92 | void xorDigest(unsigned char *digest, const void *ptr, size_t len) { |
| 93 | SHA1_CTX ctx; |
| 94 | unsigned char hash[20]; |
| 95 | const unsigned char *s = (const unsigned char*)ptr; |
| 96 | int j; |
| 97 | |
| 98 | SHA1Init(&ctx); |
| 99 | SHA1Update(&ctx,s,len); |
| 100 | SHA1Final(hash,&ctx); |
| 101 | |
| 102 | for (j = 0; j < 20; j++) |
| 103 | digest[j] ^= hash[j]; |
| 104 | } |
| 105 | |
| 106 | void xorStringObjectDigest(unsigned char *digest, robj *o) { |
| 107 | o = getDecodedObject(o); |
no test coverage detected