Commit 3ba0885a authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Extend DH ASN1 method, add DH EVP_PKEY_METHOD.

parent 023c9d8d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4,6 +4,13 @@

 Changes between 0.9.8a and 0.9.9  [xx XXX xxxx]

  *) Add DSA pkey method and DH pkey methods, extend DH ASN1 method to support
     public and private key formats. As a side effect these add additional 
     command line functionality not previously available: DSA signatures can be
     generated and verified using pkeyutl and DH key support and generation in
     pkey, genpkey.
     [Steve Henson]

  *) BeOS support.
     [Oliver Tappe <zooey@hirschkaefer.de>]

+2 −2
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@ APPS=

LIB=$(TOP)/libcrypto.a
LIBSRC= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c \
	dh_ameth.c dh_prn.c
	dh_ameth.c dh_pmeth.c dh_prn.c
LIBOBJ= dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o dh_depr.o \
	dh_ameth.o dh_prn.o
	dh_ameth.o dh_pmeth.o dh_prn.o

SRC= $(LIBSRC)

+13 −1
Original line number Diff line number Diff line
@@ -201,6 +201,18 @@ int DHparams_print(BIO *bp, const DH *x);
int	DHparams_print(char *bp, const DH *x);
#endif

#define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
			EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)

#define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
			EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)

#define	EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN	(EVP_PKEY_ALG_CTRL + 1)
#define	EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR	(EVP_PKEY_ALG_CTRL + 2)
		

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
@@ -220,9 +232,9 @@ void ERR_load_DH_strings(void);
#define DH_F_DH_PRIV_ENCODE				 111
#define DH_F_DH_PUB_DECODE				 108
#define DH_F_DH_PUB_ENCODE				 109
#define DH_F_DSA_PRIV_ENCODE				 112
#define DH_F_GENERATE_KEY				 103
#define DH_F_GENERATE_PARAMETERS			 104
#define DH_F_PKEY_DH_KEYGEN				 113

/* Reason codes. */
#define DH_R_BAD_GENERATOR				 101
+4 −4
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)

	if (!prkey)
		{
		DHerr(DH_F_DSA_PRIV_ENCODE,DH_R_BN_ERROR);
		DHerr(DH_F_DH_PRIV_ENCODE,DH_R_BN_ERROR);
		goto err;
		}

@@ -268,7 +268,7 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)

	ASN1_INTEGER_free(prkey);

	if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0,
	if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dhKeyAgreement), 0,
				V_ASN1_SEQUENCE, params, dp, dplen))
		goto err;

@@ -403,9 +403,9 @@ static int dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)

	if ((a=BN_dup(from->pkey.dh->p)) == NULL)
		return 0;
	if (to->pkey.dsa->p != NULL)
	if (to->pkey.dh->p != NULL)
		BN_free(to->pkey.dh->p);
	to->pkey.dsa->p=a;
	to->pkey.dh->p=a;

	if ((a=BN_dup(from->pkey.dh->g)) == NULL)
		return 0;
+1 −1
Original line number Diff line number Diff line
@@ -80,9 +80,9 @@ static ERR_STRING_DATA DH_str_functs[]=
{ERR_FUNC(DH_F_DH_PRIV_ENCODE),	"DH_PRIV_ENCODE"},
{ERR_FUNC(DH_F_DH_PUB_DECODE),	"DH_PUB_DECODE"},
{ERR_FUNC(DH_F_DH_PUB_ENCODE),	"DH_PUB_ENCODE"},
{ERR_FUNC(DH_F_DSA_PRIV_ENCODE),	"DSA_PRIV_ENCODE"},
{ERR_FUNC(DH_F_GENERATE_KEY),	"GENERATE_KEY"},
{ERR_FUNC(DH_F_GENERATE_PARAMETERS),	"GENERATE_PARAMETERS"},
{ERR_FUNC(DH_F_PKEY_DH_KEYGEN),	"PKEY_DH_KEYGEN"},
{0,NULL}
	};

Loading