blob: 04e3c4e6a89fb471f6cd69eb9e3baad0e41c0de5 [file] [log] [blame]
Davide Pesavento933a5672020-07-03 22:32:43 -04001SafeBag Format for Exported Credentials
2=======================================
Yingdi Yu55ea01a2015-07-21 22:42:17 -07003
Davide Pesavento93101df2021-06-15 18:33:09 -04004Sometimes it may be necessary to export an identity's credentials (i.e., private key and
5associated certificate) from one machine and import them into another. This requires a
6secure container to carry the sensitive information. We define **SafeBag**, which contains
7an :doc:`NDN certificate </specs/certificate>` and the corresponding private key in encrypted
8form. The private key is formatted as a DER-encoded
9`EncryptedPrivateKeyInfo <https://datatracker.ietf.org/doc/html/rfc5208#section-6>`__
10structure as described in PKCS #8.
Yingdi Yu55ea01a2015-07-21 22:42:17 -070011
Davide Pesavento93101df2021-06-15 18:33:09 -040012The TLV-based format of ``SafeBag`` is defined as follows:
Yingdi Yu55ea01a2015-07-21 22:42:17 -070013
Davide Pesavento933a5672020-07-03 22:32:43 -040014.. code-block:: abnf
Yingdi Yu55ea01a2015-07-21 22:42:17 -070015
Junxiao Shi9a04dda2019-07-02 15:18:20 +000016 SafeBag = SAFE-BAG-TYPE TLV-LENGTH
Davide Pesavento93101df2021-06-15 18:33:09 -040017 Certificate
18 EncryptedKey
Junxiao Shi9a04dda2019-07-02 15:18:20 +000019
Davide Pesavento93101df2021-06-15 18:33:09 -040020 EncryptedKey = ENCRYPTED-KEY-TYPE TLV-LENGTH
21 *OCTET ; PKCS #8 EncryptedPrivateKeyInfo
Yingdi Yu55ea01a2015-07-21 22:42:17 -070022
Davide Pesaventocad94b02021-04-09 21:23:03 -040023+---------------------------------------------+------------------+-----------------+
24| Type | Assigned number | Assigned number |
25| | (decimal) | (hexadecimal) |
26+=============================================+==================+=================+
27| SafeBag | 128 | 0x80 |
28+---------------------------------------------+------------------+-----------------+
Davide Pesavento93101df2021-06-15 18:33:09 -040029| EncryptedKey | 129 | 0x81 |
Davide Pesaventocad94b02021-04-09 21:23:03 -040030+---------------------------------------------+------------------+-----------------+