Skip to content

Commit

Permalink
housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Nov 21, 2024
1 parent e89528c commit e6ea3ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/wh_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,25 @@ int wh_Crypto_MlDsaSerializeKeyDer(MlDsaKey* key, uint16_t max_size,

/* Choose appropriate serialization based on key flags */
if (key->prvKeySet && key->pubKeySet) {
/* Full keypair - use KeyToDer */
#if defined(WOLFSSL_DILITHIUM_PRIVATE_KEY) && \
defined(WOLFSSL_DILITHIUM_PUBLIC_KEY)
/* Full keypair - use KeyToDer */
ret = wc_Dilithium_KeyToDer(key, buffer, max_size);
#else
ret = WH_ERROR_NOHANDLER;
#endif
}
else if (key->pubKeySet) {
/* Public key only - use PublicKeyToDer with SPKI format */
#ifdef WOLFSSL_DILITHIUM_PUBLIC_KEY
/* Public key only - use PublicKeyToDer with SPKI format */
ret = wc_Dilithium_PublicKeyToDer(key, buffer, max_size, 1);
#else
ret = WH_ERROR_NOHANDLER;
#endif
}
else if (key->prvKeySet) {
/* Private key only */
#ifdef WOLFSSL_DILITHIUM_PRIVATE_KEY
/* Private key only */
ret = wc_Dilithium_PrivateKeyToDer(key, buffer, max_size);
#else
ret = WH_ERROR_NOHANDLER;
Expand Down
12 changes: 6 additions & 6 deletions src/wh_server_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,13 @@ int wh_Server_MlDsaKeyCacheImport(whServerContext* ctx, MlDsaKey* key,
uint16_t der_size;

const uint16_t MAX_MLDSA_DER_SIZE =
#if !defined(WOLFSSL_NO_ML_DSA_87)
#if !defined(WOLFSSL_NO_ML_DSA_87)
ML_DSA_LEVEL5_PRV_KEY_DER_SIZE;
# elif !defined(WOLFSSL_NO_ML_DSA_65)
#elif !defined(WOLFSSL_NO_ML_DSA_65)
ML_DSA_LEVEL3_PRV_KEY_DER_SIZE;
#else
#else
ML_DSA_LEVEL2_PRV_KEY_DER_SIZE;
#endif
#endif

if ((ctx == NULL) || (key == NULL) || (WH_KEYID_ISERASED(keyId)) ||
((label != NULL) && (label_len > sizeof(cacheMeta->label)))) {
Expand Down Expand Up @@ -564,9 +564,9 @@ int wh_Server_MlDsaKeyCacheImport(whServerContext* ctx, MlDsaKey* key,
int wh_Server_MlDsaKeyCacheExport(whServerContext* ctx, whKeyId keyId,
MlDsaKey* key)
{
uint8_t* cacheBuf;
uint8_t* cacheBuf;
whNvmMetadata* cacheMeta;
int ret = WH_ERROR_OK;
int ret = WH_ERROR_OK;

if ((ctx == NULL) || (key == NULL) || (WH_KEYID_ISERASED(keyId))) {
return WH_ERROR_BADARGS;
Expand Down

0 comments on commit e6ea3ac

Please sign in to comment.