


The complexity of the S/MIME format means that the few other toolkits which are available require a high level of programmer knowledge of S/MIME processing issues. In contrast Cryptlib's enveloping interface makes the process as simple as pushing raw data into an envelope and popping the processed data back out, a total of three function calls, plus one more call to add the appropriate encryption or signature key. The code to create an S/MIME signed message is as follows;

CRYPT_ENVELOPE cryptEnvelope; int bytesCopied; cryptCreateEnvelope( &cryptEnvelope, CRYPT_FORMAT_SMIME ); /* Push in the signing key */ cryptSetAttribute( cryptEnvelope, CRYPT_ENVINFO_SIGNATURE, sigKeyContext ); /* Push in the data and pop out the processed data */ cryptPushData( cryptEnvelope, data, dataLength, &bytesCopied ); cryptPushData( cryptEnvelope, NULL, 0, NULL ); cryptPopData( cryptEnvelope, processedData, processedDataBufsize, &bytesCopied ); cryptDestroyEnvelope( cryptEnvelope );
To encrypt instead of signing, change the second function call to:
/* Push in the certificate */ cryptSetAttribute( cryptEnvelope, CRYPT_ENVINFO_PUBLICKEY, certificate );
This is all that is required. Just copy this code directly into your application to S/MIME enable it.
Applications | Architecture | Pricing | Contact Us | Clients | FAQ | References