@@ -2219,6 +2219,17 @@ static int getPRFAlgorithm(SecurityParameters securityParameters, int cipherSuit
22192219 throw new TlsFatalAlert (AlertDescription .illegal_parameter );
22202220 }
22212221
2222+ case CipherSuite .TLS_GOSTR341112_256_WITH_28147_CNT_IMIT :
2223+ case CipherSuite .TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC :
2224+ case CipherSuite .TLS_GOSTR341112_256_WITH_MAGMA_CTR_OMAC :
2225+ {
2226+ if (isTLSv12Exactly )
2227+ {
2228+ return PRFAlgorithm .tls_prf_gostr3411_2012_256 ;
2229+ }
2230+ throw new TlsFatalAlert (AlertDescription .illegal_parameter );
2231+ }
2232+
22222233 case CipherSuite .TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 :
22232234 case CipherSuite .TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 :
22242235 case CipherSuite .TLS_DHE_PSK_WITH_NULL_SHA384 :
@@ -2707,6 +2718,9 @@ public static int getEncryptionAlgorithm(int cipherSuite)
27072718 {
27082719 switch (cipherSuite )
27092720 {
2721+ case CipherSuite .TLS_GOSTR341112_256_WITH_28147_CNT_IMIT :
2722+ return EncryptionAlgorithm ._28147_CNT_IMIT ;
2723+
27102724 case CipherSuite .TLS_DH_anon_WITH_3DES_EDE_CBC_SHA :
27112725 case CipherSuite .TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA :
27122726 case CipherSuite .TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA :
@@ -3007,6 +3021,12 @@ public static int getEncryptionAlgorithm(int cipherSuite)
30073021 case CipherSuite .TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 :
30083022 return EncryptionAlgorithm .CHACHA20_POLY1305 ;
30093023
3024+ case CipherSuite .TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC :
3025+ return EncryptionAlgorithm .KUZNYECHIK_CTR_OMAC ;
3026+
3027+ case CipherSuite .TLS_GOSTR341112_256_WITH_MAGMA_CTR_OMAC :
3028+ return EncryptionAlgorithm .MAGMA_CTR_OMAC ;
3029+
30103030 case CipherSuite .TLS_DHE_PSK_WITH_NULL_SHA :
30113031 case CipherSuite .TLS_ECDH_anon_WITH_NULL_SHA :
30123032 case CipherSuite .TLS_ECDH_ECDSA_WITH_NULL_SHA :
@@ -3085,6 +3105,9 @@ public static int getEncryptionAlgorithmType(int encryptionAlgorithm)
30853105 case EncryptionAlgorithm .SM4_CBC :
30863106 return CipherType .block ;
30873107
3108+ case EncryptionAlgorithm ._28147_CNT_IMIT :
3109+ case EncryptionAlgorithm .KUZNYECHIK_CTR_OMAC :
3110+ case EncryptionAlgorithm .MAGMA_CTR_OMAC :
30883111 case EncryptionAlgorithm .NULL :
30893112 case EncryptionAlgorithm .RC4_40 :
30903113 case EncryptionAlgorithm .RC4_128 :
@@ -3332,6 +3355,11 @@ public static int getKeyExchangeAlgorithm(int cipherSuite)
33323355 case CipherSuite .TLS_ECDHE_RSA_WITH_NULL_SHA :
33333356 return KeyExchangeAlgorithm .ECDHE_RSA ;
33343357
3358+ case CipherSuite .TLS_GOSTR341112_256_WITH_28147_CNT_IMIT :
3359+ case CipherSuite .TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC :
3360+ case CipherSuite .TLS_GOSTR341112_256_WITH_MAGMA_CTR_OMAC :
3361+ return KeyExchangeAlgorithm .GOSTR341112_256 ;
3362+
33353363 case CipherSuite .TLS_AES_128_CCM_8_SHA256 :
33363364 case CipherSuite .TLS_AES_128_CCM_SHA256 :
33373365 case CipherSuite .TLS_AES_128_GCM_SHA256 :
@@ -3905,6 +3933,9 @@ public static ProtocolVersion getMinimumVersion(int cipherSuite)
39053933 case CipherSuite .TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 :
39063934 case CipherSuite .TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 :
39073935 case CipherSuite .TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :
3936+ case CipherSuite .TLS_GOSTR341112_256_WITH_28147_CNT_IMIT :
3937+ case CipherSuite .TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC :
3938+ case CipherSuite .TLS_GOSTR341112_256_WITH_MAGMA_CTR_OMAC :
39083939 case CipherSuite .TLS_PSK_DHE_WITH_AES_128_CCM_8 :
39093940 case CipherSuite .TLS_PSK_DHE_WITH_AES_256_CCM_8 :
39103941 case CipherSuite .TLS_PSK_WITH_AES_128_CCM :
@@ -4090,8 +4121,6 @@ static boolean isValidKeyShareSelection(ProtocolVersion negotiatedVersion, int[]
40904121
40914122 static boolean isValidSignatureAlgorithmForServerKeyExchange (short signatureAlgorithm , int keyExchangeAlgorithm )
40924123 {
4093- // TODO[tls13]
4094-
40954124 switch (keyExchangeAlgorithm )
40964125 {
40974126 case KeyExchangeAlgorithm .DHE_RSA :
@@ -4129,6 +4158,7 @@ static boolean isValidSignatureAlgorithmForServerKeyExchange(short signatureAlgo
41294158 case KeyExchangeAlgorithm .NULL :
41304159 return SignatureAlgorithm .anonymous != signatureAlgorithm ;
41314160
4161+ case KeyExchangeAlgorithm .GOSTR341112_256 :
41324162 default :
41334163 return false ;
41344164 }
@@ -4411,6 +4441,9 @@ public static boolean isSupportedKeyExchange(TlsCrypto crypto, int keyExchangeAl
44114441 return crypto .hasSRPAuthentication ()
44124442 && hasAnyRSASigAlgs (crypto );
44134443
4444+ // TODO[RFC 9189]
4445+ case KeyExchangeAlgorithm .GOSTR341112_256 :
4446+
44144447 default :
44154448 return false ;
44164449 }
@@ -5620,9 +5653,32 @@ static void negotiatedCipherSuite(SecurityParameters securityParameters, int cip
56205653 {
56215654 securityParameters .verifyDataLength = securityParameters .getPRFHashLength ();
56225655 }
5656+ else if (negotiatedVersion .isSSL ())
5657+ {
5658+ securityParameters .verifyDataLength = 36 ;
5659+ }
56235660 else
56245661 {
5625- securityParameters .verifyDataLength = negotiatedVersion .isSSL () ? 36 : 12 ;
5662+ /*
5663+ * RFC 9189 4.2.6. The verify_data_length value is equal to 32 for the CTR_OMAC cipher
5664+ * suites and is equal to 12 for the CNT_IMIT cipher suite.
5665+ */
5666+ switch (cipherSuite )
5667+ {
5668+ case CipherSuite .TLS_GOSTR341112_256_WITH_KUZNYECHIK_CTR_OMAC :
5669+ case CipherSuite .TLS_GOSTR341112_256_WITH_MAGMA_CTR_OMAC :
5670+ {
5671+ securityParameters .verifyDataLength = 32 ;
5672+ break ;
5673+ }
5674+
5675+ case CipherSuite .TLS_GOSTR341112_256_WITH_28147_CNT_IMIT :
5676+ default :
5677+ {
5678+ securityParameters .verifyDataLength = 12 ;
5679+ break ;
5680+ }
5681+ }
56265682 }
56275683 }
56285684
0 commit comments