summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2015-02-10 05:12:24 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2015-02-10 05:12:24 +0000
commita6def5ad5c441fe1ca527e706d82948daa82d961 (patch)
tree73613d35c7d63e684fb1cd72edf4496f09b0d6c0 /lib/libcrypto
parent06df4486bb20ea65e0aabaed20a74631c4d4f6ad (diff)
Expand the -IMPLEMENT_ASN1_ENCODE_FUNCTIONS_(const_)?fname macros so that
the code is visible and functions can be readily located. Change has been scripted and there is no change to the generated assembly. Discussed with beck@ miod@ tedu@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/asn1/tasn_typ.c30
-rw-r--r--lib/libcrypto/dh/dh_asn1.c16
-rw-r--r--lib/libcrypto/dsa/dsa_asn1.c58
-rw-r--r--lib/libcrypto/rsa/rsa_asn1.c30
4 files changed, 121 insertions, 13 deletions
diff --git a/lib/libcrypto/asn1/tasn_typ.c b/lib/libcrypto/asn1/tasn_typ.c
index 6e4650c089c..094b041a80a 100644
--- a/lib/libcrypto/asn1/tasn_typ.c
+++ b/lib/libcrypto/asn1/tasn_typ.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tasn_typ.c,v 1.8 2015/02/10 04:01:26 jsing Exp $ */
+/* $OpenBSD: tasn_typ.c,v 1.9 2015/02/10 05:12:23 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -600,5 +600,29 @@ ASN1_ITEM_TEMPLATE(ASN1_SET_ANY) =
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, ASN1_SET_ANY, ASN1_ANY)
ASN1_ITEM_TEMPLATE_END(ASN1_SET_ANY)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
+
+ASN1_SEQUENCE_ANY *
+d2i_ASN1_SEQUENCE_ANY(ASN1_SEQUENCE_ANY **a, const unsigned char **in, long len)
+{
+ return (ASN1_SEQUENCE_ANY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &ASN1_SEQUENCE_ANY_it);
+}
+
+int
+i2d_ASN1_SEQUENCE_ANY(const ASN1_SEQUENCE_ANY *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_SEQUENCE_ANY_it);
+}
+
+ASN1_SEQUENCE_ANY *
+d2i_ASN1_SET_ANY(ASN1_SEQUENCE_ANY **a, const unsigned char **in, long len)
+{
+ return (ASN1_SEQUENCE_ANY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &ASN1_SET_ANY_it);
+}
+
+int
+i2d_ASN1_SET_ANY(const ASN1_SEQUENCE_ANY *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_SET_ANY_it);
+}
diff --git a/lib/libcrypto/dh/dh_asn1.c b/lib/libcrypto/dh/dh_asn1.c
index ee478c7958e..9d769746595 100644
--- a/lib/libcrypto/dh/dh_asn1.c
+++ b/lib/libcrypto/dh/dh_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_asn1.c,v 1.6 2014/07/11 08:44:48 jsing Exp $ */
+/* $OpenBSD: dh_asn1.c,v 1.7 2015/02/10 05:12:23 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -86,7 +86,19 @@ ASN1_SEQUENCE_cb(DHparams, dh_cb) = {
ASN1_OPT(DH, length, ZLONG),
} ASN1_SEQUENCE_END_cb(DH, DHparams)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams)
+
+DH *
+d2i_DHparams(DH **a, const unsigned char **in, long len)
+{
+ return (DH *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &DHparams_it);
+}
+
+int
+i2d_DHparams(const DH *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &DHparams_it);
+}
DH *
DHparams_dup(DH *dh)
diff --git a/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c
index 16cb1fa3795..c6b00923fc9 100644
--- a/lib/libcrypto/dsa/dsa_asn1.c
+++ b/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsa_asn1.c,v 1.14 2015/01/28 04:14:31 beck Exp $ */
+/* $OpenBSD: dsa_asn1.c,v 1.15 2015/02/10 05:12:23 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -89,7 +89,19 @@ ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = {
ASN1_SIMPLE(DSA_SIG, s, CBIGNUM)
} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG, DSA_SIG, DSA_SIG)
+
+DSA_SIG *
+d2i_DSA_SIG(DSA_SIG **a, const unsigned char **in, long len)
+{
+ return (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &DSA_SIG_it);
+}
+
+int
+i2d_DSA_SIG(const DSA_SIG *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSA_SIG_it);
+}
/* Override the default free and new methods */
static int
@@ -117,7 +129,19 @@ ASN1_SEQUENCE_cb(DSAPrivateKey, dsa_cb) = {
ASN1_SIMPLE(DSA, priv_key, BIGNUM)
} ASN1_SEQUENCE_END_cb(DSA, DSAPrivateKey)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPrivateKey, DSAPrivateKey)
+
+DSA *
+d2i_DSAPrivateKey(DSA **a, const unsigned char **in, long len)
+{
+ return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &DSAPrivateKey_it);
+}
+
+int
+i2d_DSAPrivateKey(const DSA *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSAPrivateKey_it);
+}
ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = {
ASN1_SIMPLE(DSA, p, BIGNUM),
@@ -125,7 +149,19 @@ ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = {
ASN1_SIMPLE(DSA, g, BIGNUM),
} ASN1_SEQUENCE_END_cb(DSA, DSAparams)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)
+
+DSA *
+d2i_DSAparams(DSA **a, const unsigned char **in, long len)
+{
+ return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &DSAparams_it);
+}
+
+int
+i2d_DSAparams(const DSA *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSAparams_it);
+}
/*
* DSA public key is a bit trickier... its effectively a CHOICE type
@@ -146,7 +182,19 @@ ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = {
ASN1_EX_COMBINE(0, 0, dsa_pub_internal)
} ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey)
+
+DSA *
+d2i_DSAPublicKey(DSA **a, const unsigned char **in, long len)
+{
+ return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &DSAPublicKey_it);
+}
+
+int
+i2d_DSAPublicKey(const DSA *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSAPublicKey_it);
+}
DSA *
DSAparams_dup(DSA *dsa)
diff --git a/lib/libcrypto/rsa/rsa_asn1.c b/lib/libcrypto/rsa/rsa_asn1.c
index a75b80fa10b..525c9455bdb 100644
--- a/lib/libcrypto/rsa/rsa_asn1.c
+++ b/lib/libcrypto/rsa/rsa_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_asn1.c,v 1.10 2015/02/09 16:04:46 jsing Exp $ */
+/* $OpenBSD: rsa_asn1.c,v 1.11 2015/02/10 05:12:23 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -131,9 +131,33 @@ RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a)
ASN1_item_free((ASN1_VALUE *)a, &RSA_PSS_PARAMS_it);
}
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey)
-IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey)
+RSA *
+d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len)
+{
+ return (RSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &RSAPrivateKey_it);
+}
+
+int
+i2d_RSAPrivateKey(const RSA *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSAPrivateKey_it);
+}
+
+
+RSA *
+d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len)
+{
+ return (RSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ &RSAPublicKey_it);
+}
+
+int
+i2d_RSAPublicKey(const RSA *a, unsigned char **out)
+{
+ return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSAPublicKey_it);
+}
RSA *
RSAPublicKey_dup(RSA *rsa)