16 #ifndef OPENSSL_NO_CMS
33 return gost_params->
nid;
74 params->
length = i2d_GOST_KEY_PARAMS(gkp, ¶ms->
data);
85 GOST_KEY_PARAMS_free(gkp);
99 const unsigned char *
p;
113 gkp = d2i_GOST_KEY_PARAMS(NULL,&p,pval->
length);
121 GOST_KEY_PARAMS_free(gkp);
215 static int pkey_ctrl_gost(
EVP_PKEY *pkey,
int op,
216 long arg1,
void *arg2)
236 #ifndef OPENSSL_NO_CMS
243 NULL, NULL, &alg1, &alg2);
258 ASN1_STRING * params = encode_gost_algor_params(pkey);
268 #ifndef OPENSSL_NO_CMS
273 ASN1_STRING * params = encode_gost_algor_params(pkey);
292 static void pkey_free_gost94(
EVP_PKEY *key)
300 static void pkey_free_gost01(
EVP_PKEY *key)
311 const unsigned char *pkey_buf = NULL,*p=NULL;
322 if (!decode_gost_algor_params(pk,palg))
329 unsigned char rev_buf[32];
340 rev_buf[31-i]=s->
data[i];
347 priv_key=d2i_ASN1_INTEGER(NULL,&p,priv_len);
348 if (!priv_key)
return 0;
350 ASN1_INTEGER_free(priv_key);
359 ret= gost_set_priv_key(pk,pk_num);
368 ASN1_STRING *params = encode_gost_algor_params(pk);
369 unsigned char *priv_buf = NULL;
378 priv_len = i2d_ASN1_INTEGER(asn1key,&priv_buf);
379 ASN1_INTEGER_free(asn1key);
384 static int print_gost_94(
BIO *out,
const EVP_PKEY *pkey,
int indent,
419 static int param_print_gost94(
BIO *out,
const EVP_PKEY *pkey,
int indent,
422 return print_gost_94(out, pkey, indent, pctx,0);
425 static int pub_print_gost94(
BIO *out,
const EVP_PKEY *pkey,
int indent,
428 return print_gost_94(out,pkey, indent, pctx,1);
430 static int priv_print_gost94(
BIO *out,
const EVP_PKEY *pkey,
int indent,
433 return print_gost_94(out,pkey,indent,pctx,2);
436 static int print_gost_01(
BIO *out,
const EVP_PKEY *pkey,
int indent,
495 static int param_print_gost01(
BIO *out,
const EVP_PKEY *pkey,
int indent,
498 return print_gost_01(out,pkey,indent,pctx,0);
500 static int pub_print_gost01(
BIO *out,
const EVP_PKEY *pkey,
int indent,
503 return print_gost_01(out,pkey, indent, pctx,1);
505 static int priv_print_gost01(
BIO *out,
const EVP_PKEY *pkey,
int indent,
508 return print_gost_01(out,pkey,indent,pctx,2);
511 static int param_missing_gost94(
const EVP_PKEY *pk)
515 if (!dsa->
q)
return 1;
519 static int param_missing_gost01(
const EVP_PKEY *pk)
548 #define COPYBIGNUM(a,b,x) if (a->x) BN_free(a->x); a->x=BN_dup(b->x);
550 COPYBIGNUM(dto,dfrom,
q)
551 COPYBIGNUM(dto,dfrom,g)
609 const unsigned char *pubkey_buf = NULL;
610 unsigned char *databuf;
617 &palg, pub))
return 0;
619 if (!decode_gost_algor_params(pk,palg))
return 0;
620 octet = d2i_ASN1_OCTET_STRING(NULL,&pubkey_buf,pub_len);
629 databuf[j]=octet->
data[i];
633 ASN1_OCTET_STRING_free(octet);
644 unsigned char *buf=NULL,*databuf,*sptr;
645 int i,j,data_len,ret=0;
652 ASN1_STRING *params = encode_gost_algor_params(pk);
659 octet = ASN1_OCTET_STRING_new();
662 for (i=0,j=data_len-1; i< data_len;i++,j--)
667 ret = i2d_ASN1_OCTET_STRING(octet,&buf);
668 ASN1_BIT_STRING_free(octet);
669 if (ret <0)
return 0;
676 const unsigned char *pubkey_buf = NULL;
677 unsigned char *databuf;
687 &palg, pub))
return 0;
689 if (!decode_gost_algor_params(pk,palg))
return 0;
691 octet = d2i_ASN1_OCTET_STRING(NULL,&pubkey_buf,pub_len);
700 databuf[j]=octet->
data[i];
703 ASN1_OCTET_STRING_free(octet);
738 unsigned char *buf=NULL,*databuf,*sptr;
739 int i,j,data_len,ret=0;
748 ASN1_STRING *params = encode_gost_algor_params(pk);
768 memset(databuf,0,data_len);
775 octet = ASN1_OCTET_STRING_new();
778 for (i=0,j=data_len-1;i<data_len;i++,j--)
783 ret = i2d_ASN1_OCTET_STRING(octet,&buf);
784 ASN1_BIT_STRING_free(octet);
785 if (ret <0)
return 0;
807 if (!ea || !eb)
return 0;
810 if (!ka || !kb)
return 0;
818 static int pkey_size_gost(
const EVP_PKEY *pk)
823 static int pkey_bits_gost(
const EVP_PKEY *pk)
828 static void mackey_free_gost(
EVP_PKEY *pk)
834 static int mac_ctrl_gost(
EVP_PKEY *pkey,
int op,
long arg1,
void *arg2)
845 static int gost94_param_encode(
const EVP_PKEY *pkey,
unsigned char **pder)
850 static int gost2001_param_encode(
const EVP_PKEY *pkey,
unsigned char **pder)
856 static int gost94_param_decode(
EVP_PKEY *pkey,
const unsigned char **pder,
int derlen)
875 static int gost2001_param_decode(
EVP_PKEY *pkey,
const unsigned char **pder,
int derlen) {
902 if (!*ameth)
return 0;
908 priv_decode_gost, priv_encode_gost,
912 gost94_param_decode, gost94_param_encode,
913 param_missing_gost94, param_copy_gost94,
914 param_cmp_gost94,param_print_gost94 );
916 pub_decode_gost94, pub_encode_gost94,
917 pub_cmp_gost94, pub_print_gost94,
918 pkey_size_gost, pkey_bits_gost);
925 priv_decode_gost, priv_encode_gost,
929 gost2001_param_decode, gost2001_param_encode,
930 param_missing_gost01, param_copy_gost01,
931 param_cmp_gost01, param_print_gost01);
933 pub_decode_gost01, pub_encode_gost01,
934 pub_cmp_gost01, pub_print_gost01,
935 pkey_size_gost, pkey_bits_gost);