* GOST CMS processing functions
*/
/* FIXME reaarange declarations */
-static int pub_decode_gost_ec(EVP_PKEY *pk, const X509_PUBKEY *pub);
+static int pub_decode_gost_ec(EVP_PKEY *pk, X509_PUBKEY *pub);
static int gost_cms_set_kari_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
{
}
/* ---------- Public key functions * --------------------------------------*/
-static int pub_decode_gost_ec(EVP_PKEY *pk, const X509_PUBKEY *pub)
+static int pub_decode_gost_ec(EVP_PKEY *pk, X509_PUBKEY *pub)
{
X509_ALGOR *palg = NULL;
const unsigned char *pubkey_buf = NULL;
const int vko_dgst_nid)
{
unsigned char *databuf = NULL;
- BIGNUM *scalar = NULL, *X = NULL, *Y = NULL;
+ BIGNUM *scalar = NULL, *X = NULL, *Y = NULL, *order = NULL;
const EC_GROUP *grp = NULL;
EC_POINT *pnt = NULL;
BN_CTX *ctx = NULL;
goto err;
}
+ order = BN_CTX_get(ctx);
grp = EC_KEY_get0_group(priv_key);
scalar = BN_CTX_get(ctx);
X = BN_CTX_get(ctx);
+ EC_GROUP_get_order(grp, order, ctx);
if ((Y = BN_CTX_get(ctx)) == NULL
|| (pnt = EC_POINT_new(grp)) == NULL
goto err;
}
- half_len = BN_num_bytes(EC_GROUP_get0_field(grp));
+ half_len = BN_num_bytes(order);
buf_len = 2 * half_len;
if ((databuf = OPENSSL_malloc(buf_len)) == NULL) {
GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
ret |= err;
X509_free(y);
+#if OPENSSL_VERSION_MAJOR >= 3
/* Convert public key to PEM and back. */
T(BIO_reset(bp));
T(PEM_write_bio_X509_PUBKEY(bp, xk));
print_test_result(!err);
ret |= err;
BIO_free(bp);
+#else
+ T(BIO_reset(bp));
+ BIO_free(bp);
+#endif
/*
* Verify
EVP_PKEY_free(pkey);
#endif
+#if OPENSSL_VERSION_MAJOR >= 3
/* Convert to DER and back, using OSSL_STORE API. */
T(BIO_reset(bp));
T(i2d_PrivateKey_bio(bp, priv_key));
} else
printf(cCYAN "skipped\n" cNORM);
BIO_free(bp);
+#else
+ T(BIO_reset(bp));
+ BIO_free(bp);
+#endif
/* Convert to DER and back, using memory API. */
unsigned char *kptr = NULL;