#include "gost_lcl.h"
#include "e_gost_err.h"
+#define PK_WRAP_PARAM "LEGACY_PK_WRAP"
+
/*
* Pack bignum into byte buffer of given size, filling all leading bytes by
* zeros
{
ASN1_OBJECT *algobj = OBJ_nid2obj(EVP_PKEY_base_id(pk));
ASN1_STRING *params = encode_gost_algor_params(pk);
- unsigned char /**priv_buf = NULL,*/ *buf = NULL;
- int key_len = pkey_bits_gost(pk), /*priv_len = 0,*/ i = 0;
+ unsigned char *buf = NULL;
+ int key_len = pkey_bits_gost(pk), i = 0;
- /*ASN1_STRING *octet = NULL;*/
if (!params) {
return 0;
}
buf[key_len - 1 - i] = tmp;
}
-/*
- octet = ASN1_STRING_new();
- ASN1_OCTET_STRING_set(octet, buf, key_len);
+ /* unmasked private key */
+ const char *pk_format = get_gost_engine_param(GOST_PARAM_PK_FORMAT);
+ if(pk_format != NULL && strcmp(pk_format, PK_WRAP_PARAM) == 0) {
+ ASN1_STRING *octet = NULL;
+ int priv_len = 0;
+ unsigned char *priv_buf = NULL;
+
+ octet = ASN1_STRING_new();
+ ASN1_OCTET_STRING_set(octet, buf, key_len);
+ priv_len = i2d_ASN1_OCTET_STRING(octet, &priv_buf);
+ ASN1_STRING_free(octet);
+ OPENSSL_free(buf);
- priv_len = i2d_ASN1_OCTET_STRING(octet, &priv_buf);
- ASN1_STRING_free(octet);
- OPENSSL_free(buf);
+ return PKCS8_pkey_set0(p8, algobj, 0, V_ASN1_SEQUENCE, params,
+ priv_buf, priv_len);
+ }
return PKCS8_pkey_set0(p8, algobj, 0, V_ASN1_SEQUENCE, params,
- priv_buf, priv_len); */
- return PKCS8_pkey_set0(p8, algobj, 0, V_ASN1_SEQUENCE, params,
- buf, key_len);
+ buf, key_len);
}
/* --------- printing keys --------------------------------*/
const unsigned char *pubkey_buf = NULL;
unsigned char *databuf;
ASN1_OBJECT *palgobj = NULL;
- int pub_len, i, j;
+ int pub_len;
EC_POINT *pub_key;
BIGNUM *X, *Y;
ASN1_OCTET_STRING *octet = NULL;
- int len;
+ size_t len;
const EC_GROUP *group;
if (!X509_PUBKEY_get0_param(&palgobj, &pubkey_buf, &pub_len, &palg, pub))
ASN1_OBJECT *algobj = NULL;
ASN1_OCTET_STRING *octet = NULL;
void *pval = NULL;
- unsigned char *buf = NULL, *databuf = NULL, *sptr;
- int i, j, data_len, ret = -1;
+ unsigned char *buf = NULL, *databuf = NULL;
+ int data_len, ret = -1;
const EC_POINT *pub_key;
BIGNUM *X = NULL, *Y = NULL, *order = NULL;
const EC_KEY *ec = EVP_PKEY_get0((EVP_PKEY *)pk);