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.43k stars 151 forks source link

Use `SecKeyGetBlockSize` instead of `kSecAttrKeySizeInBits` #198

Closed dnadoba closed 10 months ago

dnadoba commented 10 months 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 10 months ago

@swift-server-bot add to allowlist