1.1 --- a/MYCryptor.h Sat Apr 04 20:42:03 2009 -0700
1.2 +++ b/MYCryptor.h Sat Apr 04 22:56:13 2009 -0700
1.3 @@ -10,9 +10,12 @@
1.4 #import <CommonCrypto/CommonCryptor.h>
1.5
1.6
1.7 -/** Symmetric encryption: a Cocoa wrapper for CommonCrypto/commonCryptor.h */
1.8 +/** Symmetric encryption: a simple Cocoa wrapper for CommonCrypto/commonCryptor.h.
1.9 + Provides a streaming interface for encrypting/decrypting data.
1.10 + This class will probably be merged into or integrated with MYSymmetricKey. */
1.11 @interface MYCryptor : NSObject
1.12 {
1.13 + @private
1.14 NSData *_key;
1.15 CCOperation _operation;
1.16 CCAlgorithm _algorithm;
1.17 @@ -24,9 +27,11 @@
1.18 size_t _outputExtraBytes;
1.19 }
1.20
1.21 -/** CommonCryptor.h defines key size and size-range constants, like kCCKeySizeAES128 */
1.22 +/** Returns a block of cryptographically-random data, suitable for use as a symmetric key.
1.23 + (CommonCryptor.h defines constants for key sizes and size-ranges, like kCCKeySizeAES128.) */
1.24 + (NSData*) randomKeyOfLength: (size_t)length;
1.25
1.26 +/** Converts a passphrase into a block of data of the given size, suitable for use as a symmetric key. */
1.27 + (NSData*) keyOfLength: (size_t)lengthInBits fromPassphrase: (NSString*)passphrase;
1.28
1.29 /** Creates a MYCryptor configured to encrypt data. */
1.30 @@ -37,22 +42,23 @@
1.31 - (id) initDecryptorWithKey: (NSData*)key
1.32 algorithm: (CCAlgorithm)algorithm;
1.33
1.34 -/** Setting this property tells the cryptor to send its output to the stream,
1.35 - instead of accumulating itself in the outputData property. */
1.36 -@property (retain) NSOutputStream *outputStream;
1.37 -
1.38 /** The encryption/decryption key; same as the 'key' parameter to the initializer. */
1.39 @property (readonly) NSData *key;
1.40
1.41 /** The cipher to use; initial value is the 'algorithm' parameter to the initializer.
1.42 - You can change this before the first call to -addData:, but not after. */
1.43 + You can change this <i>before</i> the first call to -addData:, but not after. */
1.44 @property CCAlgorithm algorithm;
1.45
1.46 /** Block-mode cipher options; you can set flags to enable PKCS7 padding or ECB mode
1.47 (default is CBC.)
1.48 - You can change this before the first call to -addData:, but not after. */
1.49 + You can change this <i>before</i> the first call to -addData:, but not after. */
1.50 @property CCOptions options;
1.51
1.52 +/** Setting this property tells the cryptor to send its output to the stream,
1.53 + instead of accumulating it in the outputData property.
1.54 + You can change this <i>before</i> the first call to -addData:, but not after. */
1.55 +@property (retain) NSOutputStream *outputStream;
1.56 +
1.57 /** The error state, if any, of this cryptor.
1.58 After -addData: or -finish: returns NO, check this property. */
1.59 @property (readonly, retain) NSError *error;