]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_ameth.c
Fix #67
[openssl-gost/engine.git] / gost_ameth.c
index b2d6abacb2544132d9ee9132f332144445d9d298..d53b89e89d577eab679b7602ec7e0d5158e21f76 100644 (file)
@@ -19,7 +19,7 @@
 #include "gost_lcl.h"
 #include "e_gost_err.h"
 
-#define PK_UNMASK_PARAM "UNMASK"
+#define PK_WRAP_PARAM "LEGACY_PK_WRAP"
 
 /*
  * Pack bignum into byte buffer of given size, filling all leading bytes by
@@ -181,7 +181,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:
@@ -419,6 +419,8 @@ static int priv_encode_gost(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk)
     ASN1_STRING *params = encode_gost_algor_params(pk);
     unsigned char *buf = NULL;
     int key_len = pkey_bits_gost(pk), i = 0;
+    /* unmasked private key */
+    const char *pk_format = get_gost_engine_param(GOST_PARAM_PK_FORMAT);
 
     if (!params) {
         return 0;
@@ -441,9 +443,7 @@ static int priv_encode_gost(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk)
         buf[key_len - 1 - i] = tmp;
     }
 
-    /* unmasked private key */
-    const char *pk_param = get_gost_engine_param(GOST_PARAM_PK_PARAMS);
-    if(pk_param != NULL && strcmp(pk_param, PK_UNMASK_PARAM) == 0) {
+    if(pk_format != NULL && strcmp(pk_format, PK_WRAP_PARAM) == 0) {
         ASN1_STRING *octet = NULL;
         int priv_len = 0;
         unsigned char *priv_buf = NULL;