File tree Expand file tree Collapse file tree 4 files changed +18
-54
lines changed
Expand file tree Collapse file tree 4 files changed +18
-54
lines changed Original file line number Diff line number Diff line change 2323 "@types/argon2-browser" : " ^1.6.0" ,
2424 "@types/chrome" : " ^0.0.86" ,
2525 "@types/crypto-js" : " ^3.1.43" ,
26- "@types/jssha" : " 2.0.0" ,
2726 "@types/uuid" : " ^3.4.5" ,
2827 "base64-loader" : " ^1.0.0" ,
2928 "fork-ts-checker-webpack-plugin" : " ^1.3.5" ,
4241 "dependencies" : {
4342 "argon2-browser" : " ^1.12.0" ,
4443 "crypto-js" : " ^3.1.9-1" ,
45- "jssha" : " ^2.3.1" ,
4644 "qrcode-generator" : " ^1.4.3" ,
4745 "qrcode-reader" : " ^1.0.4" ,
4846 "uuid" : " ^3.3.3" ,
Original file line number Diff line number Diff line change 1- import * as jsSHA from "jssha" ;
21import { OTPType } from "./otp" ;
2+ import * as CryptoJS from "crypto-js" ;
33
44// Originally based on the JavaScript implementation as provided by Russell
55// Sayers on his Tin Isles blog:
@@ -145,16 +145,14 @@ export class KeyUtilities {
145145 }
146146 }
147147
148- // external library for SHA functionality
149- const hmacObj = new jsSHA ( "SHA-1" , "HEX" ) ;
150- hmacObj . setHMACKey ( key , "HEX" ) ;
151- hmacObj . update ( time ) ;
152- const hmac = hmacObj . getHMAC ( "HEX" ) ;
148+ const hmacObj = CryptoJS . HmacSHA1 (
149+ CryptoJS . enc . Hex . parse ( time ) ,
150+ CryptoJS . enc . Hex . parse ( key )
151+ ) ;
152+ const hmac = CryptoJS . enc . Hex . stringify ( hmacObj ) ;
153153
154154 let offset = 0 ;
155- if ( hmac !== "KEY MUST BE IN BYTE INCREMENTS" ) {
156- offset = this . hex2dec ( hmac . substring ( hmac . length - 1 ) ) ;
157- }
155+ offset = this . hex2dec ( hmac . substring ( hmac . length - 1 ) ) ;
158156
159157 let otp =
160158 ( this . hex2dec ( hmac . substr ( offset * 2 , 8 ) ) & this . hex2dec ( "7fffffff" ) ) +
Original file line number Diff line number Diff line change @@ -141,9 +141,7 @@ export class OTPEntry implements IOTPEntry {
141141 }
142142
143143 genUUID ( ) {
144- // await this.delete();
145144 this . hash = uuid ( ) ;
146- // await this.create();
147145 }
148146
149147 generate ( ) {
You can’t perform that action at this time.
0 commit comments