File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ export const incrementLeastSignificantThirtyTwoBits = function (
308308) : Bytes {
309309 const result = block . slice ( )
310310
311- for ( let i = 15 ; i !== 11 ; i -- ) {
311+ for ( let i = 15 ; i > 11 ; i -- ) {
312312 result [ i ] = ( result [ i ] + 1 ) & 0xff // wrap explicitly
313313
314314 if ( result [ i ] !== 0 ) {
@@ -366,10 +366,14 @@ function buildAuthInput (cipherText: Bytes): Bytes {
366366 const aadLenBits = 0
367367 const ctLenBits = cipherText . length * 8
368368
369- const padLen =
370- cipherText . length === 0
371- ? 16
372- : ( cipherText . length % 16 === 0 ? 0 : 16 - ( cipherText . length % 16 ) )
369+ let padLen : number
370+ if ( cipherText . length === 0 ) {
371+ padLen = 16
372+ } else if ( cipherText . length % 16 === 0 ) {
373+ padLen = 0
374+ } else {
375+ padLen = 16 - ( cipherText . length % 16 )
376+ }
373377
374378 const total =
375379 16 +
@@ -393,7 +397,6 @@ function buildAuthInput (cipherText: Bytes): Bytes {
393397
394398 const ctLen = getBytes64 ( ctLenBits )
395399 out . set ( ctLen , offset )
396- offset += 8
397400
398401 return out
399402}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const PURE_HEX_REGEX = /^[0-9a-fA-F]*$/
55
66export function assertValidHex ( msg : string ) : void {
77 if ( typeof msg !== 'string' ) {
8- throw new Error ( 'Invalid hex string' )
8+ throw new TypeError ( 'Invalid hex string' )
99 }
1010
1111 // allow empty
You can’t perform that action at this time.
0 commit comments