The set command creates keys for different purposes.
The purposes are the following:
- Client private key and certificate signing request (CSR) (<key_type> 2, <response_content> 0)
- The CSR can be passed to a Certificate Authority (CA) for requesting a client
certificate for the device. The modem stores the generated private key to a
<sec_tag>. The client certificate must be stored to the device
in the same <sec_tag> as the client private key. The client
device certificate and the corresponding private key can be used as TLS client
credentials.
The %KEYGEN response contains a Certificate Signing Request (CSR) and COSE signature for the CSR separated by a dot "." with both sides Base64Url-encoded:
"Base64Url(CSR_DER).Base64Url(cose_sign)". - Client private key and public key (<key_type> 2, <response_content> 1)
- The %KEYGEN response contains a public key in CBOR device pubkey
message and COSE signature separated by dot "." with both sides Base64Url-encoded:
"Base64Url(public_key_DER).Base64Url(cose_sign)". - Device Endorsement key pair (<key_type> 8)
- Endorsement keys can be used to pass encrypted data to a device. The endorsement
private key is stored to the device in a <sec_tag>, and the
public key is returned in a %KEYGEN response. If the private key
already exists in <sec_tag>, the response is created based on
the existing key instead of creating a new key.
The %KEYGEN response contains an Endorsement Public key in CBOR device pubkey message and COSE signature separated by dot "." with both sides Base64Url-encoded:
"Base64Url(public_key_DER).Base64Url(cose_sign)".
- The %KEYGEN command is allowed only when the modem is deactivated.
- The %CMNG list operation can be used to check the availability of generated keys.
Syntax:
%KEYGEN=<sec_tag>,<key_type>[,<response_content>][,<attributes>][,<key_usage>]
- +CME ERROR code
- 514 – Not allowed.
The set command parameters and their defined values are the following:
- <sec_tag>
- Integer, 1–2147483647.
- <key_type>
- Integer
- <response_content>
- Integer
- <attributes>
- String
- <key_usage>
- String
The following command example generates a key for TLS. The key is stored to <sec_tag> 11. The <key_type> is client private key, and it includes the optional <key_usage> parameter:
AT%KEYGEN=11,2,0,,"101010000"
%KEYGEN: "ckijfiok.jdiqhdn"
OK
The following command example generates a key for TLS. The key is stored to <sec_tag> 11. The <key_type> is client private key, and it includes the optional parameters <attributes> and <key_usage>:
AT%KEYGEN=11,2,0,"O=Nordic Semiconductor,L=Trondheim,C=no","101010000"
%KEYGEN: "MIIBHDCBwAIBADBAMR0wGwYDVQQKDBROb3JkaWMgU2VtaWNvbmR1Y3RvcjESMBAGA1UEB
wwJVHJvbmRoZWltMQswCQYDVQQGEwJubzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABAP6p4ZjYNG0
FFdz5axZkbcQzfO8Fkzws4o2unhS5qqgON5BA6jj0TbHJ5imPbVXWNiDVCNc0us41NtL3TygDdqgHjA
cBgkqhkiG9w0BCQ4xDzANMAsGA1UdDwQEAwIDqDAMBggqhkjOPQQDAgUAA0kAMEYCIQDnFWQl-x25qj
EPBtLrvH5wwecrA5KmjUcK_b3eok5nmQIhALsSKRmuqDM3H09-q4R0MSpYprWZZp5iPjRMtZbjataH.
0oRDoQEmoQRBIVhL2dn3hQlQUFAwQTYzQ7CAwwEaNJbawEELWCD7er2zKHc8yAMi8x-1jAuCEqaLmJ3
PMZTHIYSrmIR0tlD7CDRaW--s0c7XA4pI3r9wWEAQOGVg5VejmHx9o_sF1RcGBMClw-MkN_wMrS2ryM
8CdA427j96z_4wjLgBvejVnYGAl7qqL77qlEbBEzXOkLx4"
OK
The following command example generates an endorsement key. The key is stored to <sec_tag> 33. The <key_type> is endorsement private key:
AT%KEYGEN=33,8
%KEYGEN: "vdofjihew.cnjeiwhfok"
OK