]> wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_ameth.c
Merge pull request #75 from IamUndef/patch-1
[openssl-gost/engine.git] / gost_ameth.c
index 5089e2a21adf1184f6edebed1b3889471ba6610f..5e20f1e21c7cedf31f7f8c19cf95377095d22b9f 100644 (file)
 
 #define PK_WRAP_PARAM "LEGACY_PK_WRAP"
 
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+/* some functions have const'ed arguments since openssl-1.1.0 */
+# define OPENSSL110_const const
+#else
+# define OPENSSL110_const
+#endif
+
 /*
  * Pack bignum into byte buffer of given size, filling all leading bytes by
  * zeros
@@ -131,9 +138,9 @@ static int gost_decode_nid_params(EVP_PKEY *pkey, int pkey_nid, int param_nid)
  * Parses GOST algorithm parameters from X509_ALGOR and modifies pkey setting
  * NID and parameters
  */
-static int decode_gost_algor_params(EVP_PKEY *pkey, const X509_ALGOR *palg)
+static int decode_gost_algor_params(EVP_PKEY *pkey, OPENSSL110_const X509_ALGOR *palg)
 {
-    const ASN1_OBJECT *palg_obj = NULL;
+    OPENSSL110_const ASN1_OBJECT *palg_obj = NULL;
     int ptype = V_ASN1_UNDEF;
     int pkey_nid = NID_undef, param_nid = NID_undef;
     ASN1_STRING *pval = NULL;
@@ -142,7 +149,7 @@ static int decode_gost_algor_params(EVP_PKEY *pkey, const X509_ALGOR *palg)
 
     if (!pkey || !palg)
         return 0;
-    X509_ALGOR_get0(&palg_obj, &ptype, (const void **)&pval, palg);
+    X509_ALGOR_get0(&palg_obj, &ptype, (OPENSSL110_const void **)&pval, palg);
     if (ptype != V_ASN1_SEQUENCE) {
         GOSTerr(GOST_F_DECODE_GOST_ALGOR_PARAMS,
                 GOST_R_BAD_KEY_PARAMETERS_FORMAT);
@@ -181,7 +188,7 @@ static int gost_set_priv_key(EVP_PKEY *pkey, BIGNUM *priv)
             if (!EC_KEY_set_private_key(ec, priv))
                 return 0;
             if (!EVP_PKEY_missing_parameters(pkey))
-                gost_ec_compute_public(ec);
+                return gost_ec_compute_public(ec);
             break;
         }
     default:
@@ -331,14 +338,14 @@ static BIGNUM *unmask_priv_key(EVP_PKEY *pk,
     return pknum_masked;
 }
 
-static int priv_decode_gost(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf)
+static int priv_decode_gost(EVP_PKEY *pk, OPENSSL110_const PKCS8_PRIV_KEY_INFO *p8inf)
 {
     const unsigned char *pkey_buf = NULL, *p = NULL;
     int priv_len = 0;
     BIGNUM *pk_num = NULL;
     int ret = 0;
-    const X509_ALGOR *palg = NULL;
-    const ASN1_OBJECT *palg_obj = NULL;
+    OPENSSL110_const X509_ALGOR *palg = NULL;
+    OPENSSL110_const ASN1_OBJECT *palg_obj = NULL;
     ASN1_INTEGER *priv_key = NULL;
     int expected_key_len = 32;