MLA key file format
MLA can use cryptography for signature and/or encryption. Thus it needs to operate with keys. An implementation can get access to these keys from a serialized format described here.
The string || denotes concatenation.
Private key file format
A private key file is an ASCII file, which may use mlapriv as file extension. The file (or whatever serialization medium) content is PrivFormatHeader||<CR><LF>PrivEncHdr||B64Priv4Enc||<CR><LF>||PrivSigHdr||B64Priv4Sig||<CR><LF>||B64PrivOpts||<CR><LF>||PrivFormatFooter||<CR><LF> where <CR> is ASCII carriage return, <LF> is ASCII line feed, and PrivFormatHeader, PrivEncHdr, B64Priv4Enc, PrivSigHdr, B64Priv4Sig, B64PrivOpts and PrivFormatFooter are described below.
-
PrivFormatHeaderis the ASCII stringDO NOT SEND THIS TO ANYONE - MLA PRIVATE KEY FILE V1. -
PrivEncHdris the ASCII stringMLA PRIVATE DECRYPTION KEY(note the trailing space). -
PrivSigHdris the ASCII stringMLA PRIVATE SIGNING KEY(note the trailing space). -
B64Priv4Encis the base64 encoding (RFC 4648) ofEncMethodId||PrivEncOpts||X25519PrivKey||MLKEM1024PrivKeywhereEncMethodId,PrivEncOpts,X25519PrivKeyandMLKEM1024PrivKeyare described below. -
B64Priv4Sigis the base64 encoding ofSigMethodId||PrivSigOpts||Ed25519PrivKey||MLDSA87PrivKeywhereMethodId,PrivEncOpts,Ed25519PrivKeyandMLDSA87PrivKeyare described below. -
PrivFormatFooteris the ASCII stringEND OF MLA PRIVATE KEY FILE -
The only valid
EncMethodIdfor the moment is the ASCIImla-kem-private-x25519-mlkem1024. -
The only valid
SigMethodIdfor the moment is the ASCIImla-signature-private-ed25519-mldsa87. -
X25519PrivKeyis a X25519 private key as specified in RFC 7748. -
MLKEM1024PrivKeyis an ML-KEM-1024 private key seed (d,z) as specified in FIPS 203 algorithm 16. d and z are concatenated in this order. -
Ed25519PrivKeyis a Ed25519 private key as specified in RFC 8032. -
MLDSA87PrivKeyis an ML-DSA-87 private key seed xi as specified in FIPS 204 algorithm 6.
For PrivEncOpts and PrivSigOpts, refer to below generic explanation for KeyOpts.
B64PrivOptsis a base64 encodedKeyOpts.
Public key file format
A public key file is an ASCII file, which may use mlapub as file extension. The file (or whatever serialization medium) content is PubFormatHeader||<CR><LF>||PubEncHdr||B64Pub4Enc||<CR><LF>||PubSigHdr||B64Pub4Sig||<CR><LF>||B64PubOpts||<CR><LF>||PubFormatFooter||<CR><LF> where <CR> is ASCII carriage return, <LF> is ASCII line feed, and PubFormatHeader, PubEncHdr, B64Pub4Enc, PubSigHdr, B64Pub4Sig, B64PubOpts and PubFormatFooter are described below.
-
PubFormatHeaderis the ASCII stringMLA PUBLIC KEY FILE V1. -
PubEncHdris the ASCII string `MLA PUBLIC ENCRYPTION KEY “ (note the trailing space). -
PubSigHdris the ASCII string `MLA PUBLIC SIGNATURE VERIFICATION KEY “ (note the trailing space). -
B64Pub4Encis the base64 encoding (RFC 4648) ofEncMethodId||PubEncOpts||X25519PubKey||MLKEM1024PubKeywhereEncMethodId,PubEncOpts,X25519PubKeyandMLKEM1024PubKeyare described below. -
B64Pub4Sigis the base64 encoding ofSigMethodId||PubSigOpts||Ed25519PubKey||MLDSA87PubKeywhereMethodId,PubEncOpts,Ed25519PubKeyandMLDSA87PubKeyare described below. -
PubFormatFooteris the ASCII stringEND OF MLA PUBLIC KEY FILE -
The only valid
EncMethodIdfor the moment is the ASCIImla-kem-public-x25519-mlkem1024. -
The only valid
SigMethodIdfor the moment is the ASCIImla-signature-verification-public-ed25519-mldsa87. -
X25519PubKeyis a X25519 public key as specified in RFC 7748. -
MLKEM1024PubKeyis an ML-KEM-1024 public key as specified in FIPS 203. -
Ed25519PubKeyis a Ed25519 public key as specified in RFC 8032. -
MLDSA87PubKeyis an ML-DSA-87 public key as specified in FIPS 204.
For PubEncOpts and PubSigOpts, refer to below generic explanation for KeyOpts.
B64PubOptsis a base64 encodedKeyOpts.
Options
KeyOpts fields are options fields for future-proofing the format in case of later non-breaking optional additions to the key file format. It is serialized with a tag of value 0 as a u8 if no option is present. Otherwise it is serialized with a tag of value 1 as u8 followed by a keyoptslen u64 and a sequence of TLVKeyOpt. This sequence of TLVKeyOpt is of keyoptslen size in bytes. Multiple fields in this key format are of type KeyOpts for future proofing reasons, but no option is defined at the moment. For future proofing, implementers of this format version must still handle the tag of value 1 and read the keyoptslen bytes even if not using their values. Thus, if an option is specified in the future, pre-dating implementations will be able to work with new keys containing the optional values. A TLVKeyOpt is a u32 KeyOptType followed by a Vec<u8> whose interpretation depends on the KeyOptType value. KeyOptType values from 0x80000000 to 0xFFFFFFFF are reserved and must not defined by third parties. For interoperability reasons, third parties willing to define new options must contact MLA maintainers to register an OptType value in the 0x00000000-0x7FFFFFFF range.