Fix the MDC-2 implementation, again
This commit is contained in:
parent
9a0b35609b
commit
c9defbaafe
17
puer.c
17
puer.c
|
@ -138,10 +138,10 @@ void compress_hash(struct hashstate *state) {
|
|||
state->a[3] = w[3];
|
||||
|
||||
// B_{i+1} = W_i^L || V_i^R
|
||||
state->b[0] = v[0];
|
||||
state->b[1] = v[1];
|
||||
state->b[2] = w[2];
|
||||
state->b[3] = w[3];
|
||||
state->b[0] = w[0];
|
||||
state->b[1] = w[1];
|
||||
state->b[2] = v[2];
|
||||
state->b[3] = v[3];
|
||||
|
||||
// Mark that we have consumed the buffer
|
||||
state->length = 0;
|
||||
|
@ -248,3 +248,12 @@ void hmac(unsigned char output[32], unsigned char key[], size_t keylen, unsigned
|
|||
feed_hash(&state, inner_hash, 32);
|
||||
finalize_hash(&state, output);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
unsigned char hashed[32];
|
||||
unsigned char key[] = "12345678901234567899";
|
||||
unsigned char message[] = "barbaz";
|
||||
hmac(hashed, key, sizeof(key)-1, message, sizeof(message)-1);
|
||||
for (size_t i = 0; i < 32; i++) {printf("%02hhx ", hashed[i]);}printf("\n"); //debg
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue