diff --git a/content.js b/content.js index 02a8128..539a809 100644 --- a/content.js +++ b/content.js @@ -146,7 +146,7 @@ if (window.location.href.startsWith("https://www.purdue.edu/apps/account/cas/log localStorage.removeItem("pin"); localStorage.removeItem("code"); localStorage.removeItem("username"); - localStorage.removeItem("count"); + localStorage.removeItem("counter"); localStorage.removeItem("hotpSecret"); //Get the user's info to setup a new BoilerKey askForInfo(); @@ -156,7 +156,7 @@ if (window.location.href.startsWith("https://www.purdue.edu/apps/account/cas/log localStorage.removeItem("pin"); localStorage.removeItem("code"); localStorage.removeItem("username"); - localStorage.removeItem("count"); + localStorage.removeItem("counter"); localStorage.removeItem("hotpSecret"); //Get the user's info to setup a new BoilerKey askForInfo(); diff --git a/jsOTP.js b/jsOTP.js index 33783e6..f14f2b2 100644 --- a/jsOTP.js +++ b/jsOTP.js @@ -94,10 +94,11 @@ } getOtp(key, counter) { - var digest, h, offset, shaObj, v; - shaObj = new jsSHA("SHA-1", "TEXT"); + var digest, h, offset, shaObj, v, counterString; + shaObj = new jsSHA("SHA-1", "HEX"); shaObj.setHMACKey(key, "TEXT"); - shaObj.update(this.uintToString(new Uint8Array(this.intToBytes(counter)))); + counterString = ("0000000000000000" + counter.toString(16)).slice(-16); // padded hex counter value + shaObj.update(counterString); digest = shaObj.getHMAC("HEX"); // Get byte array h = this.hexToBytes(digest);