Skip to content

Commit

Permalink
Merge pull request wolfSSL#731 from ejohnstown/dh-group14-sha256
Browse files Browse the repository at this point in the history
DH Group 14 with SHA256
  • Loading branch information
JacobBarthelmeh authored and jefferyq2 committed Oct 29, 2024
1 parent cd66792 commit e9b5d25
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2462,9 +2462,6 @@ static const NameIdPair NameIdMap[] = {
#ifndef WOLFSSH_NO_ECDH_SHA2_NISTP521
{ ID_ECDH_SHA2_NISTP521, TYPE_KEX, "ecdh-sha2-nistp521" },
#endif
#ifndef WOLFSSH_NO_DH_GEX_SHA256
{ ID_DH_GROUP14_SHA256, TYPE_KEX, "diffie-hellman-group14-sha256" },
#endif
#ifndef WOLFSSH_NO_ECDH_NISTP256_KYBER_LEVEL1_SHA256
{ ID_ECDH_NISTP256_KYBER_LEVEL1_SHA256, TYPE_KEX,
"[email protected]" },
Expand Down Expand Up @@ -10542,6 +10539,65 @@ int DoReceive(WOLFSSH* ssh)
return ret;
}
ssh->processReplyState = PROCESS_PACKET_LENGTH;
switch (kexId) {
#ifndef WOLFSSH_NO_DH_GROUP1_SHA1
case ID_DH_GROUP1_SHA1:
*primeGroup = dhPrimeGroup1;
*primeGroupSz = dhPrimeGroup1Sz;
*generator = dhGenerator;
*generatorSz = dhGeneratorSz;
break;
#endif
#ifndef WOLFSSH_NO_DH_GROUP14_SHA1
case ID_DH_GROUP14_SHA1:
*primeGroup = dhPrimeGroup14;
*primeGroupSz = dhPrimeGroup14Sz;
*generator = dhGenerator;
*generatorSz = dhGeneratorSz;
break;
#endif
#ifndef WOLFSSH_NO_DH_GROUP14_SHA256
case ID_DH_GROUP14_SHA256:
*primeGroup = dhPrimeGroup14;
*primeGroupSz = dhPrimeGroup14Sz;
*generator = dhGenerator;
*generatorSz = dhGeneratorSz;
break;
#endif
#ifndef WOLFSSH_NO_DH_GEX_SHA256
case ID_DH_GEX_SHA256:
*primeGroup = dhPrimeGroup14;
*primeGroupSz = dhPrimeGroup14Sz;
*generator = dhGenerator;
*generatorSz = dhGeneratorSz;
break;
#endif
default:
ret = WS_INVALID_ALGO_ID;
}

return ret;
}
#endif /* !WOLFSSH_NO_DH */


/* Sets the signing key and hashes in the public key
* returns WS_SUCCESS on success */
static int SendKexGetSigningKey(WOLFSSH* ssh,
struct wolfSSH_sigKeyBlockFull *sigKeyBlock_ptr,
enum wc_HashType hashId, wc_HashAlg* hash, word32 keyIdx)
{
int ret = 0;
byte isCert = 0;
void* heap;
byte scratchLen[LENGTH_SZ];
word32 scratch = 0;
#ifndef WOLFSSH_NO_DH_GEX_SHA256
const byte* primeGroup = NULL;
word32 primeGroupSz = 0;
const byte* generator = NULL;
word32 generatorSz = 0;
#endif

if (!aeadMode) {
/* Decrypt first block if encrypted */
Expand Down

0 comments on commit e9b5d25

Please sign in to comment.