Skip to content

Commit 6486773

Browse files
mzacharjforissier
authored andcommitted
libckteec: Validate EdDSA mechanism parameter length
This fixes Segmentation fault when no parameter is provided as specified in pkcs11 v3.0 spec for Ed25519 Signature Scheme Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Signed-off-by: Matej Zachar <zachar.matej@gmail.com>
1 parent 0a22c22 commit 6486773

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

libckteec/src/serialize_ck.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,23 @@ static CK_RV serialize_mecha_eddsa(struct serializer *obj,
674674
{
675675
CK_RV rv = CKR_GENERAL_ERROR;
676676
CK_EDDSA_PARAMS *params = mecha->pParameter;
677+
CK_ULONG params_len = mecha->ulParameterLen;
678+
/*
679+
* When no parameter is provided, the expected operation is
680+
* no-prehash and no-context.
681+
*/
682+
CK_EDDSA_PARAMS default_params = {
683+
.phFlag = 0,
684+
.ulContextDataLen = 0,
685+
};
686+
687+
if (params_len == 0) {
688+
params = &default_params;
689+
params_len = sizeof(*params);
690+
}
691+
692+
if (params_len != sizeof(*params))
693+
return CKR_ARGUMENTS_BAD;
677694

678695
rv = serialize_32b(obj, obj->type);
679696
if (rv)

0 commit comments

Comments
 (0)