Post

Replies

Boosts

Views

Activity

Comment on SecKeyCopyExternalRepresentation Fails for Symmetric Key
Thanks, Quinn, for the enlightenment! Creating these random bytes and storing them as a password in the keychain works fine. But for encryption/decryption I need a SecKey. Now when I try to create a SecKey from my byte array (rawKey of type CFData in the following code snippet, size 256 bits): let parameters = NSMutableDictionary() var error: Unmanaged<CFError>? parameters.setValue(kSecAttrKeyClassSymmetric, forKey: kSecAttrKeyClass as String) parameters.setValue(kSecAttrKeyTypeAES, forKey: kSecAttrKeyType as String) key = SecKeyCreateWithData(rawKey, parameters, &error) , I get the error "Unsupported symmetric key type: 2147483649". And with 192 bits and kSecAttrKeyType3DES in place of kSecAttrKeyTypeAES I get "Unsupported symmetric key type: 17". What symmetric key type is then supported by SecKeyCreateWithData? Kind regards, Jakob
May ’22