The textual encoding of CMS messages (RFC 7468): Base64 between
-----BEGIN CMS----- and -----END CMS----- lines.
RFC 7468 gives two labels: CMS (section 9) and PKCS7 (section 8), the
older one, which more tools expect in a .p7b certificate bundle. Both
are read; encode/2 writes CMS unless asked otherwise.
Every function of Cmsex that takes a message also takes it in PEM, so
this module is only needed to write PEM, or to read it apart.
iex> pem = Cmsex.PEM.encode(<<0x30, 0x03, 0x02, 0x01, 0x01>>)
"-----BEGIN CMS-----\nMAMCAQE=\n-----END CMS-----\n"
iex> Cmsex.PEM.decode("Text before\n" <> pem)
{:ok, <<0x30, 0x03, 0x02, 0x01, 0x01>>}
Summary
Functions
Decodes the first PEM block labelled CMS or PKCS7. Text before and
after the block, and blocks with other labels, are skipped; whitespace
inside the block is ignored. The END line must carry the same label.
Encodes a message in PEM, with the label :cms (the default) or
:pkcs7, in lines of 64 characters.
Functions
@spec decode(binary()) :: {:ok, binary()} | {:error, Cmsex.Error.t()}
Decodes the first PEM block labelled CMS or PKCS7. Text before and
after the block, and blocks with other labels, are skipped; whitespace
inside the block is ignored. The END line must carry the same label.
Encodes a message in PEM, with the label :cms (the default) or
:pkcs7, in lines of 64 characters.