File tree 3 files changed +18
-36
lines changed
3 files changed +18
-36
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ extension AuthenticatorData {
36
36
37
37
let relyingPartyIDHash = Array ( bytes [ ..< 32 ] )
38
38
let flags = AuthenticatorFlags ( bytes [ 32 ] )
39
- let counter : UInt32 = Data ( bytes [ 33 ..< 37 ] ) . toInteger ( endian : . big )
39
+ let counter = UInt32 ( bigEndianBytes : bytes [ 33 ..< 37 ] )
40
40
41
41
var remainingCount = bytes. count - minAuthDataLength
42
42
@@ -90,7 +90,7 @@ extension AuthenticatorData {
90
90
/// **credentialIdLength** (2): Byte length L of credentialId, 16-bit unsigned big-endian integer. Value MUST be ≤ 1023.
91
91
let idLengthBytes = data [ 53 ..< 55 ] // Length is 2 bytes
92
92
let idLengthData = Data ( idLengthBytes)
93
- let idLength : UInt16 = idLengthData . toInteger ( endian : . big )
93
+ let idLength = UInt16 ( bigEndianBytes : idLengthData )
94
94
95
95
guard idLength <= 1023
96
96
else { throw WebAuthnError . credentialIDTooLong }
Original file line number Diff line number Diff line change @@ -31,3 +31,19 @@ extension BidirectionalCollection where Element == UInt8 {
31
31
return result
32
32
}
33
33
}
34
+
35
+ extension FixedWidthInteger {
36
+ /// Initialize a fixed width integer from a contiguous sequence of Bytes representing a big endian type.
37
+ /// - Parameter bigEndianBytes: The Bytes to interpret as a big endian integer.
38
+ @inlinable
39
+ init ( bigEndianBytes: some BidirectionalCollection < UInt8 > ) {
40
+ self . init ( bigEndian: bigEndianBytes. casting ( ) )
41
+ }
42
+
43
+ /// Initialize a fixed width integer from a contiguous sequence of Bytes representing a little endian type.
44
+ /// - Parameter bigEndianBytes: The Bytes to interpret as a little endian integer.
45
+ @inlinable
46
+ init ( littleEndianBytes: some BidirectionalCollection < UInt8 > ) {
47
+ self . init ( littleEndian: littleEndianBytes. casting ( ) )
48
+ }
49
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments