While using some crypto implementations I got to see that many times a comment is added to the ciphertext.

For example:

Version: OpenPGP.js v1.5.0
Comment: http://openpgpjs.org




… identifies the beginning of the data.

Version: OpenPGP.js v1.5.0

… identifies which implementation of the protocol was used to encrypt the text.

Comment: http://openpgpjs.org

… provides a generic comment.


identifies the end of the data.

The first thing I am wondering if it's some standard out there for this comments, and if so some links or informations about it. Would've asked to Google but don't know what to search.

Then, I would like to use a comment like the one showed above to store my ciphered messages as plaintext.

Assuming I want to do that for a message ciphered using AES, which informations should I store?

  1. Should I store the AES mode used for encryption ?
  2. Should I store the AES implementation I used ?
  3. Should I store the initialization vector ?
  4. Should I try to be compliant to some standards while storing these informations ?
  • $\begingroup$ The implementation should be irrelevant, as all AES implementations do the same (if they're compliant to the standard). $\endgroup$
    – SEJPM
    Commented Jan 30, 2016 at 13:27
  • $\begingroup$ @SEJPM Yes, "irrelevant" is probably a better word then "inconsequential" :) $\endgroup$
    – Maarten Bodewes
    Commented Jan 30, 2016 at 13:30
  • $\begingroup$ If you use PGP format for symmetric-under-pubkey, which is far from the only standard for "AES ciphertext", the symmetric cipher algorithm is transmitted in the encrypted key value and the mode and IV are defined by the PGP standard and don't need to be represented explicitly. If you use some other format, standard or not, it depends on that format. $\endgroup$ Commented Jan 31, 2016 at 1:09

2 Answers 2


What you are looking for is a definition of PEM, privacy enhanced mail. Obviously PEM is not just used for mail anymore. The definition of the header lines seems to be best described by section 4.6: "Summary of Encapsulated Header Fields" of RFC 1421: "Privacy Enhancement for Internet Electronic Mail: Part I: Message Encryption and Authentication Procedures". Obviously for PGP specific header fields you'll have to take a look at the OpenPGP format, specifically the section about ASCII armor.

Then, i would like to use a comment like the one showed above to store my ciphered messages as plaintext. Assuming i want to do that for a message ciphered using AES, which informations should i store ?

That depends on the scheme you've chosen. For transport security the minimum would be the IV, the ciphertext and an authentication tag over both.

Should i store the AES mode used for encryption ?

That depends. You could store a protocol version instead which determines which mode is used. You should not just store the mode without authentication and then proceed to process the message based on the header fields. That would give an attacker to decide which operation is performed on the receiving side. You need to keep control over what is performed on the receiving side.

Should i store the AES implementation i used ?

No, the implementation of the block cipher should be irrelevant if you've decided upon a well defined protocol.

You could store a version of the software implementation of a protocol. In that case you may be able to work around possible bugs within the implementation. I've seen quite a few instances where the implementation of PGP did matter.

Should i store the initialization vector ?

Yes, unless you've got ways of establishing the IV out-of-band (e.g. an operation over a message counter included in a message counter, or a counter kept in sync at both sides). If unsure include a random IV of sufficient size.

Should i try to be compliant to some standards while storing these informations ?

It's strongly advisable to keep to well known container formats such as CMS or the already named OpenPGP yes.


You may need to answer some preliminary questions first:

1 - do you want to exchange encrypted data or just store it for your own use?

2 - do you want/need to interoperate with existing protocols or applications?

3 - how "stealth" do you want to be (PGP "armor" is just a red rag to a bull)?

This older thread may help: https://stackoverflow.com/questions/1306865/what-are-the-standard-encryption-file-formats

A few ideas:

1 - If you are the only user or in a small/closed community, make it simple but have a look at some of the standards to check them for good practises. Possibly pay attention to 3.

2 - Check the relevant standard(s), RFC or others, and select appropriate modes (standards may be overly complex in order to ensure interoperability with old versions)

3 - Detecting encrypted data in transfer is not difficult but you don't need to make everything obvious to an attacker with respect to your parameters/settings

Finally (or first of all!), make sure your key exchange/storage mechanism is secure if you need one.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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