apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.47k stars 166 forks source link

Use `SecKeyGetBlockSize` instead of `kSecAttrKeySizeInBits` #198

Closed dnadoba closed 1 year ago

dnadoba commented 1 year ago

Checklist

If you've made changes to gyb files

Motivation:

Security.framework has change to return the exact bit count of the key size instead of the block size in bytes in macOS 14 beta and aligned releases. However, BoringSSL and the previous implementation relyed on that. SecKeyCopyAttributes is also rather expensive to call and keySizeInBits is accessed immediately (twice) after initialisation.

Modifications:

call SecKeyGetBlockSize(_:)`` instead of looking up thekSecAttrKeySizeInBits` in the attributes dictionary.

Result:

test pass again and allocations are reduced.

Lukasa commented 1 year ago

@swift-server-bot add to allowlist