Updated the README for the 0.1 release.
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 /** The key's raw data. */
34 @property (readonly) NSData *keyData;
36 /** The user-visible name (kSecKeyPrintName) associated with this key in the Keychain.
37 The user can edit this, so don't expect it to be immutable. */
38 @property (copy) NSString *name;
40 /** An application-specific string (kSecKeyAlias) associated with this key in the Keychain.
41 Not visible to or editable by the user.
42 If you own this key, you can store any associated metadata you like here, although be aware
43 that it can be read and modified by any other app that can access this key. */
44 @property (copy) NSString *alias;
48 * Functionality not available on iPhone.
53 /** The user-visible comment (kSecKeyApplicationTag) associated with this key in the Keychain.
54 The user can edit this, so don't expect it to be immutable. */
55 @property (copy) NSString *comment;
57 /** Converts the key into a data blob in one of several standard formats, suitable for storing in
58 a file or sending over the network.
59 @param format The data format: kSecFormatOpenSSL, kSecFormatSSH, kSecFormatBSAFE or kSecFormatSSHv2.
60 @param withPEM YES if the data should be encoded in PEM format, which converts into short lines
61 of printable ASCII characters, suitable for sending in email. */
62 - (NSData*) exportKeyInFormat: (SecExternalFormat)format withPEM: (BOOL)withPEM;
73 /** Creates a MYKey object for an existing Keychain key reference.
74 This is abstract -- must be called on a MYSymmetricKey or MYPublicKey, as appropriate. */
75 - (id) initWithKeyRef: (SecKeyRef)keyRef;
77 /** The Keychain object reference for this key. */
78 @property (readonly) SecKeyRef keyRef;
81 /** The underlying CSSM_KEY structure; used with low-level crypto APIs. */
82 @property (readonly) const struct cssm_key* cssmKey;
84 /** The underlying CSSM_CSP_HANDLE structure; used with low-level crypto APIs. */
85 @property (readonly) intptr_t /*CSSM_CSP_HANDLE*/ cssmCSPHandle;
87 /** Gets CSSM authorization credentials for a specified operation, such as
88 CSSM_ACL_AUTHORIZATION_ENCRYPT. This pointer is necessary for creating some CSSM operation
90 @param operation The type of operation you are going to perform (see the enum values in
92 @param type Specifies whether the operation should be allowed to present a UI. You'll usually
93 want to pass kSecCredentialTypeDefault.
94 @param outError Will be set to point to an NSError on failure, or nil on success.
95 Pass nil if you don't care about the specific error.
96 @return The access credentials, or NULL on failure.
97 This pointer is valid for as long as you have a reference
98 to the key object. Do not free or delete it. */
99 - (const CSSM_ACCESS_CREDENTIALS*) cssmCredentialsForOperation: (CSSM_ACL_AUTHORIZATION_TAG)operation
100 type: (SecCredentialType)type
101 error: (NSError**)outError;