Skip to content

Commit

Permalink
fix: have a better error thrown if key format not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
beatt83 committed Dec 7, 2024
1 parent afb3128 commit 9a78a8a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ extension AES256GCM: KeyWrapping {
using: JWK,
arguments: [KeyEncryptionArguments]
) throws -> KeyEncriptionResultMetadata {
guard using.keyType == .octetSequence else {
throw CryptoError.keyFormatNotSupported(format: using.keyType.rawValue, supportedFormats: [JWK.KeyType.octetSequence.rawValue])
}
guard let key = using.key else {
throw CryptoError.missingArguments([])
throw CryptoError.missingArguments(["JWK.Key"])
}

let initializationVector = try arguments.initializationVector ?? generateInitializationVector()
Expand Down

0 comments on commit 9a78a8a

Please sign in to comment.