Skip to content

Commit 6d016d2

Browse files
Replaced uses of CredentialPublicKey Data with [UInt8]
1 parent 096c80d commit 6d016d2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Sources/WebAuthn/Ceremonies/Shared/CredentialPublicKey.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ enum CredentialPublicKey {
5050
self = .ec2(EC2PublicKey(
5151
algorithm: .algES256,
5252
curve: .p256,
53-
xCoordinate: Data(Array(publicKeyBytes[1...33])),
54-
yCoordinate: Data(Array(publicKeyBytes[33...65]))
53+
xCoordinate: Array(publicKeyBytes[1...33]),
54+
yCoordinate: Array(publicKeyBytes[33...65])
5555
))
5656
return
5757
}
@@ -96,13 +96,13 @@ struct EC2PublicKey: PublicKey {
9696
/// The curve on which we derive the signature from.
9797
let curve: COSECurve
9898
/// A byte string 32 bytes in length that holds the x coordinate of the key.
99-
let xCoordinate: Data
99+
let xCoordinate: [UInt8]
100100
/// A byte string 32 bytes in length that holds the y coordinate of the key.
101-
let yCoordinate: Data
101+
let yCoordinate: [UInt8]
102102

103-
var rawRepresentation: Data { xCoordinate + yCoordinate }
103+
var rawRepresentation: [UInt8] { xCoordinate + yCoordinate }
104104

105-
init(algorithm: COSEAlgorithmIdentifier, curve: COSECurve, xCoordinate: Data, yCoordinate: Data) {
105+
init(algorithm: COSEAlgorithmIdentifier, curve: COSECurve, xCoordinate: [UInt8], yCoordinate: [UInt8]) {
106106
self.algorithm = algorithm
107107
self.curve = curve
108108
self.xCoordinate = xCoordinate
@@ -126,12 +126,12 @@ struct EC2PublicKey: PublicKey {
126126
case let .byteString(xCoordinateBytes) = xCoordRaw else {
127127
throw WebAuthnError.invalidXCoordinate
128128
}
129-
xCoordinate = Data(xCoordinateBytes)
129+
xCoordinate = xCoordinateBytes
130130
guard let yCoordRaw = publicKeyObject[COSEKey.y.cbor],
131131
case let .byteString(yCoordinateBytes) = yCoordRaw else {
132132
throw WebAuthnError.invalidYCoordinate
133133
}
134-
yCoordinate = Data(yCoordinateBytes)
134+
yCoordinate = yCoordinateBytes
135135
}
136136

137137
func verify(signature: some DataProtocol, data: some DataProtocol) throws {
@@ -162,11 +162,11 @@ struct EC2PublicKey: PublicKey {
162162
struct RSAPublicKeyData: PublicKey {
163163
let algorithm: COSEAlgorithmIdentifier
164164
// swiftlint:disable:next identifier_name
165-
let n: Data
165+
let n: [UInt8]
166166
// swiftlint:disable:next identifier_name
167-
let e: Data
167+
let e: [UInt8]
168168

169-
var rawRepresentation: Data { n + e }
169+
var rawRepresentation: [UInt8] { n + e }
170170

171171
init(publicKeyObject: CBOR, algorithm: COSEAlgorithmIdentifier) throws {
172172
self.algorithm = algorithm
@@ -175,13 +175,13 @@ struct RSAPublicKeyData: PublicKey {
175175
case let .byteString(nBytes) = nRaw else {
176176
throw WebAuthnError.invalidModulus
177177
}
178-
n = Data(nBytes)
178+
n = nBytes
179179

180180
guard let eRaw = publicKeyObject[COSEKey.e.cbor],
181181
case let .byteString(eBytes) = eRaw else {
182182
throw WebAuthnError.invalidExponent
183183
}
184-
e = Data(eBytes)
184+
e = eBytes
185185
}
186186

187187
func verify(signature: some DataProtocol, data: some DataProtocol) throws {

0 commit comments

Comments
 (0)