@@ -1041,12 +1041,18 @@ static const NameIdPair NameIdMap[] = {
10411041 /* Encryption IDs */
10421042#ifndef WOLFSSH_NO_AES_CBC
10431043 { ID_AES128_CBC , "aes128-cbc" },
1044+ { ID_AES192_CBC , "aes192-cbc" },
1045+ { ID_AES256_CBC , "aes256-cbc" },
10441046#endif
10451047#ifndef WOLFSSH_NO_AES_CTR
10461048 { ID_AES128_CTR , "aes128-ctr" },
1049+ { ID_AES192_CTR , "aes192-ctr" },
1050+ { ID_AES256_CTR , "aes256-ctr" },
10471051#endif
10481052#ifndef WOLFSSH_NO_AES_GCM
10491053 { ID_AES128_GCM , "aes128-gcm@openssh.com" },
1054+ { ID_AES192_GCM , "aes192-gcm@openssh.com" },
1055+ { ID_AES256_GCM , "aes256-gcm@openssh.com" },
10501056#endif
10511057
10521058 /* Integrity IDs */
@@ -2001,12 +2007,18 @@ static int GetNameList(byte* idList, word32* idListSz,
20012007
20022008static const byte cannedEncAlgo [] = {
20032009#ifndef WOLFSSH_NO_AES_GCM
2010+ ID_AES256_GCM ,
2011+ ID_AES192_GCM ,
20042012 ID_AES128_GCM ,
20052013#endif
20062014#ifndef WOLFSSH_NO_AES_CTR
2015+ ID_AES256_CTR ,
2016+ ID_AES192_CTR ,
20072017 ID_AES128_CTR ,
20082018#endif
20092019#ifndef WOLFSSH_NO_AES_CBC
2020+ ID_AES256_CBC ,
2021+ ID_AES192_CBC ,
20102022 ID_AES128_CBC ,
20112023#endif
20122024};
@@ -2122,14 +2134,20 @@ static INLINE byte BlockSzForId(byte id)
21222134 switch (id ) {
21232135#ifndef WOLFSSH_NO_AES_CBC
21242136 case ID_AES128_CBC :
2137+ case ID_AES192_CBC :
2138+ case ID_AES256_CBC :
21252139 return AES_BLOCK_SIZE ;
21262140#endif
21272141#ifndef WOLFSSH_NO_AES_CTR
21282142 case ID_AES128_CTR :
2143+ case ID_AES192_CTR :
2144+ case ID_AES256_CTR :
21292145 return AES_BLOCK_SIZE ;
21302146#endif
21312147#ifndef WOLFSSH_NO_AES_GCM
21322148 case ID_AES128_GCM :
2149+ case ID_AES192_GCM :
2150+ case ID_AES256_GCM :
21332151 return AES_BLOCK_SIZE ;
21342152#endif
21352153 default :
@@ -2176,15 +2194,27 @@ static INLINE byte KeySzForId(byte id)
21762194#endif
21772195#ifndef WOLFSSH_NO_AES_CBC
21782196 case ID_AES128_CBC :
2179- return AES_BLOCK_SIZE ;
2197+ return AES_128_KEY_SIZE ;
2198+ case ID_AES192_CBC :
2199+ return AES_192_KEY_SIZE ;
2200+ case ID_AES256_CBC :
2201+ return AES_256_KEY_SIZE ;
21802202#endif
21812203#ifndef WOLFSSH_NO_AES_CTR
21822204 case ID_AES128_CTR :
2183- return AES_BLOCK_SIZE ;
2205+ return AES_128_KEY_SIZE ;
2206+ case ID_AES192_CTR :
2207+ return AES_192_KEY_SIZE ;
2208+ case ID_AES256_CTR :
2209+ return AES_256_KEY_SIZE ;
21842210#endif
21852211#ifndef WOLFSSH_NO_AES_GCM
21862212 case ID_AES128_GCM :
2187- return AES_BLOCK_SIZE ;
2213+ return AES_128_KEY_SIZE ;
2214+ case ID_AES192_GCM :
2215+ return AES_192_KEY_SIZE ;
2216+ case ID_AES256_GCM :
2217+ return AES_256_KEY_SIZE ;
21882218#endif
21892219 default :
21902220 return 0 ;
@@ -2306,11 +2336,16 @@ static INLINE const char *PrimeNameForId(byte id)
23062336
23072337static INLINE byte AeadModeForId (byte id )
23082338{
2339+ switch (id ) {
23092340#ifndef WOLFSSH_NO_AES_GCM
2310- return (id == ID_AES128_GCM );
2311- #else
2312- return 0 ;
2341+ case ID_AES128_GCM :
2342+ case ID_AES192_GCM :
2343+ case ID_AES256_GCM :
2344+ return 1 ;
23132345#endif
2346+ default :
2347+ return 0 ;
2348+ }
23142349}
23152350
23162351
@@ -3380,7 +3415,9 @@ static int DoNewKeys(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
33803415
33813416#ifndef WOLFSSH_NO_AES_CBC
33823417 case ID_AES128_CBC :
3383- WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes128-cbc" );
3418+ case ID_AES192_CBC :
3419+ case ID_AES256_CBC :
3420+ WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes-cbc" );
33843421 ret = wc_AesSetKey (& ssh -> decryptCipher .aes ,
33853422 ssh -> peerKeys .encKey , ssh -> peerKeys .encKeySz ,
33863423 ssh -> peerKeys .iv , AES_DECRYPTION );
@@ -3389,7 +3426,9 @@ static int DoNewKeys(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
33893426
33903427#ifndef WOLFSSH_NO_AES_CTR
33913428 case ID_AES128_CTR :
3392- WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes128-ctr" );
3429+ case ID_AES192_CTR :
3430+ case ID_AES256_CTR :
3431+ WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes-ctr" );
33933432 ret = wc_AesSetKey (& ssh -> decryptCipher .aes ,
33943433 ssh -> peerKeys .encKey , ssh -> peerKeys .encKeySz ,
33953434 ssh -> peerKeys .iv , AES_ENCRYPTION );
@@ -3398,7 +3437,9 @@ static int DoNewKeys(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
33983437
33993438#ifndef WOLFSSH_NO_AES_GCM
34003439 case ID_AES128_GCM :
3401- WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes128-gcm" );
3440+ case ID_AES192_GCM :
3441+ case ID_AES256_GCM :
3442+ WLOG (WS_LOG_DEBUG , "DNK: peer using cipher aes-gcm" );
34023443 ret = wc_AesGcmSetKey (& ssh -> decryptCipher .aes ,
34033444 ssh -> peerKeys .encKey ,
34043445 ssh -> peerKeys .encKeySz );
@@ -5603,6 +5644,8 @@ static INLINE int Encrypt(WOLFSSH* ssh, byte* cipher, const byte* input,
56035644
56045645#ifndef WOLFSSH_NO_AES_CBC
56055646 case ID_AES128_CBC :
5647+ case ID_AES192_CBC :
5648+ case ID_AES256_CBC :
56065649 if (sz % AES_BLOCK_SIZE || wc_AesCbcEncrypt (& ssh -> encryptCipher .aes ,
56075650 cipher , input , sz ) < 0 ) {
56085651
@@ -5613,6 +5656,8 @@ static INLINE int Encrypt(WOLFSSH* ssh, byte* cipher, const byte* input,
56135656
56145657#ifndef WOLFSSH_NO_AES_CTR
56155658 case ID_AES128_CTR :
5659+ case ID_AES192_CTR :
5660+ case ID_AES256_CTR :
56165661 if (sz % AES_BLOCK_SIZE || AESCTRHELPER (& ssh -> encryptCipher .aes ,
56175662 cipher , input , sz ) < 0 ) {
56185663
@@ -5647,6 +5692,8 @@ static INLINE int Decrypt(WOLFSSH* ssh, byte* plain, const byte* input,
56475692
56485693#ifndef WOLFSSH_NO_AES_CBC
56495694 case ID_AES128_CBC :
5695+ case ID_AES192_CBC :
5696+ case ID_AES256_CBC :
56505697 if (sz % AES_BLOCK_SIZE || wc_AesCbcDecrypt (& ssh -> decryptCipher .aes ,
56515698 plain , input , sz ) < 0 ) {
56525699
@@ -5657,6 +5704,8 @@ static INLINE int Decrypt(WOLFSSH* ssh, byte* plain, const byte* input,
56575704
56585705#ifndef WOLFSSH_NO_AES_CTR
56595706 case ID_AES128_CTR :
5707+ case ID_AES192_CTR :
5708+ case ID_AES256_CTR :
56605709 if (sz % AES_BLOCK_SIZE || AESCTRHELPER (& ssh -> decryptCipher .aes ,
56615710 plain , input , sz ) < 0 ) {
56625711
@@ -5855,15 +5904,20 @@ static INLINE int EncryptAead(WOLFSSH* ssh, byte* cipher,
58555904
58565905 WLOG (WS_LOG_DEBUG , "EncryptAead %s" , IdToName (ssh -> encryptId ));
58575906
5907+ switch (ssh -> encryptId ) {
58585908#ifndef WOLFSSH_NO_AES_GCM
5859- if (ssh -> encryptId == ID_AES128_GCM ) {
5860- ret = wc_AesGcmEncrypt (& ssh -> encryptCipher .aes , cipher , input , sz ,
5861- ssh -> keys .iv , ssh -> keys .ivSz ,
5862- authTag , ssh -> macSz , auth , authSz );
5863- }
5864- else
5909+ case ID_AES128_GCM :
5910+ case ID_AES192_GCM :
5911+ case ID_AES256_GCM :
5912+ ret = wc_AesGcmEncrypt (& ssh -> encryptCipher .aes , cipher , input , sz ,
5913+ ssh -> keys .iv , ssh -> keys .ivSz ,
5914+ authTag , ssh -> macSz , auth , authSz );
5915+ break ;
58655916#endif
5866- ret = WS_INVALID_ALGO_ID ;
5917+
5918+ default :
5919+ ret = WS_INVALID_ALGO_ID ;
5920+ }
58675921
58685922 AeadIncrementExpIv (ssh -> keys .iv );
58695923 ssh -> txCount += sz ;
@@ -5885,15 +5939,20 @@ static INLINE int DecryptAead(WOLFSSH* ssh, byte* plain,
58855939
58865940 WLOG (WS_LOG_DEBUG , "DecryptAead %s" , IdToName (ssh -> peerEncryptId ));
58875941
5942+ switch (ssh -> peerEncryptId ) {
58885943#ifndef WOLFSSH_NO_AES_GCM
5889- if (ssh -> peerEncryptId == ID_AES128_GCM ) {
5890- ret = wc_AesGcmDecrypt (& ssh -> decryptCipher .aes , plain , input , sz ,
5891- ssh -> peerKeys .iv , ssh -> peerKeys .ivSz ,
5892- authTag , ssh -> peerMacSz , auth , authSz );
5893- }
5894- else
5944+ case ID_AES128_GCM :
5945+ case ID_AES192_GCM :
5946+ case ID_AES256_GCM :
5947+ ret = wc_AesGcmDecrypt (& ssh -> decryptCipher .aes , plain , input , sz ,
5948+ ssh -> peerKeys .iv , ssh -> peerKeys .ivSz ,
5949+ authTag , ssh -> peerMacSz , auth , authSz );
5950+ break ;
58955951#endif
5896- ret = WS_INVALID_ALGO_ID ;
5952+
5953+ default :
5954+ ret = WS_INVALID_ALGO_ID ;
5955+ }
58975956
58985957 AeadIncrementExpIv (ssh -> peerKeys .iv );
58995958 ssh -> rxCount += sz ;
@@ -6308,12 +6367,18 @@ static INLINE void CopyNameList(byte* buf, word32* idx,
63086367
63096368static const char cannedEncAlgoNames [] =
63106369#if !defined (WOLFSSH_NO_AES_GCM )
6370+ "aes256-gcm@openssh.com,"
6371+ "aes192-gcm@openssh.com,"
63116372 "aes128-gcm@openssh.com,"
63126373#endif
63136374#if !defined(WOLFSSH_NO_AES_CTR )
6375+ "aes256-ctr,"
6376+ "aes192-ctr,"
63146377 "aes128-ctr,"
63156378#endif
63166379#if !defined(WOLFSSH_NO_AES_CBC )
6380+ "aes256-cbc,"
6381+ "aes192-cbc,"
63176382 "aes128-cbc,"
63186383#endif
63196384 "" ;
@@ -7331,7 +7396,9 @@ int SendNewKeys(WOLFSSH* ssh)
73317396
73327397#ifndef WOLFSSH_NO_AES_CBC
73337398 case ID_AES128_CBC :
7334- WLOG (WS_LOG_DEBUG , "SNK: using cipher aes128-cbc" );
7399+ case ID_AES192_CBC :
7400+ case ID_AES256_CBC :
7401+ WLOG (WS_LOG_DEBUG , "SNK: using cipher aes-cbc" );
73357402 ret = wc_AesSetKey (& ssh -> encryptCipher .aes ,
73367403 ssh -> keys .encKey , ssh -> keys .encKeySz ,
73377404 ssh -> keys .iv , AES_ENCRYPTION );
@@ -7340,7 +7407,9 @@ int SendNewKeys(WOLFSSH* ssh)
73407407
73417408#ifndef WOLFSSH_NO_AES_CTR
73427409 case ID_AES128_CTR :
7343- WLOG (WS_LOG_DEBUG , "SNK: using cipher aes128-ctr" );
7410+ case ID_AES192_CTR :
7411+ case ID_AES256_CTR :
7412+ WLOG (WS_LOG_DEBUG , "SNK: using cipher aes-ctr" );
73447413 ret = wc_AesSetKey (& ssh -> encryptCipher .aes ,
73457414 ssh -> keys .encKey , ssh -> keys .encKeySz ,
73467415 ssh -> keys .iv , AES_ENCRYPTION );
@@ -7349,7 +7418,9 @@ int SendNewKeys(WOLFSSH* ssh)
73497418
73507419#ifndef WOLFSSH_NO_AES_GCM
73517420 case ID_AES128_GCM :
7352- WLOG (WS_LOG_DEBUG , "SNK: using cipher aes128-gcm" );
7421+ case ID_AES192_GCM :
7422+ case ID_AES256_GCM :
7423+ WLOG (WS_LOG_DEBUG , "SNK: using cipher aes-gcm" );
73537424 ret = wc_AesGcmSetKey (& ssh -> encryptCipher .aes ,
73547425 ssh -> keys .encKey , ssh -> keys .encKeySz );
73557426 break ;
0 commit comments