Zero key for FIPS#1590
Conversation
There was a problem hiding this comment.
we need zero key in any return path.
There was a problem hiding this comment.
Thanks. I have added the salt zero in every return path.
There was a problem hiding this comment.
we need zero key in any return path.
|
Why does the key need to be on the stack at all? Why not use directly? |
|
Yes, I think we can change to |
ef0f9fe to
5fcc457
Compare
Thanks. I have changed the key from array to pointer. |
There was a problem hiding this comment.
Please remove /*zero salt for security*/. No need to say it every where.
There was a problem hiding this comment.
Thanks. I have removed the comments except the first comment.
c47cf33 to
d509c91
Compare
There was a problem hiding this comment.
Can also make the salt a pointer.
There was a problem hiding this comment.
If so, the XOR sequence_number need to be: *(uint64_t *)salt ^ (sequence_number - 1) ^ sequence_number
Please test it between old version and new version.
There was a problem hiding this comment.
Thanks. I have changed the salt to pointer and added a new commit to fix the unit test.
There was a problem hiding this comment.
And I have tested pass the emu.
the array salt is old version; the pointer salt is new version. The following test has passed.
new version requester <---> new version responder
old version requester <---> new version responder
new version requester <---> old version responder
0147734 to
b05163d
Compare
b05163d to
1b67895
Compare
| uint8_t key[LIBSPDM_MAX_AEAD_KEY_SIZE]; | ||
| uint8_t salt[LIBSPDM_MAX_AEAD_IV_SIZE]; | ||
| const uint8_t *key; | ||
| uint8_t *salt; |
There was a problem hiding this comment.
The salt should stay const, like the key.
Also we'll need to declare uint8_t iv[LIBSPDM_MAX_AEAD_IV_SIZE], that actually gets fed into libspdm_aead_encryption.
There was a problem hiding this comment.
I don't think we need define uint8_t iv[LIBSPDM_MAX_AEAD_IV_SIZE]. That will go back to original problem.
|
|
||
| *(uint64_t *)salt = *(uint64_t *)salt ^ sequence_number; | ||
| if (sequence_number > 0) { | ||
| *(uint64_t *)salt = *(uint64_t *)salt ^ (sequence_number - 1) ^ sequence_number; |
There was a problem hiding this comment.
This (and the 2.3 version) is misleading as once the assignment occurs this value is no longer the salt, it's the IV. So here I would zero-extend sequence_number and XOR it with salt and assign it (libspdm_copy_mem) to iv[].
There was a problem hiding this comment.
If the name is confusing, I think we can rename to uint8_t *iv. I don't see the need to cache the iv[].
|
Ok. Feel free to merge this and I'll file an issue. |
Reference: #1260
2023/1/7 Commit 1: Zero key for FIPS when encode and decode.
2023/1/13 Commit 2: Fix unit test because of the salt change.
2023/1/9 Commit 3: Zero salt1 in
libspdm_generate_session_data_key.Signed-off-by: Wenxing Hou wenxing.hou@intel.com