summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1
diff options
context:
space:
mode:
authorbeck <>2000-03-19 11:13:58 +0000
committerbeck <>2000-03-19 11:13:58 +0000
commit796d609550df3a33fc11468741c5d2f6d3df4c11 (patch)
tree6c6d539061caa20372dad0ac4ddb1dfae2fbe7fe /src/lib/libcrypto/asn1
parent5be3114c1fd7e0dfea1e38d3abb4cbba75244419 (diff)
downloadopenbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.gz
openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.bz2
openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.zip
OpenSSL 0.9.5 merge
*warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2 if you are using the ssl26 packages for ssh and other things to work you will need to get new ones (see ~beck/libsslsnap/<arch>) on cvs or ~beck/src-patent.tar.gz on cvs
Diffstat (limited to 'src/lib/libcrypto/asn1')
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl138
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c15
-rw-r--r--src/lib/libcrypto/asn1/a_bmp.c6
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c19
-rw-r--r--src/lib/libcrypto/asn1/a_digest.c11
-rw-r--r--src/lib/libcrypto/asn1/a_dup.c2
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c25
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c10
-rw-r--r--src/lib/libcrypto/asn1/a_hdr.c6
-rw-r--r--src/lib/libcrypto/asn1/a_i2d_fp.c2
-rw-r--r--src/lib/libcrypto/asn1/a_int.c41
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c390
-rw-r--r--src/lib/libcrypto/asn1/a_null.c119
-rw-r--r--src/lib/libcrypto/asn1/a_object.c6
-rw-r--r--src/lib/libcrypto/asn1/a_octet.c20
-rw-r--r--src/lib/libcrypto/asn1/a_print.c32
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c15
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c247
-rw-r--r--src/lib/libcrypto/asn1/a_time.c6
-rw-r--r--src/lib/libcrypto/asn1/a_type.c2
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c10
-rw-r--r--src/lib/libcrypto/asn1/a_utf8.c155
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c9
-rw-r--r--src/lib/libcrypto/asn1/a_vis.c6
-rw-r--r--src/lib/libcrypto/asn1/asn1.h290
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c24
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c19
-rw-r--r--src/lib/libcrypto/asn1/asn1_mac.h14
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c78
-rw-r--r--src/lib/libcrypto/asn1/d2i_dhp.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_dsap.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_pr.c23
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pr.c11
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pu.c10
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pr.c4
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pu.c4
-rw-r--r--src/lib/libcrypto/asn1/evp_asn1.c24
-rw-r--r--src/lib/libcrypto/asn1/f_enum.c2
-rw-r--r--src/lib/libcrypto/asn1/f_int.c2
-rw-r--r--src/lib/libcrypto/asn1/f_string.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_dhp.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_dsap.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pr.c8
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pu.c8
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pr.c2
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pu.c2
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c25
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c13
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c33
-rw-r--r--src/lib/libcrypto/asn1/p7_dgst.c10
-rw-r--r--src/lib/libcrypto/asn1/p7_enc.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_enc_c.c7
-rw-r--r--src/lib/libcrypto/asn1/p7_evp.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_i_s.c6
-rw-r--r--src/lib/libcrypto/asn1/p7_lib.c8
-rw-r--r--src/lib/libcrypto/asn1/p7_recip.c8
-rw-r--r--src/lib/libcrypto/asn1/p7_s_e.c4
-rw-r--r--src/lib/libcrypto/asn1/p7_signd.c4
-rw-r--r--src/lib/libcrypto/asn1/p7_signi.c10
-rw-r--r--src/lib/libcrypto/asn1/p8_key.c131
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c6
-rw-r--r--src/lib/libcrypto/asn1/pkcs8.c131
-rw-r--r--src/lib/libcrypto/asn1/t_bitst.c99
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c2
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c10
-rw-r--r--src/lib/libcrypto/asn1/t_req.c27
-rw-r--r--src/lib/libcrypto/asn1/t_spki.c116
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c9
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c102
-rw-r--r--src/lib/libcrypto/asn1/x_algor.c2
-rw-r--r--src/lib/libcrypto/asn1/x_attrib.c2
-rw-r--r--src/lib/libcrypto/asn1/x_cinf.c16
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c57
-rw-r--r--src/lib/libcrypto/asn1/x_exten.c15
-rw-r--r--src/lib/libcrypto/asn1/x_info.c3
-rw-r--r--src/lib/libcrypto/asn1/x_name.c2
-rw-r--r--src/lib/libcrypto/asn1/x_pkey.c8
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c118
-rw-r--r--src/lib/libcrypto/asn1/x_req.c18
-rw-r--r--src/lib/libcrypto/asn1/x_sig.c6
-rw-r--r--src/lib/libcrypto/asn1/x_spki.c14
-rw-r--r--src/lib/libcrypto/asn1/x_val.c10
-rw-r--r--src/lib/libcrypto/asn1/x_x509.c67
-rw-r--r--src/lib/libcrypto/asn1/x_x509a.c200
84 files changed, 2584 insertions, 558 deletions
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
index 5d668411f6..a17a713a75 100644
--- a/src/lib/libcrypto/asn1/Makefile.ssl
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -23,34 +23,34 @@ APPS=
23 23
24LIB=$(TOP)/libcrypto.a 24LIB=$(TOP)/libcrypto.a
25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \ 25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \
26 a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.c \ 26 a_null.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.c \
27 a_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c \ 27 a_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ 28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
29 x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c nsseq.c \ 29 x_name.c x_cinf.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.c \
30 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \ 30 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \
31 d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \ 31 d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \
32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\ 32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_crl.c t_pkey.c \ 33 t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c \
34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \ 34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ 35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \ 36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \
37 f_enum.c a_hdr.c x_pkey.c a_bool.c x_exten.c \ 37 f_enum.c a_hdr.c x_pkey.c a_bool.c x_exten.c \
38 asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c \ 38 asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c a_strnid.c \
39 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c 39 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \ 40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \
41 a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.o \ 41 a_null.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.o \
42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o \ 42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ 43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
44 x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o nsseq.o \ 44 x_name.o x_cinf.o x_x509.o x_x509a.o x_crl.o x_info.o x_spki.o nsseq.o \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \ 45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \
46 d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \ 46 d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \
47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \ 47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_crl.o t_pkey.o \ 48 t_req.o t_x509.o t_x509a.o t_crl.o t_pkey.o t_spki.o t_bitst.o \
49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \ 49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ 50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \ 51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \
52 f_enum.o a_hdr.o x_pkey.o a_bool.o x_exten.o \ 52 f_enum.o a_hdr.o x_pkey.o a_bool.o x_exten.o \
53 asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o \ 53 asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o a_strnid.o \
54 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o 54 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o
55 55
56SRC= $(LIBSRC) 56SRC= $(LIBSRC)
@@ -160,11 +160,13 @@ a_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 160a_digest.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 161a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 162a_digest.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h 163a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
164a_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 164a_digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
165a_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 165a_digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
166a_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 166a_digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
167a_digest.o: ../../include/openssl/stack.h ../cryptlib.h 167a_digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
168a_digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
169a_digest.o: ../cryptlib.h
168a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 170a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
169a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 171a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
170a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 172a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -207,6 +209,13 @@ a_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 209a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
208a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 210a_int.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209a_int.o: ../cryptlib.h 211a_int.o: ../cryptlib.h
212a_mbstr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
213a_mbstr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
214a_mbstr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
215a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
216a_mbstr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
217a_mbstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
218a_mbstr.o: ../cryptlib.h
210a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 219a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
211a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 220a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
212a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 221a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -214,6 +223,13 @@ a_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 223a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
215a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 224a_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
216a_meth.o: ../cryptlib.h 225a_meth.o: ../cryptlib.h
226a_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
227a_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
228a_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
229a_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
230a_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
231a_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
232a_null.o: ../cryptlib.h
217a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 233a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
218a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 234a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
219a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 235a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -259,6 +275,13 @@ a_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
259a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 275a_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
260a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 276a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
261a_sign.o: ../cryptlib.h 277a_sign.o: ../cryptlib.h
278a_strnid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
279a_strnid.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
280a_strnid.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
281a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
282a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
283a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
284a_strnid.o: ../../include/openssl/stack.h ../cryptlib.h
262a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 285a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
263a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 286a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
264a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 287a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
@@ -788,6 +811,24 @@ p8_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
788p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 811p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
789p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 812p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
790p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 813p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
814t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
815t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
816t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
817t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
818t_bitst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
819t_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
820t_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
821t_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
822t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
823t_bitst.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
824t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
825t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
826t_bitst.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
827t_bitst.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
828t_bitst.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
829t_bitst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
830t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
831t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h
791t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 832t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
792t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 833t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
793t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 834t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -812,15 +853,17 @@ t_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
812t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 853t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
813t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h 854t_pkey.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
814t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 855t_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
815t_pkey.o: ../../include/openssl/stack.h ../cryptlib.h 856t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
857t_pkey.o: ../cryptlib.h
816t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 858t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
817t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 859t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
818t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 860t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
819t_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 861t_req.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
820t_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 862t_req.o: ../../include/openssl/des.h ../../include/openssl/dh.h
821t_req.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 863t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
822t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h 864t_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
823t_req.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 865t_req.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
866t_req.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
824t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 867t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
825t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 868t_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
826t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 869t_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
@@ -829,7 +872,24 @@ t_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
829t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 872t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
830t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 873t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
831t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 874t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
832t_req.o: ../cryptlib.h 875t_req.o: ../../include/openssl/x509v3.h ../cryptlib.h
876t_spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
877t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
878t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
879t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
880t_spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
881t_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
882t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
883t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
884t_spki.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
885t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
886t_spki.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
887t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
888t_spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
889t_spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
890t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
891t_spki.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
892t_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
833t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 893t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
834t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 894t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
835t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 895t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
@@ -848,6 +908,23 @@ t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
848t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 908t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
849t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 909t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
850t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h 910t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h
911t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
912t_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
913t_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
914t_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
915t_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
916t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
917t_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
918t_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
919t_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
920t_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
921t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
922t_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
923t_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
924t_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
925t_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
926t_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
927t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
851x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 928x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
852x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 929x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
853x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 930x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
@@ -1088,3 +1165,20 @@ x_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1088x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 1165x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1089x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h 1166x_x509.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1090x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 1167x_x509.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
1168x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1169x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1170x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1171x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1172x_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
1173x_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
1174x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1175x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1176x_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md5.h
1177x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/objects.h
1178x_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1179x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1180x_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1181x_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1182x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1183x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/x509.h
1184x_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 38ea802be8..c77456b315 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -60,6 +60,15 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_BIT_STRING *ASN1_BIT_STRING_new(void)
64{ return M_ASN1_BIT_STRING_new(); }
65
66void ASN1_BIT_STRING_free(ASN1_BIT_STRING *x)
67{ M_ASN1_BIT_STRING_free(x); }
68
69int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
70{ return M_ASN1_BIT_STRING_set(x, d, len); }
71
63int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) 72int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
64 { 73 {
65 int ret,j,r,bits,len; 74 int ret,j,r,bits,len;
@@ -121,7 +130,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
121 130
122 if ((a == NULL) || ((*a) == NULL)) 131 if ((a == NULL) || ((*a) == NULL))
123 { 132 {
124 if ((ret=ASN1_BIT_STRING_new()) == NULL) return(NULL); 133 if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
125 } 134 }
126 else 135 else
127 ret=(*a); 136 ret=(*a);
@@ -164,7 +173,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
164 s=NULL; 173 s=NULL;
165 174
166 ret->length=(int)len; 175 ret->length=(int)len;
167 if (ret->data != NULL) Free((char *)ret->data); 176 if (ret->data != NULL) Free(ret->data);
168 ret->data=s; 177 ret->data=s;
169 ret->type=V_ASN1_BIT_STRING; 178 ret->type=V_ASN1_BIT_STRING;
170 if (a != NULL) (*a)=ret; 179 if (a != NULL) (*a)=ret;
@@ -173,7 +182,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
173err: 182err:
174 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i); 183 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
175 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 184 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
176 ASN1_BIT_STRING_free(ret); 185 M_ASN1_BIT_STRING_free(ret);
177 return(NULL); 186 return(NULL);
178 } 187 }
179 188
diff --git a/src/lib/libcrypto/asn1/a_bmp.c b/src/lib/libcrypto/asn1/a_bmp.c
index 6075871984..d9ac5a0475 100644
--- a/src/lib/libcrypto/asn1/a_bmp.c
+++ b/src/lib/libcrypto/asn1/a_bmp.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_BMPSTRING *ASN1_BMPSTRING_new(void)
64{ return M_ASN1_BMPSTRING_new(); }
65
66void ASN1_BMPSTRING_free(ASN1_BMPSTRING *x)
67{ M_ASN1_BMPSTRING_free(x); }
68
63int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp) 69int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index e452e03b88..8cde695804 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -71,7 +71,7 @@ B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, 71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
72 }; 72 };
73 73
74static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c); 74static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
75/* type is a 'bitmap' of acceptable string types. 75/* type is a 'bitmap' of acceptable string types.
76 */ 76 */
77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp, 77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
@@ -124,7 +124,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
124 else 124 else
125 s=NULL; 125 s=NULL;
126 126
127 if (ret->data != NULL) Free((char *)ret->data); 127 if (ret->data != NULL) Free(ret->data);
128 ret->length=(int)len; 128 ret->length=(int)len;
129 ret->data=s; 129 ret->data=s;
130 ret->type=tag; 130 ret->type=tag;
@@ -205,7 +205,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
205 c.tag=Ptag; 205 c.tag=Ptag;
206 c.xclass=Pclass; 206 c.xclass=Pclass;
207 c.max=(length == 0)?0:(p+length); 207 c.max=(length == 0)?0:(p+length);
208 if (!asn1_collate_primative(ret,&c)) 208 if (!asn1_collate_primitive(ret,&c))
209 goto err; 209 goto err;
210 else 210 else
211 { 211 {
@@ -218,8 +218,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
218 { 218 {
219 if ((ret->length < len) || (ret->data == NULL)) 219 if ((ret->length < len) || (ret->data == NULL))
220 { 220 {
221 if (ret->data != NULL) Free((char *)ret->data); 221 if (ret->data != NULL) Free(ret->data);
222 s=(unsigned char *)Malloc((int)len); 222 s=(unsigned char *)Malloc((int)len + 1);
223 if (s == NULL) 223 if (s == NULL)
224 { 224 {
225 i=ERR_R_MALLOC_FAILURE; 225 i=ERR_R_MALLOC_FAILURE;
@@ -229,12 +229,13 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
229 else 229 else
230 s=ret->data; 230 s=ret->data;
231 memcpy(s,p,(int)len); 231 memcpy(s,p,(int)len);
232 s[len] = '\0';
232 p+=len; 233 p+=len;
233 } 234 }
234 else 235 else
235 { 236 {
236 s=NULL; 237 s=NULL;
237 if (ret->data != NULL) Free((char *)ret->data); 238 if (ret->data != NULL) Free(ret->data);
238 } 239 }
239 240
240 ret->length=(int)len; 241 ret->length=(int)len;
@@ -253,11 +254,11 @@ err:
253 } 254 }
254 255
255 256
256/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapes 257/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse
257 * them into the one struture that is then returned */ 258 * them into the one structure that is then returned */
258/* There have been a few bug fixes for this function from 259/* There have been a few bug fixes for this function from
259 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */ 260 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
260static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c) 261static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
261 { 262 {
262 ASN1_STRING *os=NULL; 263 ASN1_STRING *os=NULL;
263 BUF_MEM b; 264 BUF_MEM b;
diff --git a/src/lib/libcrypto/asn1/a_digest.c b/src/lib/libcrypto/asn1/a_digest.c
index 8c45add557..3370aae998 100644
--- a/src/lib/libcrypto/asn1/a_digest.c
+++ b/src/lib/libcrypto/asn1/a_digest.c
@@ -58,16 +58,19 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/evp.h> 68#include <openssl/evp.h>
66#include <openssl/buffer.h> 69#include <openssl/buffer.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
68 71
69int ASN1_digest(int (*i2d)(), EVP_MD *type, char *data, unsigned char *md, 72int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
70 unsigned int *len) 73 unsigned char *md, unsigned int *len)
71 { 74 {
72 EVP_MD_CTX ctx; 75 EVP_MD_CTX ctx;
73 int i; 76 int i;
diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c
index c0a8709f3b..3202a816d0 100644
--- a/src/lib/libcrypto/asn1/a_dup.c
+++ b/src/lib/libcrypto/asn1/a_dup.c
@@ -78,6 +78,6 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
78 i=i2d(x,&p); 78 i=i2d(x,&p);
79 p= b; 79 p= b;
80 ret=d2i(NULL,&p,i); 80 ret=d2i(NULL,&p,i);
81 Free((char *)b); 81 Free(b);
82 return(ret); 82 return(ret);
83 } 83 }
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index 9239ecc439..ccf62e5a04 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -65,6 +65,12 @@
65 * for comments on encoding see a_int.c 65 * for comments on encoding see a_int.c
66 */ 66 */
67 67
68ASN1_ENUMERATED *ASN1_ENUMERATED_new(void)
69{ return M_ASN1_ENUMERATED_new(); }
70
71void ASN1_ENUMERATED_free(ASN1_ENUMERATED *x)
72{ M_ASN1_ENUMERATED_free(x); }
73
68int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp) 74int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp)
69 { 75 {
70 int pad=0,ret,r,i,t; 76 int pad=0,ret,r,i,t;
@@ -142,7 +148,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
142 148
143 if ((a == NULL) || ((*a) == NULL)) 149 if ((a == NULL) || ((*a) == NULL))
144 { 150 {
145 if ((ret=ASN1_ENUMERATED_new()) == NULL) return(NULL); 151 if ((ret=M_ASN1_ENUMERATED_new()) == NULL) return(NULL);
146 ret->type=V_ASN1_ENUMERATED; 152 ret->type=V_ASN1_ENUMERATED;
147 } 153 }
148 else 154 else
@@ -171,7 +177,12 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
171 goto err; 177 goto err;
172 } 178 }
173 to=s; 179 to=s;
174 if (*p & 0x80) /* a negative number */ 180 if(!len) {
181 /* Strictly speaking this is an illegal ENUMERATED but we
182 * tolerate it.
183 */
184 ret->type=V_ASN1_ENUMERATED;
185 } else if (*p & 0x80) /* a negative number */
175 { 186 {
176 ret->type=V_ASN1_NEG_ENUMERATED; 187 ret->type=V_ASN1_NEG_ENUMERATED;
177 if ((*p == 0xff) && (len != 1)) { 188 if ((*p == 0xff) && (len != 1)) {
@@ -208,7 +219,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
208 p+=len; 219 p+=len;
209 } 220 }
210 221
211 if (ret->data != NULL) Free((char *)ret->data); 222 if (ret->data != NULL) Free(ret->data);
212 ret->data=s; 223 ret->data=s;
213 ret->length=(int)len; 224 ret->length=(int)len;
214 if (a != NULL) (*a)=ret; 225 if (a != NULL) (*a)=ret;
@@ -217,7 +228,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
217err: 228err:
218 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i); 229 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i);
219 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 230 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
220 ASN1_ENUMERATED_free(ret); 231 M_ASN1_ENUMERATED_free(ret);
221 return(NULL); 232 return(NULL);
222 } 233 }
223 234
@@ -231,7 +242,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
231 if (a->length < (sizeof(long)+1)) 242 if (a->length < (sizeof(long)+1))
232 { 243 {
233 if (a->data != NULL) 244 if (a->data != NULL)
234 Free((char *)a->data); 245 Free(a->data);
235 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 246 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
236 memset((char *)a->data,0,sizeof(long)+1); 247 memset((char *)a->data,0,sizeof(long)+1);
237 } 248 }
@@ -295,7 +306,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
295 int len,j; 306 int len,j;
296 307
297 if (ai == NULL) 308 if (ai == NULL)
298 ret=ASN1_ENUMERATED_new(); 309 ret=M_ASN1_ENUMERATED_new();
299 else 310 else
300 ret=ai; 311 ret=ai;
301 if (ret == NULL) 312 if (ret == NULL)
@@ -311,7 +322,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
311 ret->length=BN_bn2bin(bn,ret->data); 322 ret->length=BN_bn2bin(bn,ret->data);
312 return(ret); 323 return(ret);
313err: 324err:
314 if (ret != ai) ASN1_ENUMERATED_free(ret); 325 if (ret != ai) M_ASN1_ENUMERATED_free(ret);
315 return(NULL); 326 return(NULL);
316 } 327 }
317 328
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index 226474f057..84062170e8 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -63,6 +63,12 @@
63#include "cryptlib.h" 63#include "cryptlib.h"
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65 65
66ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void)
67{ return M_ASN1_GENERALIZEDTIME_new(); }
68
69void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x)
70{ M_ASN1_GENERALIZEDTIME_free(x); }
71
66int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) 72int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
67 { 73 {
68#ifdef CHARSET_EBCDIC 74#ifdef CHARSET_EBCDIC
@@ -106,7 +112,7 @@ ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,
106 return(ret); 112 return(ret);
107err: 113err:
108 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 114 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
109 ASN1_GENERALIZEDTIME_free(ret); 115 M_ASN1_GENERALIZEDTIME_free(ret);
110 return(NULL); 116 return(NULL);
111 } 117 }
112 118
@@ -193,7 +199,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
193#endif 199#endif
194 200
195 if (s == NULL) 201 if (s == NULL)
196 s=ASN1_GENERALIZEDTIME_new(); 202 s=M_ASN1_GENERALIZEDTIME_new();
197 if (s == NULL) 203 if (s == NULL)
198 return(NULL); 204 return(NULL);
199 205
diff --git a/src/lib/libcrypto/asn1/a_hdr.c b/src/lib/libcrypto/asn1/a_hdr.c
index 1171d36443..434610e8e1 100644
--- a/src/lib/libcrypto/asn1/a_hdr.c
+++ b/src/lib/libcrypto/asn1/a_hdr.c
@@ -102,7 +102,7 @@ ASN1_HEADER *ASN1_HEADER_new(void)
102 ASN1_CTX c; 102 ASN1_CTX c;
103 103
104 M_ASN1_New_Malloc(ret,ASN1_HEADER); 104 M_ASN1_New_Malloc(ret,ASN1_HEADER);
105 M_ASN1_New(ret->header,ASN1_OCTET_STRING_new); 105 M_ASN1_New(ret->header,M_ASN1_OCTET_STRING_new);
106 ret->meth=NULL; 106 ret->meth=NULL;
107 ret->data=NULL; 107 ret->data=NULL;
108 return(ret); 108 return(ret);
@@ -112,8 +112,8 @@ ASN1_HEADER *ASN1_HEADER_new(void)
112void ASN1_HEADER_free(ASN1_HEADER *a) 112void ASN1_HEADER_free(ASN1_HEADER *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_OCTET_STRING_free(a->header); 115 M_ASN1_OCTET_STRING_free(a->header);
116 if (a->meth != NULL) 116 if (a->meth != NULL)
117 a->meth->destroy(a->data); 117 a->meth->destroy(a->data);
118 Free((char *)a); 118 Free(a);
119 } 119 }
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c
index 6bd845443c..d9b8035e17 100644
--- a/src/lib/libcrypto/asn1/a_i2d_fp.c
+++ b/src/lib/libcrypto/asn1/a_i2d_fp.c
@@ -108,6 +108,6 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
108 j+=i; 108 j+=i;
109 n-=i; 109 n-=i;
110 } 110 }
111 Free((char *)b); 111 Free(b);
112 return(ret); 112 return(ret);
113 } 113 }
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index d05436378b..8b6794e8c1 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -60,6 +60,18 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_INTEGER *ASN1_INTEGER_new(void)
64{ return M_ASN1_INTEGER_new();}
65
66void ASN1_INTEGER_free(ASN1_INTEGER *x)
67{ M_ASN1_INTEGER_free(x);}
68
69ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x)
70{ return M_ASN1_INTEGER_dup(x);}
71
72int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
73{ return M_ASN1_INTEGER_cmp(x,y);}
74
63/* 75/*
64 * This converts an ASN1 INTEGER into its DER encoding. 76 * This converts an ASN1 INTEGER into its DER encoding.
65 * The internal representation is an ASN1_STRING whose data is a big endian 77 * The internal representation is an ASN1_STRING whose data is a big endian
@@ -160,7 +172,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
160 172
161 if ((a == NULL) || ((*a) == NULL)) 173 if ((a == NULL) || ((*a) == NULL))
162 { 174 {
163 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 175 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
164 ret->type=V_ASN1_INTEGER; 176 ret->type=V_ASN1_INTEGER;
165 } 177 }
166 else 178 else
@@ -190,7 +202,12 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
190 goto err; 202 goto err;
191 } 203 }
192 to=s; 204 to=s;
193 if (*p & 0x80) /* a negative number */ 205 if(!len) {
206 /* Strictly speaking this is an illegal INTEGER but we
207 * tolerate it.
208 */
209 ret->type=V_ASN1_INTEGER;
210 } else if (*p & 0x80) /* a negative number */
194 { 211 {
195 ret->type=V_ASN1_NEG_INTEGER; 212 ret->type=V_ASN1_NEG_INTEGER;
196 if ((*p == 0xff) && (len != 1)) { 213 if ((*p == 0xff) && (len != 1)) {
@@ -231,7 +248,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
231 memcpy(s,p,(int)len); 248 memcpy(s,p,(int)len);
232 } 249 }
233 250
234 if (ret->data != NULL) Free((char *)ret->data); 251 if (ret->data != NULL) Free(ret->data);
235 ret->data=s; 252 ret->data=s;
236 ret->length=(int)len; 253 ret->length=(int)len;
237 if (a != NULL) (*a)=ret; 254 if (a != NULL) (*a)=ret;
@@ -240,7 +257,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
240err: 257err:
241 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i); 258 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
242 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 259 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
243 ASN1_INTEGER_free(ret); 260 M_ASN1_INTEGER_free(ret);
244 return(NULL); 261 return(NULL);
245 } 262 }
246 263
@@ -260,7 +277,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
260 277
261 if ((a == NULL) || ((*a) == NULL)) 278 if ((a == NULL) || ((*a) == NULL))
262 { 279 {
263 if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL); 280 if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
264 ret->type=V_ASN1_INTEGER; 281 ret->type=V_ASN1_INTEGER;
265 } 282 }
266 else 283 else
@@ -289,7 +306,8 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
289 goto err; 306 goto err;
290 } 307 }
291 to=s; 308 to=s;
292 ret->type=V_ASN1_INTEGER; 309 ret->type=V_ASN1_INTEGER;
310 if(len) {
293 if ((*p == 0) && (len != 1)) 311 if ((*p == 0) && (len != 1))
294 { 312 {
295 p++; 313 p++;
@@ -297,8 +315,9 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
297 } 315 }
298 memcpy(s,p,(int)len); 316 memcpy(s,p,(int)len);
299 p+=len; 317 p+=len;
318 }
300 319
301 if (ret->data != NULL) Free((char *)ret->data); 320 if (ret->data != NULL) Free(ret->data);
302 ret->data=s; 321 ret->data=s;
303 ret->length=(int)len; 322 ret->length=(int)len;
304 if (a != NULL) (*a)=ret; 323 if (a != NULL) (*a)=ret;
@@ -307,7 +326,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
307err: 326err:
308 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i); 327 ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i);
309 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 328 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
310 ASN1_INTEGER_free(ret); 329 M_ASN1_INTEGER_free(ret);
311 return(NULL); 330 return(NULL);
312 } 331 }
313 332
@@ -321,7 +340,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
321 if (a->length < (sizeof(long)+1)) 340 if (a->length < (sizeof(long)+1))
322 { 341 {
323 if (a->data != NULL) 342 if (a->data != NULL)
324 Free((char *)a->data); 343 Free(a->data);
325 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL) 344 if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
326 memset((char *)a->data,0,sizeof(long)+1); 345 memset((char *)a->data,0,sizeof(long)+1);
327 } 346 }
@@ -385,7 +404,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
385 int len,j; 404 int len,j;
386 405
387 if (ai == NULL) 406 if (ai == NULL)
388 ret=ASN1_INTEGER_new(); 407 ret=M_ASN1_INTEGER_new();
389 else 408 else
390 ret=ai; 409 ret=ai;
391 if (ret == NULL) 410 if (ret == NULL)
@@ -401,7 +420,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
401 ret->length=BN_bn2bin(bn,ret->data); 420 ret->length=BN_bn2bin(bn,ret->data);
402 return(ret); 421 return(ret);
403err: 422err:
404 if (ret != ai) ASN1_INTEGER_free(ret); 423 if (ret != ai) M_ASN1_INTEGER_free(ret);
405 return(NULL); 424 return(NULL);
406 } 425 }
407 426
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
new file mode 100644
index 0000000000..7a710d5459
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -0,0 +1,390 @@
1/* a_mbstr.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63
64static int traverse_string(const unsigned char *p, int len, int inform,
65 int (*rfunc)(unsigned long value, void *in), void *arg);
66static int in_utf8(unsigned long value, void *arg);
67static int out_utf8(unsigned long value, void *arg);
68static int type_str(unsigned long value, void *arg);
69static int cpy_asc(unsigned long value, void *arg);
70static int cpy_bmp(unsigned long value, void *arg);
71static int cpy_univ(unsigned long value, void *arg);
72static int cpy_utf8(unsigned long value, void *arg);
73static int is_printable(unsigned long value);
74
75/* These functions take a string in UTF8, ASCII or multibyte form and
76 * a mask of permissible ASN1 string types. It then works out the minimal
77 * type (using the order Printable < IA5 < T61 < BMP < Universal < UTF8)
78 * and creates a string of the correct type with the supplied data.
79 * Yes this is horrible: it has to be :-(
80 * The 'ncopy' form checks minimum and maximum size limits too.
81 */
82
83int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
84 int inform, unsigned long mask)
85{
86 return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
87}
88
89int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
90 int inform, unsigned long mask,
91 long minsize, long maxsize)
92{
93 int str_type;
94 int ret;
95 int outform, outlen;
96 ASN1_STRING *dest;
97 unsigned char *p;
98 int nchar;
99 char strbuf[32];
100 int (*cpyfunc)(unsigned long,void *) = NULL;
101 if(len == -1) len = strlen((const char *)in);
102 if(!mask) mask = DIRSTRING_TYPE;
103
104 /* First do a string check and work out the number of characters */
105 switch(inform) {
106
107 case MBSTRING_BMP:
108 if(len & 1) {
109 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
110 ASN1_R_INVALID_BMPSTRING_LENGTH);
111 return -1;
112 }
113 nchar = len >> 1;
114 break;
115
116 case MBSTRING_UNIV:
117 if(len & 3) {
118 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
119 ASN1_R_INVALID_UNIVERSALSTRING_LENGTH);
120 return -1;
121 }
122 nchar = len >> 2;
123 break;
124
125 case MBSTRING_UTF8:
126 nchar = 0;
127 /* This counts the characters and does utf8 syntax checking */
128 ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar);
129 if(ret < 0) {
130 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
131 ASN1_R_INVALID_UTF8STRING);
132 return -1;
133 }
134 break;
135
136 case MBSTRING_ASC:
137 nchar = len;
138 break;
139
140 default:
141 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_UNKNOWN_FORMAT);
142 return -1;
143 }
144
145 if((minsize > 0) && (nchar < minsize)) {
146 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
147 sprintf(strbuf, "%ld", minsize);
148 ERR_add_error_data(2, "minsize=", strbuf);
149 return -1;
150 }
151
152 if((maxsize > 0) && (nchar > maxsize)) {
153 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
154 sprintf(strbuf, "%ld", maxsize);
155 ERR_add_error_data(2, "maxsize=", strbuf);
156 return -1;
157 }
158
159 /* Now work out minimal type (if any) */
160 if(traverse_string(in, len, inform, type_str, &mask) < 0) {
161 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_ILLEGAL_CHARACTERS);
162 return -1;
163 }
164
165
166 /* Now work out output format and string type */
167 outform = MBSTRING_ASC;
168 if(mask & B_ASN1_PRINTABLESTRING) str_type = V_ASN1_PRINTABLESTRING;
169 else if(mask & B_ASN1_IA5STRING) str_type = V_ASN1_IA5STRING;
170 else if(mask & B_ASN1_T61STRING) str_type = V_ASN1_T61STRING;
171 else if(mask & B_ASN1_BMPSTRING) {
172 str_type = V_ASN1_BMPSTRING;
173 outform = MBSTRING_BMP;
174 } else if(mask & B_ASN1_UNIVERSALSTRING) {
175 str_type = V_ASN1_UNIVERSALSTRING;
176 outform = MBSTRING_UNIV;
177 } else {
178 str_type = V_ASN1_UTF8STRING;
179 outform = MBSTRING_UTF8;
180 }
181 if(!out) return str_type;
182 if(*out) {
183 dest = *out;
184 if(dest->data) {
185 dest->length = 0;
186 Free(dest->data);
187 dest->data = NULL;
188 }
189 dest->type = str_type;
190 } else {
191 dest = ASN1_STRING_type_new(str_type);
192 if(!dest) {
193 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
194 ERR_R_MALLOC_FAILURE);
195 return -1;
196 }
197 *out = dest;
198 }
199 /* If both the same type just copy across */
200 if(inform == outform) {
201 if(!ASN1_STRING_set(dest, in, len)) {
202 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
203 return -1;
204 }
205 return str_type;
206 }
207
208 /* Work out how much space the destination will need */
209 switch(outform) {
210 case MBSTRING_ASC:
211 outlen = nchar;
212 cpyfunc = cpy_asc;
213 break;
214
215 case MBSTRING_BMP:
216 outlen = nchar << 1;
217 cpyfunc = cpy_bmp;
218 break;
219
220 case MBSTRING_UNIV:
221 outlen = nchar << 2;
222 cpyfunc = cpy_univ;
223 break;
224
225 case MBSTRING_UTF8:
226 outlen = 0;
227 traverse_string(in, len, inform, out_utf8, &outlen);
228 cpyfunc = cpy_utf8;
229 break;
230 }
231 if(!(p = Malloc(outlen + 1))) {
232 ASN1_STRING_free(dest);
233 ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
234 return -1;
235 }
236 dest->length = outlen;
237 dest->data = p;
238 p[outlen] = 0;
239 traverse_string(in, len, inform, cpyfunc, &p);
240 return str_type;
241}
242
243/* This function traverses a string and passes the value of each character
244 * to an optional function along with a void * argument.
245 */
246
247static int traverse_string(const unsigned char *p, int len, int inform,
248 int (*rfunc)(unsigned long value, void *in), void *arg)
249{
250 unsigned long value;
251 int ret;
252 while(len) {
253 if(inform == MBSTRING_ASC) {
254 value = *p++;
255 len--;
256 } else if(inform == MBSTRING_BMP) {
257 value = *p++ << 8;
258 value |= *p++;
259 len -= 2;
260 } else if(inform == MBSTRING_UNIV) {
261 value = *p++ << 24;
262 value |= *p++ << 16;
263 value |= *p++ << 8;
264 value |= *p++;
265 len -= 4;
266 } else {
267 ret = UTF8_getc(p, len, &value);
268 if(ret < 0) return -1;
269 len -= ret;
270 p += ret;
271 }
272 if(rfunc) {
273 ret = rfunc(value, arg);
274 if(ret <= 0) return ret;
275 }
276 }
277 return 1;
278}
279
280/* Various utility functions for traverse_string */
281
282/* Just count number of characters */
283
284static int in_utf8(unsigned long value, void *arg)
285{
286 int *nchar;
287 nchar = arg;
288 (*nchar)++;
289 return 1;
290}
291
292/* Determine size of output as a UTF8 String */
293
294static int out_utf8(unsigned long value, void *arg)
295{
296 long *outlen;
297 outlen = arg;
298 *outlen += UTF8_putc(NULL, -1, value);
299 return 1;
300}
301
302/* Determine the "type" of a string: check each character against a
303 * supplied "mask".
304 */
305
306static int type_str(unsigned long value, void *arg)
307{
308 unsigned long types;
309 types = *((unsigned long *)arg);
310 if((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
311 types &= ~B_ASN1_PRINTABLESTRING;
312 if((types & B_ASN1_IA5STRING) && (value > 127))
313 types &= ~B_ASN1_IA5STRING;
314 if((types & B_ASN1_T61STRING) && (value > 0xff))
315 types &= ~B_ASN1_T61STRING;
316 if((types & B_ASN1_BMPSTRING) && (value > 0xffff))
317 types &= ~B_ASN1_BMPSTRING;
318 if(!types) return -1;
319 *((unsigned long *)arg) = types;
320 return 1;
321}
322
323/* Copy one byte per character ASCII like strings */
324
325static int cpy_asc(unsigned long value, void *arg)
326{
327 unsigned char **p, *q;
328 p = arg;
329 q = *p;
330 *q = (unsigned char) value;
331 (*p)++;
332 return 1;
333}
334
335/* Copy two byte per character BMPStrings */
336
337static int cpy_bmp(unsigned long value, void *arg)
338{
339 unsigned char **p, *q;
340 p = arg;
341 q = *p;
342 *q++ = (unsigned char) ((value >> 8) & 0xff);
343 *q = (unsigned char) (value & 0xff);
344 *p += 2;
345 return 1;
346}
347
348/* Copy four byte per character UniversalStrings */
349
350static int cpy_univ(unsigned long value, void *arg)
351{
352 unsigned char **p, *q;
353 p = arg;
354 q = *p;
355 *q++ = (unsigned char) ((value >> 24) & 0xff);
356 *q++ = (unsigned char) ((value >> 16) & 0xff);
357 *q++ = (unsigned char) ((value >> 8) & 0xff);
358 *q = (unsigned char) (value & 0xff);
359 *p += 4;
360 return 1;
361}
362
363/* Copy to a UTF8String */
364
365static int cpy_utf8(unsigned long value, void *arg)
366{
367 unsigned char **p;
368 int ret;
369 p = arg;
370 /* We already know there is enough room so pass 0xff as the length */
371 ret = UTF8_putc(*p, 0xff, value);
372 *p += ret;
373 return 1;
374}
375
376/* Return 1 if the character is permitted in a PrintableString */
377static int is_printable(unsigned long value)
378{
379 int ch;
380 if(value > 0x7f) return 0;
381 ch = (int) value;
382 /* Note: we can't use 'isalnum' because certain accented
383 * characters may count as alphanumeric in some environments.
384 */
385 if((ch >= 'a') && (ch <= 'z')) return 1;
386 if((ch >= 'A') && (ch <= 'Z')) return 1;
387 if((ch >= '0') && (ch <= '9')) return 1;
388 if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1;
389 return 0;
390}
diff --git a/src/lib/libcrypto/asn1/a_null.c b/src/lib/libcrypto/asn1/a_null.c
new file mode 100644
index 0000000000..119fd784be
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_null.c
@@ -0,0 +1,119 @@
1/* a_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1.h>
62
63/* ASN1 functions for NULL type. For compatibility with other ASN1 code
64 * it returns a pointer to an "ASN1_NULL" structure. The new/free functions
65 * don't need to do any allocating because nothing is stored in a NULL.
66 */
67
68int i2d_ASN1_NULL(ASN1_NULL *a, unsigned char **pp)
69 {
70 if(!a) return 0;
71 if (pp) ASN1_put_object(pp,0,0,V_ASN1_NULL,V_ASN1_UNIVERSAL);
72 return 2;
73 }
74
75ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp, long length)
76 {
77 ASN1_NULL *ret = NULL;
78 unsigned char *p;
79 long len;
80 int inf,tag,xclass;
81 int i=0;
82
83 p= *pp;
84 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
85 if (inf & 0x80)
86 {
87 i=ASN1_R_BAD_OBJECT_HEADER;
88 goto err;
89 }
90
91 if (tag != V_ASN1_NULL)
92 {
93 i=ASN1_R_EXPECTING_A_NULL;
94 goto err;
95 }
96
97 if (len != 0)
98 {
99 i=ASN1_R_NULL_IS_WRONG_LENGTH;
100 goto err;
101 }
102 ret=(ASN1_NULL *)1;
103 if (a != NULL) (*a)=ret;
104 *pp=p;
105 return(ret);
106err:
107 ASN1err(ASN1_F_D2I_ASN1_NULL,i);
108 return(ret);
109 }
110
111ASN1_NULL *ASN1_NULL_new(void)
112{
113 return (ASN1_NULL *)1;
114}
115
116void ASN1_NULL_free(ASN1_NULL *a)
117{
118 return;
119}
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index b94b418ee8..09d56fb669 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -222,8 +222,8 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
222 } 222 }
223 if ((ret->data == NULL) || (ret->length < len)) 223 if ((ret->data == NULL) || (ret->length < len))
224 { 224 {
225 if (ret->data != NULL) Free((char *)ret->data); 225 if (ret->data != NULL) Free(ret->data);
226 ret->data=(unsigned char *)Malloc((int)len); 226 ret->data=(unsigned char *)Malloc(len ? (int)len : 1);
227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 227 ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
228 if (ret->data == NULL) 228 if (ret->data == NULL)
229 { i=ERR_R_MALLOC_FAILURE; goto err; } 229 { i=ERR_R_MALLOC_FAILURE; goto err; }
@@ -269,7 +269,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
269 if (a == NULL) return; 269 if (a == NULL) return;
270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) 270 if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS)
271 { 271 {
272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause mempory leaks */ 272#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */
273 if (a->sn != NULL) Free((void *)a->sn); 273 if (a->sn != NULL) Free((void *)a->sn);
274 if (a->ln != NULL) Free((void *)a->ln); 274 if (a->ln != NULL) Free((void *)a->ln);
275#endif 275#endif
diff --git a/src/lib/libcrypto/asn1/a_octet.c b/src/lib/libcrypto/asn1/a_octet.c
index 7659a13bd3..2586f4327d 100644
--- a/src/lib/libcrypto/asn1/a_octet.c
+++ b/src/lib/libcrypto/asn1/a_octet.c
@@ -60,11 +60,23 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void)
64{ return M_ASN1_OCTET_STRING_new(); }
65
66void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *x)
67{ M_ASN1_OCTET_STRING_free(x); }
68
69ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *x)
70{ return M_ASN1_OCTET_STRING_dup(x); }
71
72int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b)
73{ return M_ASN1_OCTET_STRING_cmp(a, b); }
74
75int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len)
76{ return M_ASN1_OCTET_STRING_set(x, d, len); }
77
63int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp) 78int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp)
64 { 79{ return M_i2d_ASN1_OCTET_STRING(a, pp); }
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
66 V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL));
67 }
68 80
69ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 81ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
70 unsigned char **pp, long length) 82 unsigned char **pp, long length)
diff --git a/src/lib/libcrypto/asn1/a_print.c b/src/lib/libcrypto/asn1/a_print.c
index cdec7a1561..b7bd2bd18a 100644
--- a/src/lib/libcrypto/asn1/a_print.c
+++ b/src/lib/libcrypto/asn1/a_print.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_IA5STRING *ASN1_IA5STRING_new(void)
64{ return M_ASN1_IA5STRING_new();}
65
66void ASN1_IA5STRING_free(ASN1_IA5STRING *x)
67{ M_ASN1_IA5STRING_free(x);}
68
63int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp) 69int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp)
64 { return(M_i2d_ASN1_IA5STRING(a,pp)); } 70 { return(M_i2d_ASN1_IA5STRING(a,pp)); }
65 71
@@ -67,15 +73,30 @@ ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, unsigned char **pp,
67 long l) 73 long l)
68 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); } 74 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); }
69 75
76ASN1_T61STRING *ASN1_T61STRING_new(void)
77{ return M_ASN1_T61STRING_new();}
78
79void ASN1_T61STRING_free(ASN1_T61STRING *x)
80{ M_ASN1_T61STRING_free(x);}
81
70ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp, 82ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp,
71 long l) 83 long l)
72 { return(M_d2i_ASN1_T61STRING(a,pp,l)); } 84 { return(M_d2i_ASN1_T61STRING(a,pp,l)); }
73 85
86ASN1_PRINTABLESTRING *ASN1_PRINTABLESTRING_new(void)
87{ return M_ASN1_PRINTABLESTRING_new();}
88
89void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *x)
90{ M_ASN1_PRINTABLESTRING_free(x);}
91
74ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 92ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
75 unsigned char **pp, long l) 93 unsigned char **pp, long l)
76 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp, 94 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp,
77 l)); } 95 l)); }
78 96
97int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp)
98 { return(M_i2d_ASN1_PRINTABLESTRING(a,pp)); }
99
79int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp) 100int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp)
80 { return(M_i2d_ASN1_PRINTABLE(a,pp)); } 101 { return(M_i2d_ASN1_PRINTABLE(a,pp)); }
81 102
@@ -149,6 +170,11 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
149 return(1); 170 return(1);
150 } 171 }
151 172
173ASN1_STRING *DIRECTORYSTRING_new(void)
174{ return M_DIRECTORYSTRING_new();}
175
176void DIRECTORYSTRING_free(ASN1_STRING *x)
177{ M_DIRECTORYSTRING_free(x);}
152 178
153int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp) 179int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp)
154 { return(M_i2d_DIRECTORYSTRING(a,pp)); } 180 { return(M_i2d_DIRECTORYSTRING(a,pp)); }
@@ -157,6 +183,12 @@ ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
157 long l) 183 long l)
158 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); } 184 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); }
159 185
186ASN1_STRING *DISPLAYTEXT_new(void)
187{ return M_DISPLAYTEXT_new();}
188
189void DISPLAYTEXT_free(ASN1_STRING *x)
190{ M_DISPLAYTEXT_free(x);}
191
160int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp) 192int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp)
161 { return(M_i2d_DISPLAYTEXT(a,pp)); } 193 { return(M_i2d_DISPLAYTEXT(a,pp)); }
162 194
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 57595692e5..cfb4bca4f1 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/evp.h> 69#include <openssl/evp.h>
67#include <openssl/x509.h> 70#include <openssl/x509.h>
@@ -126,11 +129,11 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
126 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB); 129 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
127 goto err; 130 goto err;
128 } 131 }
129 if (signature->data != NULL) Free((char *)signature->data); 132 if (signature->data != NULL) Free(signature->data);
130 signature->data=buf_out; 133 signature->data=buf_out;
131 buf_out=NULL; 134 buf_out=NULL;
132 signature->length=outl; 135 signature->length=outl;
133 /* In the interests of compatability, I'll make sure that 136 /* In the interests of compatibility, I'll make sure that
134 * the bit string has a 'not-used bits' value of 0 137 * the bit string has a 'not-used bits' value of 0
135 */ 138 */
136 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 139 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
@@ -138,8 +141,8 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
138err: 141err:
139 memset(&ctx,0,sizeof(ctx)); 142 memset(&ctx,0,sizeof(ctx));
140 if (buf_in != NULL) 143 if (buf_in != NULL)
141 { memset((char *)buf_in,0,(unsigned int)inl); Free((char *)buf_in); } 144 { memset((char *)buf_in,0,(unsigned int)inl); Free(buf_in); }
142 if (buf_out != NULL) 145 if (buf_out != NULL)
143 { memset((char *)buf_out,0,outll); Free((char *)buf_out); } 146 { memset((char *)buf_out,0,outll); Free(buf_out); }
144 return(outl); 147 return(outl);
145 } 148 }
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
new file mode 100644
index 0000000000..ab8417ffab
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -0,0 +1,247 @@
1/* a_strnid.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/objects.h>
64
65
66static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
67static void st_free(ASN1_STRING_TABLE *tbl);
68static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b);
69static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b);
70
71
72/* This is the global mask for the mbstring functions: this is use to
73 * mask out certain types (such as BMPString and UTF8String) because
74 * certain software (e.g. Netscape) has problems with them.
75 */
76
77static unsigned long global_mask = 0xFFFFFFFFL;
78
79void ASN1_STRING_set_default_mask(unsigned long mask)
80{
81 global_mask = mask;
82}
83
84unsigned long ASN1_STRING_get_default_mask(void)
85{
86 return global_mask;
87}
88
89/* This function sets the default to various "flavours" of configuration.
90 * based on an ASCII string. Currently this is:
91 * MASK:XXXX : a numerical mask value.
92 * nobmp : Don't use BMPStrings (just Printable, T61).
93 * pkix : PKIX recommendation in RFC2459.
94 * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004).
95 * default: the default value, Printable, T61, BMP.
96 */
97
98int ASN1_STRING_set_default_mask_asc(char *p)
99{
100 unsigned long mask;
101 char *end;
102 if(!strncmp(p, "MASK:", 5)) {
103 if(!p[5]) return 0;
104 mask = strtoul(p + 5, &end, 0);
105 if(*end) return 0;
106 } else if(!strcmp(p, "nombstr"))
107 mask = ~(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING);
108 else if(!strcmp(p, "pkix"))
109 mask = ~B_ASN1_T61STRING;
110 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING;
111 else if(!strcmp(p, "default"))
112 mask = 0xFFFFFFFFL;
113 else return 0;
114 ASN1_STRING_set_default_mask(mask);
115 return 1;
116}
117
118/* The following function generates an ASN1_STRING based on limits in a table.
119 * Frequently the types and length of an ASN1_STRING are restricted by a
120 * corresponding OID. For example certificates and certificate requests.
121 */
122
123ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
124 int inlen, int inform, int nid)
125{
126 ASN1_STRING_TABLE *tbl;
127 ASN1_STRING *str = NULL;
128 unsigned long mask;
129 int ret;
130 if(!out) out = &str;
131 tbl = ASN1_STRING_TABLE_get(nid);
132 if(tbl) {
133 mask = tbl->mask;
134 if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask;
135 ret = ASN1_mbstring_ncopy(out, in, inlen, inform, tbl->mask,
136 tbl->minsize, tbl->maxsize);
137 } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask);
138 if(ret <= 0) return NULL;
139 return *out;
140}
141
142/* Now the tables and helper functions for the string table:
143 */
144
145/* size limits: this stuff is taken straight from RFC2459 */
146
147#define ub_name 32768
148#define ub_common_name 64
149#define ub_locality_name 128
150#define ub_state_name 128
151#define ub_organization_name 64
152#define ub_organization_unit_name 64
153#define ub_title 64
154#define ub_email_address 128
155
156/* This table must be kept in NID order */
157
158static ASN1_STRING_TABLE tbl_standard[] = {
159{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
160{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
161{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
162{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
163{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
164{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE, 0},
165{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING, STABLE_NO_MASK},
166{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
167{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
168{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
169{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
170{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
172{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}
174};
175
176static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b)
177{
178 return (*a)->nid - (*b)->nid;
179}
180
181static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b)
182{
183 return a->nid - b->nid;
184}
185
186ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
187{
188 int idx;
189 ASN1_STRING_TABLE *ttmp;
190 ASN1_STRING_TABLE fnd;
191 fnd.nid = nid;
192 ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
193 (char *)tbl_standard,
194 sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
195 sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp);
196 if(ttmp) return ttmp;
197 if(!stable) return NULL;
198 idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
199 if(idx < 0) return NULL;
200 return sk_ASN1_STRING_TABLE_value(stable, idx);
201}
202
203int ASN1_STRING_TABLE_add(int nid,
204 long minsize, long maxsize, unsigned long mask,
205 unsigned long flags)
206{
207 ASN1_STRING_TABLE *tmp;
208 char new_nid = 0;
209 flags &= ~STABLE_FLAGS_MALLOC;
210 if(!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
211 if(!stable) {
212 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE);
213 return 0;
214 }
215 if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
216 tmp = Malloc(sizeof(ASN1_STRING_TABLE));
217 if(!tmp) {
218 ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
219 ERR_R_MALLOC_FAILURE);
220 return 0;
221 }
222 tmp->flags = flags | STABLE_FLAGS_MALLOC;
223 tmp->nid = nid;
224 new_nid = 1;
225 } else tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
226 if(minsize != -1) tmp->minsize = minsize;
227 if(maxsize != -1) tmp->maxsize = maxsize;
228 tmp->mask = mask;
229 if(new_nid) sk_ASN1_STRING_TABLE_push(stable, tmp);
230 return 1;
231}
232
233void ASN1_STRING_TABLE_cleanup(void)
234{
235 STACK_OF(ASN1_STRING_TABLE) *tmp;
236 tmp = stable;
237 if(!tmp) return;
238 stable = NULL;
239 sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
240}
241
242static void st_free(ASN1_STRING_TABLE *tbl)
243{
244 if(tbl->flags & STABLE_FLAGS_MALLOC) Free(tbl);
245}
246
247IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index c1690a5694..b193f1c71f 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_TIME *ASN1_TIME_new(void)
70{ return M_ASN1_TIME_new(); }
71
72void ASN1_TIME_free(ASN1_TIME *x)
73{ M_ASN1_TIME_free(x); }
74
69int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) 75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
70 { 76 {
71#ifdef CHARSET_EBCDIC 77#ifdef CHARSET_EBCDIC
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index 3f2ecee5c2..161ef81197 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -282,7 +282,7 @@ void ASN1_TYPE_free(ASN1_TYPE *a)
282 { 282 {
283 if (a == NULL) return; 283 if (a == NULL) return;
284 ASN1_TYPE_component_free(a); 284 ASN1_TYPE_component_free(a);
285 Free((char *)(char *)a); 285 Free(a);
286 } 286 }
287 287
288int ASN1_TYPE_get(ASN1_TYPE *a) 288int ASN1_TYPE_get(ASN1_TYPE *a)
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index 688199fdd2..07565974e3 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -66,6 +66,12 @@
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include <openssl/asn1.h>
68 68
69ASN1_UTCTIME *ASN1_UTCTIME_new(void)
70{ return M_ASN1_UTCTIME_new(); }
71
72void ASN1_UTCTIME_free(ASN1_UTCTIME *x)
73{ M_ASN1_UTCTIME_free(x); }
74
69int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) 75int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
70 { 76 {
71#ifndef CHARSET_EBCDIC 77#ifndef CHARSET_EBCDIC
@@ -109,7 +115,7 @@ ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp,
109 return(ret); 115 return(ret);
110err: 116err:
111 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 117 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
112 ASN1_UTCTIME_free(ret); 118 M_ASN1_UTCTIME_free(ret);
113 return(NULL); 119 return(NULL);
114 } 120 }
115 121
@@ -192,7 +198,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
192#endif 198#endif
193 199
194 if (s == NULL) 200 if (s == NULL)
195 s=ASN1_UTCTIME_new(); 201 s=M_ASN1_UTCTIME_new();
196 if (s == NULL) 202 if (s == NULL)
197 return(NULL); 203 return(NULL);
198 204
diff --git a/src/lib/libcrypto/asn1/a_utf8.c b/src/lib/libcrypto/asn1/a_utf8.c
index 4a8a92e9e4..b5125af224 100644
--- a/src/lib/libcrypto/asn1/a_utf8.c
+++ b/src/lib/libcrypto/asn1/a_utf8.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_UTF8STRING *ASN1_UTF8STRING_new(void)
64{ return M_ASN1_UTF8STRING_new();}
65
66void ASN1_UTF8STRING_free(ASN1_UTF8STRING *x)
67{ M_ASN1_UTF8STRING_free(x);}
68
63int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp) 69int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
@@ -81,3 +87,152 @@ ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, unsigned char **pp,
81 return(ret); 87 return(ret);
82 } 88 }
83 89
90
91/* UTF8 utilities */
92
93/* This parses a UTF8 string one character at a time. It is passed a pointer
94 * to the string and the length of the string. It sets 'value' to the value of
95 * the current character. It returns the number of characters read or a
96 * negative error code:
97 * -1 = string too short
98 * -2 = illegal character
99 * -3 = subsequent characters not of the form 10xxxxxx
100 * -4 = character encoded incorrectly (not minimal length).
101 */
102
103int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
104{
105 const unsigned char *p;
106 unsigned long value;
107 int ret;
108 if(len <= 0) return 0;
109 p = str;
110
111 /* Check syntax and work out the encoded value (if correct) */
112 if((*p & 0x80) == 0) {
113 value = *p++ & 0x7f;
114 ret = 1;
115 } else if((*p & 0xe0) == 0xc0) {
116 if(len < 2) return -1;
117 if((p[1] & 0xc0) != 0x80) return -3;
118 value = (*p++ & 0x1f) << 6;
119 value |= *p++ & 0x3f;
120 if(value < 0x80) return -4;
121 ret = 2;
122 } else if((*p & 0xf0) == 0xe0) {
123 if(len < 3) return -1;
124 if( ((p[1] & 0xc0) != 0x80)
125 || ((p[2] & 0xc0) != 0x80) ) return -3;
126 value = (*p++ & 0xf) << 12;
127 value |= (*p++ & 0x3f) << 6;
128 value |= *p++ & 0x3f;
129 if(value < 0x800) return -4;
130 ret = 3;
131 } else if((*p & 0xf8) == 0xf0) {
132 if(len < 4) return -1;
133 if( ((p[1] & 0xc0) != 0x80)
134 || ((p[2] & 0xc0) != 0x80)
135 || ((p[3] & 0xc0) != 0x80) ) return -3;
136 value = (*p++ & 0x7) << 18;
137 value |= (*p++ & 0x3f) << 12;
138 value |= (*p++ & 0x3f) << 6;
139 value |= *p++ & 0x3f;
140 if(value < 0x10000) return -4;
141 ret = 4;
142 } else if((*p & 0xfc) == 0xf8) {
143 if(len < 5) return -1;
144 if( ((p[1] & 0xc0) != 0x80)
145 || ((p[2] & 0xc0) != 0x80)
146 || ((p[3] & 0xc0) != 0x80)
147 || ((p[4] & 0xc0) != 0x80) ) return -3;
148 value = (*p++ & 0x3) << 24;
149 value |= (*p++ & 0x3f) << 18;
150 value |= (*p++ & 0x3f) << 12;
151 value |= (*p++ & 0x3f) << 6;
152 value |= *p++ & 0x3f;
153 if(value < 0x200000) return -4;
154 ret = 5;
155 } else if((*p & 0xfe) == 0xfc) {
156 if(len < 6) return -1;
157 if( ((p[1] & 0xc0) != 0x80)
158 || ((p[2] & 0xc0) != 0x80)
159 || ((p[3] & 0xc0) != 0x80)
160 || ((p[4] & 0xc0) != 0x80)
161 || ((p[5] & 0xc0) != 0x80) ) return -3;
162 value = (*p++ & 0x1) << 30;
163 value |= (*p++ & 0x3f) << 24;
164 value |= (*p++ & 0x3f) << 18;
165 value |= (*p++ & 0x3f) << 12;
166 value |= (*p++ & 0x3f) << 6;
167 value |= *p++ & 0x3f;
168 if(value < 0x4000000) return -4;
169 ret = 6;
170 } else return -2;
171 *val = value;
172 return ret;
173}
174
175/* This takes a character 'value' and writes the UTF8 encoded value in
176 * 'str' where 'str' is a buffer containing 'len' characters. Returns
177 * the number of characters written or -1 if 'len' is too small. 'str' can
178 * be set to NULL in which case it just returns the number of characters.
179 * It will need at most 6 characters.
180 */
181
182int UTF8_putc(unsigned char *str, int len, unsigned long value)
183{
184 if(!str) len = 6; /* Maximum we will need */
185 else if(len <= 0) return -1;
186 if(value < 0x80) {
187 if(str) *str = (unsigned char)value;
188 return 1;
189 }
190 if(value < 0x800) {
191 if(len < 2) return -1;
192 if(str) {
193 *str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
194 *str = (unsigned char)((value & 0x3f) | 0x80);
195 }
196 return 2;
197 }
198 if(value < 0x10000) {
199 if(len < 3) return -1;
200 if(str) {
201 *str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
202 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
203 *str = (unsigned char)((value & 0x3f) | 0x80);
204 }
205 return 3;
206 }
207 if(value < 0x200000) {
208 if(len < 4) return -1;
209 if(str) {
210 *str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
211 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
212 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
213 *str = (unsigned char)((value & 0x3f) | 0x80);
214 }
215 return 4;
216 }
217 if(value < 0x4000000) {
218 if(len < 5) return -1;
219 if(str) {
220 *str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
221 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
222 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
223 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
224 *str = (unsigned char)((value & 0x3f) | 0x80);
225 }
226 return 5;
227 }
228 if(len < 6) return -1;
229 if(str) {
230 *str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
231 *str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
232 *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
233 *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
234 *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
235 *str = (unsigned char)((value & 0x3f) | 0x80);
236 }
237 return 6;
238}
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index 6383d2c698..d4aede85c3 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -58,10 +58,13 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include <sys/types.h>
62#include <sys/stat.h>
63 61
64#include "cryptlib.h" 62#include "cryptlib.h"
63
64#ifndef NO_SYS_TYPES_H
65# include <sys/types.h>
66#endif
67
65#include <openssl/bn.h> 68#include <openssl/bn.h>
66#include <openssl/x509.h> 69#include <openssl/x509.h>
67#include <openssl/objects.h> 70#include <openssl/objects.h>
@@ -98,7 +101,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
98 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 101 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
99 102
100 memset(buf_in,0,(unsigned int)inl); 103 memset(buf_in,0,(unsigned int)inl);
101 Free((char *)buf_in); 104 Free(buf_in);
102 105
103 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 106 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
104 (unsigned int)signature->length,pkey) <= 0) 107 (unsigned int)signature->length,pkey) <= 0)
diff --git a/src/lib/libcrypto/asn1/a_vis.c b/src/lib/libcrypto/asn1/a_vis.c
index 2072be780d..5cfc080bec 100644
--- a/src/lib/libcrypto/asn1/a_vis.c
+++ b/src/lib/libcrypto/asn1/a_vis.c
@@ -60,6 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_VISIBLESTRING *ASN1_VISIBLESTRING_new(void)
64{ return M_ASN1_VISIBLESTRING_new(); }
65
66void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *x)
67{ M_ASN1_VISIBLESTRING_free(x); }
68
63int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp) 69int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a, unsigned char **pp)
64 { 70 {
65 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index 5c2d8999bc..99bd64a11e 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -68,6 +68,10 @@ extern "C" {
68#include <openssl/stack.h> 68#include <openssl/stack.h>
69#include <openssl/safestack.h> 69#include <openssl/safestack.h>
70 70
71#ifdef VMS
72#include <openssl/vms_idhacks.h>
73#endif
74
71#define V_ASN1_UNIVERSAL 0x00 75#define V_ASN1_UNIVERSAL 0x00
72#define V_ASN1_APPLICATION 0x40 76#define V_ASN1_APPLICATION 0x40
73#define V_ASN1_CONTEXT_SPECIFIC 0x80 77#define V_ASN1_CONTEXT_SPECIFIC 0x80
@@ -77,7 +81,7 @@ extern "C" {
77#define V_ASN1_PRIMITIVE_TAG 0x1f 81#define V_ASN1_PRIMITIVE_TAG 0x1f
78#define V_ASN1_PRIMATIVE_TAG 0x1f 82#define V_ASN1_PRIMATIVE_TAG 0x1f
79 83
80#define V_ASN1_APP_CHOOSE -2 /* let the recipent choose */ 84#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
81 85
82#define V_ASN1_UNDEF -1 86#define V_ASN1_UNDEF -1
83#define V_ASN1_EOC 0 87#define V_ASN1_EOC 0
@@ -129,6 +133,13 @@ extern "C" {
129#define B_ASN1_UNKNOWN 0x1000 133#define B_ASN1_UNKNOWN 0x1000
130#define B_ASN1_UTF8STRING 0x2000 134#define B_ASN1_UTF8STRING 0x2000
131 135
136/* For use with ASN1_mbstring_copy() */
137#define MBSTRING_FLAG 0x1000
138#define MBSTRING_ASC (MBSTRING_FLAG|1)
139#define MBSTRING_BMP (MBSTRING_FLAG|2)
140#define MBSTRING_UNIV (MBSTRING_FLAG|3)
141#define MBSTRING_UTF8 (MBSTRING_FLAG|4)
142
132#define DECLARE_ASN1_SET_OF(type) \ 143#define DECLARE_ASN1_SET_OF(type) \
133int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \ 144int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
134 int (*func)(type *,unsigned char **), int ex_tag, \ 145 int (*func)(type *,unsigned char **), int ex_tag, \
@@ -165,7 +176,7 @@ typedef struct asn1_ctx_st
165 int tag; /* tag from last 'get object' */ 176 int tag; /* tag from last 'get object' */
166 int xclass; /* class from last 'get object' */ 177 int xclass; /* class from last 'get object' */
167 long slen; /* length of last 'get object' */ 178 long slen; /* length of last 'get object' */
168 unsigned char *max; /* largest value of p alowed */ 179 unsigned char *max; /* largest value of p allowed */
169 unsigned char *q;/* temporary variable */ 180 unsigned char *q;/* temporary variable */
170 unsigned char **pp;/* variable */ 181 unsigned char **pp;/* variable */
171 int line; /* used in error processing */ 182 int line; /* used in error processing */
@@ -200,7 +211,34 @@ typedef struct asn1_string_st
200 long flags; 211 long flags;
201 } ASN1_STRING; 212 } ASN1_STRING;
202 213
203#ifndef DEBUG 214#define STABLE_FLAGS_MALLOC 0x01
215#define STABLE_NO_MASK 0x02
216#define DIRSTRING_TYPE \
217 (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
218#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
219
220typedef struct asn1_string_table_st {
221 int nid;
222 long minsize;
223 long maxsize;
224 unsigned long mask;
225 unsigned long flags;
226} ASN1_STRING_TABLE;
227
228DECLARE_STACK_OF(ASN1_STRING_TABLE)
229
230/* size limits: this stuff is taken straight from RFC2459 */
231
232#define ub_name 32768
233#define ub_common_name 64
234#define ub_locality_name 128
235#define ub_state_name 128
236#define ub_organization_name 64
237#define ub_organization_unit_name 64
238#define ub_title 64
239#define ub_email_address 128
240
241#ifdef NO_ASN1_TYPEDEFS
204#define ASN1_INTEGER ASN1_STRING 242#define ASN1_INTEGER ASN1_STRING
205#define ASN1_ENUMERATED ASN1_STRING 243#define ASN1_ENUMERATED ASN1_STRING
206#define ASN1_BIT_STRING ASN1_STRING 244#define ASN1_BIT_STRING ASN1_STRING
@@ -234,6 +272,8 @@ typedef struct asn1_string_st ASN1_VISIBLESTRING;
234typedef struct asn1_string_st ASN1_UTF8STRING; 272typedef struct asn1_string_st ASN1_UTF8STRING;
235#endif 273#endif
236 274
275typedef int ASN1_NULL;
276
237typedef struct asn1_type_st 277typedef struct asn1_type_st
238 { 278 {
239 int type; 279 int type;
@@ -281,60 +321,58 @@ typedef struct asn1_header_st
281 ASN1_METHOD *meth; 321 ASN1_METHOD *meth;
282 } ASN1_HEADER; 322 } ASN1_HEADER;
283 323
284#define ASN1_STRING_length(x) ((x)->length) 324/* This is used to contain a list of bit names */
285#define ASN1_STRING_type(x) ((x)->type) 325typedef struct BIT_STRING_BITNAME_st {
286#define ASN1_STRING_data(x) ((x)->data) 326 int bitnum;
327 const char *lname;
328 const char *sname;
329} BIT_STRING_BITNAME;
330
331
332#define M_ASN1_STRING_length(x) ((x)->length)
333#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n))
334#define M_ASN1_STRING_type(x) ((x)->type)
335#define M_ASN1_STRING_data(x) ((x)->data)
287 336
288/* Macros for string operations */ 337/* Macros for string operations */
289#define ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ 338#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\
290 ASN1_STRING_type_new(V_ASN1_BIT_STRING) 339 ASN1_STRING_type_new(V_ASN1_BIT_STRING)
291#define ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 340#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
292#define ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 341#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
293 ASN1_STRING_dup((ASN1_STRING *)a) 342 ASN1_STRING_dup((ASN1_STRING *)a)
294#define ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 343#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
295 (ASN1_STRING *)a,(ASN1_STRING *)b) 344 (ASN1_STRING *)a,(ASN1_STRING *)b)
296#define ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 345#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
297/* i2d_ASN1_BIT_STRING() is a function */
298/* d2i_ASN1_BIT_STRING() is a function */
299 346
300#define ASN1_INTEGER_new() (ASN1_INTEGER *)\ 347#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\
301 ASN1_STRING_type_new(V_ASN1_INTEGER) 348 ASN1_STRING_type_new(V_ASN1_INTEGER)
302#define ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 349#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)
303#define ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) 350#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
304#define ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 351#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\
305 (ASN1_STRING *)a,(ASN1_STRING *)b) 352 (ASN1_STRING *)a,(ASN1_STRING *)b)
306/* ASN1_INTEGER_set() is a function, also see BN_to_ASN1_INTEGER() */
307/* ASN1_INTEGER_get() is a function, also see ASN1_INTEGER_to_BN() */
308/* i2d_ASN1_INTEGER() is a function */
309/* d2i_ASN1_INTEGER() is a function */
310 353
311#define ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 354#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\
312 ASN1_STRING_type_new(V_ASN1_ENUMERATED) 355 ASN1_STRING_type_new(V_ASN1_ENUMERATED)
313#define ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 356#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a)
314#define ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) 357#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
315#define ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 358#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\
316 (ASN1_STRING *)a,(ASN1_STRING *)b) 359 (ASN1_STRING *)a,(ASN1_STRING *)b)
317/* ASN1_ENUMERATED_set() is a function, also see BN_to_ASN1_ENUMERATED() */
318/* ASN1_ENUMERATED_get() is a function, also see ASN1_ENUMERATED_to_BN() */
319/* i2d_ASN1_ENUMERATED() is a function */
320/* d2i_ASN1_ENUMERATED() is a function */
321 360
322#define ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 361#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\
323 ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 362 ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
324#define ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 363#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
325#define ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 364#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
326 ASN1_STRING_dup((ASN1_STRING *)a) 365 ASN1_STRING_dup((ASN1_STRING *)a)
327#define ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 366#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
328 (ASN1_STRING *)a,(ASN1_STRING *)b) 367 (ASN1_STRING *)a,(ASN1_STRING *)b)
329#define ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 368#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
330#define ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 369#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
331#define M_i2d_ASN1_OCTET_STRING(a,pp) \ 370#define M_i2d_ASN1_OCTET_STRING(a,pp) \
332 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 371 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
333 V_ASN1_OCTET_STRING) 372 V_ASN1_UNIVERSAL)
334/* d2i_ASN1_OCTET_STRING() is a function */
335 373
336#define ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 374#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING)
337#define ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 375#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
338#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 376#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
339 pp,a->type,V_ASN1_UNIVERSAL) 377 pp,a->type,V_ASN1_UNIVERSAL)
340#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 378#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
@@ -345,10 +383,11 @@ typedef struct asn1_header_st
345 B_ASN1_BIT_STRING| \ 383 B_ASN1_BIT_STRING| \
346 B_ASN1_UNIVERSALSTRING|\ 384 B_ASN1_UNIVERSALSTRING|\
347 B_ASN1_BMPSTRING|\ 385 B_ASN1_BMPSTRING|\
386 B_ASN1_UTF8STRING|\
348 B_ASN1_UNKNOWN) 387 B_ASN1_UNKNOWN)
349 388
350#define DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 389#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
351#define DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 390#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
352#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 391#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
353 pp,a->type,V_ASN1_UNIVERSAL) 392 pp,a->type,V_ASN1_UNIVERSAL)
354#define M_d2i_DIRECTORYSTRING(a,pp,l) \ 393#define M_d2i_DIRECTORYSTRING(a,pp,l) \
@@ -359,8 +398,8 @@ typedef struct asn1_header_st
359 B_ASN1_UNIVERSALSTRING|\ 398 B_ASN1_UNIVERSALSTRING|\
360 B_ASN1_UTF8STRING) 399 B_ASN1_UTF8STRING)
361 400
362#define DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 401#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
363#define DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 402#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
364#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 403#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
365 pp,a->type,V_ASN1_UNIVERSAL) 404 pp,a->type,V_ASN1_UNIVERSAL)
366#define M_d2i_DISPLAYTEXT(a,pp,l) \ 405#define M_d2i_DISPLAYTEXT(a,pp,l) \
@@ -369,9 +408,9 @@ typedef struct asn1_header_st
369 B_ASN1_BMPSTRING|\ 408 B_ASN1_BMPSTRING|\
370 B_ASN1_UTF8STRING) 409 B_ASN1_UTF8STRING)
371 410
372#define ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 411#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
373 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 412 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
374#define ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 413#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
375#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 414#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
376 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ 415 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
377 V_ASN1_UNIVERSAL) 416 V_ASN1_UNIVERSAL)
@@ -379,9 +418,9 @@ typedef struct asn1_header_st
379 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ 418 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
380 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) 419 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
381 420
382#define ASN1_T61STRING_new() (ASN1_T61STRING_STRING *)\ 421#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\
383 ASN1_STRING_type_new(V_ASN1_T61STRING) 422 ASN1_STRING_type_new(V_ASN1_T61STRING)
384#define ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 423#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
385#define M_i2d_ASN1_T61STRING(a,pp) \ 424#define M_i2d_ASN1_T61STRING(a,pp) \
386 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ 425 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
387 V_ASN1_UNIVERSAL) 426 V_ASN1_UNIVERSAL)
@@ -389,10 +428,10 @@ typedef struct asn1_header_st
389 (ASN1_T61STRING *)d2i_ASN1_type_bytes\ 428 (ASN1_T61STRING *)d2i_ASN1_type_bytes\
390 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) 429 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
391 430
392#define ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ 431#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\
393 ASN1_STRING_type_new(V_ASN1_IA5STRING) 432 ASN1_STRING_type_new(V_ASN1_IA5STRING)
394#define ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 433#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
395#define ASN1_IA5STRING_dup(a) \ 434#define M_ASN1_IA5STRING_dup(a) \
396 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) 435 (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
397#define M_i2d_ASN1_IA5STRING(a,pp) \ 436#define M_i2d_ASN1_IA5STRING(a,pp) \
398 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
@@ -401,38 +440,25 @@ typedef struct asn1_header_st
401 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ 440 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
402 B_ASN1_IA5STRING) 441 B_ASN1_IA5STRING)
403 442
404#define ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 443#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\
405 ASN1_STRING_type_new(V_ASN1_UTCTIME) 444 ASN1_STRING_type_new(V_ASN1_UTCTIME)
406#define ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 445#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
407#define ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) 446#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
408/* i2d_ASN1_UTCTIME() is a function */ 447
409/* d2i_ASN1_UTCTIME() is a function */ 448#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
410/* ASN1_UTCTIME_set() is a function */
411/* ASN1_UTCTIME_check() is a function */
412
413#define ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\
414 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 449 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
415#define ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 450#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
416#define ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 451#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
417 (ASN1_STRING *)a) 452 (ASN1_STRING *)a)
418/* i2d_ASN1_GENERALIZEDTIME() is a function */
419/* d2i_ASN1_GENERALIZEDTIME() is a function */
420/* ASN1_GENERALIZEDTIME_set() is a function */
421/* ASN1_GENERALIZEDTIME_check() is a function */
422 453
423#define ASN1_TIME_new() (ASN1_TIME *)\ 454#define M_ASN1_TIME_new() (ASN1_TIME *)\
424 ASN1_STRING_type_new(V_ASN1_UTCTIME) 455 ASN1_STRING_type_new(V_ASN1_UTCTIME)
425#define ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 456#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
426#define ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) 457#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
427 458
428/* i2d_ASN1_TIME() is a function */ 459#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
429/* d2i_ASN1_TIME() is a function */
430/* ASN1_TIME_set() is a function */
431/* ASN1_TIME_check() is a function */
432
433#define ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\
434 ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 460 ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
435#define ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 461#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
436#define M_i2d_ASN1_GENERALSTRING(a,pp) \ 462#define M_i2d_ASN1_GENERALSTRING(a,pp) \
437 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ 463 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
438 V_ASN1_UNIVERSAL) 464 V_ASN1_UNIVERSAL)
@@ -440,9 +466,9 @@ typedef struct asn1_header_st
440 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ 466 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
441 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) 467 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
442 468
443#define ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ 469#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\
444 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) 470 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
445#define ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 471#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
446#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 472#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
447 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ 473 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
448 V_ASN1_UNIVERSAL) 474 V_ASN1_UNIVERSAL)
@@ -450,9 +476,9 @@ typedef struct asn1_header_st
450 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ 476 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
451 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) 477 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
452 478
453#define ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ 479#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\
454 ASN1_STRING_type_new(V_ASN1_BMPSTRING) 480 ASN1_STRING_type_new(V_ASN1_BMPSTRING)
455#define ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 481#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
456#define M_i2d_ASN1_BMPSTRING(a,pp) \ 482#define M_i2d_ASN1_BMPSTRING(a,pp) \
457 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ 483 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
458 V_ASN1_UNIVERSAL) 484 V_ASN1_UNIVERSAL)
@@ -460,9 +486,9 @@ typedef struct asn1_header_st
460 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ 486 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
461 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) 487 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
462 488
463#define ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ 489#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\
464 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 490 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
465#define ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 491#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
466#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 492#define M_i2d_ASN1_VISIBLESTRING(a,pp) \
467 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ 493 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
468 V_ASN1_UNIVERSAL) 494 V_ASN1_UNIVERSAL)
@@ -470,9 +496,9 @@ typedef struct asn1_header_st
470 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ 496 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
471 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) 497 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
472 498
473#define ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ 499#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\
474 ASN1_STRING_type_new(V_ASN1_UTF8STRING) 500 ASN1_STRING_type_new(V_ASN1_UTF8STRING)
475#define ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 501#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
476#define M_i2d_ASN1_UTF8STRING(a,pp) \ 502#define M_i2d_ASN1_UTF8STRING(a,pp) \
477 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ 503 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
478 V_ASN1_UNIVERSAL) 504 V_ASN1_UNIVERSAL)
@@ -500,7 +526,7 @@ ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
500DECLARE_STACK_OF(ASN1_OBJECT) 526DECLARE_STACK_OF(ASN1_OBJECT)
501DECLARE_ASN1_SET_OF(ASN1_OBJECT) 527DECLARE_ASN1_SET_OF(ASN1_OBJECT)
502 528
503ASN1_STRING * ASN1_STRING_new(void ); 529ASN1_STRING * ASN1_STRING_new(void);
504void ASN1_STRING_free(ASN1_STRING *a); 530void ASN1_STRING_free(ASN1_STRING *a);
505ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); 531ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
506ASN1_STRING * ASN1_STRING_type_new(int type ); 532ASN1_STRING * ASN1_STRING_type_new(int type );
@@ -508,23 +534,44 @@ int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
508 /* Since this is used to store all sorts of things, via macros, for now, make 534 /* Since this is used to store all sorts of things, via macros, for now, make
509 its data void * */ 535 its data void * */
510int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 536int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
537int ASN1_STRING_length(ASN1_STRING *x);
538void ASN1_STRING_length_set(ASN1_STRING *x, int n);
539int ASN1_STRING_type(ASN1_STRING *x);
540unsigned char * ASN1_STRING_data(ASN1_STRING *x);
511 541
542ASN1_BIT_STRING * ASN1_BIT_STRING_new(void);
543void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
512int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 544int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
513ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp, 545ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
514 long length); 546 long length);
547int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
548 int length );
515int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 549int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
516int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 550int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
517 551
552#ifdef HEADER_BIO_H
553int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
554 BIT_STRING_BITNAME *tbl, int indent);
555#endif
556int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
557int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
558 BIT_STRING_BITNAME *tbl);
518 559
519int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); 560int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
520int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length); 561int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
521 562
563ASN1_INTEGER * ASN1_INTEGER_new(void);
564void ASN1_INTEGER_free(ASN1_INTEGER *a);
522int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); 565int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
523ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp, 566ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
524 long length); 567 long length);
525ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp, 568ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
526 long length); 569 long length);
570ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
571int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
527 572
573ASN1_ENUMERATED * ASN1_ENUMERATED_new(void);
574void ASN1_ENUMERATED_free(ASN1_ENUMERATED *a);
528int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp); 575int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp);
529ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp, 576ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
530 long length); 577 long length);
@@ -537,49 +584,88 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
537ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 584ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
538int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str); 585int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str);
539 586
587ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void);
588void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
540int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp); 589int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp);
541ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a, 590ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
542 unsigned char **pp,long length); 591 unsigned char **pp,long length);
592ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
593int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
594int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len);
543 595
596ASN1_VISIBLESTRING * ASN1_VISIBLESTRING_new(void);
597void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a);
544int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp); 598int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp);
545ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a, 599ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a,
546 unsigned char **pp,long length); 600 unsigned char **pp,long length);
547 601
602ASN1_UTF8STRING * ASN1_UTF8STRING_new(void);
603void ASN1_UTF8STRING_free(ASN1_UTF8STRING *a);
548int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp); 604int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp);
549ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, 605ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a,
550 unsigned char **pp,long length); 606 unsigned char **pp,long length);
551 607
608ASN1_NULL * ASN1_NULL_new(void);
609void ASN1_NULL_free(ASN1_NULL *a);
610int i2d_ASN1_NULL(ASN1_NULL *a,unsigned char **pp);
611ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp,long length);
612
613ASN1_BMPSTRING * ASN1_BMPSTRING_new(void);
614void ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);
552int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp); 615int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
553ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp, 616ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp,
554 long length); 617 long length);
555 618
619
620int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
621int UTF8_putc(unsigned char *str, int len, unsigned long value);
622
556int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp); 623int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp);
557ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a, 624ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a,
558 unsigned char **pp, long l); 625 unsigned char **pp, long l);
626
627ASN1_PRINTABLESTRING * ASN1_PRINTABLESTRING_new(void);
628void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);
559ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a, 629ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
560 unsigned char **pp, long l); 630 unsigned char **pp, long l);
631int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp);
561 632
633ASN1_STRING * DIRECTORYSTRING_new(void);
634void DIRECTORYSTRING_free(ASN1_STRING *a);
562int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp); 635int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp);
563ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp, 636ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
564 long length); 637 long length);
565 638
639ASN1_STRING * DISPLAYTEXT_new(void);
640void DISPLAYTEXT_free(ASN1_STRING *a);
566int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp); 641int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp);
567ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length); 642ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length);
568 643
644ASN1_T61STRING * ASN1_T61STRING_new(void);
645void ASN1_T61STRING_free(ASN1_IA5STRING *a);
569ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, 646ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a,
570 unsigned char **pp, long l); 647 unsigned char **pp, long l);
648
649ASN1_IA5STRING * ASN1_IA5STRING_new(void);
650void ASN1_IA5STRING_free(ASN1_IA5STRING *a);
571int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp); 651int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp);
572ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, 652ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a,
573 unsigned char **pp, long l); 653 unsigned char **pp, long l);
574 654
655ASN1_UTCTIME * ASN1_UTCTIME_new(void);
656void ASN1_UTCTIME_free(ASN1_UTCTIME *a);
575int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp); 657int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp);
576ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp, 658ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp,
577 long length); 659 long length);
578 660
661ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_new(void);
662void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a);
579int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp); 663int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp);
580ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp, 664ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp,
581 long length); 665 long length);
582 666
667ASN1_TIME * ASN1_TIME_new(void);
668void ASN1_TIME_free(ASN1_TIME *a);
583int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp); 669int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp);
584ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length); 670ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length);
585ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); 671ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
@@ -654,6 +740,7 @@ int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
654int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); 740int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
655int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent); 741int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
656#endif 742#endif
743const char *ASN1_tag2str(int tag);
657 744
658/* Used to load and write netscape format cert/key */ 745/* Used to load and write netscape format cert/key */
659int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); 746int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
@@ -687,6 +774,21 @@ unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
687void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)()); 774void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
688ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct); 775ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
689 776
777void ASN1_STRING_set_default_mask(unsigned long mask);
778int ASN1_STRING_set_default_mask_asc(char *p);
779unsigned long ASN1_STRING_get_default_mask(void);
780int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
781 int inform, unsigned long mask);
782int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
783 int inform, unsigned long mask,
784 long minsize, long maxsize);
785
786ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
787 const unsigned char *in, int inlen, int inform, int nid);
788ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
789int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
790void ASN1_STRING_TABLE_cleanup(void);
791
690/* BEGIN ERROR CODES */ 792/* BEGIN ERROR CODES */
691/* The following lines are auto generated by the script mkerr.pl. Any changes 793/* The following lines are auto generated by the script mkerr.pl. Any changes
692 * made after this point may be overwritten when the script is next run. 794 * made after this point may be overwritten when the script is next run.
@@ -699,6 +801,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
699#define ASN1_F_A2I_ASN1_ENUMERATED 236 801#define ASN1_F_A2I_ASN1_ENUMERATED 236
700#define ASN1_F_A2I_ASN1_INTEGER 101 802#define ASN1_F_A2I_ASN1_INTEGER 101
701#define ASN1_F_A2I_ASN1_STRING 102 803#define ASN1_F_A2I_ASN1_STRING 102
804#define ASN1_F_ACCESS_DESCRIPTION_NEW 291
702#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103 805#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103
703#define ASN1_F_ASN1_D2I_BIO 104 806#define ASN1_F_ASN1_D2I_BIO 104
704#define ASN1_F_ASN1_D2I_FP 105 807#define ASN1_F_ASN1_D2I_FP 105
@@ -712,6 +815,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
712#define ASN1_F_ASN1_I2D_FP 110 815#define ASN1_F_ASN1_I2D_FP 110
713#define ASN1_F_ASN1_INTEGER_SET 111 816#define ASN1_F_ASN1_INTEGER_SET 111
714#define ASN1_F_ASN1_INTEGER_TO_BN 112 817#define ASN1_F_ASN1_INTEGER_TO_BN 112
818#define ASN1_F_ASN1_MBSTRING_COPY 282
715#define ASN1_F_ASN1_OBJECT_NEW 113 819#define ASN1_F_ASN1_OBJECT_NEW 113
716#define ASN1_F_ASN1_PACK_STRING 245 820#define ASN1_F_ASN1_PACK_STRING 245
717#define ASN1_F_ASN1_PBE_SET 253 821#define ASN1_F_ASN1_PBE_SET 253
@@ -719,6 +823,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
719#define ASN1_F_ASN1_SEQ_UNPACK 247 823#define ASN1_F_ASN1_SEQ_UNPACK 247
720#define ASN1_F_ASN1_SIGN 114 824#define ASN1_F_ASN1_SIGN 114
721#define ASN1_F_ASN1_STRING_NEW 115 825#define ASN1_F_ASN1_STRING_NEW 115
826#define ASN1_F_ASN1_STRING_TABLE_ADD 283
722#define ASN1_F_ASN1_STRING_TYPE_NEW 116 827#define ASN1_F_ASN1_STRING_TYPE_NEW 116
723#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 828#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117
724#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 829#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118
@@ -730,6 +835,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
730#define ASN1_F_BASIC_CONSTRAINTS_NEW 226 835#define ASN1_F_BASIC_CONSTRAINTS_NEW 226
731#define ASN1_F_BN_TO_ASN1_ENUMERATED 234 836#define ASN1_F_BN_TO_ASN1_ENUMERATED 234
732#define ASN1_F_BN_TO_ASN1_INTEGER 122 837#define ASN1_F_BN_TO_ASN1_INTEGER 122
838#define ASN1_F_D2I_ACCESS_DESCRIPTION 284
733#define ASN1_F_D2I_ASN1_BIT_STRING 123 839#define ASN1_F_D2I_ASN1_BIT_STRING 123
734#define ASN1_F_D2I_ASN1_BMPSTRING 124 840#define ASN1_F_D2I_ASN1_BMPSTRING 124
735#define ASN1_F_D2I_ASN1_BOOLEAN 125 841#define ASN1_F_D2I_ASN1_BOOLEAN 125
@@ -738,6 +844,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
738#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223 844#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223
739#define ASN1_F_D2I_ASN1_HEADER 127 845#define ASN1_F_D2I_ASN1_HEADER 127
740#define ASN1_F_D2I_ASN1_INTEGER 128 846#define ASN1_F_D2I_ASN1_INTEGER 128
847#define ASN1_F_D2I_ASN1_NULL 292
741#define ASN1_F_D2I_ASN1_OBJECT 129 848#define ASN1_F_D2I_ASN1_OBJECT 129
742#define ASN1_F_D2I_ASN1_OCTET_STRING 130 849#define ASN1_F_D2I_ASN1_OCTET_STRING 130
743#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 850#define ASN1_F_D2I_ASN1_PRINT_TYPE 131
@@ -765,6 +872,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
765#define ASN1_F_D2I_NETSCAPE_SPKAC 143 872#define ASN1_F_D2I_NETSCAPE_SPKAC 143
766#define ASN1_F_D2I_NETSCAPE_SPKI 144 873#define ASN1_F_D2I_NETSCAPE_SPKI 144
767#define ASN1_F_D2I_NOTICEREF 268 874#define ASN1_F_D2I_NOTICEREF 268
875#define ASN1_F_D2I_OTHERNAME 287
768#define ASN1_F_D2I_PBE2PARAM 262 876#define ASN1_F_D2I_PBE2PARAM 262
769#define ASN1_F_D2I_PBEPARAM 249 877#define ASN1_F_D2I_PBEPARAM 249
770#define ASN1_F_D2I_PBKDF2PARAM 263 878#define ASN1_F_D2I_PBKDF2PARAM 263
@@ -796,6 +904,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
796#define ASN1_F_D2I_X509 159 904#define ASN1_F_D2I_X509 159
797#define ASN1_F_D2I_X509_ALGOR 160 905#define ASN1_F_D2I_X509_ALGOR 160
798#define ASN1_F_D2I_X509_ATTRIBUTE 161 906#define ASN1_F_D2I_X509_ATTRIBUTE 161
907#define ASN1_F_D2I_X509_CERT_AUX 285
799#define ASN1_F_D2I_X509_CINF 162 908#define ASN1_F_D2I_X509_CINF 162
800#define ASN1_F_D2I_X509_CRL 163 909#define ASN1_F_D2I_X509_CRL 163
801#define ASN1_F_D2I_X509_CRL_INFO 164 910#define ASN1_F_D2I_X509_CRL_INFO 164
@@ -819,12 +928,14 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
819#define ASN1_F_I2D_DSAPARAMS 178 928#define ASN1_F_I2D_DSAPARAMS 178
820#define ASN1_F_I2D_DSAPRIVATEKEY 179 929#define ASN1_F_I2D_DSAPRIVATEKEY 179
821#define ASN1_F_I2D_DSAPUBLICKEY 180 930#define ASN1_F_I2D_DSAPUBLICKEY 180
931#define ASN1_F_I2D_DSA_PUBKEY 290
822#define ASN1_F_I2D_NETSCAPE_RSA 181 932#define ASN1_F_I2D_NETSCAPE_RSA 181
823#define ASN1_F_I2D_PKCS7 182 933#define ASN1_F_I2D_PKCS7 182
824#define ASN1_F_I2D_PRIVATEKEY 183 934#define ASN1_F_I2D_PRIVATEKEY 183
825#define ASN1_F_I2D_PUBLICKEY 184 935#define ASN1_F_I2D_PUBLICKEY 184
826#define ASN1_F_I2D_RSAPRIVATEKEY 185 936#define ASN1_F_I2D_RSAPRIVATEKEY 185
827#define ASN1_F_I2D_RSAPUBLICKEY 186 937#define ASN1_F_I2D_RSAPUBLICKEY 186
938#define ASN1_F_I2D_RSA_PUBKEY 289
828#define ASN1_F_I2D_X509_ATTRIBUTE 187 939#define ASN1_F_I2D_X509_ATTRIBUTE 187
829#define ASN1_F_I2T_ASN1_OBJECT 188 940#define ASN1_F_I2T_ASN1_OBJECT 188
830#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229 941#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229
@@ -832,6 +943,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
832#define ASN1_F_NETSCAPE_SPKAC_NEW 190 943#define ASN1_F_NETSCAPE_SPKAC_NEW 190
833#define ASN1_F_NETSCAPE_SPKI_NEW 191 944#define ASN1_F_NETSCAPE_SPKI_NEW 191
834#define ASN1_F_NOTICEREF_NEW 272 945#define ASN1_F_NOTICEREF_NEW 272
946#define ASN1_F_OTHERNAME_NEW 288
835#define ASN1_F_PBE2PARAM_NEW 264 947#define ASN1_F_PBE2PARAM_NEW 264
836#define ASN1_F_PBEPARAM_NEW 251 948#define ASN1_F_PBEPARAM_NEW 251
837#define ASN1_F_PBKDF2PARAM_NEW 265 949#define ASN1_F_PBKDF2PARAM_NEW 265
@@ -859,6 +971,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
859#define ASN1_F_USERNOTICE_NEW 275 971#define ASN1_F_USERNOTICE_NEW 275
860#define ASN1_F_X509_ALGOR_NEW 202 972#define ASN1_F_X509_ALGOR_NEW 202
861#define ASN1_F_X509_ATTRIBUTE_NEW 203 973#define ASN1_F_X509_ATTRIBUTE_NEW 203
974#define ASN1_F_X509_CERT_AUX_NEW 286
862#define ASN1_F_X509_CINF_NEW 204 975#define ASN1_F_X509_CINF_NEW 204
863#define ASN1_F_X509_CRL_INFO_NEW 205 976#define ASN1_F_X509_CRL_INFO_NEW 205
864#define ASN1_F_X509_CRL_NEW 206 977#define ASN1_F_X509_CRL_NEW 206
@@ -889,6 +1002,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
889#define ASN1_R_BN_LIB 107 1002#define ASN1_R_BN_LIB 107
890#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108 1003#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108
891#define ASN1_R_BUFFER_TOO_SMALL 109 1004#define ASN1_R_BUFFER_TOO_SMALL 109
1005#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 166
892#define ASN1_R_DATA_IS_WRONG 110 1006#define ASN1_R_DATA_IS_WRONG 110
893#define ASN1_R_DECODE_ERROR 155 1007#define ASN1_R_DECODE_ERROR 155
894#define ASN1_R_DECODING_ERROR 111 1008#define ASN1_R_DECODING_ERROR 111
@@ -902,24 +1016,31 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
902#define ASN1_R_EXPECTING_A_BIT_STRING 116 1016#define ASN1_R_EXPECTING_A_BIT_STRING 116
903#define ASN1_R_EXPECTING_A_BOOLEAN 117 1017#define ASN1_R_EXPECTING_A_BOOLEAN 117
904#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151 1018#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151
1019#define ASN1_R_EXPECTING_A_NULL 164
905#define ASN1_R_EXPECTING_A_TIME 152 1020#define ASN1_R_EXPECTING_A_TIME 152
906#define ASN1_R_EXPECTING_A_UTCTIME 118 1021#define ASN1_R_EXPECTING_A_UTCTIME 118
907#define ASN1_R_FIRST_NUM_TOO_LARGE 119 1022#define ASN1_R_FIRST_NUM_TOO_LARGE 119
908#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153 1023#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153
909#define ASN1_R_HEADER_TOO_LONG 120 1024#define ASN1_R_HEADER_TOO_LONG 120
1025#define ASN1_R_ILLEGAL_CHARACTERS 158
1026#define ASN1_R_INVALID_BMPSTRING_LENGTH 159
910#define ASN1_R_INVALID_DIGIT 121 1027#define ASN1_R_INVALID_DIGIT 121
911#define ASN1_R_INVALID_SEPARATOR 122 1028#define ASN1_R_INVALID_SEPARATOR 122
912#define ASN1_R_INVALID_TIME_FORMAT 123 1029#define ASN1_R_INVALID_TIME_FORMAT 123
1030#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 160
1031#define ASN1_R_INVALID_UTF8STRING 161
913#define ASN1_R_IV_TOO_LARGE 124 1032#define ASN1_R_IV_TOO_LARGE 124
914#define ASN1_R_LENGTH_ERROR 125 1033#define ASN1_R_LENGTH_ERROR 125
915#define ASN1_R_MISSING_SECOND_NUMBER 126 1034#define ASN1_R_MISSING_SECOND_NUMBER 126
916#define ASN1_R_NON_HEX_CHARACTERS 127 1035#define ASN1_R_NON_HEX_CHARACTERS 127
917#define ASN1_R_NOT_ENOUGH_DATA 128 1036#define ASN1_R_NOT_ENOUGH_DATA 128
1037#define ASN1_R_NULL_IS_WRONG_LENGTH 165
918#define ASN1_R_ODD_NUMBER_OF_CHARS 129 1038#define ASN1_R_ODD_NUMBER_OF_CHARS 129
919#define ASN1_R_PARSING 130 1039#define ASN1_R_PARSING 130
920#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131 1040#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131
921#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132 1041#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132
922#define ASN1_R_SHORT_LINE 133 1042#define ASN1_R_SHORT_LINE 133
1043#define ASN1_R_STRING_TOO_LONG 163
923#define ASN1_R_STRING_TOO_SHORT 134 1044#define ASN1_R_STRING_TOO_SHORT 134
924#define ASN1_R_TAG_VALUE_TOO_HIGH 135 1045#define ASN1_R_TAG_VALUE_TOO_HIGH 135
925#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136 1046#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136
@@ -927,6 +1048,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
927#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138 1048#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138
928#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139 1049#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139
929#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140 1050#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140
1051#define ASN1_R_UNKNOWN_FORMAT 162
930#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141 1052#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141
931#define ASN1_R_UNKNOWN_OBJECT_TYPE 142 1053#define ASN1_R_UNKNOWN_OBJECT_TYPE 142
932#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143 1054#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index 16755a0b05..b183814242 100644
--- a/src/lib/libcrypto/asn1/asn1_err.c
+++ b/src/lib/libcrypto/asn1/asn1_err.c
@@ -69,19 +69,21 @@ static ERR_STRING_DATA ASN1_str_functs[]=
69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"}, 69{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"},
70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"}, 70{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"},
71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"}, 71{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"},
72{ERR_PACK(0,ASN1_F_ACCESS_DESCRIPTION_NEW,0), "ACCESS_DESCRIPTION_new"},
72{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"}, 73{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"},
73{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"}, 74{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"},
74{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"}, 75{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"},
75{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"}, 76{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"},
76{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"}, 77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"},
77{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"}, 78{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"},
78{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_NEW"}, 79{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_new"},
79{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"}, 80{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"},
80{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"}, 81{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"},
81{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"}, 82{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"},
82{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"}, 83{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"},
83{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"}, 84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"},
84{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"}, 85{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"},
86{ERR_PACK(0,ASN1_F_ASN1_MBSTRING_COPY,0), "ASN1_mbstring_copy"},
85{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"}, 87{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"},
86{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"}, 88{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"},
87{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"}, 89{ERR_PACK(0,ASN1_F_ASN1_PBE_SET,0), "ASN1_PBE_SET"},
@@ -89,17 +91,19 @@ static ERR_STRING_DATA ASN1_str_functs[]=
89{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"}, 91{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"},
90{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"}, 92{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"},
91{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"}, 93{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"},
94{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0), "ASN1_STRING_TABLE_add"},
92{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"}, 95{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"},
93{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, 96{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
94{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, 97{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
95{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"}, 98{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"},
96{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, 99{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
97{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_NEW"}, 100{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_new"},
98{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"}, 101{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"},
99{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"}, 102{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"},
100{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"}, 103{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"},
101{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"}, 104{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"},
102{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"}, 105{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"},
106{ERR_PACK(0,ASN1_F_D2I_ACCESS_DESCRIPTION,0), "d2i_ACCESS_DESCRIPTION"},
103{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"}, 107{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"},
104{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"}, 108{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"},
105{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"}, 109{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"},
@@ -108,6 +112,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
108{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"}, 112{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"},
109{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"}, 113{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"},
110{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"}, 114{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"},
115{ERR_PACK(0,ASN1_F_D2I_ASN1_NULL,0), "d2i_ASN1_NULL"},
111{ERR_PACK(0,ASN1_F_D2I_ASN1_OBJECT,0), "d2i_ASN1_OBJECT"}, 116{ERR_PACK(0,ASN1_F_D2I_ASN1_OBJECT,0), "d2i_ASN1_OBJECT"},
112{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"}, 117{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"},
113{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"}, 118{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"},
@@ -135,6 +140,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
135{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"}, 140{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"},
136{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"}, 141{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"},
137{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"}, 142{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"},
143{ERR_PACK(0,ASN1_F_D2I_OTHERNAME,0), "d2i_OTHERNAME"},
138{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"}, 144{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"},
139{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"}, 145{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"},
140{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"}, 146{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"},
@@ -166,6 +172,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
166{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"}, 172{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"},
167{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"}, 173{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"},
168{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"}, 174{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"},
175{ERR_PACK(0,ASN1_F_D2I_X509_CERT_AUX,0), "d2i_X509_CERT_AUX"},
169{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"}, 176{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"},
170{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"}, 177{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"},
171{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"}, 178{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"},
@@ -189,12 +196,14 @@ static ERR_STRING_DATA ASN1_str_functs[]=
189{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"}, 196{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"},
190{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"}, 197{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"},
191{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"}, 198{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"},
199{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0), "i2d_DSA_PUBKEY"},
192{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"}, 200{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"},
193{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"}, 201{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"},
194{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"}, 202{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"},
195{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"}, 203{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"},
196{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"}, 204{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"},
197{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"}, 205{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"},
206{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0), "i2d_RSA_PUBKEY"},
198{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"}, 207{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"},
199{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"}, 208{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"},
200{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"}, 209{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"},
@@ -202,6 +211,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
202{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"}, 211{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"},
203{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"}, 212{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"},
204{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"}, 213{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"},
214{ERR_PACK(0,ASN1_F_OTHERNAME_NEW,0), "OTHERNAME_new"},
205{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"}, 215{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"},
206{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"}, 216{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"},
207{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"}, 217{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"},
@@ -229,6 +239,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
229{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"}, 239{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"},
230{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"}, 240{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"},
231{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"}, 241{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"},
242{ERR_PACK(0,ASN1_F_X509_CERT_AUX_NEW,0), "X509_CERT_AUX_new"},
232{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"}, 243{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"},
233{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"}, 244{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"},
234{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"}, 245{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"},
@@ -262,6 +273,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
262{ASN1_R_BN_LIB ,"bn lib"}, 273{ASN1_R_BN_LIB ,"bn lib"},
263{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"}, 274{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"},
264{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"}, 275{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"},
276{ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER ,"cipher has no object identifier"},
265{ASN1_R_DATA_IS_WRONG ,"data is wrong"}, 277{ASN1_R_DATA_IS_WRONG ,"data is wrong"},
266{ASN1_R_DECODE_ERROR ,"decode error"}, 278{ASN1_R_DECODE_ERROR ,"decode error"},
267{ASN1_R_DECODING_ERROR ,"decoding error"}, 279{ASN1_R_DECODING_ERROR ,"decoding error"},
@@ -275,24 +287,31 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
275{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"}, 287{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"},
276{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"}, 288{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"},
277{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"}, 289{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"},
290{ASN1_R_EXPECTING_A_NULL ,"expecting a null"},
278{ASN1_R_EXPECTING_A_TIME ,"expecting a time"}, 291{ASN1_R_EXPECTING_A_TIME ,"expecting a time"},
279{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"}, 292{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"},
280{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"}, 293{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"},
281{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"}, 294{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"},
282{ASN1_R_HEADER_TOO_LONG ,"header too long"}, 295{ASN1_R_HEADER_TOO_LONG ,"header too long"},
296{ASN1_R_ILLEGAL_CHARACTERS ,"illegal characters"},
297{ASN1_R_INVALID_BMPSTRING_LENGTH ,"invalid bmpstring length"},
283{ASN1_R_INVALID_DIGIT ,"invalid digit"}, 298{ASN1_R_INVALID_DIGIT ,"invalid digit"},
284{ASN1_R_INVALID_SEPARATOR ,"invalid separator"}, 299{ASN1_R_INVALID_SEPARATOR ,"invalid separator"},
285{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"}, 300{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"},
301{ASN1_R_INVALID_UNIVERSALSTRING_LENGTH ,"invalid universalstring length"},
302{ASN1_R_INVALID_UTF8STRING ,"invalid utf8string"},
286{ASN1_R_IV_TOO_LARGE ,"iv too large"}, 303{ASN1_R_IV_TOO_LARGE ,"iv too large"},
287{ASN1_R_LENGTH_ERROR ,"length error"}, 304{ASN1_R_LENGTH_ERROR ,"length error"},
288{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"}, 305{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"},
289{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"}, 306{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"},
290{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"}, 307{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"},
308{ASN1_R_NULL_IS_WRONG_LENGTH ,"null is wrong length"},
291{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"}, 309{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"},
292{ASN1_R_PARSING ,"parsing"}, 310{ASN1_R_PARSING ,"parsing"},
293{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"}, 311{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"},
294{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"}, 312{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"},
295{ASN1_R_SHORT_LINE ,"short line"}, 313{ASN1_R_SHORT_LINE ,"short line"},
314{ASN1_R_STRING_TOO_LONG ,"string too long"},
296{ASN1_R_STRING_TOO_SHORT ,"string too short"}, 315{ASN1_R_STRING_TOO_SHORT ,"string too short"},
297{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"}, 316{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"},
298{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 317{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
@@ -300,6 +319,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
300{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"}, 319{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"},
301{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"}, 320{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"},
302{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"}, 321{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"},
322{ASN1_R_UNKNOWN_FORMAT ,"unknown format"},
303{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"}, 323{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"},
304{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"}, 324{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"},
305{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"}, 325{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"},
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 95e54ed626..be8daa8688 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -176,7 +176,7 @@ static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
176 } 176 }
177 177
178/* class 0 is constructed 178/* class 0 is constructed
179 * constructed == 2 for indefinitle length constructed */ 179 * constructed == 2 for indefinite length constructed */
180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, 180void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
181 int xclass) 181 int xclass)
182 { 182 {
@@ -349,7 +349,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
349 if (data != NULL) 349 if (data != NULL)
350 { 350 {
351 memcpy(str->data,data,len); 351 memcpy(str->data,data,len);
352 /* an alowance for strings :-) */ 352 /* an allowance for strings :-) */
353 str->data[len]='\0'; 353 str->data[len]='\0';
354 } 354 }
355 return(1); 355 return(1);
@@ -381,8 +381,8 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
381void ASN1_STRING_free(ASN1_STRING *a) 381void ASN1_STRING_free(ASN1_STRING *a)
382 { 382 {
383 if (a == NULL) return; 383 if (a == NULL) return;
384 if (a->data != NULL) Free((char *)a->data); 384 if (a->data != NULL) Free(a->data);
385 Free((char *)a); 385 Free(a);
386 } 386 }
387 387
388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b) 388int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b)
@@ -411,3 +411,14 @@ void asn1_add_error(unsigned char *address, int offset)
411 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 411 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
412 } 412 }
413 413
414int ASN1_STRING_length(ASN1_STRING *x)
415{ return M_ASN1_STRING_length(x); }
416
417void ASN1_STRING_length_set(ASN1_STRING *x, int len)
418{ M_ASN1_STRING_length_set(x, len); return; }
419
420int ASN1_STRING_type(ASN1_STRING *x)
421{ return M_ASN1_STRING_type(x); }
422
423unsigned char * ASN1_STRING_data(ASN1_STRING *x)
424{ return M_ASN1_STRING_data(x); }
diff --git a/src/lib/libcrypto/asn1/asn1_mac.h b/src/lib/libcrypto/asn1/asn1_mac.h
index 93f9c5193c..4f2a82d340 100644
--- a/src/lib/libcrypto/asn1/asn1_mac.h
+++ b/src/lib/libcrypto/asn1/asn1_mac.h
@@ -106,6 +106,20 @@ err:\
106#define M_ASN1_D2I_start_sequence() \ 106#define M_ASN1_D2I_start_sequence() \
107 if (!asn1_GetSequence(&c,&length)) \ 107 if (!asn1_GetSequence(&c,&length)) \
108 { c.line=__LINE__; goto err; } 108 { c.line=__LINE__; goto err; }
109/* Begin reading ASN1 without a surrounding sequence */
110#define M_ASN1_D2I_begin() \
111 c.slen = length;
112
113/* End reading ASN1 with no check on length */
114#define M_ASN1_D2I_Finish_nolen(a, func, e) \
115 *pp=c.p; \
116 if (a != NULL) (*a)=ret; \
117 return(ret); \
118err:\
119 ASN1_MAC_H_err((e),c.error,c.line); \
120 asn1_add_error(*pp,(int)(c.q- *pp)); \
121 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
122 return(NULL)
109 123
110#define M_ASN1_D2I_end_sequence() \ 124#define M_ASN1_D2I_end_sequence() \
111 (((c.inf&1) == 0)?(c.slen <= 0): \ 125 (((c.inf&1) == 0)?(c.slen <= 0): \
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 86886606ef..d1e9816bad 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -93,55 +93,8 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
93 sprintf(str,"cont [ %d ]",tag); 93 sprintf(str,"cont [ %d ]",tag);
94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) 94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
95 sprintf(str,"appl [ %d ]",tag); 95 sprintf(str,"appl [ %d ]",tag);
96 else if ((tag == V_ASN1_EOC) /* && (xclass == V_ASN1_UNIVERSAL) */) 96 else p = ASN1_tag2str(tag);
97 p="EOC";
98 else if (tag == V_ASN1_BOOLEAN)
99 p="BOOLEAN";
100 else if (tag == V_ASN1_INTEGER)
101 p="INTEGER";
102 else if (tag == V_ASN1_ENUMERATED)
103 p="ENUMERATED";
104 else if (tag == V_ASN1_BIT_STRING)
105 p="BIT STRING";
106 else if (tag == V_ASN1_OCTET_STRING)
107 p="OCTET STRING";
108 else if (tag == V_ASN1_NULL)
109 p="NULL";
110 else if (tag == V_ASN1_OBJECT)
111 p="OBJECT";
112 else if (tag == V_ASN1_SEQUENCE)
113 p="SEQUENCE";
114 else if (tag == V_ASN1_SET)
115 p="SET";
116 else if (tag == V_ASN1_PRINTABLESTRING)
117 p="PRINTABLESTRING";
118 else if (tag == V_ASN1_T61STRING)
119 p="T61STRING";
120 else if (tag == V_ASN1_IA5STRING)
121 p="IA5STRING";
122 else if (tag == V_ASN1_UTCTIME)
123 p="UTCTIME";
124 97
125 /* extras */
126 else if (tag == V_ASN1_NUMERICSTRING)
127 p="NUMERICSTRING";
128 else if (tag == V_ASN1_VIDEOTEXSTRING)
129 p="VIDEOTEXSTRING";
130 else if (tag == V_ASN1_GENERALIZEDTIME)
131 p="GENERALIZEDTIME";
132 else if (tag == V_ASN1_GRAPHICSTRING)
133 p="GRAPHICSTRING";
134 else if (tag == V_ASN1_VISIBLESTRING)
135 p="VISIBLESTRING";
136 else if (tag == V_ASN1_GENERALSTRING)
137 p="GENERALSTRING";
138 else if (tag == V_ASN1_UNIVERSALSTRING)
139 p="UNIVERSALSTRING";
140 else if (tag == V_ASN1_BMPSTRING)
141 p="BMPSTRING";
142 else
143 p2="(unknown)";
144
145 if (p2 != NULL) 98 if (p2 != NULL)
146 { 99 {
147 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err; 100 if (BIO_printf(bp,fmt2,tag,p2) <= 0) goto err;
@@ -320,7 +273,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
320 os->length) <= 0) 273 os->length) <= 0)
321 goto end; 274 goto end;
322 } 275 }
323 ASN1_OCTET_STRING_free(os); 276 M_ASN1_OCTET_STRING_free(os);
324 os=NULL; 277 os=NULL;
325 } 278 }
326 } 279 }
@@ -354,7 +307,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
354 if (BIO_write(bp,"BAD INTEGER",11) <= 0) 307 if (BIO_write(bp,"BAD INTEGER",11) <= 0)
355 goto end; 308 goto end;
356 } 309 }
357 ASN1_INTEGER_free(bs); 310 M_ASN1_INTEGER_free(bs);
358 } 311 }
359 else if (tag == V_ASN1_ENUMERATED) 312 else if (tag == V_ASN1_ENUMERATED)
360 { 313 {
@@ -386,7 +339,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
386 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0) 339 if (BIO_write(bp,"BAD ENUMERATED",11) <= 0)
387 goto end; 340 goto end;
388 } 341 }
389 ASN1_ENUMERATED_free(bs); 342 M_ASN1_ENUMERATED_free(bs);
390 } 343 }
391 344
392 if (!nl) 345 if (!nl)
@@ -405,7 +358,28 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
405 ret=1; 358 ret=1;
406end: 359end:
407 if (o != NULL) ASN1_OBJECT_free(o); 360 if (o != NULL) ASN1_OBJECT_free(o);
408 if (os != NULL) ASN1_OCTET_STRING_free(os); 361 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
409 *pp=p; 362 *pp=p;
410 return(ret); 363 return(ret);
411 } 364 }
365
366const char *ASN1_tag2str(int tag)
367{
368 const static char *tag2str[] = {
369 "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */
370 "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */
371 "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */
372 "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */
373 "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */
374 "VIDEOTEXSTRING", "IA5STRING", "UTCTIME","GENERALIZEDTIME", /* 21-24 */
375 "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */
376 "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */
377 };
378
379 if((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
380 tag &= ~0x100;
381
382 if(tag < 0 || tag > 30) return "(unknown)";
383 return tag2str[tag];
384}
385
diff --git a/src/lib/libcrypto/asn1/d2i_dhp.c b/src/lib/libcrypto/asn1/d2i_dhp.c
index a077211a4c..635ae829db 100644
--- a/src/lib/libcrypto/asn1/d2i_dhp.c
+++ b/src/lib/libcrypto/asn1/d2i_dhp.c
@@ -86,7 +86,7 @@ DH *d2i_DHparams(DH **a, unsigned char **pp, long length)
86 ret->length=(int)v; 86 ret->length=(int)v;
87 } 87 }
88 88
89 ASN1_BIT_STRING_free(bs); 89 M_ASN1_BIT_STRING_free(bs);
90 90
91 M_ASN1_D2I_Finish_2(a); 91 M_ASN1_D2I_Finish_2(a);
92 92
@@ -95,7 +95,7 @@ err_bn:
95err: 95err:
96 ASN1err(ASN1_F_D2I_DHPARAMS,i); 96 ASN1err(ASN1_F_D2I_DHPARAMS,i);
97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret); 97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret);
98 if (bs != NULL) ASN1_BIT_STRING_free(bs); 98 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
99 return(NULL); 99 return(NULL);
100 } 100 }
101#endif 101#endif
diff --git a/src/lib/libcrypto/asn1/d2i_dsap.c b/src/lib/libcrypto/asn1/d2i_dsap.c
index cdd7136f51..6d1c297133 100644
--- a/src/lib/libcrypto/asn1/d2i_dsap.c
+++ b/src/lib/libcrypto/asn1/d2i_dsap.c
@@ -83,7 +83,7 @@ DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; 84 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
85 85
86 ASN1_BIT_STRING_free(bs); 86 M_ASN1_BIT_STRING_free(bs);
87 87
88 M_ASN1_D2I_Finish_2(a); 88 M_ASN1_D2I_Finish_2(a);
89 89
@@ -92,7 +92,7 @@ err_bn:
92err: 92err:
93 ASN1err(ASN1_F_D2I_DSAPARAMS,i); 93 ASN1err(ASN1_F_D2I_DSAPARAMS,i);
94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 94 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
95 if (bs != NULL) ASN1_BIT_STRING_free(bs); 95 if (bs != NULL) M_ASN1_BIT_STRING_free(bs);
96 return(NULL); 96 return(NULL);
97 } 97 }
98#endif 98#endif
diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c
index f3d1aa6240..c92b8325d8 100644
--- a/src/lib/libcrypto/asn1/d2i_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_pr.c
@@ -112,3 +112,26 @@ err:
112 return(NULL); 112 return(NULL);
113 } 113 }
114 114
115/* This works like d2i_PrivateKey() except it automatically works out the type */
116
117EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
118 long length)
119{
120 STACK_OF(ASN1_TYPE) *inkey;
121 unsigned char *p;
122 int keytype;
123 p = *pp;
124 /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE):
125 * by analyzing it we can determine the passed structure: this
126 * assumes the input is surrounded by an ASN1 SEQUENCE.
127 */
128 inkey = d2i_ASN1_SET_OF_ASN1_TYPE(NULL, &p, length, d2i_ASN1_TYPE,
129 ASN1_TYPE_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
130 /* Since we only need to discern "traditional format" RSA and DSA
131 * keys we can just count the elements.
132 */
133 if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
134 else keytype = EVP_PKEY_RSA;
135 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
136 return d2i_PrivateKey(keytype, a, pp, length);
137}
diff --git a/src/lib/libcrypto/asn1/d2i_r_pr.c b/src/lib/libcrypto/asn1/d2i_r_pr.c
index 18f11b6f5e..6c8a45f821 100644
--- a/src/lib/libcrypto/asn1/d2i_r_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_r_pr.c
@@ -107,7 +107,7 @@ RSA *d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length)
107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL) 107 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
108 goto err_bn; 108 goto err_bn;
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 111
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,14 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i); 116 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119
119 return(NULL); 120 return(NULL);
120 } 121 }
122#else /* !NO_RSA */
123
124# if PEDANTIC
125static void *dummy=&dummy;
126# endif
127
121#endif 128#endif
diff --git a/src/lib/libcrypto/asn1/d2i_r_pu.c b/src/lib/libcrypto/asn1/d2i_r_pu.c
index c4ae58b594..d1289f160e 100644
--- a/src/lib/libcrypto/asn1/d2i_r_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_r_pu.c
@@ -81,7 +81,7 @@ RSA *d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length)
81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 81 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; 82 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
83 83
84 ASN1_INTEGER_free(bs); 84 M_ASN1_INTEGER_free(bs);
85 bs=NULL; 85 bs=NULL;
86 86
87 M_ASN1_D2I_Finish_2(a); 87 M_ASN1_D2I_Finish_2(a);
@@ -91,7 +91,13 @@ err_bn:
91err: 91err:
92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i); 92 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); 93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
94 if (bs != NULL) ASN1_INTEGER_free(bs); 94 if (bs != NULL) M_ASN1_INTEGER_free(bs);
95 return(NULL); 95 return(NULL);
96 } 96 }
97#else /* !NO_RSA */
98
99# if PEDANTIC
100static void *dummy=&dummy;
101# endif
102
97#endif 103#endif
diff --git a/src/lib/libcrypto/asn1/d2i_s_pr.c b/src/lib/libcrypto/asn1/d2i_s_pr.c
index 050e1cc5fb..dec2a2ebd3 100644
--- a/src/lib/libcrypto/asn1/d2i_s_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_s_pr.c
@@ -91,7 +91,7 @@ DSA *d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length)
91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key)) 91 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key))
92 == NULL) goto err_bn; 92 == NULL) goto err_bn;
93 93
94 ASN1_INTEGER_free(bs); 94 M_ASN1_INTEGER_free(bs);
95 95
96 M_ASN1_D2I_Finish_2(a); 96 M_ASN1_D2I_Finish_2(a);
97err_bn: 97err_bn:
@@ -99,7 +99,7 @@ err_bn:
99err: 99err:
100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i); 100 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i);
101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 101 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
102 if (bs != NULL) ASN1_INTEGER_free(bs); 102 if (bs != NULL) M_ASN1_INTEGER_free(bs);
103 return(NULL); 103 return(NULL);
104 } 104 }
105#endif 105#endif
diff --git a/src/lib/libcrypto/asn1/d2i_s_pu.c b/src/lib/libcrypto/asn1/d2i_s_pu.c
index 94ea1c313b..e0adaa0393 100644
--- a/src/lib/libcrypto/asn1/d2i_s_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_s_pu.c
@@ -107,7 +107,7 @@ DSA *d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length)
107 ret->write_params=1; 107 ret->write_params=1;
108 } 108 }
109 109
110 ASN1_INTEGER_free(bs); 110 M_ASN1_INTEGER_free(bs);
111 bs=NULL; 111 bs=NULL;
112 M_ASN1_D2I_Finish_2(a); 112 M_ASN1_D2I_Finish_2(a);
113err_bn: 113err_bn:
@@ -115,7 +115,7 @@ err_bn:
115err: 115err:
116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i); 116 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i);
117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); 117 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
118 if (bs != NULL) ASN1_INTEGER_free(bs); 118 if (bs != NULL) M_ASN1_INTEGER_free(bs);
119 return(NULL); 119 return(NULL);
120 } 120 }
121#endif 121#endif
diff --git a/src/lib/libcrypto/asn1/evp_asn1.c b/src/lib/libcrypto/asn1/evp_asn1.c
index 41ced49c19..3506005a71 100644
--- a/src/lib/libcrypto/asn1/evp_asn1.c
+++ b/src/lib/libcrypto/asn1/evp_asn1.c
@@ -65,8 +65,8 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
65 { 65 {
66 ASN1_STRING *os; 66 ASN1_STRING *os;
67 67
68 if ((os=ASN1_OCTET_STRING_new()) == NULL) return(0); 68 if ((os=M_ASN1_OCTET_STRING_new()) == NULL) return(0);
69 if (!ASN1_OCTET_STRING_set(os,data,len)) return(0); 69 if (!M_ASN1_OCTET_STRING_set(os,data,len)) return(0);
70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os); 70 ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os);
71 return(1); 71 return(1);
72 } 72 }
@@ -83,8 +83,8 @@ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 83 ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
84 return(-1); 84 return(-1);
85 } 85 }
86 p=ASN1_STRING_data(a->value.octet_string); 86 p=M_ASN1_STRING_data(a->value.octet_string);
87 ret=ASN1_STRING_length(a->value.octet_string); 87 ret=M_ASN1_STRING_length(a->value.octet_string);
88 if (ret < max_len) 88 if (ret < max_len)
89 num=ret; 89 num=ret;
90 else 90 else
@@ -117,8 +117,8 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
117 /* Grow the 'string' */ 117 /* Grow the 'string' */
118 ASN1_STRING_set(osp,NULL,size); 118 ASN1_STRING_set(osp,NULL,size);
119 119
120 ASN1_STRING_length(osp)=size; 120 M_ASN1_STRING_length_set(osp, size);
121 p=ASN1_STRING_data(osp); 121 p=M_ASN1_STRING_data(osp);
122 122
123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); 123 ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
124 i2d_ASN1_INTEGER(&in,&p); 124 i2d_ASN1_INTEGER(&in,&p);
@@ -145,8 +145,8 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
145 { 145 {
146 goto err; 146 goto err;
147 } 147 }
148 p=ASN1_STRING_data(a->value.sequence); 148 p=M_ASN1_STRING_data(a->value.sequence);
149 length=ASN1_STRING_length(a->value.sequence); 149 length=M_ASN1_STRING_length(a->value.sequence);
150 150
151 c.pp= &p; 151 c.pp= &p;
152 c.p=p; 152 c.p=p;
@@ -165,21 +165,21 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
165 if (num != NULL) 165 if (num != NULL)
166 *num=ASN1_INTEGER_get(ai); 166 *num=ASN1_INTEGER_get(ai);
167 167
168 ret=ASN1_STRING_length(os); 168 ret=M_ASN1_STRING_length(os);
169 if (max_len > ret) 169 if (max_len > ret)
170 n=ret; 170 n=ret;
171 else 171 else
172 n=max_len; 172 n=max_len;
173 173
174 if (data != NULL) 174 if (data != NULL)
175 memcpy(data,ASN1_STRING_data(os),n); 175 memcpy(data,M_ASN1_STRING_data(os),n);
176 if (0) 176 if (0)
177 { 177 {
178err: 178err:
179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG); 179 ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG);
180 } 180 }
181 if (os != NULL) ASN1_OCTET_STRING_free(os); 181 if (os != NULL) M_ASN1_OCTET_STRING_free(os);
182 if (ai != NULL) ASN1_INTEGER_free(ai); 182 if (ai != NULL) M_ASN1_INTEGER_free(ai);
183 return(ret); 183 return(ret);
184 } 184 }
185 185
diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c
index 3bcceecdb8..3d0b1107cb 100644
--- a/src/lib/libcrypto/asn1/f_enum.c
+++ b/src/lib/libcrypto/asn1/f_enum.c
@@ -161,7 +161,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
161 if (sp == NULL) 161 if (sp == NULL)
162 { 162 {
163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
164 if (s != NULL) Free((char *)s); 164 if (s != NULL) Free(s);
165 goto err; 165 goto err;
166 } 166 }
167 s=sp; 167 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 55560dd814..cd57331c3f 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -168,7 +168,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
168 if (sp == NULL) 168 if (sp == NULL)
169 { 169 {
170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 170 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
171 if (s != NULL) Free((char *)s); 171 if (s != NULL) Free(s);
172 goto err; 172 goto err;
173 } 173 }
174 s=sp; 174 s=sp;
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index 5d0cf5a46d..088313689a 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -166,7 +166,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
166 if (sp == NULL) 166 if (sp == NULL)
167 { 167 {
168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 168 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
169 if (s != NULL) Free((char *)s); 169 if (s != NULL) Free(s);
170 goto err; 170 goto err;
171 } 171 }
172 s=sp; 172 s=sp;
diff --git a/src/lib/libcrypto/asn1/i2d_dhp.c b/src/lib/libcrypto/asn1/i2d_dhp.c
index fdda4ec41b..61eeb646f9 100644
--- a/src/lib/libcrypto/asn1/i2d_dhp.c
+++ b/src/lib/libcrypto/asn1/i2d_dhp.c
@@ -118,7 +118,7 @@ int i2d_DHparams(DH *a, unsigned char **pp)
118 bs.length=BN_bn2bin(num[i],bs.data); 118 bs.length=BN_bn2bin(num[i],bs.data);
119 i2d_ASN1_INTEGER(&bs,&p); 119 i2d_ASN1_INTEGER(&bs,&p);
120 } 120 }
121 Free((char *)bs.data); 121 Free(bs.data);
122 ret=t; 122 ret=t;
123err: 123err:
124 if (num[2] != NULL) BN_free(num[2]); 124 if (num[2] != NULL) BN_free(num[2]);
diff --git a/src/lib/libcrypto/asn1/i2d_dsap.c b/src/lib/libcrypto/asn1/i2d_dsap.c
index f36f0da4e2..4021123ba3 100644
--- a/src/lib/libcrypto/asn1/i2d_dsap.c
+++ b/src/lib/libcrypto/asn1/i2d_dsap.c
@@ -107,7 +107,7 @@ int i2d_DSAparams(DSA *a, unsigned char **pp)
107 bs.length=BN_bn2bin(num[i],bs.data); 107 bs.length=BN_bn2bin(num[i],bs.data);
108 i2d_ASN1_INTEGER(&bs,&p); 108 i2d_ASN1_INTEGER(&bs,&p);
109 } 109 }
110 Free((char *)bs.data); 110 Free(bs.data);
111 ret=t; 111 ret=t;
112err: 112err:
113 *pp=p; 113 *pp=p;
diff --git a/src/lib/libcrypto/asn1/i2d_r_pr.c b/src/lib/libcrypto/asn1/i2d_r_pr.c
index 27e6844a7f..1250fa4b2d 100644
--- a/src/lib/libcrypto/asn1/i2d_r_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_r_pr.c
@@ -119,9 +119,15 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
119 bs.length=BN_bn2bin(num[i],bs.data); 119 bs.length=BN_bn2bin(num[i],bs.data);
120 i2d_ASN1_INTEGER(&bs,&p); 120 i2d_ASN1_INTEGER(&bs,&p);
121 } 121 }
122 Free((char *)bs.data); 122 Free(bs.data);
123 *pp=p; 123 *pp=p;
124 return(t); 124 return(t);
125 } 125 }
126#else /* !NO_RSA */
127
128# if PEDANTIC
129static void *dummy=&dummy;
130# endif
131
126#endif 132#endif
127 133
diff --git a/src/lib/libcrypto/asn1/i2d_r_pu.c b/src/lib/libcrypto/asn1/i2d_r_pu.c
index 6d01bfa8b5..582b92ee4c 100644
--- a/src/lib/libcrypto/asn1/i2d_r_pu.c
+++ b/src/lib/libcrypto/asn1/i2d_r_pu.c
@@ -105,8 +105,14 @@ int i2d_RSAPublicKey(RSA *a, unsigned char **pp)
105 bs.length=BN_bn2bin(num[i],bs.data); 105 bs.length=BN_bn2bin(num[i],bs.data);
106 i2d_ASN1_INTEGER(&bs,&p); 106 i2d_ASN1_INTEGER(&bs,&p);
107 } 107 }
108 Free((char *)bs.data); 108 Free(bs.data);
109 *pp=p; 109 *pp=p;
110 return(t); 110 return(t);
111 } 111 }
112#else /* !NO_RSA */
113
114# if PEDANTIC
115static void *dummy=&dummy;
116# endif
117
112#endif 118#endif
diff --git a/src/lib/libcrypto/asn1/i2d_s_pr.c b/src/lib/libcrypto/asn1/i2d_s_pr.c
index 5d3dcdf197..e399ceaeb9 100644
--- a/src/lib/libcrypto/asn1/i2d_s_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_s_pr.c
@@ -116,7 +116,7 @@ int i2d_DSAPrivateKey(DSA *a, unsigned char **pp)
116 bs.length=BN_bn2bin(num[i],bs.data); 116 bs.length=BN_bn2bin(num[i],bs.data);
117 i2d_ASN1_INTEGER(&bs,&p); 117 i2d_ASN1_INTEGER(&bs,&p);
118 } 118 }
119 Free((char *)bs.data); 119 Free(bs.data);
120 *pp=p; 120 *pp=p;
121 return(t); 121 return(t);
122 } 122 }
diff --git a/src/lib/libcrypto/asn1/i2d_s_pu.c b/src/lib/libcrypto/asn1/i2d_s_pu.c
index 18f790f746..ca7f251b71 100644
--- a/src/lib/libcrypto/asn1/i2d_s_pu.c
+++ b/src/lib/libcrypto/asn1/i2d_s_pu.c
@@ -121,7 +121,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp)
121 bs.length=BN_bn2bin(num[i],bs.data); 121 bs.length=BN_bn2bin(num[i],bs.data);
122 i2d_ASN1_INTEGER(&bs,&p); 122 i2d_ASN1_INTEGER(&bs,&p);
123 } 123 }
124 Free((char *)bs.data); 124 Free(bs.data);
125 *pp=p; 125 *pp=p;
126 if(all) return(t); 126 if(all) return(t);
127 else return(tot); 127 else return(tot);
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index cdc0d8b7c4..d804986b73 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -139,7 +139,7 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
139 } 139 }
140 140
141 if (pkey->private_key->data != NULL) 141 if (pkey->private_key->data != NULL)
142 Free((char *)pkey->private_key->data); 142 Free(pkey->private_key->data);
143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL) 143 if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL)
144 { 144 {
145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); 145 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
@@ -205,10 +205,10 @@ RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)())
205 (char *)os->data,os->length) != 0)) 205 (char *)os->data,os->length) != 0))
206 { 206 {
207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING); 207 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
208 ASN1_BIT_STRING_free(os); 208 M_ASN1_BIT_STRING_free(os);
209 goto err; 209 goto err;
210 } 210 }
211 ASN1_BIT_STRING_free(os); 211 M_ASN1_BIT_STRING_free(os);
212 c.q=c.p; 212 c.q=c.p;
213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err; 213 if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err;
214 c.slen-=(c.p-c.q); 214 c.slen-=(c.p-c.q);
@@ -279,7 +279,7 @@ RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length,
279 *pp=c.p; 279 *pp=c.p;
280err: 280err:
281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey); 281 if (pkey != NULL) NETSCAPE_PKEY_free(pkey);
282 if (os != NULL) ASN1_BIT_STRING_free(os); 282 if (os != NULL) M_ASN1_BIT_STRING_free(os);
283 if (alg != NULL) X509_ALGOR_free(alg); 283 if (alg != NULL) X509_ALGOR_free(alg);
284 return(ret); 284 return(ret);
285 } 285 }
@@ -321,9 +321,9 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
321 ASN1_CTX c; 321 ASN1_CTX c;
322 322
323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY); 323 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY);
324 M_ASN1_New(ret->version,ASN1_INTEGER_new); 324 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
325 M_ASN1_New(ret->algor,X509_ALGOR_new); 325 M_ASN1_New(ret->algor,X509_ALGOR_new);
326 M_ASN1_New(ret->private_key,ASN1_OCTET_STRING_new); 326 M_ASN1_New(ret->private_key,M_ASN1_OCTET_STRING_new);
327 return(ret); 327 return(ret);
328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW); 328 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW);
329 } 329 }
@@ -331,11 +331,18 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a) 331static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a)
332 { 332 {
333 if (a == NULL) return; 333 if (a == NULL) return;
334 ASN1_INTEGER_free(a->version); 334 M_ASN1_INTEGER_free(a->version);
335 X509_ALGOR_free(a->algor); 335 X509_ALGOR_free(a->algor);
336 ASN1_OCTET_STRING_free(a->private_key); 336 M_ASN1_OCTET_STRING_free(a->private_key);
337 Free((char *)a); 337 Free(a);
338 } 338 }
339 339
340#endif /* NO_RC4 */ 340#endif /* NO_RC4 */
341
342#else /* !NO_RSA */
343
344# if PEDANTIC
345static void *dummy=&dummy;
346# endif
347
341#endif 348#endif
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index b831836e7b..64e90237cc 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -82,8 +82,8 @@ PBEPARAM *PBEPARAM_new(void)
82 PBEPARAM *ret=NULL; 82 PBEPARAM *ret=NULL;
83 ASN1_CTX c; 83 ASN1_CTX c;
84 M_ASN1_New_Malloc(ret, PBEPARAM); 84 M_ASN1_New_Malloc(ret, PBEPARAM);
85 M_ASN1_New(ret->iter,ASN1_INTEGER_new); 85 M_ASN1_New(ret->iter,M_ASN1_INTEGER_new);
86 M_ASN1_New(ret->salt,ASN1_OCTET_STRING_new); 86 M_ASN1_New(ret->salt,M_ASN1_OCTET_STRING_new);
87 return (ret); 87 return (ret);
88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW); 88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW);
89} 89}
@@ -101,9 +101,9 @@ PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)
101void PBEPARAM_free (PBEPARAM *a) 101void PBEPARAM_free (PBEPARAM *a)
102{ 102{
103 if(a==NULL) return; 103 if(a==NULL) return;
104 ASN1_OCTET_STRING_free(a->salt); 104 M_ASN1_OCTET_STRING_free(a->salt);
105 ASN1_INTEGER_free (a->iter); 105 M_ASN1_INTEGER_free (a->iter);
106 Free ((char *)a); 106 Free (a);
107} 107}
108 108
109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */ 109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
@@ -129,7 +129,8 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
129 } 129 }
130 pbe->salt->length = saltlen; 130 pbe->salt->length = saltlen;
131 if (salt) memcpy (pbe->salt->data, salt, saltlen); 131 if (salt) memcpy (pbe->salt->data, salt, saltlen);
132 else RAND_bytes (pbe->salt->data, saltlen); 132 else if (RAND_bytes (pbe->salt->data, saltlen) <= 0)
133 return NULL;
133 134
134 if (!(astype = ASN1_TYPE_new())) { 135 if (!(astype = ASN1_TYPE_new())) {
135 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE); 136 ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 09f4bf6112..4ce06a94ab 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -104,7 +104,7 @@ void PBE2PARAM_free (PBE2PARAM *a)
104 if(a==NULL) return; 104 if(a==NULL) return;
105 X509_ALGOR_free(a->keyfunc); 105 X509_ALGOR_free(a->keyfunc);
106 X509_ALGOR_free(a->encryption); 106 X509_ALGOR_free(a->encryption);
107 Free ((char *)a); 107 Free (a);
108} 108}
109 109
110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp) 110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
@@ -131,7 +131,7 @@ PBKDF2PARAM *PBKDF2PARAM_new(void)
131 ASN1_CTX c; 131 ASN1_CTX c;
132 M_ASN1_New_Malloc(ret, PBKDF2PARAM); 132 M_ASN1_New_Malloc(ret, PBKDF2PARAM);
133 M_ASN1_New(ret->salt, ASN1_TYPE_new); 133 M_ASN1_New(ret->salt, ASN1_TYPE_new);
134 M_ASN1_New(ret->iter, ASN1_INTEGER_new); 134 M_ASN1_New(ret->iter, M_ASN1_INTEGER_new);
135 ret->keylength = NULL; 135 ret->keylength = NULL;
136 ret->prf = NULL; 136 ret->prf = NULL;
137 return (ret); 137 return (ret);
@@ -155,10 +155,10 @@ void PBKDF2PARAM_free (PBKDF2PARAM *a)
155{ 155{
156 if(a==NULL) return; 156 if(a==NULL) return;
157 ASN1_TYPE_free(a->salt); 157 ASN1_TYPE_free(a->salt);
158 ASN1_INTEGER_free(a->iter); 158 M_ASN1_INTEGER_free(a->iter);
159 ASN1_INTEGER_free(a->keylength); 159 M_ASN1_INTEGER_free(a->keylength);
160 X509_ALGOR_free(a->prf); 160 X509_ALGOR_free(a->prf);
161 Free ((char *)a); 161 Free (a);
162} 162}
163 163
164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: 164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
@@ -175,19 +175,26 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
175 PBKDF2PARAM *kdf = NULL; 175 PBKDF2PARAM *kdf = NULL;
176 PBE2PARAM *pbe2 = NULL; 176 PBE2PARAM *pbe2 = NULL;
177 ASN1_OCTET_STRING *osalt = NULL; 177 ASN1_OCTET_STRING *osalt = NULL;
178 ASN1_OBJECT *obj;
179
180 alg_nid = EVP_CIPHER_type(cipher);
181 if(alg_nid == NID_undef) {
182 ASN1err(ASN1_F_PKCS5_PBE2_SET,
183 ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
184 goto err;
185 }
186 obj = OBJ_nid2obj(alg_nid);
178 187
179 if(!(pbe2 = PBE2PARAM_new())) goto merr; 188 if(!(pbe2 = PBE2PARAM_new())) goto merr;
180 189
181 /* Setup the AlgorithmIdentifier for the encryption scheme */ 190 /* Setup the AlgorithmIdentifier for the encryption scheme */
182 scheme = pbe2->encryption; 191 scheme = pbe2->encryption;
183 192
184 alg_nid = EVP_CIPHER_type(cipher); 193 scheme->algorithm = obj;
185
186 scheme->algorithm = OBJ_nid2obj(alg_nid);
187 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; 194 if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
188 195
189 /* Create random IV */ 196 /* Create random IV */
190 RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)); 197 RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher));
191 198
192 /* Dummy cipherinit to just setup the IV */ 199 /* Dummy cipherinit to just setup the IV */
193 EVP_CipherInit(&ctx, cipher, NULL, iv, 0); 200 EVP_CipherInit(&ctx, cipher, NULL, iv, 0);
@@ -199,13 +206,13 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
199 EVP_CIPHER_CTX_cleanup(&ctx); 206 EVP_CIPHER_CTX_cleanup(&ctx);
200 207
201 if(!(kdf = PBKDF2PARAM_new())) goto merr; 208 if(!(kdf = PBKDF2PARAM_new())) goto merr;
202 if(!(osalt = ASN1_OCTET_STRING_new())) goto merr; 209 if(!(osalt = M_ASN1_OCTET_STRING_new())) goto merr;
203 210
204 if (!saltlen) saltlen = PKCS5_SALT_LEN; 211 if (!saltlen) saltlen = PKCS5_SALT_LEN;
205 if (!(osalt->data = Malloc (saltlen))) goto merr; 212 if (!(osalt->data = Malloc (saltlen))) goto merr;
206 osalt->length = saltlen; 213 osalt->length = saltlen;
207 if (salt) memcpy (osalt->data, salt, saltlen); 214 if (salt) memcpy (osalt->data, salt, saltlen);
208 else RAND_bytes (osalt->data, saltlen); 215 else if (RAND_bytes (osalt->data, saltlen) <= 0) goto merr;
209 216
210 if(iter <= 0) iter = PKCS5_DEFAULT_ITER; 217 if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
211 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; 218 if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;
@@ -218,7 +225,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
218 /* If its RC2 then we'd better setup the key length */ 225 /* If its RC2 then we'd better setup the key length */
219 226
220 if(alg_nid == NID_rc2_cbc) { 227 if(alg_nid == NID_rc2_cbc) {
221 if(!(kdf->keylength = ASN1_INTEGER_new())) goto merr; 228 if(!(kdf->keylength = M_ASN1_INTEGER_new())) goto merr;
222 if(!ASN1_INTEGER_set (kdf->keylength, 229 if(!ASN1_INTEGER_set (kdf->keylength,
223 EVP_CIPHER_key_length(cipher))) goto merr; 230 EVP_CIPHER_key_length(cipher))) goto merr;
224 } 231 }
@@ -264,7 +271,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
264 err: 271 err:
265 PBE2PARAM_free(pbe2); 272 PBE2PARAM_free(pbe2);
266 /* Note 'scheme' is freed as part of pbe2 */ 273 /* Note 'scheme' is freed as part of pbe2 */
267 ASN1_OCTET_STRING_free(osalt); 274 M_ASN1_OCTET_STRING_free(osalt);
268 PBKDF2PARAM_free(kdf); 275 PBKDF2PARAM_free(kdf);
269 X509_ALGOR_free(kalg); 276 X509_ALGOR_free(kalg);
270 X509_ALGOR_free(ret); 277 X509_ALGOR_free(ret);
diff --git a/src/lib/libcrypto/asn1/p7_dgst.c b/src/lib/libcrypto/asn1/p7_dgst.c
index 62783a2b8d..cba90e94a1 100644
--- a/src/lib/libcrypto/asn1/p7_dgst.c
+++ b/src/lib/libcrypto/asn1/p7_dgst.c
@@ -101,10 +101,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST); 103 M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->md,X509_ALGOR_new); 105 M_ASN1_New(ret->md,X509_ALGOR_new);
106 M_ASN1_New(ret->contents,PKCS7_new); 106 M_ASN1_New(ret->contents,PKCS7_new);
107 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
108 return(ret); 108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW); 109 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW);
110 } 110 }
@@ -112,10 +112,10 @@ PKCS7_DIGEST *PKCS7_DIGEST_new(void)
112void PKCS7_DIGEST_free(PKCS7_DIGEST *a) 112void PKCS7_DIGEST_free(PKCS7_DIGEST *a)
113 { 113 {
114 if (a == NULL) return; 114 if (a == NULL) return;
115 ASN1_INTEGER_free(a->version); 115 M_ASN1_INTEGER_free(a->version);
116 X509_ALGOR_free(a->md); 116 X509_ALGOR_free(a->md);
117 PKCS7_free(a->contents); 117 PKCS7_free(a->contents);
118 ASN1_OCTET_STRING_free(a->digest); 118 M_ASN1_OCTET_STRING_free(a->digest);
119 Free((char *)a); 119 Free(a);
120 } 120 }
121 121
diff --git a/src/lib/libcrypto/asn1/p7_enc.c b/src/lib/libcrypto/asn1/p7_enc.c
index 4741126587..83b0e15faa 100644
--- a/src/lib/libcrypto/asn1/p7_enc.c
+++ b/src/lib/libcrypto/asn1/p7_enc.c
@@ -95,7 +95,7 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
95 ASN1_CTX c; 95 ASN1_CTX c;
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT); 97 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
98 M_ASN1_New(ret->version,ASN1_INTEGER_new); 98 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 99 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW);
@@ -104,8 +104,8 @@ PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void)
104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) 104void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 ASN1_INTEGER_free(a->version); 107 M_ASN1_INTEGER_free(a->version);
108 PKCS7_ENC_CONTENT_free(a->enc_data); 108 PKCS7_ENC_CONTENT_free(a->enc_data);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libcrypto/asn1/p7_enc_c.c b/src/lib/libcrypto/asn1/p7_enc_c.c
index a832737a38..582cc78b06 100644
--- a/src/lib/libcrypto/asn1/p7_enc_c.c
+++ b/src/lib/libcrypto/asn1/p7_enc_c.c
@@ -101,7 +101,8 @@ PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new(void)
101 101
102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT); 102 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */ 103 /* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */
104 ret->content_type=OBJ_nid2obj(NID_pkcs7_encrypted); 104 /* We will almost always want this: so make it the default */
105 ret->content_type=OBJ_nid2obj(NID_pkcs7_data);
105 M_ASN1_New(ret->algorithm,X509_ALGOR_new); 106 M_ASN1_New(ret->algorithm,X509_ALGOR_new);
106 ret->enc_data=NULL; 107 ret->enc_data=NULL;
107 return(ret); 108 return(ret);
@@ -113,7 +114,7 @@ void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a)
113 if (a == NULL) return; 114 if (a == NULL) return;
114 ASN1_OBJECT_free(a->content_type); 115 ASN1_OBJECT_free(a->content_type);
115 X509_ALGOR_free(a->algorithm); 116 X509_ALGOR_free(a->algorithm);
116 ASN1_OCTET_STRING_free(a->enc_data); 117 M_ASN1_OCTET_STRING_free(a->enc_data);
117 Free((char *)a); 118 Free(a);
118 } 119 }
119 120
diff --git a/src/lib/libcrypto/asn1/p7_evp.c b/src/lib/libcrypto/asn1/p7_evp.c
index b2b3d50dcd..4e734fdd28 100644
--- a/src/lib/libcrypto/asn1/p7_evp.c
+++ b/src/lib/libcrypto/asn1/p7_evp.c
@@ -101,7 +101,7 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE); 103 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 105 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 106 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
107 return(ret); 107 return(ret);
@@ -111,9 +111,9 @@ PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void)
111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) 111void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a)
112 { 112 {
113 if (a == NULL) return; 113 if (a == NULL) return;
114 ASN1_INTEGER_free(a->version); 114 M_ASN1_INTEGER_free(a->version);
115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 115 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
116 PKCS7_ENC_CONTENT_free(a->enc_data); 116 PKCS7_ENC_CONTENT_free(a->enc_data);
117 Free((char *)a); 117 Free(a);
118 } 118 }
119 119
diff --git a/src/lib/libcrypto/asn1/p7_i_s.c b/src/lib/libcrypto/asn1/p7_i_s.c
index 7d4b457e01..d21f7ddb84 100644
--- a/src/lib/libcrypto/asn1/p7_i_s.c
+++ b/src/lib/libcrypto/asn1/p7_i_s.c
@@ -96,7 +96,7 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void)
96 96
97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL); 97 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
98 M_ASN1_New(ret->issuer,X509_NAME_new); 98 M_ASN1_New(ret->issuer,X509_NAME_new);
99 M_ASN1_New(ret->serial,ASN1_INTEGER_new); 99 M_ASN1_New(ret->serial,M_ASN1_INTEGER_new);
100 return(ret); 100 return(ret);
101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW); 101 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW);
102 } 102 }
@@ -105,7 +105,7 @@ void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a)
105 { 105 {
106 if (a == NULL) return; 106 if (a == NULL) return;
107 X509_NAME_free(a->issuer); 107 X509_NAME_free(a->issuer);
108 ASN1_INTEGER_free(a->serial); 108 M_ASN1_INTEGER_free(a->serial);
109 Free((char *)a); 109 Free(a);
110 } 110 }
111 111
diff --git a/src/lib/libcrypto/asn1/p7_lib.c b/src/lib/libcrypto/asn1/p7_lib.c
index 846be17158..86db82cfa1 100644
--- a/src/lib/libcrypto/asn1/p7_lib.c
+++ b/src/lib/libcrypto/asn1/p7_lib.c
@@ -152,7 +152,7 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
152 { 152 {
153 if ((*a)->asn1 != NULL) 153 if ((*a)->asn1 != NULL)
154 { 154 {
155 Free((char *)(*a)->asn1); 155 Free((*a)->asn1);
156 (*a)->asn1=NULL; 156 (*a)->asn1=NULL;
157 } 157 }
158 (*a)->length=0; 158 (*a)->length=0;
@@ -251,7 +251,7 @@ void PKCS7_free(PKCS7 *a)
251 { 251 {
252 ASN1_OBJECT_free(a->type); 252 ASN1_OBJECT_free(a->type);
253 } 253 }
254 Free((char *)(char *)a); 254 Free(a);
255 } 255 }
256 256
257void PKCS7_content_free(PKCS7 *a) 257void PKCS7_content_free(PKCS7 *a)
@@ -259,7 +259,7 @@ void PKCS7_content_free(PKCS7 *a)
259 if(a == NULL) 259 if(a == NULL)
260 return; 260 return;
261 261
262 if (a->asn1 != NULL) Free((char *)a->asn1); 262 if (a->asn1 != NULL) Free(a->asn1);
263 263
264 if (a->d.ptr != NULL) 264 if (a->d.ptr != NULL)
265 { 265 {
@@ -268,7 +268,7 @@ void PKCS7_content_free(PKCS7 *a)
268 switch (OBJ_obj2nid(a->type)) 268 switch (OBJ_obj2nid(a->type))
269 { 269 {
270 case NID_pkcs7_data: 270 case NID_pkcs7_data:
271 ASN1_OCTET_STRING_free(a->d.data); 271 M_ASN1_OCTET_STRING_free(a->d.data);
272 break; 272 break;
273 case NID_pkcs7_signed: 273 case NID_pkcs7_signed:
274 PKCS7_SIGNED_free(a->d.sign); 274 PKCS7_SIGNED_free(a->d.sign);
diff --git a/src/lib/libcrypto/asn1/p7_recip.c b/src/lib/libcrypto/asn1/p7_recip.c
index 9fda4f20d4..b1abfa3b8f 100644
--- a/src/lib/libcrypto/asn1/p7_recip.c
+++ b/src/lib/libcrypto/asn1/p7_recip.c
@@ -101,10 +101,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
101 ASN1_CTX c; 101 ASN1_CTX c;
102 102
103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO); 103 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
104 M_ASN1_New(ret->version,ASN1_INTEGER_new); 104 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 105 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new); 106 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new);
107 M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new); 107 M_ASN1_New(ret->enc_key,M_ASN1_OCTET_STRING_new);
108 ret->cert=NULL; 108 ret->cert=NULL;
109 return(ret); 109 return(ret);
110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW); 110 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW);
@@ -113,10 +113,10 @@ PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void)
113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) 113void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a)
114 { 114 {
115 if (a == NULL) return; 115 if (a == NULL) return;
116 ASN1_INTEGER_free(a->version); 116 M_ASN1_INTEGER_free(a->version);
117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 117 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
118 X509_ALGOR_free(a->key_enc_algor); 118 X509_ALGOR_free(a->key_enc_algor);
119 ASN1_OCTET_STRING_free(a->enc_key); 119 M_ASN1_OCTET_STRING_free(a->enc_key);
120 if (a->cert != NULL) X509_free(a->cert); 120 if (a->cert != NULL) X509_free(a->cert);
121 Free(a); 121 Free(a);
122 } 122 }
diff --git a/src/lib/libcrypto/asn1/p7_s_e.c b/src/lib/libcrypto/asn1/p7_s_e.c
index 90946695c9..3d18fedf8e 100644
--- a/src/lib/libcrypto/asn1/p7_s_e.c
+++ b/src/lib/libcrypto/asn1/p7_s_e.c
@@ -119,7 +119,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null); 123 M_ASN1_New(ret->recipientinfo,sk_PKCS7_RECIP_INFO_new_null);
124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 124 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); 125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
@@ -133,7 +133,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) 133void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a)
134 { 134 {
135 if (a == NULL) return; 135 if (a == NULL) return;
136 ASN1_INTEGER_free(a->version); 136 M_ASN1_INTEGER_free(a->version);
137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); 137 sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 138 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
139 PKCS7_ENC_CONTENT_free(a->enc_data); 139 PKCS7_ENC_CONTENT_free(a->enc_data);
diff --git a/src/lib/libcrypto/asn1/p7_signd.c b/src/lib/libcrypto/asn1/p7_signd.c
index 74f0f522e1..f6f16a8715 100644
--- a/src/lib/libcrypto/asn1/p7_signd.c
+++ b/src/lib/libcrypto/asn1/p7_signd.c
@@ -112,7 +112,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
112 ASN1_CTX c; 112 ASN1_CTX c;
113 113
114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED); 114 M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
115 M_ASN1_New(ret->version,ASN1_INTEGER_new); 115 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null); 116 M_ASN1_New(ret->md_algs,sk_X509_ALGOR_new_null);
117 M_ASN1_New(ret->contents,PKCS7_new); 117 M_ASN1_New(ret->contents,PKCS7_new);
118 ret->cert=NULL; 118 ret->cert=NULL;
@@ -125,7 +125,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
125void PKCS7_SIGNED_free(PKCS7_SIGNED *a) 125void PKCS7_SIGNED_free(PKCS7_SIGNED *a)
126 { 126 {
127 if (a == NULL) return; 127 if (a == NULL) return;
128 ASN1_INTEGER_free(a->version); 128 M_ASN1_INTEGER_free(a->version);
129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free); 129 sk_X509_ALGOR_pop_free(a->md_algs,X509_ALGOR_free);
130 PKCS7_free(a->contents); 130 PKCS7_free(a->contents);
131 sk_X509_pop_free(a->cert,X509_free); 131 sk_X509_pop_free(a->cert,X509_free);
diff --git a/src/lib/libcrypto/asn1/p7_signi.c b/src/lib/libcrypto/asn1/p7_signi.c
index 21132ef4dd..f74658ffe6 100644
--- a/src/lib/libcrypto/asn1/p7_signi.c
+++ b/src/lib/libcrypto/asn1/p7_signi.c
@@ -119,12 +119,12 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
119 ASN1_CTX c; 119 ASN1_CTX c;
120 120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO); 121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new); 122 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); 123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new); 124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new);
125 ret->auth_attr=NULL; 125 ret->auth_attr=NULL;
126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new); 126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new);
127 M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new); 127 M_ASN1_New(ret->enc_digest,M_ASN1_OCTET_STRING_new);
128 ret->unauth_attr=NULL; 128 ret->unauth_attr=NULL;
129 ret->pkey=NULL; 129 ret->pkey=NULL;
130 return(ret); 130 return(ret);
@@ -134,16 +134,16 @@ PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void)
134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) 134void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a)
135 { 135 {
136 if (a == NULL) return; 136 if (a == NULL) return;
137 ASN1_INTEGER_free(a->version); 137 M_ASN1_INTEGER_free(a->version);
138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); 138 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
139 X509_ALGOR_free(a->digest_alg); 139 X509_ALGOR_free(a->digest_alg);
140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free); 140 sk_X509_ATTRIBUTE_pop_free(a->auth_attr,X509_ATTRIBUTE_free);
141 X509_ALGOR_free(a->digest_enc_alg); 141 X509_ALGOR_free(a->digest_enc_alg);
142 ASN1_OCTET_STRING_free(a->enc_digest); 142 M_ASN1_OCTET_STRING_free(a->enc_digest);
143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free); 143 sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
144 if (a->pkey != NULL) 144 if (a->pkey != NULL)
145 EVP_PKEY_free(a->pkey); 145 EVP_PKEY_free(a->pkey);
146 Free((char *)a); 146 Free(a);
147 } 147 }
148 148
149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO) 149IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO)
diff --git a/src/lib/libcrypto/asn1/p8_key.c b/src/lib/libcrypto/asn1/p8_key.c
new file mode 100644
index 0000000000..0b24374627
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p8_key.c
@@ -0,0 +1,131 @@
1/* crypto/asn1/p8_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free(a);
130 }
131
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index aa9a4f6c96..59cfbe7f28 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -88,7 +88,7 @@ PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void)
88 PKCS8_PRIV_KEY_INFO *ret=NULL; 88 PKCS8_PRIV_KEY_INFO *ret=NULL;
89 ASN1_CTX c; 89 ASN1_CTX c;
90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO); 90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO);
91 M_ASN1_New (ret->version, ASN1_INTEGER_new); 91 M_ASN1_New (ret->version, M_ASN1_INTEGER_new);
92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new); 92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new);
93 M_ASN1_New (ret->pkey, ASN1_TYPE_new); 93 M_ASN1_New (ret->pkey, ASN1_TYPE_new);
94 ret->attributes = NULL; 94 ret->attributes = NULL;
@@ -109,15 +109,13 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes, 109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
110 d2i_X509_ATTRIBUTE, 110 d2i_X509_ATTRIBUTE,
111 X509_ATTRIBUTE_free, 0); 111 X509_ATTRIBUTE_free, 0);
112 if (ASN1_TYPE_get(ret->pkey) == V_ASN1_SEQUENCE)
113 ret->broken = PKCS8_NO_OCTET;
114 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO); 112 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
115} 113}
116 114
117void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a) 115void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
118{ 116{
119 if (a == NULL) return; 117 if (a == NULL) return;
120 ASN1_INTEGER_free (a->version); 118 M_ASN1_INTEGER_free (a->version);
121 X509_ALGOR_free(a->pkeyalg); 119 X509_ALGOR_free(a->pkeyalg);
122 /* Clear sensitive data */ 120 /* Clear sensitive data */
123 if (a->pkey->value.octet_string) 121 if (a->pkey->value.octet_string)
diff --git a/src/lib/libcrypto/asn1/pkcs8.c b/src/lib/libcrypto/asn1/pkcs8.c
index 29c4ea6a29..e69de29bb2 100644
--- a/src/lib/libcrypto/asn1/pkcs8.c
+++ b/src/lib/libcrypto/asn1/pkcs8.c
@@ -1,131 +0,0 @@
1/* crypto/asn1/pkcs8.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63
64int i2d_X509_KEY(X509 *a, unsigned char **pp)
65 {
66 M_ASN1_I2D_vars(a);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_Malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 Free((char *)a);
130 }
131
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c
new file mode 100644
index 0000000000..8ee789f082
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_bitst.c
@@ -0,0 +1,99 @@
1/* t_bitst.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/conf.h>
62#include <openssl/x509v3.h>
63
64int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
65 BIT_STRING_BITNAME *tbl, int indent)
66{
67 BIT_STRING_BITNAME *bnam;
68 char first = 1;
69 BIO_printf(out, "%*s", indent, "");
70 for(bnam = tbl; bnam->lname; bnam++) {
71 if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
72 if(!first) BIO_puts(out, ", ");
73 BIO_puts(out, bnam->lname);
74 first = 0;
75 }
76 }
77 BIO_puts(out, "\n");
78 return 1;
79}
80
81int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
82 BIT_STRING_BITNAME *tbl)
83{
84 int bitnum;
85 bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
86 if(bitnum < 0) return 0;
87 if(bs) ASN1_BIT_STRING_set_bit(bs, bitnum, value);
88 return 1;
89}
90
91int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
92{
93 BIT_STRING_BITNAME *bnam;
94 for(bnam = tbl; bnam->lname; bnam++) {
95 if(!strcmp(bnam->sname, name) ||
96 !strcmp(bnam->lname, name) ) return bnam->bitnum;
97 }
98 return -1;
99}
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index c2e447ce6f..d78e4a8f88 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -160,7 +160,7 @@ static void ext_print(BIO *out, X509_EXTENSION *ex)
160 BIO_printf(out, ": %s\n", j ? "critical":"",""); 160 BIO_printf(out, ": %s\n", j ? "critical":"","");
161 if(!X509V3_EXT_print(out, ex, 0, 16)) { 161 if(!X509V3_EXT_print(out, ex, 0, 16)) {
162 BIO_printf(out, "%16s", ""); 162 BIO_printf(out, "%16s", "");
163 ASN1_OCTET_STRING_print(out,ex->value); 163 M_ASN1_OCTET_STRING_print(out,ex->value);
164 } 164 }
165 BIO_write(out,"\n",1); 165 BIO_write(out,"\n",1);
166} 166}
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index 0dc6e30c3d..e570ed1c47 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -133,7 +133,7 @@ int RSA_print(BIO *bp, RSA *x, int off)
133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; 133 if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err;
134 ret=1; 134 ret=1;
135err: 135err:
136 if (m != NULL) Free((char *)m); 136 if (m != NULL) Free(m);
137 return(ret); 137 return(ret);
138 } 138 }
139#endif /* NO_RSA */ 139#endif /* NO_RSA */
@@ -204,7 +204,7 @@ int DSA_print(BIO *bp, DSA *x, int off)
204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; 204 if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
205 ret=1; 205 ret=1;
206err: 206err:
207 if (m != NULL) Free((char *)m); 207 if (m != NULL) Free(m);
208 return(ret); 208 return(ret);
209 } 209 }
210#endif /* !NO_DSA */ 210#endif /* !NO_DSA */
@@ -298,7 +298,7 @@ int DHparams_print(BIO *bp, DH *x)
298 if (!print(bp,"generator:",x->g,m,4)) goto err; 298 if (!print(bp,"generator:",x->g,m,4)) goto err;
299 if (x->length != 0) 299 if (x->length != 0)
300 { 300 {
301 if (BIO_printf(bp," recomented-private-length: %d bits\n", 301 if (BIO_printf(bp," recommended-private-length: %d bits\n",
302 (int)x->length) <= 0) goto err; 302 (int)x->length) <= 0) goto err;
303 } 303 }
304 ret=1; 304 ret=1;
@@ -307,7 +307,7 @@ int DHparams_print(BIO *bp, DH *x)
307err: 307err:
308 DHerr(DH_F_DHPARAMS_PRINT,reason); 308 DHerr(DH_F_DHPARAMS_PRINT,reason);
309 } 309 }
310 if (m != NULL) Free((char *)m); 310 if (m != NULL) Free(m);
311 return(ret); 311 return(ret);
312 } 312 }
313#endif 313#endif
@@ -352,7 +352,7 @@ int DSAparams_print(BIO *bp, DSA *x)
352 if (!print(bp,"g:",x->g,m,4)) goto err; 352 if (!print(bp,"g:",x->g,m,4)) goto err;
353 ret=1; 353 ret=1;
354err: 354err:
355 if (m != NULL) Free((char *)m); 355 if (m != NULL) Free(m);
356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason); 356 DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
357 return(ret); 357 return(ret);
358 } 358 }
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index bdd749436a..81dd6355a8 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -62,6 +62,7 @@
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
65 66
66#ifndef NO_FP_API 67#ifndef NO_FP_API
67int X509_REQ_print_fp(FILE *fp, X509_REQ *x) 68int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
@@ -90,6 +91,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
90 X509_REQ_INFO *ri; 91 X509_REQ_INFO *ri;
91 EVP_PKEY *pkey; 92 EVP_PKEY *pkey;
92 STACK_OF(X509_ATTRIBUTE) *sk; 93 STACK_OF(X509_ATTRIBUTE) *sk;
94 STACK_OF(X509_EXTENSION) *exts;
93 char str[128]; 95 char str[128];
94 96
95 ri=x->req_info; 97 ri=x->req_info;
@@ -161,6 +163,8 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
161 int j,type=0,count=1,ii=0; 163 int j,type=0,count=1,ii=0;
162 164
163 a=sk_X509_ATTRIBUTE_value(sk,i); 165 a=sk_X509_ATTRIBUTE_value(sk,i);
166 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
167 continue;
164 sprintf(str,"%12s",""); 168 sprintf(str,"%12s","");
165 if (BIO_puts(bp,str) <= 0) goto err; 169 if (BIO_puts(bp,str) <= 0) goto err;
166 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 170 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
@@ -201,6 +205,29 @@ get_next:
201 } 205 }
202 } 206 }
203 207
208 exts = X509_REQ_get_extensions(x);
209 if(exts) {
210 BIO_printf(bp,"%8sRequested Extensions:\n","");
211 for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
212 ASN1_OBJECT *obj;
213 X509_EXTENSION *ex;
214 int j;
215 ex=sk_X509_EXTENSION_value(exts, i);
216 if (BIO_printf(bp,"%12s","") <= 0) goto err;
217 obj=X509_EXTENSION_get_object(ex);
218 i2a_ASN1_OBJECT(bp,obj);
219 j=X509_EXTENSION_get_critical(ex);
220 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
221 goto err;
222 if(!X509V3_EXT_print(bp, ex, 0, 16)) {
223 BIO_printf(bp, "%16s", "");
224 M_ASN1_OCTET_STRING_print(bp,ex->value);
225 }
226 if (BIO_write(bp,"\n",1) <= 0) goto err;
227 }
228 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
229 }
230
204 i=OBJ_obj2nid(x->sig_alg->algorithm); 231 i=OBJ_obj2nid(x->sig_alg->algorithm);
205 sprintf(str,"%4sSignature Algorithm: %s","", 232 sprintf(str,"%4sSignature Algorithm: %s","",
206 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); 233 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c
new file mode 100644
index 0000000000..d708434fca
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_spki.c
@@ -0,0 +1,116 @@
1/* t_spki.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/x509.h>
62#include <openssl/asn1_mac.h>
63
64/* Print out an SPKI */
65
66int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
67{
68 EVP_PKEY *pkey;
69 ASN1_IA5STRING *chal;
70 int i, n;
71 char *s;
72 BIO_printf(out, "Netscape SPKI:\n");
73 i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm);
74 BIO_printf(out," Public Key Algorithm: %s\n",
75 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
76 pkey = X509_PUBKEY_get(spki->spkac->pubkey);
77 if(!pkey) BIO_printf(out, " Unable to load public key\n");
78 else {
79#ifndef NO_RSA
80 if (pkey->type == EVP_PKEY_RSA)
81 {
82 BIO_printf(out," RSA Public Key: (%d bit)\n",
83 BN_num_bits(pkey->pkey.rsa->n));
84 RSA_print(out,pkey->pkey.rsa,2);
85 }
86 else
87#endif
88#ifndef NO_DSA
89 if (pkey->type == EVP_PKEY_DSA)
90 {
91 BIO_printf(out," DSA Public Key:\n");
92 DSA_print(out,pkey->pkey.dsa,2);
93 }
94 else
95#endif
96 BIO_printf(out," Unknown Public Key:\n");
97 EVP_PKEY_free(pkey);
98 }
99 chal = spki->spkac->challenge;
100 if(chal->length)
101 BIO_printf(out, " Challenge String: %s\n", chal->data);
102 i=OBJ_obj2nid(spki->sig_algor->algorithm);
103 BIO_printf(out," Signature Algorithm: %s",
104 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
105
106 n=spki->signature->length;
107 s=(char *)spki->signature->data;
108 for (i=0; i<n; i++)
109 {
110 if ((i%18) == 0) BIO_write(out,"\n ",7);
111 BIO_printf(out,"%02x%s",(unsigned char)s[i],
112 ((i+1) == n)?"":":");
113 }
114 BIO_write(out,"\n",1);
115 return 1;
116}
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 42f4d498cf..6ee1065ce9 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -188,11 +188,7 @@ int X509_print(BIO *bp, X509 *x)
188 BIO_printf(bp,"%8sX509v3 extensions:\n",""); 188 BIO_printf(bp,"%8sX509v3 extensions:\n","");
189 for (i=0; i<n; i++) 189 for (i=0; i<n; i++)
190 { 190 {
191#if 0
192 int data_type,pack_type;
193#endif
194 ASN1_OBJECT *obj; 191 ASN1_OBJECT *obj;
195
196 ex=X509_get_ext(x,i); 192 ex=X509_get_ext(x,i);
197 if (BIO_printf(bp,"%12s","") <= 0) goto err; 193 if (BIO_printf(bp,"%12s","") <= 0) goto err;
198 obj=X509_EXTENSION_get_object(ex); 194 obj=X509_EXTENSION_get_object(ex);
@@ -203,7 +199,7 @@ int X509_print(BIO *bp, X509 *x)
203 if(!X509V3_EXT_print(bp, ex, 0, 16)) 199 if(!X509V3_EXT_print(bp, ex, 0, 16))
204 { 200 {
205 BIO_printf(bp, "%16s", ""); 201 BIO_printf(bp, "%16s", "");
206 ASN1_OCTET_STRING_print(bp,ex->value); 202 M_ASN1_OCTET_STRING_print(bp,ex->value);
207 } 203 }
208 if (BIO_write(bp,"\n",1) <= 0) goto err; 204 if (BIO_write(bp,"\n",1) <= 0) goto err;
209 } 205 }
@@ -223,10 +219,11 @@ int X509_print(BIO *bp, X509 *x)
223 ((i+1) == n)?"":":") <= 0) goto err; 219 ((i+1) == n)?"":":") <= 0) goto err;
224 } 220 }
225 if (BIO_write(bp,"\n",1) != 1) goto err; 221 if (BIO_write(bp,"\n",1) != 1) goto err;
222 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
226 ret=1; 223 ret=1;
227err: 224err:
228 if (str != NULL) ASN1_STRING_free(str); 225 if (str != NULL) ASN1_STRING_free(str);
229 if (m != NULL) Free((char *)m); 226 if (m != NULL) Free(m);
230 return(ret); 227 return(ret);
231 } 228 }
232 229
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
new file mode 100644
index 0000000000..a18ebb586c
--- /dev/null
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -0,0 +1,102 @@
1/* t_x509a.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX and string set routines
66 */
67
68int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
69{
70 char oidstr[80], first;
71 int i;
72 if(!aux) return 1;
73 if(aux->trust) {
74 first = 1;
75 BIO_printf(out, "%*sTrusted Uses:\n%*s",
76 indent, "", indent + 2, "");
77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78 if(!first) BIO_puts(out, ", ");
79 else first = 0;
80 OBJ_obj2txt(oidstr, 80,
81 sk_ASN1_OBJECT_value(aux->trust, i), 0);
82 BIO_puts(out, oidstr);
83 }
84 BIO_puts(out, "\n");
85 } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, "");
86 if(aux->reject) {
87 first = 1;
88 BIO_printf(out, "%*sRejected Uses:\n%*s",
89 indent, "", indent + 2, "");
90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91 if(!first) BIO_puts(out, ", ");
92 else first = 0;
93 OBJ_obj2txt(oidstr, 80,
94 sk_ASN1_OBJECT_value(aux->reject, i), 0);
95 BIO_puts(out, oidstr);
96 }
97 BIO_puts(out, "\n");
98 } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
99 if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "",
100 aux->alias->data);
101 return 1;
102}
diff --git a/src/lib/libcrypto/asn1/x_algor.c b/src/lib/libcrypto/asn1/x_algor.c
index b2c20d139f..fe023842f8 100644
--- a/src/lib/libcrypto/asn1/x_algor.c
+++ b/src/lib/libcrypto/asn1/x_algor.c
@@ -111,7 +111,7 @@ void X509_ALGOR_free(X509_ALGOR *a)
111 if (a == NULL) return; 111 if (a == NULL) return;
112 ASN1_OBJECT_free(a->algorithm); 112 ASN1_OBJECT_free(a->algorithm);
113 ASN1_TYPE_free(a->parameter); 113 ASN1_TYPE_free(a->parameter);
114 Free((char *)a); 114 Free(a);
115 } 115 }
116 116
117IMPLEMENT_STACK_OF(X509_ALGOR) 117IMPLEMENT_STACK_OF(X509_ALGOR)
diff --git a/src/lib/libcrypto/asn1/x_attrib.c b/src/lib/libcrypto/asn1/x_attrib.c
index a1cbebf5a5..a874df79db 100644
--- a/src/lib/libcrypto/asn1/x_attrib.c
+++ b/src/lib/libcrypto/asn1/x_attrib.c
@@ -160,6 +160,6 @@ void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free); 160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
161 else 161 else
162 ASN1_TYPE_free(a->value.single); 162 ASN1_TYPE_free(a->value.single);
163 Free((char *)a); 163 Free(a);
164 } 164 }
165 165
diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c
index fe1b18a90f..b87c8fff17 100644
--- a/src/lib/libcrypto/asn1/x_cinf.c
+++ b/src/lib/libcrypto/asn1/x_cinf.c
@@ -115,7 +115,7 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
115 { 115 {
116 if (ret->version != NULL) 116 if (ret->version != NULL)
117 { 117 {
118 ASN1_INTEGER_free(ret->version); 118 M_ASN1_INTEGER_free(ret->version);
119 ret->version=NULL; 119 ret->version=NULL;
120 } 120 }
121 } 121 }
@@ -129,12 +129,12 @@ X509_CINF *d2i_X509_CINF(X509_CINF **a, unsigned char **pp, long length)
129 { 129 {
130 if (ret->issuerUID != NULL) 130 if (ret->issuerUID != NULL)
131 { 131 {
132 ASN1_BIT_STRING_free(ret->issuerUID); 132 M_ASN1_BIT_STRING_free(ret->issuerUID);
133 ret->issuerUID=NULL; 133 ret->issuerUID=NULL;
134 } 134 }
135 if (ret->subjectUID != NULL) 135 if (ret->subjectUID != NULL)
136 { 136 {
137 ASN1_BIT_STRING_free(ret->subjectUID); 137 M_ASN1_BIT_STRING_free(ret->subjectUID);
138 ret->subjectUID=NULL; 138 ret->subjectUID=NULL;
139 } 139 }
140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1, 140 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
@@ -170,7 +170,7 @@ X509_CINF *X509_CINF_new(void)
170 170
171 M_ASN1_New_Malloc(ret,X509_CINF); 171 M_ASN1_New_Malloc(ret,X509_CINF);
172 ret->version=NULL; 172 ret->version=NULL;
173 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 173 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
174 M_ASN1_New(ret->signature,X509_ALGOR_new); 174 M_ASN1_New(ret->signature,X509_ALGOR_new);
175 M_ASN1_New(ret->issuer,X509_NAME_new); 175 M_ASN1_New(ret->issuer,X509_NAME_new);
176 M_ASN1_New(ret->validity,X509_VAL_new); 176 M_ASN1_New(ret->validity,X509_VAL_new);
@@ -186,15 +186,15 @@ X509_CINF *X509_CINF_new(void)
186void X509_CINF_free(X509_CINF *a) 186void X509_CINF_free(X509_CINF *a)
187 { 187 {
188 if (a == NULL) return; 188 if (a == NULL) return;
189 ASN1_INTEGER_free(a->version); 189 M_ASN1_INTEGER_free(a->version);
190 ASN1_INTEGER_free(a->serialNumber); 190 M_ASN1_INTEGER_free(a->serialNumber);
191 X509_ALGOR_free(a->signature); 191 X509_ALGOR_free(a->signature);
192 X509_NAME_free(a->issuer); 192 X509_NAME_free(a->issuer);
193 X509_VAL_free(a->validity); 193 X509_VAL_free(a->validity);
194 X509_NAME_free(a->subject); 194 X509_NAME_free(a->subject);
195 X509_PUBKEY_free(a->key); 195 X509_PUBKEY_free(a->key);
196 ASN1_BIT_STRING_free(a->issuerUID); 196 M_ASN1_BIT_STRING_free(a->issuerUID);
197 ASN1_BIT_STRING_free(a->subjectUID); 197 M_ASN1_BIT_STRING_free(a->subjectUID);
198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 198 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
199 Free(a); 199 Free(a);
200 } 200 }
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index cd46bbebc2..12a42d04c7 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -130,9 +130,9 @@ int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **pp)
130 } 130 }
131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR); 131 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME); 132 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_UTCTIME); 133 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_TIME);
134 if (a->nextUpdate != NULL) 134 if (a->nextUpdate != NULL)
135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_UTCTIME); } 135 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_TIME); }
136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked, 136 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
137 i2d_X509_REVOKED); 137 i2d_X509_REVOKED);
138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions, 138 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
@@ -157,20 +157,16 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
157 157
158 if ((ver == 0) && (ret->version != NULL)) 158 if ((ver == 0) && (ret->version != NULL))
159 { 159 {
160 ASN1_INTEGER_free(ret->version); 160 M_ASN1_INTEGER_free(ret->version);
161 ret->version=NULL; 161 ret->version=NULL;
162 } 162 }
163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR); 163 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); 164 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME); 165 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME);
166 /* Manually handle the OPTIONAL ASN1_TIME stuff */ 166 /* Manually handle the OPTIONAL ASN1_TIME stuff */
167 if(c.slen != 0 167 /* First try UTCTime */
168 && ( (M_ASN1_next & ~V_ASN1_CONSTRUCTED) == 168 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_UTCTIME, V_ASN1_UTCTIME);
169 (V_ASN1_UNIVERSAL|V_ASN1_UTCTIME) 169 /* If that doesn't work try GeneralizedTime */
170 || (M_ASN1_next & ~V_ASN1_CONSTRUCTED) ==
171 (V_ASN1_UNIVERSAL|V_ASN1_GENERALIZEDTIME) ) ) {
172 M_ASN1_D2I_get(ret->nextUpdate,d2i_ASN1_TIME);
173 }
174 if(!ret->nextUpdate) 170 if(!ret->nextUpdate)
175 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME, 171 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME,
176 V_ASN1_GENERALIZEDTIME); 172 V_ASN1_GENERALIZEDTIME);
@@ -190,20 +186,17 @@ X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp,
190 } 186 }
191 } 187 }
192 188
193 if (ver >= 1) 189 if (ret->extensions != NULL)
194 { 190 {
195 if (ret->extensions != NULL) 191 while (sk_X509_EXTENSION_num(ret->extensions))
196 { 192 X509_EXTENSION_free(
197 while (sk_X509_EXTENSION_num(ret->extensions)) 193 sk_X509_EXTENSION_pop(ret->extensions));
198 X509_EXTENSION_free(
199 sk_X509_EXTENSION_pop(ret->extensions));
200 }
201
202 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
203 d2i_X509_EXTENSION,
204 X509_EXTENSION_free,0,
205 V_ASN1_SEQUENCE);
206 } 194 }
195
196 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
197 d2i_X509_EXTENSION,
198 X509_EXTENSION_free,0,
199 V_ASN1_SEQUENCE);
207 200
208 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO); 201 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
209 } 202 }
@@ -245,8 +238,8 @@ X509_REVOKED *X509_REVOKED_new(void)
245 ASN1_CTX c; 238 ASN1_CTX c;
246 239
247 M_ASN1_New_Malloc(ret,X509_REVOKED); 240 M_ASN1_New_Malloc(ret,X509_REVOKED);
248 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); 241 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
249 M_ASN1_New(ret->revocationDate,ASN1_UTCTIME_new); 242 M_ASN1_New(ret->revocationDate,M_ASN1_UTCTIME_new);
250 ret->extensions=NULL; 243 ret->extensions=NULL;
251 return(ret); 244 return(ret);
252 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW); 245 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW);
@@ -261,7 +254,7 @@ X509_CRL_INFO *X509_CRL_INFO_new(void)
261 ret->version=NULL; 254 ret->version=NULL;
262 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 255 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
263 M_ASN1_New(ret->issuer,X509_NAME_new); 256 M_ASN1_New(ret->issuer,X509_NAME_new);
264 M_ASN1_New(ret->lastUpdate,ASN1_UTCTIME_new); 257 M_ASN1_New(ret->lastUpdate,M_ASN1_UTCTIME_new);
265 ret->nextUpdate=NULL; 258 ret->nextUpdate=NULL;
266 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null); 259 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null);
267 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null); 260 M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null);
@@ -279,7 +272,7 @@ X509_CRL *X509_CRL_new(void)
279 ret->references=1; 272 ret->references=1;
280 M_ASN1_New(ret->crl,X509_CRL_INFO_new); 273 M_ASN1_New(ret->crl,X509_CRL_INFO_new);
281 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 274 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
282 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 275 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
283 return(ret); 276 return(ret);
284 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW); 277 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW);
285 } 278 }
@@ -287,8 +280,8 @@ X509_CRL *X509_CRL_new(void)
287void X509_REVOKED_free(X509_REVOKED *a) 280void X509_REVOKED_free(X509_REVOKED *a)
288 { 281 {
289 if (a == NULL) return; 282 if (a == NULL) return;
290 ASN1_INTEGER_free(a->serialNumber); 283 M_ASN1_INTEGER_free(a->serialNumber);
291 ASN1_UTCTIME_free(a->revocationDate); 284 M_ASN1_UTCTIME_free(a->revocationDate);
292 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 285 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
293 Free(a); 286 Free(a);
294 } 287 }
@@ -296,12 +289,12 @@ void X509_REVOKED_free(X509_REVOKED *a)
296void X509_CRL_INFO_free(X509_CRL_INFO *a) 289void X509_CRL_INFO_free(X509_CRL_INFO *a)
297 { 290 {
298 if (a == NULL) return; 291 if (a == NULL) return;
299 ASN1_INTEGER_free(a->version); 292 M_ASN1_INTEGER_free(a->version);
300 X509_ALGOR_free(a->sig_alg); 293 X509_ALGOR_free(a->sig_alg);
301 X509_NAME_free(a->issuer); 294 X509_NAME_free(a->issuer);
302 ASN1_UTCTIME_free(a->lastUpdate); 295 M_ASN1_UTCTIME_free(a->lastUpdate);
303 if (a->nextUpdate) 296 if (a->nextUpdate)
304 ASN1_UTCTIME_free(a->nextUpdate); 297 M_ASN1_UTCTIME_free(a->nextUpdate);
305 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free); 298 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
306 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free); 299 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
307 Free(a); 300 Free(a);
@@ -328,7 +321,7 @@ void X509_CRL_free(X509_CRL *a)
328 321
329 X509_CRL_INFO_free(a->crl); 322 X509_CRL_INFO_free(a->crl);
330 X509_ALGOR_free(a->sig_alg); 323 X509_ALGOR_free(a->sig_alg);
331 ASN1_BIT_STRING_free(a->signature); 324 M_ASN1_BIT_STRING_free(a->signature);
332 Free(a); 325 Free(a);
333 } 326 }
334 327
diff --git a/src/lib/libcrypto/asn1/x_exten.c b/src/lib/libcrypto/asn1/x_exten.c
index d5f9e1df9e..185cbd78a0 100644
--- a/src/lib/libcrypto/asn1/x_exten.c
+++ b/src/lib/libcrypto/asn1/x_exten.c
@@ -100,10 +100,6 @@ X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, unsigned char **pp,
100 M_ASN1_D2I_start_sequence(); 100 M_ASN1_D2I_start_sequence();
101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT); 101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
102 102
103 if ((ret->argp != NULL) && (ret->ex_free != NULL))
104 ret->ex_free(ret);
105 ret->argl=0;
106 ret->argp=NULL;
107 ret->netscape_hack=0; 103 ret->netscape_hack=0;
108 if ((c.slen != 0) && 104 if ((c.slen != 0) &&
109 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN))) 105 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN)))
@@ -126,12 +122,9 @@ X509_EXTENSION *X509_EXTENSION_new(void)
126 122
127 M_ASN1_New_Malloc(ret,X509_EXTENSION); 123 M_ASN1_New_Malloc(ret,X509_EXTENSION);
128 ret->object=OBJ_nid2obj(NID_undef); 124 ret->object=OBJ_nid2obj(NID_undef);
129 M_ASN1_New(ret->value,ASN1_OCTET_STRING_new); 125 M_ASN1_New(ret->value,M_ASN1_OCTET_STRING_new);
130 ret->critical=0; 126 ret->critical=0;
131 ret->netscape_hack=0; 127 ret->netscape_hack=0;
132 ret->argl=0L;
133 ret->argp=NULL;
134 ret->ex_free=NULL;
135 return(ret); 128 return(ret);
136 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW); 129 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW);
137 } 130 }
@@ -139,10 +132,8 @@ X509_EXTENSION *X509_EXTENSION_new(void)
139void X509_EXTENSION_free(X509_EXTENSION *a) 132void X509_EXTENSION_free(X509_EXTENSION *a)
140 { 133 {
141 if (a == NULL) return; 134 if (a == NULL) return;
142 if ((a->argp != NULL) && (a->ex_free != NULL))
143 a->ex_free(a);
144 ASN1_OBJECT_free(a->object); 135 ASN1_OBJECT_free(a->object);
145 ASN1_OCTET_STRING_free(a->value); 136 M_ASN1_OCTET_STRING_free(a->value);
146 Free((char *)a); 137 Free(a);
147 } 138 }
148 139
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c
index 99ce011f07..7fdc6f9dc8 100644
--- a/src/lib/libcrypto/asn1/x_info.c
+++ b/src/lib/libcrypto/asn1/x_info.c
@@ -106,7 +106,8 @@ void X509_INFO_free(X509_INFO *x)
106 if (x->x509 != NULL) X509_free(x->x509); 106 if (x->x509 != NULL) X509_free(x->x509);
107 if (x->crl != NULL) X509_CRL_free(x->crl); 107 if (x->crl != NULL) X509_CRL_free(x->crl);
108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); 108 if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey);
109 Free((char *)x); 109 if (x->enc_data != NULL) Free(x->enc_data);
110 Free(x);
110 } 111 }
111 112
112IMPLEMENT_STACK_OF(X509_INFO) 113IMPLEMENT_STACK_OF(X509_INFO)
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index b09fba33fb..64baf5719d 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -253,7 +253,7 @@ void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
253 { 253 {
254 if (a == NULL) return; 254 if (a == NULL) return;
255 ASN1_OBJECT_free(a->object); 255 ASN1_OBJECT_free(a->object);
256 ASN1_BIT_STRING_free(a->value); 256 M_ASN1_BIT_STRING_free(a->value);
257 Free(a); 257 Free(a);
258 } 258 }
259 259
diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c
index b0057eb212..fe58919dbb 100644
--- a/src/lib/libcrypto/asn1/x_pkey.c
+++ b/src/lib/libcrypto/asn1/x_pkey.c
@@ -112,7 +112,7 @@ X509_PKEY *X509_PKEY_new(void)
112 M_ASN1_New_Malloc(ret,X509_PKEY); 112 M_ASN1_New_Malloc(ret,X509_PKEY);
113 ret->version=0; 113 ret->version=0;
114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new); 114 M_ASN1_New(ret->enc_algor,X509_ALGOR_new);
115 M_ASN1_New(ret->enc_pkey,ASN1_OCTET_STRING_new); 115 M_ASN1_New(ret->enc_pkey,M_ASN1_OCTET_STRING_new);
116 ret->dec_pkey=NULL; 116 ret->dec_pkey=NULL;
117 ret->key_length=0; 117 ret->key_length=0;
118 ret->key_data=NULL; 118 ret->key_data=NULL;
@@ -144,8 +144,8 @@ void X509_PKEY_free(X509_PKEY *x)
144#endif 144#endif
145 145
146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); 146 if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor);
147 if (x->enc_pkey != NULL) ASN1_OCTET_STRING_free(x->enc_pkey); 147 if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey);
148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey); 148 if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey);
149 if ((x->key_data != NULL) && (x->key_free)) Free((char *)x->key_data); 149 if ((x->key_data != NULL) && (x->key_free)) Free(x->key_data);
150 Free((char *)(char *)x); 150 Free(x);
151 } 151 }
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index 4ac32c59dd..81e9815222 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -100,7 +100,7 @@ X509_PUBKEY *X509_PUBKEY_new(void)
100 100
101 M_ASN1_New_Malloc(ret,X509_PUBKEY); 101 M_ASN1_New_Malloc(ret,X509_PUBKEY);
102 M_ASN1_New(ret->algor,X509_ALGOR_new); 102 M_ASN1_New(ret->algor,X509_ALGOR_new);
103 M_ASN1_New(ret->public_key,ASN1_BIT_STRING_new); 103 M_ASN1_New(ret->public_key,M_ASN1_BIT_STRING_new);
104 ret->pkey=NULL; 104 ret->pkey=NULL;
105 return(ret); 105 return(ret);
106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW); 106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW);
@@ -110,9 +110,9 @@ void X509_PUBKEY_free(X509_PUBKEY *a)
110 { 110 {
111 if (a == NULL) return; 111 if (a == NULL) return;
112 X509_ALGOR_free(a->algor); 112 X509_ALGOR_free(a->algor);
113 ASN1_BIT_STRING_free(a->public_key); 113 M_ASN1_BIT_STRING_free(a->public_key);
114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey); 114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey);
115 Free((char *)a); 115 Free(a);
116 } 116 }
117 117
118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) 118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
@@ -176,7 +176,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err; 176 if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err;
177 p=s; 177 p=s;
178 i2d_PublicKey(pkey,&p); 178 i2d_PublicKey(pkey,&p);
179 if (!ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err; 179 if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
180 /* Set number of unused bits to zero */ 180 /* Set number of unused bits to zero */
181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 181 pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT; 182 pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
@@ -252,3 +252,113 @@ err:
252 return(NULL); 252 return(NULL);
253 } 253 }
254 254
255/* Now two pseudo ASN1 routines that take an EVP_PKEY structure
256 * and encode or decode as X509_PUBKEY
257 */
258
259EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, unsigned char **pp,
260 long length)
261{
262 X509_PUBKEY *xpk;
263 EVP_PKEY *pktmp;
264 xpk = d2i_X509_PUBKEY(NULL, pp, length);
265 if(!xpk) return NULL;
266 pktmp = X509_PUBKEY_get(xpk);
267 X509_PUBKEY_free(xpk);
268 if(!pktmp) return NULL;
269 if(a) {
270 EVP_PKEY_free(*a);
271 *a = pktmp;
272 }
273 return pktmp;
274}
275
276int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
277{
278 X509_PUBKEY *xpk=NULL;
279 int ret;
280 if(!a) return 0;
281 if(!X509_PUBKEY_set(&xpk, a)) return 0;
282 ret = i2d_X509_PUBKEY(xpk, pp);
283 X509_PUBKEY_free(xpk);
284 return ret;
285}
286
287/* The following are equivalents but which return RSA and DSA
288 * keys
289 */
290#ifndef NO_RSA
291RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp,
292 long length)
293{
294 EVP_PKEY *pkey;
295 RSA *key;
296 unsigned char *q;
297 q = *pp;
298 pkey = d2i_PUBKEY(NULL, &q, length);
299 if(!pkey) return NULL;
300 key = EVP_PKEY_get1_RSA(pkey);
301 EVP_PKEY_free(pkey);
302 if(!key) return NULL;
303 *pp = q;
304 if(a) {
305 RSA_free(*a);
306 *a = key;
307 }
308 return key;
309}
310
311int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
312{
313 EVP_PKEY *pktmp;
314 int ret;
315 if(!a) return 0;
316 pktmp = EVP_PKEY_new();
317 if(!pktmp) {
318 ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE);
319 return 0;
320 }
321 EVP_PKEY_set1_RSA(pktmp, a);
322 ret = i2d_PUBKEY(pktmp, pp);
323 EVP_PKEY_free(pktmp);
324 return ret;
325}
326#endif
327
328#ifndef NO_DSA
329DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp,
330 long length)
331{
332 EVP_PKEY *pkey;
333 DSA *key;
334 unsigned char *q;
335 q = *pp;
336 pkey = d2i_PUBKEY(NULL, &q, length);
337 if(!pkey) return NULL;
338 key = EVP_PKEY_get1_DSA(pkey);
339 EVP_PKEY_free(pkey);
340 if(!key) return NULL;
341 *pp = q;
342 if(a) {
343 DSA_free(*a);
344 *a = key;
345 }
346 return key;
347}
348
349int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
350{
351 EVP_PKEY *pktmp;
352 int ret;
353 if(!a) return 0;
354 pktmp = EVP_PKEY_new();
355 if(!pktmp) {
356 ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE);
357 return 0;
358 }
359 EVP_PKEY_set1_DSA(pktmp, a);
360 ret = i2d_PUBKEY(pktmp, pp);
361 EVP_PKEY_free(pktmp);
362 return ret;
363}
364#endif
diff --git a/src/lib/libcrypto/asn1/x_req.c b/src/lib/libcrypto/asn1/x_req.c
index 9b1d6abe64..0cd572ee73 100644
--- a/src/lib/libcrypto/asn1/x_req.c
+++ b/src/lib/libcrypto/asn1/x_req.c
@@ -73,7 +73,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
73 * allow some CA Software to accept the cert request. 73 * allow some CA Software to accept the cert request.
74 * It is not following the PKCS standards ... 74 * It is not following the PKCS standards ...
75 * PKCS#10 pg 5 75 * PKCS#10 pg 5
76 * attributes [0] IMPLICIT Attibutes 76 * attributes [0] IMPLICIT Attributes
77 * NOTE: no OPTIONAL ... so it *must* be there 77 * NOTE: no OPTIONAL ... so it *must* be there
78 */ 78 */
79 if (a->req_kludge) 79 if (a->req_kludge)
@@ -94,7 +94,7 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
94 /* this is a *nasty* hack reported to be required by some CA's. 94 /* this is a *nasty* hack reported to be required by some CA's.
95 * It is not following the PKCS standards ... 95 * It is not following the PKCS standards ...
96 * PKCS#10 pg 5 96 * PKCS#10 pg 5
97 * attributes [0] IMPLICIT Attibutes 97 * attributes [0] IMPLICIT Attributes
98 * NOTE: no OPTIONAL ... so it *must* be there 98 * NOTE: no OPTIONAL ... so it *must* be there
99 */ 99 */
100 if (a->req_kludge) 100 if (a->req_kludge)
@@ -126,7 +126,7 @@ X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, unsigned char **pp,
126 * have been reported as requiring it. 126 * have been reported as requiring it.
127 * It is not following the PKCS standards ... 127 * It is not following the PKCS standards ...
128 * PKCS#10 pg 5 128 * PKCS#10 pg 5
129 * attributes [0] IMPLICIT Attibutes 129 * attributes [0] IMPLICIT Attributes
130 * NOTE: no OPTIONAL ... so it *must* be there 130 * NOTE: no OPTIONAL ... so it *must* be there
131 */ 131 */
132 if (asn1_Finish(&c)) 132 if (asn1_Finish(&c))
@@ -147,7 +147,7 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
147 ASN1_CTX c; 147 ASN1_CTX c;
148 148
149 M_ASN1_New_Malloc(ret,X509_REQ_INFO); 149 M_ASN1_New_Malloc(ret,X509_REQ_INFO);
150 M_ASN1_New(ret->version,ASN1_INTEGER_new); 150 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
151 M_ASN1_New(ret->subject,X509_NAME_new); 151 M_ASN1_New(ret->subject,X509_NAME_new);
152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 152 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null); 153 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
@@ -159,11 +159,11 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
159void X509_REQ_INFO_free(X509_REQ_INFO *a) 159void X509_REQ_INFO_free(X509_REQ_INFO *a)
160 { 160 {
161 if (a == NULL) return; 161 if (a == NULL) return;
162 ASN1_INTEGER_free(a->version); 162 M_ASN1_INTEGER_free(a->version);
163 X509_NAME_free(a->subject); 163 X509_NAME_free(a->subject);
164 X509_PUBKEY_free(a->pubkey); 164 X509_PUBKEY_free(a->pubkey);
165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free); 165 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
166 Free((char *)a); 166 Free(a);
167 } 167 }
168 168
169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp) 169int i2d_X509_REQ(X509_REQ *a, unsigned char **pp)
@@ -203,7 +203,7 @@ X509_REQ *X509_REQ_new(void)
203 ret->references=1; 203 ret->references=1;
204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new); 204 M_ASN1_New(ret->req_info,X509_REQ_INFO_new);
205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 205 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
206 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 206 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
207 return(ret); 207 return(ret);
208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW); 208 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW);
209 } 209 }
@@ -229,8 +229,8 @@ void X509_REQ_free(X509_REQ *a)
229 229
230 X509_REQ_INFO_free(a->req_info); 230 X509_REQ_INFO_free(a->req_info);
231 X509_ALGOR_free(a->sig_alg); 231 X509_ALGOR_free(a->sig_alg);
232 ASN1_BIT_STRING_free(a->signature); 232 M_ASN1_BIT_STRING_free(a->signature);
233 Free((char *)a); 233 Free(a);
234 } 234 }
235 235
236 236
diff --git a/src/lib/libcrypto/asn1/x_sig.c b/src/lib/libcrypto/asn1/x_sig.c
index c2782d1b9c..3559bd5368 100644
--- a/src/lib/libcrypto/asn1/x_sig.c
+++ b/src/lib/libcrypto/asn1/x_sig.c
@@ -94,7 +94,7 @@ X509_SIG *X509_SIG_new(void)
94 94
95 M_ASN1_New_Malloc(ret,X509_SIG); 95 M_ASN1_New_Malloc(ret,X509_SIG);
96 M_ASN1_New(ret->algor,X509_ALGOR_new); 96 M_ASN1_New(ret->algor,X509_ALGOR_new);
97 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); 97 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW);
100 } 100 }
@@ -103,8 +103,8 @@ void X509_SIG_free(X509_SIG *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 X509_ALGOR_free(a->algor); 105 X509_ALGOR_free(a->algor);
106 ASN1_OCTET_STRING_free(a->digest); 106 M_ASN1_OCTET_STRING_free(a->digest);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
110 110
diff --git a/src/lib/libcrypto/asn1/x_spki.c b/src/lib/libcrypto/asn1/x_spki.c
index 43e0023839..8f5e7e6380 100644
--- a/src/lib/libcrypto/asn1/x_spki.c
+++ b/src/lib/libcrypto/asn1/x_spki.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59 /* This module was send to me my Pat Richards <patr@x509.com> who 59 /* This module was send to me my Pat Richards <patr@x509.com> who
60 * wrote it. It is under my Copyright with his permision 60 * wrote it. It is under my Copyright with his permission
61 */ 61 */
62 62
63#include <stdio.h> 63#include <stdio.h>
@@ -99,7 +99,7 @@ NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void)
99 99
100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC); 100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC);
101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new); 101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
102 M_ASN1_New(ret->challenge,ASN1_IA5STRING_new); 102 M_ASN1_New(ret->challenge,M_ASN1_IA5STRING_new);
103 return(ret); 103 return(ret);
104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW); 104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW);
105 } 105 }
@@ -108,8 +108,8 @@ void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a)
108 { 108 {
109 if (a == NULL) return; 109 if (a == NULL) return;
110 X509_PUBKEY_free(a->pubkey); 110 X509_PUBKEY_free(a->pubkey);
111 ASN1_IA5STRING_free(a->challenge); 111 M_ASN1_IA5STRING_free(a->challenge);
112 Free((char *)a); 112 Free(a);
113 } 113 }
114 114
115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp) 115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp)
@@ -150,7 +150,7 @@ NETSCAPE_SPKI *NETSCAPE_SPKI_new(void)
150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI); 150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI);
151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new); 151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new);
152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new); 152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new);
153 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 153 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
154 return(ret); 154 return(ret);
155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW); 155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW);
156 } 156 }
@@ -160,7 +160,7 @@ void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a)
160 if (a == NULL) return; 160 if (a == NULL) return;
161 NETSCAPE_SPKAC_free(a->spkac); 161 NETSCAPE_SPKAC_free(a->spkac);
162 X509_ALGOR_free(a->sig_algor); 162 X509_ALGOR_free(a->sig_algor);
163 ASN1_BIT_STRING_free(a->signature); 163 M_ASN1_BIT_STRING_free(a->signature);
164 Free((char *)a); 164 Free(a);
165 } 165 }
166 166
diff --git a/src/lib/libcrypto/asn1/x_val.c b/src/lib/libcrypto/asn1/x_val.c
index 84d6f7ca4d..1a2f49ffdf 100644
--- a/src/lib/libcrypto/asn1/x_val.c
+++ b/src/lib/libcrypto/asn1/x_val.c
@@ -93,8 +93,8 @@ X509_VAL *X509_VAL_new(void)
93 ASN1_CTX c; 93 ASN1_CTX c;
94 94
95 M_ASN1_New_Malloc(ret,X509_VAL); 95 M_ASN1_New_Malloc(ret,X509_VAL);
96 M_ASN1_New(ret->notBefore,ASN1_TIME_new); 96 M_ASN1_New(ret->notBefore,M_ASN1_TIME_new);
97 M_ASN1_New(ret->notAfter,ASN1_TIME_new); 97 M_ASN1_New(ret->notAfter,M_ASN1_TIME_new);
98 return(ret); 98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW); 99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW);
100 } 100 }
@@ -102,8 +102,8 @@ X509_VAL *X509_VAL_new(void)
102void X509_VAL_free(X509_VAL *a) 102void X509_VAL_free(X509_VAL *a)
103 { 103 {
104 if (a == NULL) return; 104 if (a == NULL) return;
105 ASN1_TIME_free(a->notBefore); 105 M_ASN1_TIME_free(a->notBefore);
106 ASN1_TIME_free(a->notAfter); 106 M_ASN1_TIME_free(a->notAfter);
107 Free((char *)a); 107 Free(a);
108 } 108 }
109 109
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c
index 7abf6b2a6b..11e564ea30 100644
--- a/src/lib/libcrypto/asn1/x_x509.c
+++ b/src/lib/libcrypto/asn1/x_x509.c
@@ -62,6 +62,9 @@
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65static int x509_meth_num = 0;
66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_meth = NULL;
67
65static ASN1_METHOD meth={ 68static ASN1_METHOD meth={
66 (int (*)()) i2d_X509, 69 (int (*)()) i2d_X509,
67 (char *(*)())d2i_X509, 70 (char *(*)())d2i_X509,
@@ -113,10 +116,13 @@ X509 *X509_new(void)
113 M_ASN1_New_Malloc(ret,X509); 116 M_ASN1_New_Malloc(ret,X509);
114 ret->references=1; 117 ret->references=1;
115 ret->valid=0; 118 ret->valid=0;
119 ret->ex_flags = 0;
116 ret->name=NULL; 120 ret->name=NULL;
121 ret->aux=NULL;
117 M_ASN1_New(ret->cert_info,X509_CINF_new); 122 M_ASN1_New(ret->cert_info,X509_CINF_new);
118 M_ASN1_New(ret->sig_alg,X509_ALGOR_new); 123 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
119 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); 124 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
125 CRYPTO_new_ex_data(x509_meth, ret, &ret->ex_data);
120 return(ret); 126 return(ret);
121 M_ASN1_New_Error(ASN1_F_X509_NEW); 127 M_ASN1_New_Error(ASN1_F_X509_NEW);
122 } 128 }
@@ -140,12 +146,65 @@ void X509_free(X509 *a)
140 } 146 }
141#endif 147#endif
142 148
143 /* CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); */ 149 CRYPTO_free_ex_data(x509_meth,a,&a->ex_data);
144 X509_CINF_free(a->cert_info); 150 X509_CINF_free(a->cert_info);
145 X509_ALGOR_free(a->sig_alg); 151 X509_ALGOR_free(a->sig_alg);
146 ASN1_BIT_STRING_free(a->signature); 152 M_ASN1_BIT_STRING_free(a->signature);
153 X509_CERT_AUX_free(a->aux);
147 154
148 if (a->name != NULL) Free(a->name); 155 if (a->name != NULL) Free(a->name);
149 Free((char *)a); 156 Free(a);
157 }
158
159int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
160 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
161 {
162 x509_meth_num++;
163 return(CRYPTO_get_ex_new_index(x509_meth_num-1,
164 &x509_meth,argl,argp,new_func,dup_func,free_func));
165 }
166
167int X509_set_ex_data(X509 *r, int idx, void *arg)
168 {
169 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
150 } 170 }
151 171
172void *X509_get_ex_data(X509 *r, int idx)
173 {
174 return(CRYPTO_get_ex_data(&r->ex_data,idx));
175 }
176
177/* X509_AUX ASN1 routines. X509_AUX is the name given to
178 * a certificate with extra info tagged on the end. Since these
179 * functions set how a certificate is trusted they should only
180 * be used when the certificate comes from a reliable source
181 * such as local storage.
182 *
183 */
184
185X509 *d2i_X509_AUX(X509 **a, unsigned char **pp, long length)
186{
187 unsigned char *q;
188 X509 *ret;
189 /* Save start position */
190 q = *pp;
191 ret = d2i_X509(a, pp, length);
192 /* If certificate unreadable then forget it */
193 if(!ret) return NULL;
194 /* update length */
195 length -= *pp - q;
196 if(!length) return ret;
197 if(!d2i_X509_CERT_AUX(&ret->aux, pp, length)) goto err;
198 return ret;
199 err:
200 X509_free(ret);
201 return NULL;
202}
203
204int i2d_X509_AUX(X509 *a, unsigned char **pp)
205{
206 int length;
207 length = i2d_X509(a, pp);
208 if(a) length += i2d_X509_CERT_AUX(a->aux, pp);
209 return length;
210}
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c
new file mode 100644
index 0000000000..b9987ea968
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_x509a.c
@@ -0,0 +1,200 @@
1/* a_x509a.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h>
64
65/* X509_CERT_AUX routines. These are used to encode additional
66 * user modifiable data about a certificate. This data is
67 * appended to the X509 encoding when the *_X509_AUX routines
68 * are used. This means that the "traditional" X509 routines
69 * will simply ignore the extra data.
70 */
71
72static X509_CERT_AUX *aux_get(X509 *x);
73
74X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, unsigned char **pp, long length)
75{
76 M_ASN1_D2I_vars(a, X509_CERT_AUX *, X509_CERT_AUX_new);
77
78 M_ASN1_D2I_Init();
79 M_ASN1_D2I_start_sequence();
80
81 M_ASN1_D2I_get_seq_opt_type(ASN1_OBJECT, ret->trust,
82 d2i_ASN1_OBJECT, ASN1_OBJECT_free);
83 M_ASN1_D2I_get_IMP_set_opt_type(ASN1_OBJECT, ret->reject,
84 d2i_ASN1_OBJECT, ASN1_OBJECT_free, 0);
85 M_ASN1_D2I_get_opt(ret->alias, d2i_ASN1_UTF8STRING, V_ASN1_UTF8STRING);
86 M_ASN1_D2I_get_opt(ret->keyid, d2i_ASN1_OCTET_STRING, V_ASN1_OCTET_STRING);
87 M_ASN1_D2I_get_IMP_set_opt_type(X509_ALGOR, ret->other,
88 d2i_X509_ALGOR, X509_ALGOR_free, 1);
89
90 M_ASN1_D2I_Finish(a, X509_CERT_AUX_free, ASN1_F_D2I_X509_CERT_AUX);
91}
92
93X509_CERT_AUX *X509_CERT_AUX_new()
94{
95 X509_CERT_AUX *ret = NULL;
96 ASN1_CTX c;
97 M_ASN1_New_Malloc(ret, X509_CERT_AUX);
98 ret->trust = NULL;
99 ret->reject = NULL;
100 ret->alias = NULL;
101 ret->keyid = NULL;
102 ret->other = NULL;
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_CERT_AUX_NEW);
105}
106
107void X509_CERT_AUX_free(X509_CERT_AUX *a)
108{
109 if(a == NULL) return;
110 sk_ASN1_OBJECT_pop_free(a->trust, ASN1_OBJECT_free);
111 sk_ASN1_OBJECT_pop_free(a->reject, ASN1_OBJECT_free);
112 ASN1_UTF8STRING_free(a->alias);
113 ASN1_OCTET_STRING_free(a->keyid);
114 sk_X509_ALGOR_pop_free(a->other, X509_ALGOR_free);
115 Free(a);
116}
117
118int i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **pp)
119{
120 M_ASN1_I2D_vars(a);
121
122 M_ASN1_I2D_len_SEQUENCE_opt_type(ASN1_OBJECT, a->trust, i2d_ASN1_OBJECT);
123 M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(ASN1_OBJECT, a->reject, i2d_ASN1_OBJECT, 0);
124
125 M_ASN1_I2D_len(a->alias, i2d_ASN1_UTF8STRING);
126 M_ASN1_I2D_len(a->keyid, i2d_ASN1_OCTET_STRING);
127 M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(X509_ALGOR, a->other, i2d_X509_ALGOR, 1);
128
129 M_ASN1_I2D_seq_total();
130
131 M_ASN1_I2D_put_SEQUENCE_opt_type(ASN1_OBJECT, a->trust, i2d_ASN1_OBJECT);
132 M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(ASN1_OBJECT, a->reject, i2d_ASN1_OBJECT, 0);
133
134 M_ASN1_I2D_put(a->alias, i2d_ASN1_UTF8STRING);
135 M_ASN1_I2D_put(a->keyid, i2d_ASN1_OCTET_STRING);
136 M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(X509_ALGOR, a->other, i2d_X509_ALGOR, 1);
137
138 M_ASN1_I2D_finish();
139}
140
141static X509_CERT_AUX *aux_get(X509 *x)
142{
143 if(!x) return NULL;
144 if(!x->aux && !(x->aux = X509_CERT_AUX_new())) return NULL;
145 return x->aux;
146}
147
148int X509_alias_set1(X509 *x, unsigned char *name, int len)
149{
150 X509_CERT_AUX *aux;
151 if(!(aux = aux_get(x))) return 0;
152 if(!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0;
153 return ASN1_STRING_set(aux->alias, name, len);
154}
155
156unsigned char *X509_alias_get0(X509 *x, int *len)
157{
158 if(!x->aux || !x->aux->alias) return NULL;
159 if(len) *len = x->aux->alias->length;
160 return x->aux->alias->data;
161}
162
163int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
164{
165 X509_CERT_AUX *aux;
166 ASN1_OBJECT *objtmp;
167 if(!(objtmp = OBJ_dup(obj))) return 0;
168 if(!(aux = aux_get(x))) return 0;
169 if(!aux->trust
170 && !(aux->trust = sk_ASN1_OBJECT_new_null())) return 0;
171 return sk_ASN1_OBJECT_push(aux->trust, objtmp);
172}
173
174int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
175{
176 X509_CERT_AUX *aux;
177 ASN1_OBJECT *objtmp;
178 if(!(objtmp = OBJ_dup(obj))) return 0;
179 if(!(aux = aux_get(x))) return 0;
180 if(!aux->reject
181 && !(aux->reject = sk_ASN1_OBJECT_new_null())) return 0;
182 return sk_ASN1_OBJECT_push(aux->reject, objtmp);
183}
184
185void X509_trust_clear(X509 *x)
186{
187 if(x->aux && x->aux->trust) {
188 sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free);
189 x->aux->trust = NULL;
190 }
191}
192
193void X509_reject_clear(X509 *x)
194{
195 if(x->aux && x->aux->reject) {
196 sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free);
197 x->aux->reject = NULL;
198 }
199}
200