Skip to content

Commit

Permalink
Specify kSecUseDataProtectionKeychain when generating RSA/ECC keys
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed May 18, 2021
1 parent 4e4b8bf commit 1074e56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ int32_t AppleCryptoNative_EccGenerateKey(int32_t keySizeBits,
{
CFDictionaryAddValue(attributes, kSecAttrKeyType, kSecAttrKeyTypeEC);
CFDictionaryAddValue(attributes, kSecAttrKeySizeInBits, cfKeySizeValue);
if (__builtin_available(macOS 10.15, iOS 13, tvOS 13, *))
{
CFDictionaryAddValue(attributes, kSecUseDataProtectionKeychain, kCFBooleanTrue);
}

*pPrivateKey = SecKeyCreateRandomKey(attributes, pErrorOut);
if (*pPrivateKey != NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ int32_t AppleCryptoNative_RsaGenerateKey(int32_t keySizeBits,
{
CFDictionaryAddValue(attributes, kSecAttrKeyType, kSecAttrKeyTypeRSA);
CFDictionaryAddValue(attributes, kSecAttrKeySizeInBits, cfKeySizeValue);
if (__builtin_available(macOS 10.15, iOS 13, tvOS 13, *))
{
CFDictionaryAddValue(attributes, kSecUseDataProtectionKeychain, kCFBooleanTrue);
}

*pPrivateKey = SecKeyCreateRandomKey(attributes, pErrorOut);
if (*pPrivateKey != NULL)
Expand Down

0 comments on commit 1074e56

Please sign in to comment.