OpenSSL CVS Repository
http://cvs.openssl.org/
____________________________________________________________
________________
Server: cvs.openssl.org Name: Dr.
Stephen Henson
Root: /v/openssl/cvs Email: steve openssl.org
Module: openssl Date:
24-Mar-2006 14:47:00
Branch: HEAD Handle:
2006032413465503
Modified files:
openssl/crypto/asn1 ameth_lib.c asn1_locl.h
openssl/crypto/evp evp.h p_lib.c
openssl/crypto/pem pem.h pem_err.c pem_pkey.c
Log:
Initial support for generalized public key parameters.
Summary:
Revision Changes Path
1.6 +11 -5 openssl/crypto/asn1/ameth_lib.c
1.5 +5 -4 openssl/crypto/asn1/asn1_locl.h
1.121 +6 -2 openssl/crypto/evp/evp.h
1.37 +5 -0 openssl/crypto/evp/p_lib.c
1.56 +2 -0 openssl/crypto/pem/pem.h
1.13 +1 -0 openssl/crypto/pem/pem_err.c
1.11 +54 -0 openssl/crypto/pem/pem_pkey.c
____________________________________________________________
________________
patch -p0 <<' .'
Index: openssl/crypto/asn1/ameth_lib.c
============================================================
================
$ cvs diff -u -r1.5 -r1.6 ameth_lib.c
--- openssl/crypto/asn1/ameth_lib.c 23 Mar 2006 18:02:12
-0000 1.5
+++ openssl/crypto/asn1/ameth_lib.c 24 Mar 2006 13:46:55
-0000 1.6
 -70,15 +70,23 
/* Keep this sorted in type order !! */
const EVP_PKEY_ASN1_METHOD *standard_methods[] =
{
+#ifndef OPENSSL_NO_RSA
&rsa_asn1_meths[0],
&rsa_asn1_meths[1],
+#endif
+#ifndef OPENSSL_NO_DH
&dh_asn1_meth,
+#endif
+#ifndef OPENSSL_NO_DSA
&dsa_asn1_meths[0],
&dsa_asn1_meths[1],
&dsa_asn1_meths[2],
&dsa_asn1_meths[3],
&dsa_asn1_meths[4],
+#endif
+#ifndef OPENSSL_NO_EC
&eckey_asn1_meth
+#endif
};
typedef int sk_cmp_fn_type(const char * const *a, const
char * const *b);
 -209,11 +217,9 
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;
 -225,7 +231,6 
ameth->param_cmp = 0;
ameth->param_print = 0;
-
ameth->pkey_free = 0;
ameth->pkey_ctrl = 0;
 -279,8 +284,9 
}
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_decode)(EVP_PKEY *pkey,
+ const unsigned char **pder, int derlen),
+ int (*param_encode)(const EVP_PKEY *pkey, unsigned char
**pder),
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),
 .
patch -p0 <<' .'
Index: openssl/crypto/asn1/asn1_locl.h
============================================================
================
$ cvs diff -u -r1.4 -r1.5 asn1_locl.h
--- openssl/crypto/asn1/asn1_locl.h 23 Mar 2006 18:02:12
-0000 1.4
+++ openssl/crypto/asn1/asn1_locl.h 24 Mar 2006 13:46:55
-0000 1.5
 -1,9 +1,9 
/* asn1t.h */
/* Written by Dr Stephen N Henson (shenson bigfoot.com) for the OpenSSL
- * project 2005.
+ * project 2006.
*/
/*
============================================================
========
- * Copyright (c) 2005 The OpenSSL Project. All rights
reserved.
+ * Copyright (c) 2006 The OpenSSL Project. All rights
reserved.
*
* Redistribution and use in source and binary forms,
with or without
* modification, are permitted provided that the
following conditions
 -97,8 +97,9 
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_decode)(EVP_PKEY *pkey,
+ const unsigned char **pder, int derlen);
+ int (*param_encode)(const EVP_PKEY *pkey, unsigned char
**pder);
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);
 .
patch -p0 <<' .'
Index: openssl/crypto/evp/evp.h
============================================================
================
$ cvs diff -u -r1.120 -r1.121 evp.h
--- openssl/crypto/evp/evp.h 23 Mar 2006 18:02:17
-0000 1.120
+++ openssl/crypto/evp/evp.h 24 Mar 2006 13:46:56
-0000 1.121
 -777,6 +777,7 
int EVP_PKEY_bits(EVP_PKEY *pkey);
int EVP_PKEY_size(EVP_PKEY *pkey);
int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
+void * EVP_PKEY_get0(EVP_PKEY *pkey);
#ifndef OPENSSL_NO_RSA
struct rsa_st;
 -868,14 +869,17 
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));
+
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_decode)(EVP_PKEY *pkey,
+ const unsigned char **pder, int derlen),
+ int (*param_encode)(const EVP_PKEY *pkey, unsigned char
**pder),
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 EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
void (*pkey_free)(EVP_PKEY *pkey));
void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
 .
patch -p0 <<' .'
Index: openssl/crypto/evp/p_lib.c
============================================================
================
$ cvs diff -u -r1.36 -r1.37 p_lib.c
--- openssl/crypto/evp/p_lib.c 22 Mar 2006 17:59:48
-0000 1.36
+++ openssl/crypto/evp/p_lib.c 24 Mar 2006 13:46:56
-0000 1.37
 -199,6 +199,11 
return(key != NULL);
}
+void *EVP_PKEY_get0(EVP_PKEY *pkey)
+ {
+ return pkey->pkey.ptr;
+ }
+
#ifndef OPENSSL_NO_RSA
int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
{
 .
patch -p0 <<' .'
Index: openssl/crypto/pem/pem.h
============================================================
================
$ cvs diff -u -r1.55 -r1.56 pem.h
--- openssl/crypto/pem/pem.h 23 Mar 2006 18:02:18
-0000 1.55
+++ openssl/crypto/pem/pem.h 24 Mar 2006 13:46:57
-0000 1.56
 -133,6 +133,7 
#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC
KEY"
#define PEM_STRING_ECPARAMETERS "EC
PARAMETERS"
#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE
KEY"
+#define PEM_STRING_PARAMETERS "PARAMETERS"
/* Note that this structure is initialised by
PEM_SealInit and cleaned up
by PEM_SealFinal (at least for now) */
 -724,6 +725,7 
#define PEM_F_PEM_PK8PKEY 119
#define PEM_F_PEM_READ 108
#define PEM_F_PEM_READ_BIO 109
+#define PEM_F_PEM_READ_BIO_PARAMETERS 140
#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123
#define PEM_F_PEM_READ_PRIVATEKEY 124
#define PEM_F_PEM_SEALFINAL 110
 .
patch -p0 <<' .'
Index: openssl/crypto/pem/pem_err.c
============================================================
================
$ cvs diff -u -r1.12 -r1.13 pem_err.c
--- openssl/crypto/pem/pem_err.c 23 Mar 2006 18:02:18
-0000 1.12
+++ openssl/crypto/pem/pem_err.c 24 Mar 2006 13:46:58
-0000 1.13
 -98,6 +98,7 
{ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"},
{ERR_FUNC(PEM_F_PEM_READ), "PEM_read"},
{ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"},
+{ERR_FUNC(PEM_F_PEM_READ_BIO_PARAMETERS), "PEM_READ_B
IO_PARAMETERS"},
{ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BI
O_PRIVATEKEY"},
{ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVAT
EKEY"},
{ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"}
,
 .
patch -p0 <<' .'
Index: openssl/crypto/pem/pem_pkey.c
============================================================
================
$ cvs diff -u -r1.10 -r1.11 pem_pkey.c
--- openssl/crypto/pem/pem_pkey.c 23 Mar 2006 18:02:19
-0000 1.10
+++ openssl/crypto/pem/pem_pkey.c 24 Mar 2006 13:46:58
-0000 1.11
 -149,6 +149,60 
pem_str,bp,(char *)x,enc,kstr,klen,cb,u);
}
+EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x,
pem_password_cb *cb, void *u)
+ {
+ char *nm=NULL;
+ const unsigned char *p=NULL;
+ unsigned char *data=NULL;
+ long len;
+ int slen;
+ EVP_PKEY *ret=NULL;
+
+ if (!PEM_bytes_read_bio(&data, &len, &nm,
PEM_STRING_PARAMETERS,
+ bp, cb, u))
+ return NULL;
+ p = data;
+
+ if ((slen = pem_check_suffix(nm,
"PARAMETERS")) > 0)
+ {
+ const EVP_PKEY_ASN1_METHOD *ameth;
+ ameth = EVP_PKEY_asn1_find_str(nm, slen);
+ if (!ameth || !ameth->param_decode)
+ goto err;
+ ret = EVP_PKEY_new();
+ if (!ret)
+ goto err;
+ if (!ameth->param_decode(ret, &p, len))
+ {
+ EVP_PKEY_free(ret);
+ ret = NULL;
+ goto err;
+ }
+ if(x)
+ {
+ if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
+ *x = ret;
+ }
+ }
+err:
+ if (ret == NULL)
+ PEMerr(PEM_F_PEM_READ_BIO_PARAMETERS,ERR_R_ASN1_LIB);
+ OPENSSL_free(nm);
+ OPENSSL_free(data);
+ return(ret);
+ }
+
+int PEM_write_bio_Paramters(BIO *bp, EVP_PKEY *x)
+ {
+ char pem_str[80];
+ if (!x->ameth || !x->ameth->param_encode)
+ return 0;
+
+ BIO_snprintf(pem_str, 80, "%s PARAMETERS",
x->ameth->pem_str);
+ return PEM_ASN1_write_bio(
+ (i2d_of_void
*)openssl_fcast(x->ameth->param_encode),
+ pem_str,bp,(char *)x,NULL,NULL,0,0,NULL);
+ }
#ifndef OPENSSL_NO_FP_API
EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x,
pem_password_cb *cb, void *u)
 .
____________________________________________________________
__________
OpenSSL Project http://www.openssl.org
CVS Repository Commit List
openssl-cvs openssl.org
Automated List Manager
majordomo openssl.org
|