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) */
| 77 | * |
| 78 | * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */ |
| 79 | void xorDigest(unsigned char *digest, void *ptr, size_t len) { |
| 80 | SHA1_CTX ctx; |
| 81 | unsigned char hash[20], *s = ptr; |
| 82 | int j; |
| 83 | |
| 84 | SHA1Init(&ctx); |
| 85 | SHA1Update(&ctx,s,len); |
| 86 | SHA1Final(hash,&ctx); |
| 87 | |
| 88 | for (j = 0; j < 20; j++) |
| 89 | digest[j] ^= hash[j]; |
| 90 | } |
| 91 | |
| 92 | void xorStringObjectDigest(unsigned char *digest, robj *o) { |
| 93 | o = getDecodedObject(o); |
no test coverage detected