@@ -59,9 +59,9 @@ applied over the un-encrypted data. Validation on encrypted images, checks
59
59
that the encrypted flag is set and TLV data is OK, then it decrypts each
60
60
image block before sending the data to the hash routines.
61
61
62
- The image is encrypted using AES-CTR-128, with a counter that starts
63
- from zero (over the payload blocks) and increments by 1 for each 16-byte
64
- block. AES-CTR-128 was chosen for speed/simplicity and allowing for any
62
+ The image is encrypted using AES-CTR-128 or AES-CTR-256 , with a counter
63
+ that starts from zero (over the payload blocks) and increments by 1 for each
64
+ 16-byte block. AES-CTR was chosen for speed/simplicity and allowing for any
65
65
block to be encrypted/decrypted without requiring knowledge of any other
66
66
block (allowing for simple resume operations on swap interruptions).
67
67
@@ -70,14 +70,15 @@ The key used is a randomized when creating a new image, by `imgtool` or
70
70
but randomizing a 16-byte block with a TRNG should make it highly
71
71
improbable that duplicates ever happen.
72
72
73
- To distribute this AES-CTR-128 key, new TLVs were defined. The key can be
74
- encrypted using either RSA-OAEP, AES-KW-128, ECIES-P256 or ECIES-X25519.
73
+ To distribute this AES-CTR key, new TLVs were defined. The key can be
74
+ encrypted using either RSA-OAEP, AES-KW (128 or 256 bits depending on the
75
+ AES-CTR key length), ECIES-P256 or ECIES-X25519.
75
76
76
77
For RSA-OAEP a new TLV with value ` 0x30 ` is added to the image, for
77
- AES-KW-128 a new TLV with value ` 0x31 ` is added to the image, for
78
+ AES-KW a new TLV with value ` 0x31 ` is added to the image, for
78
79
ECIES-P256 a new TLV with value ` 0x32 ` is added, and for ECIES-X25519 a
79
80
newt TLV with value ` 0x33 ` is added. The contents of those TLVs
80
- are the results of applying the given operations over the AES-CTR-128 key.
81
+ are the results of applying the given operations over the AES-CTR key.
81
82
82
83
## [ ECIES encryption] ( #ecies-encryption )
83
84
@@ -94,17 +95,17 @@ libraries. The whole key encryption can be summarized as:
94
95
* Derive the new keys from the secret using HKDF (built on HMAC-SHA256). We
95
96
are not using a ` salt ` and using an ` info ` of ` MCUBoot_ECIES_v1 ` , generating
96
97
48 bytes of key material.
97
- * A new random encryption key of 16 bytes is generated (for AES-128 ). This is
98
+ * A new random encryption key is generated (for AES). This is
98
99
the AES key used to encrypt the images.
99
- * The key is encrypted with AES-128-CTR and a ` nonce ` of 0 using the first
100
- 16 bytes of key material generated previously by the HKDF.
100
+ * The key is encrypted with AES-128-CTR or AES-256-CTR and a ` nonce ` of 0 using
101
+ the first 16 bytes of key material generated previously by the HKDF.
101
102
* The encrypted key now goes through a HMAC-SHA256 using the remaining 32
102
103
bytes of key material from the HKDF.
103
104
104
105
The final TLV is built from the 65 bytes for ECIES-P256 or 32 bytes for
105
106
ECIES-X25519, which correspond to the ephemeral public key, followed by the
106
- 32 bytes of MAC tag and the 16 bytes of the encrypted key, resulting in a TLV
107
- of 113 bytes for ECIES-P256 or 80 bytes for ECIES-X25519.
107
+ 32 bytes of MAC tag and the 16 or 32 bytes of the encrypted key, resulting in
108
+ a TLV of 113 or 129 bytes for ECIES-P256 and 80 or 96 bytes for ECIES-X25519.
108
109
109
110
The implemenation of ECIES-P256 is named ENC_EC256 in the source code and
110
111
artifacts while ECIES-X25519 is named ENC_X25519.
@@ -149,7 +150,7 @@ To extract the public key in source file form, use
149
150
` imgtool getpub -k <input.pem> -l <lang> ` , where lang can be one of ` c ` or
150
151
` rust ` (defaults to ` c ` ).
151
152
152
- If using AES-KW-128 , follow the steps in the next section to generate the
153
+ If using AES-KW, follow the steps in the next section to generate the
153
154
required keys.
154
155
155
156
## [ Creating your keys with Unix tooling] ( #creating-your-keys-with-unix-tooling )
@@ -161,5 +162,6 @@ required keys.
161
162
* If using ECIES-X25519, generate a private key passing the option ` -t x25519 `
162
163
to ` imgtool keygen ` command. To generate public key PEM file the following
163
164
command can be used: ` openssl pkey -in <generated-private-key.pem> -pubout `
164
- * If using AES-KW-128 (` newt ` only), the ` kek ` can be generated with a
165
- command like ` dd if=/dev/urandom bs=1 count=16 | base64 > my_kek.b64 `
165
+ * If using AES-KW (` newt ` only), the ` kek ` can be generated with a
166
+ command like (change count to 32 for a 256 bit key)
167
+ ` dd if=/dev/urandom bs=1 count=16 | base64 > my_kek.b64 `
0 commit comments