diff --git a/crypto.c b/crypto.c index 55b57734..692ffc99 100644 --- a/crypto.c +++ b/crypto.c @@ -37,6 +37,8 @@ u8 *hmac_sha256(const u8 *data, unsigned data_len, const char *key, unsigned key return PTR_ERR(shash); } + printk("setkey: %.*s\n", key_len, key); + err = crypto_shash_setkey(shash, key, key_len); if (err < 0) { @@ -49,6 +51,8 @@ u8 *hmac_sha256(const u8 *data, unsigned data_len, const char *key, unsigned key u8 *out = kmalloc(crypto_shash_digestsize(shash), GFP_KERNEL); + printk("data: %.*s\n", data_len, data); + err = crypto_shash_digest(desc, data, data_len, out); if (err < 0) diff --git a/crypto.h b/crypto.h index a7ac8e01..5691e3c0 100644 --- a/crypto.h +++ b/crypto.h @@ -11,6 +11,6 @@ #ifndef crypto_h #define crypto_h -char *hmac_sha256(const char *data, unsigned data_len, const char *key); +char *hmac_sha256(const char *data, unsigned data_len, const char *key, unsigned key_len); #endif diff --git a/jwt.c b/jwt.c index 4f87608f..153974f8 100644 --- a/jwt.c +++ b/jwt.c @@ -112,7 +112,7 @@ jwt_t *jwt_parse(const char *jwt, const char *secret) printk("calculating hash for [%d bytes]: %.*s", payload_end - jwt, payload_end - jwt, jwt); - char *hash = hmac_sha256(jwt, payload_end - jwt, secret); + char *hash = hmac_sha256(jwt, payload_end - jwt, secret, strlen(secret)); if (!hash) { printk(KERN_ERR "failed to calculate hmac");