diff --git a/puer.c b/puer.c index 6bc3ec5..eb748d3 100644 --- a/puer.c +++ b/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; +}