Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Pull Request

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches: [main]

jobs:
unit-tests:
Expand Down
4 changes: 2 additions & 2 deletions Sources/WebAuthn/Ceremonies/Shared/AuthenticatorData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension AuthenticatorData {

let relyingPartyIDHash = Array(bytes[..<32])
let flags = AuthenticatorFlags(bytes[32])
let counter: UInt32 = Data(bytes[33..<37]).toInteger(endian: .big)
let counter = UInt32(bigEndianBytes: bytes[33..<37])

var remainingCount = bytes.count - minAuthDataLength

Expand Down Expand Up @@ -90,7 +90,7 @@ extension AuthenticatorData {
/// **credentialIdLength** (2): Byte length L of credentialId, 16-bit unsigned big-endian integer. Value MUST be ≤ 1023.
let idLengthBytes = data[53..<55] // Length is 2 bytes
let idLengthData = Data(idLengthBytes)
let idLength: UInt16 = idLengthData.toInteger(endian: .big)
let idLength = UInt16(bigEndianBytes: idLengthData)

guard idLength <= 1023
else { throw WebAuthnError.credentialIDTooLong }
Expand Down
16 changes: 16 additions & 0 deletions Sources/WebAuthn/Helpers/ByteCasting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ extension BidirectionalCollection where Element == UInt8 {
return result
}
}

extension FixedWidthInteger {
/// Initialize a fixed width integer from a contiguous sequence of Bytes representing a big endian type.
/// - Parameter bigEndianBytes: The Bytes to interpret as a big endian integer.
@inlinable
init(bigEndianBytes: some BidirectionalCollection<UInt8>) {
self.init(bigEndian: bigEndianBytes.casting())
}

/// Initialize a fixed width integer from a contiguous sequence of Bytes representing a little endian type.
/// - Parameter bigEndianBytes: The Bytes to interpret as a little endian integer.
@inlinable
init(littleEndianBytes: some BidirectionalCollection<UInt8>) {
self.init(littleEndian: littleEndianBytes.casting())
}
}
34 changes: 0 additions & 34 deletions Sources/WebAuthn/Helpers/Numbers+Bytes.swift

This file was deleted.

Loading