Fixed iPhone OS build. (issue 3)
5 // Created by Jens Alfke on 3/30/09.
6 // Copyright 2009 Jens Alfke. All rights reserved.
9 #import "MYKeychainItem.h"
12 @protocol MYEncryption <NSObject>
14 /** Encrypts data using this key, returning the raw encrypted result. */
15 - (NSData*) encryptData: (NSData*)data;
19 @protocol MYDecryption <NSObject>
21 /** Decrypts data using this key, returning the original data. */
22 - (NSData*) decryptData: (NSData*)data;
28 /** Abstract superclass for keys.
29 Concrete subclasses are MYSymmetricKey and MYPublicKey. */
30 @interface MYKey : MYKeychainItem
36 /** Creates a key from encoded data (but does not add it to any keychain.) */
37 - (id) initWithKeyData: (NSData*)data;
39 /** The key's raw data. */
40 @property (readonly) NSData *keyData;
42 /** The key's size/length, in bits. */
43 @property (readonly) unsigned keySizeInBits;
45 /** The user-visible name (kSecKeyPrintName) associated with this key in the Keychain.
46 The user can edit this, so don't expect it to be immutable. */
47 @property (copy) NSString *name;
49 /** An application-specific string (kSecKeyAlias) associated with this key in the Keychain.
50 Not visible to or editable by the user.
51 If you own this key, you can store any associated metadata you like here, although be aware
52 that it can be read and modified by any other app that can access this key. */
53 @property (copy) NSString *alias;
57 * Functionality not available on iPhone.
62 /** The user-visible comment (kSecKeyApplicationTag) associated with this key in the Keychain.
63 The user can edit this, so don't expect it to be immutable. */
64 @property (copy) NSString *comment;
75 /** Creates a MYKey object for an existing Keychain key reference.
76 This is abstract -- must be called on a MYSymmetricKey or MYPublicKey, as appropriate. */
77 - (id) initWithKeyRef: (SecKeyRef)keyRef;
79 /** The Keychain object reference for this key. */
80 @property (readonly) SecKeyRef keyRef;
83 /** The underlying CSSM_KEY structure; used with low-level crypto APIs. */
84 @property (readonly) const struct cssm_key* cssmKey;
86 /** The underlying CSSM_CSP_HANDLE structure; used with low-level crypto APIs. */
87 @property (readonly) intptr_t /*CSSM_CSP_HANDLE*/ cssmCSPHandle;
89 @property (readonly) CSSM_ALGORITHMS cssmAlgorithm;
91 /** Gets CSSM authorization credentials for a specified operation, such as
92 CSSM_ACL_AUTHORIZATION_ENCRYPT. This pointer is necessary for creating some CSSM operation
94 @param operation The type of operation you are going to perform (see the enum values in
96 @param type Specifies whether the operation should be allowed to present a UI. You'll usually
97 want to pass kSecCredentialTypeDefault.
98 @param outError Will be set to point to an NSError on failure, or nil on success.
99 Pass nil if you don't care about the specific error.
100 @return The access credentials, or NULL on failure.
101 This pointer is valid for as long as you have a reference
102 to the key object. Do not free or delete it. */
103 - (const CSSM_ACCESS_CREDENTIALS*) cssmCredentialsForOperation: (CSSM_ACL_AUTHORIZATION_TAG)operation
104 type: (SecCredentialType)type
105 error: (NSError**)outError;