Skip to content

Commit 54e8ee0

Browse files
committed
More CodeRabbitAI suggestions
1 parent 8609c5a commit 54e8ee0

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/lib/SoftHSM.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ static CK_RV newP11Object(CK_OBJECT_CLASS objClass, CK_KEY_TYPE keyType, CK_CERT
146146
*p11object = new P11GOSTPublicKeyObj();
147147
else if (keyType == CKK_EC_EDWARDS)
148148
*p11object = new P11EDPublicKeyObj();
149+
#ifdef WITH_ML_DSA
149150
else if (keyType == CKK_ML_DSA)
150151
*p11object = new P11MLDSAPublicKeyObj();
152+
#endif
151153
else
152154
return CKR_ATTRIBUTE_VALUE_INVALID;
153155
break;
@@ -165,8 +167,10 @@ static CK_RV newP11Object(CK_OBJECT_CLASS objClass, CK_KEY_TYPE keyType, CK_CERT
165167
*p11object = new P11GOSTPrivateKeyObj();
166168
else if (keyType == CKK_EC_EDWARDS)
167169
*p11object = new P11EDPrivateKeyObj();
170+
#ifdef WITH_ML_DSA
168171
else if (keyType == CKK_ML_DSA)
169172
*p11object = new P11MLDSAPrivateKeyObj();
173+
#endif
170174
else
171175
return CKR_ATTRIBUTE_VALUE_INVALID;
172176
break;
@@ -10064,8 +10068,8 @@ CK_RV SoftHSM::generateMLDSA
1006410068
return CKR_TEMPLATE_INCOMPLETE;
1006510069
}
1006610070

10067-
if (paramSet != 1UL && paramSet != 2UL && paramSet != 3UL) {
10068-
INFO_MSG("Wrong parameterSet: %ld", paramSet);
10071+
if (paramSet != CKP_ML_DSA_44 && paramSet != CKP_ML_DSA_65 && paramSet != CKP_ML_DSA_87) {
10072+
INFO_MSG("Unsupported parameter set: %lu", (unsigned long)paramSet);
1006910073
return CKR_PARAMETER_SET_NOT_SUPPORTED;
1007010074
}
1007110075

src/lib/crypto/OSSLMLDSAPrivateKey.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ void OSSLMLDSAPrivateKey::createOSSLKey()
148148
ByteString localValue = getValue();
149149

150150
const char* name = OSSL::mldsaParameterSet2Name(getParameterSet());
151+
if (name == NULL)
152+
{
153+
ERROR_MSG("Unknown ML-DSA parameter set (value length: %zu)", localValue.size());
154+
return;
155+
}
156+
if (localValue.size() == 0)
157+
{
158+
ERROR_MSG("Empty ML-DSA private key value; cannot create EVP_PKEY");
159+
return;
160+
}
151161

152162
int selection = 0;
153163
EVP_PKEY_CTX *ctx = NULL;

0 commit comments

Comments
 (0)