Bugfix: GOST2012 certificates for GOST ciphersuites were broken.
authorDmitry Belyavskiy <beldmit@gmail.com>
Thu, 3 May 2018 14:25:48 +0000 (17:25 +0300)
committerMatt Caswell <matt@openssl.org>
Wed, 30 May 2018 08:14:04 +0000 (09:14 +0100)
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6168)

ssl/ssl_locl.h
ssl/t1_lib.c

index 4aec81017984881d132c6056b4ab85b5842cb58c..31e5cc8aa94edbd7f278980ed358a3ccd60fe0c3 100644 (file)
 # define SSL_PKEY_ED25519        7
 # define SSL_PKEY_ED448          8
 # define SSL_PKEY_NUM            9
-/*
- * Pseudo-constant. GOST cipher suites can use different certs for 1
- * SSL_CIPHER. So let's see which one we have in fact.
- */
-# define SSL_PKEY_GOST_EC SSL_PKEY_NUM+1
 
 /*-
  * SSL_kRSA <- RSA_ENC
index c076782842086fb3c3c9fca93f5845b6db7c4def..e72ac737377132b79b197d5dd1bb3539fb3b3e57 100644 (file)
@@ -857,6 +857,21 @@ static const SIGALG_LOOKUP *tls1_get_legacy_sigalg(const SSL *s, int idx)
                     break;
                 }
             }
+
+            /*
+             * Some GOST ciphersuites allow more than one signature algorithms
+             * */
+            if (idx == SSL_PKEY_GOST01 && s->s3->tmp.new_cipher->algorithm_auth != SSL_aGOST01) {
+                int real_idx;
+
+                for (real_idx = SSL_PKEY_GOST12_512; real_idx >= SSL_PKEY_GOST01;
+                     real_idx--) {
+                    if (s->cert->pkeys[real_idx].privatekey != NULL) {
+                        idx = real_idx;
+                        break;
+                    }
+                }
+            }
         } else {
             idx = s->cert->key - s->cert->pkeys;
         }