Factored out the name accessors of MYParsedCertificate into a new class MYCertificateName, so that both subject and issuer can be accessed. A bit of other cleanup too.
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
33 /** Creates a key from encoded data (but does not add it to any keychain.) */
34 - (id) initWithKeyData: (NSData*)data;
36 /** The key's raw data. */
37 @property (readonly) NSData *keyData;
39 /** The user-visible name (kSecKeyPrintName) associated with this key in the Keychain.
40 The user can edit this, so don't expect it to be immutable. */
41 @property (copy) NSString *name;
43 /** An application-specific string (kSecKeyAlias) associated with this key in the Keychain.
44 Not visible to or editable by the user.
45 If you own this key, you can store any associated metadata you like here, although be aware
46 that it can be read and modified by any other app that can access this key. */
47 @property (copy) NSString *alias;
51 * Functionality not available on iPhone.
56 /** The user-visible comment (kSecKeyApplicationTag) associated with this key in the Keychain.
57 The user can edit this, so don't expect it to be immutable. */
58 @property (copy) NSString *comment;
69 /** Creates a MYKey object for an existing Keychain key reference.
70 This is abstract -- must be called on a MYSymmetricKey or MYPublicKey, as appropriate. */
71 - (id) initWithKeyRef: (SecKeyRef)keyRef;
73 /** The Keychain object reference for this key. */
74 @property (readonly) SecKeyRef keyRef;
77 /** The underlying CSSM_KEY structure; used with low-level crypto APIs. */
78 @property (readonly) const struct cssm_key* cssmKey;
80 /** The underlying CSSM_CSP_HANDLE structure; used with low-level crypto APIs. */
81 @property (readonly) intptr_t /*CSSM_CSP_HANDLE*/ cssmCSPHandle;
83 @property (readonly) CSSM_ALGORITHMS cssmAlgorithm;
85 /** Gets CSSM authorization credentials for a specified operation, such as
86 CSSM_ACL_AUTHORIZATION_ENCRYPT. This pointer is necessary for creating some CSSM operation
88 @param operation The type of operation you are going to perform (see the enum values in
90 @param type Specifies whether the operation should be allowed to present a UI. You'll usually
91 want to pass kSecCredentialTypeDefault.
92 @param outError Will be set to point to an NSError on failure, or nil on success.
93 Pass nil if you don't care about the specific error.
94 @return The access credentials, or NULL on failure.
95 This pointer is valid for as long as you have a reference
96 to the key object. Do not free or delete it. */
97 - (const CSSM_ACCESS_CREDENTIALS*) cssmCredentialsForOperation: (CSSM_ACL_AUTHORIZATION_TAG)operation
98 type: (SecCredentialType)type
99 error: (NSError**)outError;