MYEncoder Class Reference

Creates a CMS-formatted message from a blob of data; it can be signed and/or encrypted. More...

List of all members.

Public Member Functions

(id) - init
 Initializes a new encoder.
(BOOL) - addSigner:
 Tells the encoder to sign the content with this identity's private key.
(BOOL) - addRecipient:
 Tells the encoder to encrypt the content with this recipient's public key.
(BOOL) - addData:
 Adds data to the encoder.
(NSData *) - encodedData
 The signed/encoded output data.

Static Public Member Functions

(NSData *) + encodeData:signer:recipient:error:
 A convenience method for one-shot encoding of a block of data.

Properties

NSError * error
 The current error status of the encoder.
BOOL hasDetachedContent
 Setting this property to YES tells the encoder not to copy the content itself into the encoded message.

Expert

Advanced methods.



CMSCertificateChainMode certificateChainMode
 Specifies which certificates to include in the message: none, only the signer certs, or the signer certs' entire chain (the default).
CSSM_OID contentType
 The X.509 content type of the message data.
(BOOL) - addTimestamp
 Adds a timestamp showing when the message was encoded.
(BOOL) - addSupportingCert:
 Adds an extra certificate to the encoded data, for the recipient's use.

Detailed Description

Creates a CMS-formatted message from a blob of data; it can be signed and/or encrypted.


Member Function Documentation

- (BOOL) addData: (NSData*)  data  

Adds data to the encoder.

You can add the entire data at once, or in bits and pieces (if you're reading it from a stream).

- (BOOL) addRecipient: (MYCertificate*)  recipient  

Tells the encoder to encrypt the content with this recipient's public key.

Multiple recipients can be added; any one of them will be able to decrypt the message.

- (BOOL) addSigner: (MYIdentity*)  signer  

Tells the encoder to sign the content with this identity's private key.

(Multiple signers can be added, but this is rare.)

- (BOOL) addSupportingCert: (MYCertificate*)  supportingCert  

Adds an extra certificate to the encoded data, for the recipient's use.

Rarely needed.

- (BOOL) addTimestamp  

Adds a timestamp showing when the message was encoded.

[Unfortunately there is no system API for reading these timestamps in decoded messages...]

+ (NSData *) encodeData: (NSData*)  data
signer: (MYIdentity*)  signerOrNil
recipient: (MYCertificate*)  recipientOrNil
error: (NSError**)  outError 

A convenience method for one-shot encoding of a block of data.

Parameters:
data The data that will be signed/encrypted.
signerOrNil If non-nil, an Identity whose private key will sign the data.
recipientOrNil If non-nil, the data will be encrypted so only the owner of this certificate can read it.
outError On return, will be set to an NSError if something went wrong.
Returns:
The encoded data.
- (NSData *) encodedData  

The signed/encoded output data.

Don't call this until after the last call to -addData:.

- (id) init  

Initializes a new encoder.

You must add at least one signer or recipient.


Property Documentation

- (CMSCertificateChainMode) certificateChainMode [read, write, assign]

Specifies which certificates to include in the message: none, only the signer certs, or the signer certs' entire chain (the default).

- (CSSM_OID) contentType [read, write, assign]

The X.509 content type of the message data.

- (NSError *) error [read, assign]

The current error status of the encoder.

If something goes wrong with an operation, it will return NO, and this property will contain the error.

- (BOOL) hasDetachedContent [read, write, assign]

Setting this property to YES tells the encoder not to copy the content itself into the encoded message.

The encodedData property will then contain only metadata, such as signatures and certificates. This is useful if you're working with a data format that already specifies a content format: it allows you to attach the encoded data elsewhere, e.g. in a header or metadata attribute.


The documentation for this class was generated from the following files:
Generated on Sun Apr 17 12:23:58 2011 for MYCrypto by  doxygen 1.6.3