Caligatio / jsSHA

A JavaScript/TypeScript implementation of the complete Secure Hash Standard (SHA) family (SHA-1, SHA-224/256/384/512, SHA3-224/256/384/512, SHAKE128/256, cSHAKE128/256, and KMAC128/256) with HMAC.

Home Page:https://caligatio.github.io/jsSHA/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setHMACKey with B64

TitusInfo opened this issue · comments

When running SHA.js in server-side classic ASP, there is a problem converting the HMACKey from Base-64, which causes an incorrect HMAC to be generated. The line
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(q[f]);
should be:
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(q.charAt(f));

This is an easy enough fix but I'm shocked this hasn't cropped up in the last decade. Do you have an easy to repeat example of it breaking?

Can you try the sha.js in dceb277?

Completely understand. I realize it doesn't help much now but src_dev.js is the plaintext version which gets "compressed" into sha.js