Repository navigation
Commit 4568675
committed
crypto/mbedtls: support AES sessions keyed by key id
Add mbedtls_aes_set{128,192,256}key_{enc,dec}_keyid(): like the plain
setkey functions, but the buffer the caller hands over carries a
32-bit key id (padded to the full key size) and the session is
created with SOP_F_KEYID, so the crypto backend loads the key from
its key store instead of taking the material inline. The key must
already live in a store the backend can reach, e.g. one populated
through CIOCKEY CRK_ALLOCATE_KEY/CRK_IMPORT_KEY/CRK_SAVE_KEY.
The regular setkey path clears SOP_F_KEYID, so a context that was
once keyed by id can be reused with plain key material.
Verified on sim:crypto + software cryptodev with the swkey key store
(/dev/nvs): a key imported and saved through CIOCKEY, then used via
mbedtls_aes_set128key_enc_keyid() + mbedtls_aes_crypt_cbc(), produces
the same ciphertext as the direct cryptodev reference call with the
real key material.
Signed-off-by: makejian <makejian@xiaomi.com>1 parent a8e07e0 commit 4568675
2 files changed
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
46 | 65 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
38 | 73 | | |
39 | 74 | | |
40 | 75 | | |
| |||
68 | 103 | | |
69 | 104 | | |
70 | 105 | | |
| 106 | + | |
71 | 107 | | |
72 | 108 | | |
73 | 109 | | |
| |||
78 | 114 | | |
79 | 115 | | |
80 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
81 | 159 | | |
82 | 160 | | |
83 | 161 | | |
| |||
0 commit comments