Archived Forum Post

Index of archived forum posts

Question:

CkEmail.AesEncrypt seems to have no effect

Jan 25 '16 at 09:57

Trying to use CkEmail.AesEncrypt method (with password string), and resulting email is not encrypted, although success is returned.

This is using the C++ Linux library.


Answer

I haven't used this function, so I'm just guessing here, but when do you call AesEncrypt? If you call it after setting your body text, attachments, etc... try calling it before, or if you already call it before, try calling it after.

If that doesn't help, could you post some sample code?

Also, are you using the latest version of the library?


Answer

I call it when the email is complete, of course. Doesn't make sense (to me) to try to encrypt before everything is ready to go.

I'm using 9.5.0-x86_64.


Answer

Ahh, I see!

It is a streaming cypher. Makes sense. I imagine it's always padding the last block (if necessary) until something else comes in (if it works that way).

I'll give it a try.

Thanks.


Answer

Tried it both ways.

1)

CkEmail email; 
email.AesEncrypt("password");
email.LoadEml("Test.eml"); // Properly formatted, with attachments. 
email.SaveEml("Test-enc.eml");

2)

CkEmail email; 
email.LoadEml("Test.eml"); // Properly formatted, with attachments. 
email.AesEncrypt("password");
email.SaveEml("Test-enc.eml");

Neither test-enc.eml files were encrypted.


Answer

I'll have a look. This functionality should already have been in Chilkat's QA test suite and automatically tested prior to every new version release -- may be something was amiss...


Answer

I tested it, and everything worked fine for me. The resultant email (after calling AesEncrypt) will contain the same top-level unencrypted header, but all message bodies, sub-parts (related parts, attachments, attached messages, etc.) will be condensed into a single AES encrypted blob that is base64 encoded.

Maybe the confusion is that you expected the top-level header to also be encrypted?