Post not yet marked as solved
Post marked as unsolved with 3 replies, 226 views
Hi,
I noticed that when running my program as root (using sudo) and calling SecKeyCreateRandomKey, the attribute for hash public key value is wrongly set.
Reading the documentation, hush public key correspond to kSecAttrApplicationLabel.
I tried setting only kSecAttrApplicationTag (or kSecAttrLabel) but it still mess up the hash key value.
Here is my code:
NSDictionary *attributes = @{(id) kSecAttrKeyType: (id)kSecAttrKeyTypeRSA,
(id) kSecAttrKeySizeInBits: [NSNumber numberWithInt:key_size],
(id) kSecAttrApplicationTag: tag_name,
(id) kSecPrivateKeyAttrs: @{
(id) kSecAttrIsPermanent: @YES,
(id) kSecAttrLabel : label_name} };
private_key = SecKeyCreateRandomKey((__bridge CFDictionaryRef)attributes, &error);
I also try save it to keychain with SecItemAdd but it did not help:
NSDictionary* addquery = @{ (id)kSecValueRef: (__bridge id)private_key,
(id)kSecClass: (id)kSecClassKey,
(id)kSecAttrApplicationTag: tag };
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)addquery, NULL);
I verify the value of the public hash value using command - security dump-keychain (looking at 0x00000006 attribute).
Is that a know bug ?
Is there a way to set attributes on a private key after creating it ?
for example, create it with no tag, set a tag and save it using SecItemAdd.
Thanks,
Tal