X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_lcl.h;h=4801e17aeb14086e49a6ac10e0c7cf3978720f41;hb=265d89dcbce7fce4fa2b560b70597132fd8eb3b2;hp=6ca32972ffe4a0db3e4468abf86a08cff0a402e3;hpb=970934039a4481b67c9c6433e20ca3002098cae6;p=openssl-gost%2Fengine.git diff --git a/gost_lcl.h b/gost_lcl.h index 6ca3297..4801e17 100644 --- a/gost_lcl.h +++ b/gost_lcl.h @@ -10,6 +10,7 @@ * OpenSSL 0.9.9 libraries required to compile and use * * this code * **********************************************************************/ +# include # include # include # include @@ -36,11 +37,14 @@ typedef struct R3410_ec { char *x; char *y; char *cofactor; + EC_GROUP *group; } R3410_ec_params; extern R3410_ec_params R3410_2001_paramset[], *R3410_2012_256_paramset, R3410_2012_512_paramset[]; +void free_cached_groups(void); + extern const ENGINE_CMD_DEFN gost_cmds[]; int gost_control_func(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); const char *get_gost_engine_param(int param); @@ -57,6 +61,7 @@ int register_pmeth_gost(int id, EVP_PKEY_METHOD **pmeth, int flags); /* For GOST R34.10 parameters */ # define param_ctrl_string "paramset" # define ukm_ctrl_string "ukmhex" +# define vko_ctrl_string "vko" # define EVP_PKEY_CTRL_GOST_PARAMSET (EVP_PKEY_ALG_CTRL+1) /* For GOST 28147 MAC */ # define key_ctrl_string "key" @@ -64,6 +69,7 @@ int register_pmeth_gost(int id, EVP_PKEY_METHOD **pmeth, int flags); # define maclen_ctrl_string "size" # define EVP_PKEY_CTRL_GOST_MAC_HEXKEY (EVP_PKEY_ALG_CTRL+3) # define EVP_PKEY_CTRL_MAC_LEN (EVP_PKEY_ALG_CTRL+5) +# define EVP_PKEY_CTRL_SET_VKO (EVP_PKEY_ALG_CTRL+11) /* Pmeth internal representation */ struct gost_pmeth_data { int sign_param_nid; /* Should be set whenever parameters are @@ -73,6 +79,7 @@ struct gost_pmeth_data { size_t shared_ukm_size; int peer_key_used; int cipher_nid; /* KExp15/KImp15 algs */ + int vko_dgst_nid; }; struct gost_mac_pmeth_data { @@ -247,6 +254,22 @@ 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, ECDSA_SIG *sig, EC_KEY *ec); int gost_ec_compute_public(EC_KEY *ec); +int gost_ec_point_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, + const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); + +#define CURVEDEF(a) \ +int point_mul_##a(const EC_GROUP *group, EC_POINT *r, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\ +int point_mul_g_##a(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, BN_CTX *ctx);\ +int point_mul_two_##a(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); + +CURVEDEF(id_GostR3410_2001_CryptoPro_A_ParamSet) +CURVEDEF(id_GostR3410_2001_CryptoPro_B_ParamSet) +CURVEDEF(id_GostR3410_2001_CryptoPro_C_ParamSet) +CURVEDEF(id_GostR3410_2001_TestParamSet) +CURVEDEF(id_tc26_gost_3410_2012_256_paramSetA) +CURVEDEF(id_tc26_gost_3410_2012_512_paramSetA) +CURVEDEF(id_tc26_gost_3410_2012_512_paramSetB) +CURVEDEF(id_tc26_gost_3410_2012_512_paramSetC) /* VKO */ int VKO_compute_key(unsigned char *shared_key, @@ -286,6 +309,9 @@ int pack_sign_cp(ECDSA_SIG *s, int order, unsigned char *sig, size_t *siglen); /* Get private key as BIGNUM from both 34.10-2001 keys*/ /* Returns pointer into EVP_PKEY structure */ BIGNUM *gost_get0_priv_key(const EVP_PKEY *pkey); +/* from gost_crypt.c */ +/* Decrements 8-byte sequence */ +int decrement_sequence(unsigned char *seq, int decrement); /* Struct describing cipher and used for init/deinit.*/ struct gost_cipher_st {