swift-crypto icon indicating copy to clipboard operation
swift-crypto copied to clipboard

extras: Add meaningful description to BoringSSL errors

Open simonjbeaumont opened this issue 1 year ago • 3 comments

Motivation

When an error occurs in a BoringSSL call, we typically embed the packed error code in a CryptoKitError.underlyingCoreCryptoError(error: Int32). This packed error code consists of the library and the reason and BoringSSL has functions for unpacking these and getting descriptive messages for them. I often spend my time in a debugger, manually calling these C functions and then looking things up in header files.

Modifications

In _CryptoExtras (not in Crypto) add a (possibly retroactive) conformance to CustomStringConvertible.

Result

If _CryptoExtras is imported, errors will likely be much more informative. For example,

error: "underlyingCoreCryptoError(error: 50331755)"  // before

error: "lib: bignum routines, reason: INPUT_NOT_REDUCED, code: 50331755"  // after

simonjbeaumont avatar Jun 06 '24 15:06 simonjbeaumont