1
$\begingroup$

Still trying to design a fully binary cryptography container format for my mobile app, I am here asking if container is ever relevant.

Thanks to Apple, I cannot use GPG directly because I can neither call GPG through GPGME (fork(2) is not allowed) nor embed it (license conflicts)

The container format is simple ar(1) format that store its contents in plaintext, probably then compressed with some algorithm like Gzip. I am wondering if the container format affects the security of the already encrypted data, the MAC and IV that is held as separate entities within.

The plan is to use AES-CTR (or AES-CFB, or AES-OFB, or my homebrew cipher SHA512-HMAC-OFB which turned out to be just as fast as AES thanks to its larger block size) to encrypt the data and put it in the archive file (data.obj in the archive), its initialization vector in plain (iv.bin), asymmetrically encrypted symmetric key (key.bin, if relevant), the SHA512-HMAC of the archive in "check archive" form that is described below (mac.bin) and some metadata (algorithms used, compression of plaintext used, probably a user supplied tag in plain text) in plain (info.json)

EDIT

ar(1) format stores file name (up to 16 characters), owner UID/GID, modification time, file mode (permissions) in its file header.

MAC (or signature) is calculated on a "check archive": every entity except the MAC (or signature) itself are in the check archive, which is also in ar(1) format, sorted in binary order based on their file names, retaining all their properties (name, owner, modification date and file mode).

$\endgroup$
0
$\begingroup$

Converting the comments to an answer…

Ricky Demer:

"algorithms used" should be stored with the key(s). "compression of plaintext used, probably a user supplied tag" should go into the MAC.

Maxthon Chan:

That is, algorithm should not appear in the container at all, and everything that is not MAC itself should be included in MAC?

Ricky Demer:

Yes. Also note that compression may be problematic.

Maxthon Chan:

I forgot the asymmetrically encrypted symmetric key may appear in the file as well as key.bin. How to deal with that?

Ricky Demer:

If you're using public keys too, then you should probably use digital signatures, possibly instead of a MAC.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.