@@ -130,7 +130,7 @@ export class WebAuthnController {
130
130
function convertDEREncodedECDSASignature ( derEncoded : Uint8Array ) : Uint8Array {
131
131
const rStart = 4 ;
132
132
const rLength = derEncoded [ 3 ] ;
133
- const rEnd = rStart + rLength ! ;
133
+ const rEnd = rStart + rLength ;
134
134
const DEREncodedR = derEncoded . slice ( rStart , rEnd ) ;
135
135
// DER encoded 32 bytes integers can have leading 0x00s or be smaller than 32 bytes
136
136
const r = decodeDERInteger ( DEREncodedR , 32 ) ;
@@ -146,13 +146,14 @@ function convertDEREncodedECDSASignature(derEncoded: Uint8Array): Uint8Array {
146
146
}
147
147
148
148
function decodeDERInteger ( integerBytes : Uint8Array , expectedLength : number ) : Uint8Array {
149
- if ( integerBytes . byteLength === expectedLength ) return integerBytes ;
149
+ if ( integerBytes . byteLength === expectedLength ) {
150
+ return integerBytes ;
151
+ }
150
152
if ( integerBytes . byteLength < expectedLength ) {
151
- return concatenateBytes (
152
- // add leading 0x00s if smaller than expected length
153
- new Uint8Array ( expectedLength - integerBytes . byteLength ) . fill ( 0 ) ,
154
- integerBytes
155
- ) ;
153
+ // add leading 0x00s if smaller than expected length
154
+ const result = new Uint8Array ( expectedLength ) ;
155
+ result . set ( integerBytes , expectedLength - integerBytes . byteLength ) ;
156
+ return result ;
156
157
}
157
158
// remove leading 0x00s if larger then expected length
158
159
return integerBytes . slice ( - 32 ) ;
0 commit comments