-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: crypto: hisilicon: add pbkdf2 algorithm #7180
base: master
Are you sure you want to change the base?
Conversation
static enum hisi_drv_status sec_pbkdf2_parse_sqe(void *bd, void *msg __unused) | ||
{ | ||
struct hisi_sec_sqe *sqe = bd; | ||
uint16_t done; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= 0
Ditto at line 63.
{ | ||
struct hisi_qp *qp; | ||
TEE_Result res = 0; | ||
int32_t ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct hisi_qp *qp = NULL;
TEE_Result res = TEE_ERROR_SUCCESS;
enum hisi_drv_status ret = <something>;
size_t dk_len) | ||
{ | ||
size_t t_num, hash_len, time; | ||
TEE_Result ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t t_num = 0;
size_t hash_len = 0;
size_t time = 0;
TEE_Result ret = TEE_ERROR_GENERIC;
return TEE_ERROR_NOT_SUPPORTED; | ||
} | ||
|
||
t_num = dk_len / hash_len + (dk_len % hash_len ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t_num = ROUNDUP_DIV(dk_len, hash_len);
|
||
done = SEC_GET_FIELD(sqe->type2.done_flag, SEC_DONE_MASK, 0); | ||
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) { | ||
EMSG("SEC do pbkdf2 fail! done=0x%x, etype=0x%x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... done=0x%"PRIx16", etype=0x%"PRIx8
Ditto at line 67.
|
||
if ((alg < TEE_ALG_HMAC_SHA384 || alg > TEE_ALG_HMAC_SHA512) && | ||
(password_len > (SEC_MAX_PASSWORD_LEN / 2))) { | ||
EMSG("Password_len %lu does not match alg 0x%x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%zu and %"PRIx32: "Password_len %zu does not match alg 0x%"PRIx32
uint8_t *derived_key, size_t derived_key_len) | ||
{ | ||
struct sec_pbkdf2_msg *msg = NULL; | ||
TEE_Result ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= TEE_ERROR_GENERIC
msg = malloc(sizeof(*msg)); | ||
if (!msg) { | ||
EMSG("Fail to malloc msg"); | ||
return TEE_ERROR_STORAGE_NO_SPACE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEE_ERROR_OUT_OF_MEMORY
FYI TEE_ERROR_STORAGE_NO_SPACE
relates to the secure storage space.
TEE_Result ret; | ||
|
||
#ifndef CFG_CRYPTO_HW_PBKDF2_WITH_EFUSE | ||
if (!password) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer if (!IS_ENABLED(CFG_CRYPTO_HW_PBKDF2_WITH_EFUSE) && !password)
sqe->type2.pass_word_len = (uint16_t)pbkdf2_msg->key_len; | ||
sqe->type2.dk_len = (uint16_t)pbkdf2_msg->out_len; | ||
|
||
#ifdef CFG_CRYPTO_HW_PBKDF2_WITH_EFUSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer use if (IS_ENABLED(CFG_CRYPTO_HW_PBKDF2_WITH_EFUSE))
Ditto at line 94.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All review comments have been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @etienne-lms, If it's okay, can you give me an Acked-by?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking minor comments on commit message:
s/pbkdf2/PBKDF2/g (header line and body)
s/hisilicon/Hisilicon/
Add a period (.
) after "... driver".
With these (and the 2 below) addressed: Acked-by: Etienne Carriere <[email protected]>
.
(edited)
msg->derive_type = SEC_HMAC_SM3; | ||
break; | ||
default: | ||
EMSG("Invalid hamc alg type 0x%x", alg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/0x%x/0x%"PRIx32"/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (ret) | ||
return ret; | ||
|
||
msg = malloc(sizeof(*msg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is recommended to use calloc()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,@etienne-lms ,All review comments have been modified.
Add pbkdf2 algorithm for hisilicon SEC driver. Signed-off-by: leisen <[email protected]>
Add pbkdf2 algorithm for hisilicon SEC driver