Skip to content
Draft
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
25 changes: 25 additions & 0 deletions Sources/_CryptoExtras/Util/CryptoKitErrors_boring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@ extension CryptoKitError {
return .underlyingCoreCryptoError(error: Int32(bitPattern: CCryptoBoringSSL_ERR_get_error()))
}
}

extension CryptoKitError {
public var description: String {
switch self {
case .underlyingCoreCryptoError(error: let error):
let errorCode = UInt32(bitPattern: error)
let lib = String(cString: CCryptoBoringSSL_ERR_lib_error_string(errorCode))
let reason = String(cString: CCryptoBoringSSL_ERR_reason_error_string(errorCode))
return "lib: \(lib), reason: \(reason), code: \(errorCode)"
case .incorrectKeySize: return "incorrectKeySize"
case .incorrectParameterSize: return "incorrectParameterSize"
case .authenticationFailure: return "authenticationFailure"
case .wrapFailure: return "wrapFailure"
case .unwrapFailure: return "unwrapFailure"
case .invalidParameter: return "invalidParameter"
@unknown default: return "unknown"
}
}
}

#if hasAttribute(retroactive)
extension CryptoKitError: @retroactive CustomStringConvertible {}
#else
extension CryptoKitError: CustomStringConvertible {}
#endif