forked from wolfSSL/wolfssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wolfSSL#731 from ejohnstown/dh-group14-sha256
DH Group 14 with SHA256
- Loading branch information
1 parent
cd66792
commit e9b5d25
Showing
1 changed file
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]" }, | ||
|
@@ -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 */ | ||
|