Commit 0b6f3c66 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Initial definitions and a few functions for EVP_PKEY_METHOD: an extension

of the EVP routines to public key algorithms.
parent a01d9ac5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@

 Changes between 0.9.8a and 0.9.9  [xx XXX xxxx]

  *) Initial definitions for EVP_PKEY_METHOD. This will be a high level public
     key API, doesn't do much yet.
     [Steve Henson]

  *) New function EVP_PKEY_asn1_get0_info() to retrieve information about
     public key algorithms. New option to openssl utility:
     "list-public-key-algorithms" to print out info.
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ TOP= ..
CC=		cc
INCLUDE=	-I. -I$(TOP) -I../include
# INCLUDES targets sudbirs!
INCLUDES=	-I.. -I../.. -I../asn1 -I../../include
INCLUDES=	-I.. -I../.. -I../asn1 -I../evp -I../../include
CFLAG=		-g
MAKEDEPPROG=	makedepend
MAKEDEPEND=	$(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
	bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
	c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
	evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \
	e_old.c
	e_old.c pmeth_lib.c

LIBOBJ=	encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
	e_des.o e_bf.o e_idea.o e_des3.o \
@@ -40,7 +40,7 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
	bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
	c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
	evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \
	e_old.o
	e_old.o pmeth_lib.o

SRC= $(LIBSRC)

+1 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ struct evp_pkey_st
	int save_type;
	int references;
	const EVP_PKEY_ASN1_METHOD *ameth;
	const EVP_PKEY_METHOD *pmeth;
	union	{
		char *ptr;
#ifndef OPENSSL_NO_RSA
+71 −0
Original line number Diff line number Diff line
@@ -234,3 +234,74 @@ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
			     EVP_CIPHER_set_asn1_iv, \
			     EVP_CIPHER_get_asn1_iv, \
			     NULL)


struct evp_pkey_ctx_st
	{
	/* Method associated with this operation */
	const EVP_PKEY_METHOD *pmeth;
	/* Key: may be NULL */
	EVP_PKEY *pkey;
	/* Actual operation */
	int operation;
	/* Algorithm specific data */
	void *data;
	} /* EVP_PKEY_CTX */;

#define EVP_PKEY_OP_UNDEFINED		0
#define EVP_PKEY_OP_PARAMGEN		1
#define EVP_PKEY_OP_KEYGEN		2
#define EVP_PKEY_OP_SIGN		3
#define EVP_PKEY_OP_VERIFY		4
#define EVP_PKEY_OP_VERIFYRECOVER	5
#define EVP_PKEY_OP_SIGNCTX		6
#define EVP_PKEY_OP_VERIFYCTX		7
#define EVP_PKEY_OP_ENCRYPT		8
#define EVP_PKEY_OP_DECRYPT		9

struct evp_pkey_method_st
	{
	int pkey_id;
	int (*paramgen_init)(EVP_PKEY_CTX *ctx);
	int (*paramgen)(EVP_PKEY *key, EVP_PKEY_CTX *ctx);

	int (*keygen_init)(EVP_PKEY_CTX *ctx);
	int (*keygen)(EVP_PKEY *key, EVP_PKEY_CTX *ctx);

	int (*sign_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
	int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, int *siglen,
					unsigned char *tbs, int tbslen);

	int (*verify_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
	int (*verify)(EVP_PKEY_CTX *ctx, unsigned char *sig, int siglen,
					unsigned char *tbs, int tbslen);

	int (*verify_recover_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
	int (*verify_recover)(EVP_PKEY_CTX *ctx,
					unsigned char *rout, int *routlen,
					unsigned char *sig, int siglen);

	int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx,
					EVP_PKEY *pkey);
	int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, int *siglen,
					EVP_MD_CTX *mctx);

	int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx,
							EVP_PKEY *pkey);
	int (*verifyctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, int siglen,
					EVP_MD_CTX *mctx);

	int (*encrypt_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
	int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen,
					unsigned char *in, int inlen);

	int (*decrypt_init)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
	int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen,
					unsigned char *in, int inlen);

	int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
	int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value);

	void (*cleanup)(EVP_PKEY_CTX *ctx);

	} /* EVP_PKEY_METHOD */;
Loading