extern
void dump_signature(const char *message, const unsigned char *buffer,
size_t len);
-void dump_dsa_sig(const char *message, DSA_SIG *sig);
+void dump_dsa_sig(const char *message, ECDSA_SIG *sig);
#else
# define dump_signature(a,b,c)
}
/*
- * Computes gost_ec signature as DSA_SIG structure
+ * Computes gost_ec signature as ECDSA_SIG structure
*
*/
-DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
+ECDSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
{
- DSA_SIG *newsig = NULL, *ret = NULL;
+ ECDSA_SIG *newsig = NULL, *ret = NULL;
BIGNUM *md = NULL;
BIGNUM *order = NULL;
const EC_GROUP *group;
BN_CTX_start(ctx);
OPENSSL_assert(dlen == 32 || dlen == 64);
md = hashsum2bn(dgst, dlen);
- newsig = DSA_SIG_new();
+ newsig = ECDSA_SIG_new();
if (!newsig || !md) {
GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
}
- DSA_SIG_set0(newsig, new_r, new_s);
+ ECDSA_SIG_set0(newsig, new_r, new_s);
ret = newsig;
err:
if (md)
BN_free(md);
if (!ret && newsig) {
- DSA_SIG_free(newsig);
+ ECDSA_SIG_free(newsig);
}
return ret;
}
*
*/
int gost_ec_verify(const unsigned char *dgst, int dgst_len,
- DSA_SIG *sig, EC_KEY *ec)
+ ECDSA_SIG *sig, EC_KEY *ec)
{
BN_CTX *ctx;
const EC_GROUP *group = (ec) ? EC_KEY_get0_group(ec) : NULL;
goto err;
}
- DSA_SIG_get0(sig, &sig_r, &sig_s);
+ ECDSA_SIG_get0(sig, &sig_r, &sig_s);
if (BN_is_zero(sig_s) || BN_is_zero(sig_r) ||
(BN_cmp(sig_s, order) >= 1) || (BN_cmp(sig_r, order) >= 1)) {
**********************************************************************/
# include <openssl/bn.h>
# include <openssl/evp.h>
-# include <openssl/dsa.h>
# include <openssl/asn1t.h>
# include <openssl/x509.h>
# include <openssl/engine.h>
/* From gost_ec_keyx.c */
int pkey_gost_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
int fill_GOST_EC_params(EC_KEY *eckey, int nid);
-int gost_sign_keygen(DSA *dsa);
int gost_ec_keygen(EC_KEY *ec);
-DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey);
-
-int gost_do_verify(const unsigned char *dgst, int dgst_len,
- DSA_SIG *sig, DSA *dsa);
+ECDSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey);
int gost_ec_verify(const unsigned char *dgst, int dgst_len,
- DSA_SIG *sig, EC_KEY *ec);
+ ECDSA_SIG *sig, EC_KEY *ec);
int gost_ec_compute_public(EC_KEY *ec);
/* KDF TREE */
*/
int store_bignum(const BIGNUM *bn, unsigned char *buf, int len);
/* Pack GOST R 34.10 signature according to CryptoPro rules */
-int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen);
+int pack_sign_cp(ECDSA_SIG *s, int order, unsigned char *sig, size_t *siglen);
/* from ameth.c */
/* Get private key as BIGNUM from both 34.10-2001 keys*/
/* Returns pointer into EVP_PKEY structure */
/* ----------- sign callbacks --------------------------------------*/
/*
* Packs signature according to Cryptopro rules
- * and frees up DSA_SIG structure
+ * and frees up ECDSA_SIG structure
*/
-int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen)
+int pack_sign_cp(ECDSA_SIG *s, int order, unsigned char *sig, size_t *siglen)
{
const BIGNUM *sig_r = NULL, *sig_s = NULL;
- DSA_SIG_get0(s, &sig_r, &sig_s);
+ ECDSA_SIG_get0(s, &sig_r, &sig_s);
*siglen = 2 * order;
memset(sig, 0, *siglen);
store_bignum(sig_s, sig, order);
store_bignum(sig_r, sig + order, order);
- DSA_SIG_free(s);
+ ECDSA_SIG_free(s);
return 1;
}
size_t *siglen, const unsigned char *tbs,
size_t tbs_len)
{
- DSA_SIG *unpacked_sig = NULL;
+ ECDSA_SIG *unpacked_sig = NULL;
EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
int order = 0;
/* ------------------- verify callbacks ---------------------------*/
/* Unpack signature according to cryptopro rules */
-DSA_SIG *unpack_cp_signature(const unsigned char *sigbuf, size_t siglen)
+ECDSA_SIG *unpack_cp_signature(const unsigned char *sigbuf, size_t siglen)
{
- DSA_SIG *sig;
+ ECDSA_SIG *sig;
BIGNUM *r = NULL, *s = NULL;
- sig = DSA_SIG_new();
+ sig = ECDSA_SIG_new();
if (sig == NULL) {
GOSTerr(GOST_F_UNPACK_CP_SIGNATURE, ERR_R_MALLOC_FAILURE);
return NULL;
}
s = BN_bin2bn(sigbuf, siglen / 2, NULL);
r = BN_bin2bn(sigbuf + siglen / 2, siglen / 2, NULL);
- DSA_SIG_set0(sig, r, s);
+ ECDSA_SIG_set0(sig, r, s);
return sig;
}
{
int ok = 0;
EVP_PKEY *pub_key = EVP_PKEY_CTX_get0_pkey(ctx);
- DSA_SIG *s = (sig) ? unpack_cp_signature(sig, siglen) : NULL;
+ ECDSA_SIG *s = (sig) ? unpack_cp_signature(sig, siglen) : NULL;
if (!s)
return 0;
#ifdef DEBUG_SIGN
#endif
if (pub_key)
ok = gost_ec_verify(tbs, tbs_len, s, EVP_PKEY_get0(pub_key));
- DSA_SIG_free(s);
+ ECDSA_SIG_free(s);
return ok;
}