List Info

Thread: OpenSSL: openssl/crypto/ Makefile openssl/crypto/asn1/ ameth_lib...




OpenSSL: openssl/crypto/ Makefile openssl/crypto/asn1/ ameth_lib...
user name
2006-03-22 17:59:49
  OpenSSL CVS Repository
  http://cvs.openssl.org/
 
____________________________________________________________
________________

  Server: cvs.openssl.org                  Name:   Dr.
Stephen Henson
  Root:   /v/openssl/cvs                   Email:  steveopenssl.org
  Module: openssl                          Date:  
22-Mar-2006 18:59:49
  Branch: HEAD                             Handle:
2006032217594405

  Modified files:
    openssl/crypto          Makefile
    openssl/crypto/asn1     ameth_lib.c asn1.h asn1_locl.h
d2i_pr.c x_pubkey.c
    openssl/crypto/dh       dh_ameth.c
    openssl/crypto/dsa      dsa_ameth.c
    openssl/crypto/ec       ec_ameth.c
    openssl/crypto/evp      evp.h evp_pkey.c p_lib.c
    openssl/crypto/rsa      rsa_ameth.c

  Log:
    Make EVP_PKEY_ASN1_METHOD opaque. Add application level
functions to
    initialize it. Initial support for application added
public key ASN1.

  Summary:
    Revision    Changes     Path
    1.15        +1  -1      openssl/crypto/Makefile
    1.3         +125 -3     openssl/crypto/asn1/ameth_lib.c
    1.143       +0  -36     openssl/crypto/asn1/asn1.h
    1.2         +37 -0      openssl/crypto/asn1/asn1_locl.h
    1.17        +1  -1      openssl/crypto/asn1/d2i_pr.c
    1.42        +3  -2      openssl/crypto/asn1/x_pubkey.c
    1.2         +1  -0      openssl/crypto/dh/dh_ameth.c
    1.4         +1  -0      openssl/crypto/dsa/dsa_ameth.c
    1.5         +1  -0      openssl/crypto/ec/ec_ameth.c
    1.118       +1  -1      openssl/crypto/evp/evp.h
    1.43        +3  -9      openssl/crypto/evp/evp_pkey.c
    1.36        +4  -2      openssl/crypto/evp/p_lib.c
    1.4         +1  -0      openssl/crypto/rsa/rsa_ameth.c
 
____________________________________________________________
________________

  patch -p0 <<' .'
  Index: openssl/crypto/Makefile
 
============================================================
================
  $ cvs diff -u -r1.14 -r1.15 Makefile
  --- openssl/crypto/Makefile	4 Feb 2006 01:45:19 -0000	1.14
  +++ openssl/crypto/Makefile	22 Mar 2006 17:59:44
-0000	1.15
   -7,7 +7,7 
   CC=		cc
   INCLUDE=	-I. -I$(TOP) -I../include
   # INCLUDES targets sudbirs!
  -INCLUDES=	-I.. -I../.. -I../../include
  +INCLUDES=	-I.. -I../.. -I../asn1 -I../../include
   CFLAG=		-g
   MAKEDEPPROG=	makedepend
   MAKEDEPEND=	$(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
   .
  patch -p0 <<' .'
  Index: openssl/crypto/asn1/ameth_lib.c
 
============================================================
================
  $ cvs diff -u -r1.2 -r1.3 ameth_lib.c
  --- openssl/crypto/asn1/ameth_lib.c	20 Mar 2006 17:56:03
-0000	1.2
  +++ openssl/crypto/asn1/ameth_lib.c	22 Mar 2006 17:59:45
-0000	1.3
   -81,6 +81,11 
   	&eckey_asn1_meth
   	};
   
  +typedef int sk_cmp_fn_type(const char * const *a, const
char * const *b);
  +static STACK *app_methods = NULL;
  +
  +
  +
   #ifdef TEST
   void main()
   	{
   -97,14 +102,21 
   static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const
*a,
                   const EVP_PKEY_ASN1_METHOD * const *b)
   	{
  -/*fprintf(stderr, "Comparing %d with %d\n",
(*a)->pkey_id, (*b)->pkey_id);*/
           return ((*a)->pkey_id - (*b)->pkey_id);
   	}
   
  -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_ASN1_find(int type)
  +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(int type)
   	{
   	EVP_PKEY_ASN1_METHOD tmp, *t = &tmp, **ret;
   	tmp.pkey_id = type;
  +	if (app_methods)
  +		{
  +		int idx;
  +		idx = sk_find(app_methods, (char *)&t);
  +		if (idx > 0)
  +			return (EVP_PKEY_ASN1_METHOD *)
  +				sk_value(app_methods, idx);
  +		}
   	ret = (EVP_PKEY_ASN1_METHOD **) OBJ_bsearch((char
*)&t,
           		(char *)standard_methods,
   			sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD
*),
   -113,7 +125,117 
   	if (!ret || !*ret)
   		return NULL;
   	if ((*ret)->pkey_flags & ASN1_PKEY_ALIAS)
  -		return EVP_PKEY_ASN1_find((*ret)->pkey_base_id);
  +		return EVP_PKEY_asn1_find((*ret)->pkey_base_id);
   	return *ret;
   	}
   
  +int EVP_PKEY_asn1_add(const EVP_PKEY_ASN1_METHOD *ameth)
  +	{
  +	if (app_methods == NULL)
  +		{
  +		app_methods = sk_new((sk_cmp_fn_type *)ameth_cmp);
  +		if (!app_methods)
  +			return 0;
  +		}
  +	if (!sk_push(app_methods, (char *)ameth))
  +		return 0;
  +	sk_sort(app_methods);
  +	return 1;
  +	}
  +
  +EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id)
  +	{
  +	EVP_PKEY_ASN1_METHOD *ameth;
  +	ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD));
  +	if (!ameth)
  +		return NULL;
  +
  +	ameth->pkey_id = id;
  +	ameth->pkey_base_id = id;
  +	ameth->pkey_flags = ASN1_PKEY_DYNAMIC;
  +	
  +	ameth->pub_decode = 0;
  +	ameth->pub_encode = 0;
  +	ameth->pub_cmp = 0;
  +	ameth->pub_print = 0;
  +
  +
  +	ameth->priv_decode = 0;
  +	ameth->priv_encode = 0;
  +	ameth->priv_print = 0;
  +	
  +
  +	ameth->pkey_size = 0;
  +	ameth->pkey_bits = 0;
  +
  +	ameth->param_decode = 0;
  +	ameth->param_encode = 0;
  +	ameth->param_missing = 0;
  +	ameth->param_copy = 0;
  +	ameth->param_cmp = 0;
  +	ameth->param_print = 0;
  +
  +
  +	ameth->pkey_free = 0;
  +	ameth->pkey_ctrl = 0;
  +
  +	return ameth;
  +	}
  +
  +void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD
*ameth,
  +		int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub),
  +		int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY
*pk),
  +		int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
  +		int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx),
  +		int (*pkey_size)(const EVP_PKEY *pk),
  +		int (*pkey_bits)(const EVP_PKEY *pk))
  +	{
  +	ameth->pub_decode = pub_decode;
  +	ameth->pub_encode = pub_encode;
  +	ameth->pub_cmp = pub_cmp;
  +	ameth->pub_print = pub_print;
  +	ameth->pkey_size = pkey_size;
  +	ameth->pkey_bits = pkey_bits;
  +	}
  +
  +void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD
*ameth,
  +		int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO
*p8inf),
  +		int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const
EVP_PKEY *pk),
  +		int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx))
  +	{
  +	ameth->priv_decode = priv_decode;
  +	ameth->priv_encode = priv_encode;
  +	ameth->priv_print = priv_print;
  +	}
  +
  +void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
  +		int (*param_decode)(const EVP_PKEY *pk, X509_PUBKEY
*pub),
  +		int (*param_encode)(X509_PUBKEY *pub, const EVP_PKEY
*pk),
  +		int (*param_missing)(const EVP_PKEY *pk),
  +		int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from),
  +		int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
  +		int (*param_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx))
  +	{
  +	ameth->param_decode = param_decode;
  +	ameth->param_encode = param_encode;
  +	ameth->param_missing = param_missing;
  +	ameth->param_copy = param_copy;
  +	ameth->param_cmp = param_cmp;
  +	ameth->param_print = param_print;
  +	}
  +
  +void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
  +		void (*pkey_free)(EVP_PKEY *pkey))
  +	{
  +	ameth->pkey_free = pkey_free;
  +	}
  +
  +void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
  +		void (*pkey_ctrl)(EVP_PKEY *pkey, int op,
  +							long arg1, void *arg2))
  +	{
  +	ameth->pkey_ctrl = pkey_ctrl;
  +	}
   .
  patch -p0 <<' .'
  Index: openssl/crypto/asn1/asn1.h
 
============================================================
================
  $ cvs diff -u -r1.142 -r1.143 asn1.h
  --- openssl/crypto/asn1/asn1.h	22 Mar 2006 13:09:31
-0000	1.142
  +++ openssl/crypto/asn1/asn1.h	22 Mar 2006 17:59:45
-0000	1.143
   -282,42 +282,6 
   /* This is just an opaque pointer */
   typedef struct ASN1_VALUE_st ASN1_VALUE;
   
  -/* ASN1 public key method structure */
  -
  -#define ASN1_PKEY_ALIAS		0x1
  -
  -struct evp_pkey_asn1_method_st
  -	{
  -	int pkey_id;
  -	int pkey_base_id;
  -	unsigned long pkey_flags;
  -
  -	int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub);
  -	int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk);
  -	int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
  -	int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  -							ASN1_PCTX *pctx);
  -
  -	int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO
*p8inf);
  -	int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const
EVP_PKEY *pk);
  -	int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  -							ASN1_PCTX *pctx);
  -
  -	int (*pkey_size)(const EVP_PKEY *pk);
  -	int (*pkey_bits)(const EVP_PKEY *pk);
  -
  -	int (*param_decode)(const EVP_PKEY *pk, X509_PUBKEY
*pub);
  -	int (*param_encode)(X509_PUBKEY *pub, const EVP_PKEY
*pk);
  -	int (*param_missing)(const EVP_PKEY *pk);
  -	int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from);
  -	int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
  -	int (*param_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  -							ASN1_PCTX *pctx);
  -
  -	void (*pkey_free)(EVP_PKEY *pkey);
  -	void (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1,
void *arg2);
  -	} /* EVP_PKEY_ASN1_METHOD */;
  -
   /* Declare ASN1 functions: the implement macro in in
asn1t.h */
   
   #define DECLARE_ASN1_FUNCTIONS(type)
DECLARE_ASN1_FUNCTIONS_name(type, type)
   .
  patch -p0 <<' .'
  Index: openssl/crypto/asn1/asn1_locl.h
 
============================================================
================
  $ cvs diff -u -r1.1 -r1.2 asn1_locl.h
  --- openssl/crypto/asn1/asn1_locl.h	26 Jul 2005 11:46:23
-0000	1.1
  +++ openssl/crypto/asn1/asn1_locl.h	22 Mar 2006 17:59:45
-0000	1.2
   -68,3 +68,40 
   	unsigned long oid_flags;
   	unsigned long str_flags;
   	} /* ASN1_PCTX */;
  +
  +/* ASN1 public key method structure */
  +
  +#define ASN1_PKEY_ALIAS		0x1
  +#define ASN1_PKEY_DYNAMIC	0x2
  +
  +struct evp_pkey_asn1_method_st
  +	{
  +	int pkey_id;
  +	int pkey_base_id;
  +	unsigned long pkey_flags;
  +
  +	int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub);
  +	int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk);
  +	int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
  +	int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx);
  +
  +	int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO
*p8inf);
  +	int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const
EVP_PKEY *pk);
  +	int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx);
  +
  +	int (*pkey_size)(const EVP_PKEY *pk);
  +	int (*pkey_bits)(const EVP_PKEY *pk);
  +
  +	int (*param_decode)(const EVP_PKEY *pk, X509_PUBKEY
*pub);
  +	int (*param_encode)(X509_PUBKEY *pub, const EVP_PKEY
*pk);
  +	int (*param_missing)(const EVP_PKEY *pk);
  +	int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from);
  +	int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
  +	int (*param_print)(BIO *out, const EVP_PKEY *pkey, int
indent,
  +							ASN1_PCTX *pctx);
  +
  +	void (*pkey_free)(EVP_PKEY *pkey);
  +	void (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1,
void *arg2);
  +	} /* EVP_PKEY_ASN1_METHOD */;
   .
  patch -p0 <<' .'
  Index: openssl/crypto/asn1/d2i_pr.c
 
============================================================
================
  $ cvs diff -u -r1.16 -r1.17 d2i_pr.c
  --- openssl/crypto/asn1/d2i_pr.c	20 Mar 2006 17:56:03
-0000	1.16
  +++ openssl/crypto/asn1/d2i_pr.c	22 Mar 2006 17:59:45
-0000	1.17
   -89,7 +89,7 
   
   	ret->save_type=type;
   	ret->type=EVP_PKEY_type(type);
  -	ret->ameth = EVP_PKEY_ASN1_find(type);
  +	ret->ameth = EVP_PKEY_asn1_find(type);
   	switch (ret->type)
   		{
   #ifndef OPENSSL_NO_RSA
   .
  patch -p0 <<' .'
  Index: openssl/crypto/asn1/x_pubkey.c
 
============================================================
================
  $ cvs diff -u -r1.41 -r1.42 x_pubkey.c
  --- openssl/crypto/asn1/x_pubkey.c	20 Mar 2006 12:22:20
-0000	1.41
  +++ openssl/crypto/asn1/x_pubkey.c	22 Mar 2006 17:59:45
-0000	1.42
   -60,6 +60,7 
   #include "cryptlib.h"
   #include <openssl/asn1t.h>
   #include <openssl/x509.h>
  +#include "asn1_locl.h"
   #ifndef OPENSSL_NO_RSA
   #include <openssl/rsa.h>
   #endif
   -95,7 +96,7 
   
   	if ((pk=X509_PUBKEY_new()) == NULL) goto error;
   
  -	meth = EVP_PKEY_ASN1_find(pkey->type);
  +	meth = EVP_PKEY_asn1_find(pkey->type);
   
   	if (meth)
   		{
   -153,7 +154,7 
   		goto error;
   		}
   
  -	meth =
EVP_PKEY_ASN1_find(OBJ_obj2nid(key->algor->algorithm))
;
  +	meth =
EVP_PKEY_asn1_find(OBJ_obj2nid(key->algor->algorithm))
;
   
   	if (meth)
   		{
   .
  patch -p0 <<' .'
  Index: openssl/crypto/dh/dh_ameth.c
 
============================================================
================
  $ cvs diff -u -r1.1 -r1.2 dh_ameth.c
  --- openssl/crypto/dh/dh_ameth.c	20 Mar 2006 18:37:40
-0000	1.1
  +++ openssl/crypto/dh/dh_ameth.c	22 Mar 2006 17:59:46
-0000	1.2
   -60,6 +60,7 
   #include <openssl/x509.h>
   #include <openssl/asn1.h>
   #include <openssl/dh.h>
  +#include "asn1_locl.h"
   
   static void int_dh_free(EVP_PKEY *pkey)
   	{
   .
  patch -p0 <<' .'
  Index: openssl/crypto/dsa/dsa_ameth.c
 
============================================================
================
  $ cvs diff -u -r1.3 -r1.4 dsa_ameth.c
  --- openssl/crypto/dsa/dsa_ameth.c	22 Mar 2006 13:09:33
-0000	1.3
  +++ openssl/crypto/dsa/dsa_ameth.c	22 Mar 2006 17:59:47
-0000	1.4
   -60,6 +60,7 
   #include <openssl/x509.h>
   #include <openssl/asn1.h>
   #include <openssl/dsa.h>
  +#include "asn1_locl.h"
   
   static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY
*pubkey)
   	{
   .
  patch -p0 <<' .'
  Index: openssl/crypto/ec/ec_ameth.c
 
============================================================
================
  $ cvs diff -u -r1.4 -r1.5 ec_ameth.c
  --- openssl/crypto/ec/ec_ameth.c	22 Mar 2006 13:34:18
-0000	1.4
  +++ openssl/crypto/ec/ec_ameth.c	22 Mar 2006 17:59:47
-0000	1.5
   -59,6 +59,7 
   #include "cryptlib.h"
   #include <openssl/x509.h>
   #include <openssl/ec.h>
  +#include "asn1_locl.h"
   
   static int eckey_param2type(int *pptype, void **ppval,
EC_KEY *ec_key)
   	{
   .
  patch -p0 <<' .'
  Index: openssl/crypto/evp/evp.h
 
============================================================
================
  $ cvs diff -u -r1.117 -r1.118 evp.h
  --- openssl/crypto/evp/evp.h	22 Mar 2006 13:09:34
-0000	1.117
  +++ openssl/crypto/evp/evp.h	22 Mar 2006 17:59:48
-0000	1.118
   -855,7 +855,7 
   		    EVP_PBE_KEYGEN *keygen);
   void EVP_PBE_cleanup(void);
   
  -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_ASN1_find(int type);
  +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(int type);
   
   /* BEGIN ERROR CODES */
   /* The following lines are auto generated by the script
mkerr.pl. Any changes
   .
  patch -p0 <<' .'
  Index: openssl/crypto/evp/evp_pkey.c
 
============================================================
================
  $ cvs diff -u -r1.42 -r1.43 evp_pkey.c
  --- openssl/crypto/evp/evp_pkey.c	22 Mar 2006 13:09:34
-0000	1.42
  +++ openssl/crypto/evp/evp_pkey.c	22 Mar 2006 17:59:48
-0000	1.43
   -61,13 +61,7 
   #include "cryptlib.h"
   #include <openssl/x509.h>
   #include <openssl/rand.h>
  -#ifndef OPENSSL_NO_RSA
  -#include <openssl/rsa.h>
  -#endif
  -#ifndef OPENSSL_NO_DSA
  -#include <openssl/dsa.h>
  -#endif
  -#include <openssl/bn.h>
  +#include "asn1_locl.h"
   
   /* Extract a private key from a PKCS8 structure */
   
   -86,7 +80,7 
   		return NULL;
   	}
   
  -	meth = EVP_PKEY_ASN1_find(OBJ_obj2nid(algoid));
  +	meth = EVP_PKEY_asn1_find(OBJ_obj2nid(algoid));
   
   	if (meth)
   		{
   -138,7 +132,7 
   	}
   	p8->broken = broken;
   
  -	meth = EVP_PKEY_ASN1_find(pkey->type);
  +	meth = EVP_PKEY_asn1_find(pkey->type);
   
   	if (meth)
   		{
   .
  patch -p0 <<' .'
  Index: openssl/crypto/evp/p_lib.c
 
============================================================
================
  $ cvs diff -u -r1.35 -r1.36 p_lib.c
  --- openssl/crypto/evp/p_lib.c	22 Mar 2006 13:09:34
-0000	1.35
  +++ openssl/crypto/evp/p_lib.c	22 Mar 2006 17:59:48
-0000	1.36
   -74,6 +74,8 
   #include <openssl/dh.h>
   #endif
   
  +#include "asn1_locl.h"
  +
   static void EVP_PKEY_free_it(EVP_PKEY *x);
   
   int EVP_PKEY_bits(EVP_PKEY *pkey)
   -189,7 +191,7 
   	if (pkey == NULL) return(0);
   	if (pkey->pkey.ptr != NULL)
   		EVP_PKEY_free_it(pkey);
  -	ameth = EVP_PKEY_ASN1_find(type);
  +	ameth = EVP_PKEY_asn1_find(type);
   	pkey->ameth = ameth;
   	pkey->type = ameth->pkey_id;
   	pkey->save_type=type;
   -284,7 +286,7 
   int EVP_PKEY_type(int type)
   	{
   	const EVP_PKEY_ASN1_METHOD *ameth;
  -	ameth = EVP_PKEY_ASN1_find(type);
  +	ameth = EVP_PKEY_asn1_find(type);
   	if (ameth)
   		return ameth->pkey_id;
   	return NID_undef;
   .
  patch -p0 <<' .'
  Index: openssl/crypto/rsa/rsa_ameth.c
 
============================================================
================
  $ cvs diff -u -r1.3 -r1.4 rsa_ameth.c
  --- openssl/crypto/rsa/rsa_ameth.c	22 Mar 2006 13:09:35
-0000	1.3
  +++ openssl/crypto/rsa/rsa_ameth.c	22 Mar 2006 17:59:49
-0000	1.4
   -60,6 +60,7 
   #include <openssl/asn1t.h>
   #include <openssl/x509.h>
   #include <openssl/rsa.h>
  +#include "asn1_locl.h"
   
   static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY
*pkey)
   	{
   .
____________________________________________________________
__________
OpenSSL Project                                 http://www.openssl.org
CVS Repository Commit List                    
openssl-cvsopenssl.org
Automated List Manager                          
majordomoopenssl.org
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )