mirror of https://github.com/wolfSSL/wolfssh.git
fixes for c++ error on missing enum cast and warning on MlKemKey initialization
parent
91cbb647d1
commit
8a945c7b35
|
|
@ -5527,12 +5527,14 @@ static int KeyAgreeEcdhMlKem_client(WOLFSSH* ssh, byte hashId,
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
byte sharedSecretHashSz = 0;
|
byte sharedSecretHashSz = 0;
|
||||||
byte *sharedSecretHash = NULL;
|
byte *sharedSecretHash = NULL;
|
||||||
MlKemKey kem = {0};
|
MlKemKey kem;
|
||||||
word32 length_ciphertext = 0;
|
word32 length_ciphertext = 0;
|
||||||
word32 length_sharedsecret = 0;
|
word32 length_sharedsecret = 0;
|
||||||
word32 length_privatekey = 0;
|
word32 length_privatekey = 0;
|
||||||
int mlKemType = WC_ML_KEM_768;
|
int mlKemType = WC_ML_KEM_768;
|
||||||
byte kexId = ssh->handshake->kexId;
|
byte kexId = ssh->handshake->kexId;
|
||||||
|
|
||||||
|
WMEMSET(&kem, 0, sizeof(kem));
|
||||||
#if !defined(WOLFSSH_NO_NISTP256_MLKEM768_SHA256) || \
|
#if !defined(WOLFSSH_NO_NISTP256_MLKEM768_SHA256) || \
|
||||||
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384)
|
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384)
|
||||||
ecc_key *key_ptr = NULL;
|
ecc_key *key_ptr = NULL;
|
||||||
|
|
@ -5694,7 +5696,7 @@ static int KeyAgreeEcdhMlKem_client(WOLFSSH* ssh, byte hashId,
|
||||||
/* Replace the concatenated shared secrets with the hash. That
|
/* Replace the concatenated shared secrets with the hash. That
|
||||||
* will become the new shared secret. */
|
* will become the new shared secret. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
sharedSecretHashSz = wc_HashGetDigestSize(hashId);
|
sharedSecretHashSz = wc_HashGetDigestSize((enum wc_HashType)hashId);
|
||||||
sharedSecretHash = (byte *)WMALLOC(sharedSecretHashSz,
|
sharedSecretHash = (byte *)WMALLOC(sharedSecretHashSz,
|
||||||
ssh->ctx->heap,
|
ssh->ctx->heap,
|
||||||
DYNTYPE_PRIVKEY);
|
DYNTYPE_PRIVKEY);
|
||||||
|
|
@ -5704,8 +5706,8 @@ static int KeyAgreeEcdhMlKem_client(WOLFSSH* ssh, byte hashId,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_Hash(hashId, ssh->k, ssh->kSz, sharedSecretHash,
|
ret = wc_Hash((enum wc_HashType)hashId, ssh->k, ssh->kSz,
|
||||||
sharedSecretHashSz);
|
sharedSecretHash, sharedSecretHashSz);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
@ -12144,12 +12146,14 @@ static int KeyAgreeEcdhMlKem_server(WOLFSSH* ssh, byte hashId,
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
byte sharedSecretHashSz = 0;
|
byte sharedSecretHashSz = 0;
|
||||||
byte *sharedSecretHash = NULL;
|
byte *sharedSecretHash = NULL;
|
||||||
MlKemKey kem = {0};
|
MlKemKey kem;
|
||||||
word32 length_publickey = 0;
|
word32 length_publickey = 0;
|
||||||
word32 length_ciphertext = 0;
|
word32 length_ciphertext = 0;
|
||||||
word32 length_sharedsecret = 0;
|
word32 length_sharedsecret = 0;
|
||||||
int mlKemType = WC_ML_KEM_768;
|
int mlKemType = WC_ML_KEM_768;
|
||||||
byte kexId = ssh->handshake->kexId;
|
byte kexId = ssh->handshake->kexId;
|
||||||
|
|
||||||
|
WMEMSET(&kem, 0, sizeof(kem));
|
||||||
#if !defined(WOLFSSH_NO_NISTP256_MLKEM768_SHA256) || \
|
#if !defined(WOLFSSH_NO_NISTP256_MLKEM768_SHA256) || \
|
||||||
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384)
|
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384)
|
||||||
ecc_key* pubKey = NULL;
|
ecc_key* pubKey = NULL;
|
||||||
|
|
@ -12366,7 +12370,7 @@ static int KeyAgreeEcdhMlKem_server(WOLFSSH* ssh, byte hashId,
|
||||||
/* Replace the concatenated shared secrets with the hash. That
|
/* Replace the concatenated shared secrets with the hash. That
|
||||||
* will become the new shared secret.*/
|
* will become the new shared secret.*/
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
sharedSecretHashSz = wc_HashGetDigestSize(hashId);
|
sharedSecretHashSz = wc_HashGetDigestSize((enum wc_HashType)hashId);
|
||||||
sharedSecretHash = (byte *)WMALLOC(sharedSecretHashSz,
|
sharedSecretHash = (byte *)WMALLOC(sharedSecretHashSz,
|
||||||
ssh->ctx->heap, DYNTYPE_PRIVKEY);
|
ssh->ctx->heap, DYNTYPE_PRIVKEY);
|
||||||
if (sharedSecretHash == NULL) {
|
if (sharedSecretHash == NULL) {
|
||||||
|
|
@ -12374,8 +12378,8 @@ static int KeyAgreeEcdhMlKem_server(WOLFSSH* ssh, byte hashId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_Hash(hashId, ssh->k, ssh->kSz, sharedSecretHash,
|
ret = wc_Hash((enum wc_HashType)hashId, ssh->k, ssh->kSz,
|
||||||
sharedSecretHashSz);
|
sharedSecretHash, sharedSecretHashSz);
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
XMEMCPY(ssh->k, sharedSecretHash, sharedSecretHashSz);
|
XMEMCPY(ssh->k, sharedSecretHash, sharedSecretHashSz);
|
||||||
|
|
@ -13554,12 +13558,14 @@ int SendKexDhInit(WOLFSSH* ssh)
|
||||||
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384) || \
|
!defined(WOLFSSH_NO_NISTP384_MLKEM1024_SHA384) || \
|
||||||
!defined(WOLFSSH_NO_CURVE25519_MLKEM768_SHA256)
|
!defined(WOLFSSH_NO_CURVE25519_MLKEM768_SHA256)
|
||||||
if (ssh->handshake->useEccMlKem) {
|
if (ssh->handshake->useEccMlKem) {
|
||||||
MlKemKey kem = {0};
|
MlKemKey kem;
|
||||||
word32 length_publickey = 0;
|
word32 length_publickey = 0;
|
||||||
word32 length_privatekey = 0;
|
word32 length_privatekey = 0;
|
||||||
int mlKemType = WC_ML_KEM_768;
|
int mlKemType = WC_ML_KEM_768;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
WMEMSET(&kem, 0, sizeof(kem));
|
||||||
|
|
||||||
#ifndef WOLFSSH_NO_NISTP384_MLKEM1024_SHA384
|
#ifndef WOLFSSH_NO_NISTP384_MLKEM1024_SHA384
|
||||||
if (ssh->handshake->kexId == ID_NISTP384_MLKEM1024_SHA384) {
|
if (ssh->handshake->kexId == ID_NISTP384_MLKEM1024_SHA384) {
|
||||||
mlKemType = WC_ML_KEM_1024;
|
mlKemType = WC_ML_KEM_1024;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue