+ *privateKey = privItem->handle();
+
+ END_SECAPI
+}
+
+OSStatus
+SecKeyGenerate(
+ SecKeychainRef keychainRef,
+ CSSM_ALGORITHMS algorithm,
+ uint32 keySizeInBits,
+ CSSM_CC_HANDLE contextHandle,
+ CSSM_KEYUSE keyUsage,
+ uint32 keyAttr,
+ SecAccessRef initialAccess,
+ SecKeyRef* keyRef)
+{
+ BEGIN_SECAPI
+
+ Keychain keychain;
+ SecPointer<Access> theAccess;
+
+ if (keychainRef)
+ keychain = KeychainImpl::required(keychainRef);
+ if (initialAccess)
+ theAccess = Access::required(initialAccess);
+
+ KeyItem *item = KeyItem::generate(keychain,
+ algorithm,
+ keySizeInBits,
+ contextHandle,
+ keyUsage,
+ keyAttr,
+ theAccess);
+
+ // Return the generated key.
+ if (keyRef)
+ *keyRef = item->handle();
+
+ END_SECAPI
+}
+
+
+OSStatus SecKeyCreate(const CSSM_KEY *cssmKey,
+ SecKeyRef* keyRef)
+{
+ BEGIN_SECAPI
+
+ Required(cssmKey);
+ CssmClient::CSP csp(cssmKey->KeyHeader.CspId);
+ CssmClient::Key key(csp, *cssmKey);
+ KeyItem *item = new KeyItem(key);
+
+ // Return the generated key.
+ if (keyRef)
+ *keyRef = item->handle();