diff options
| author | beck <> | 2002-05-15 02:29:21 +0000 |
|---|---|---|
| committer | beck <> | 2002-05-15 02:29:21 +0000 |
| commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
| tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/pem | |
| parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
| download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip | |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/pem')
| -rw-r--r-- | src/lib/libcrypto/pem/Makefile.ssl | 268 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem.h | 33 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_all.c | 23 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_err.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_info.c | 14 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_lib.c | 278 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_oth.c | 85 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_pk8.c | 243 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_pkey.c | 139 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_seal.c | 31 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_sign.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_x509.c | 69 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_xaux.c | 68 |
13 files changed, 851 insertions, 406 deletions
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl index 31db6b65a1..2153723509 100644 --- a/src/lib/libcrypto/pem/Makefile.ssl +++ b/src/lib/libcrypto/pem/Makefile.ssl | |||
| @@ -5,13 +5,14 @@ | |||
| 5 | DIR= pem | 5 | DIR= pem |
| 6 | TOP= ../.. | 6 | TOP= ../.. |
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= -I.. -I../../include | 8 | INCLUDES= -I.. -I$(TOP) -I../../include |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | 10 | INSTALL_PREFIX= |
| 11 | OPENSSLDIR= /usr/local/ssl | 11 | OPENSSLDIR= /usr/local/ssl |
| 12 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 13 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) | 14 | MAKEDEPPROG= makedepend |
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 15 | MAKEFILE= Makefile.ssl | 16 | MAKEFILE= Makefile.ssl |
| 16 | AR= ar r | 17 | AR= ar r |
| 17 | 18 | ||
| @@ -22,9 +23,11 @@ TEST= | |||
| 22 | APPS= | 23 | APPS= |
| 23 | 24 | ||
| 24 | LIB=$(TOP)/libcrypto.a | 25 | LIB=$(TOP)/libcrypto.a |
| 25 | LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c | 26 | LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c \ |
| 27 | pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c | ||
| 26 | 28 | ||
| 27 | LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o | 29 | LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o \ |
| 30 | pem_x509.o pem_xaux.o pem_oth.o pem_pk8.o pem_pkey.o | ||
| 28 | 31 | ||
| 29 | SRC= $(LIBSRC) | 32 | SRC= $(LIBSRC) |
| 30 | 33 | ||
| @@ -40,8 +43,7 @@ all: lib | |||
| 40 | 43 | ||
| 41 | lib: $(LIBOBJ) | 44 | lib: $(LIBOBJ) |
| 42 | $(AR) $(LIB) $(LIBOBJ) | 45 | $(AR) $(LIB) $(LIBOBJ) |
| 43 | @echo You may get an error following this line. Please ignore. | 46 | $(RANLIB) $(LIB) || echo Never mind. |
| 44 | - $(RANLIB) $(LIB) | ||
| 45 | @touch lib | 47 | @touch lib |
| 46 | 48 | ||
| 47 | files: | 49 | files: |
| @@ -80,125 +82,169 @@ clean: | |||
| 80 | 82 | ||
| 81 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 83 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 82 | 84 | ||
| 83 | pem_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 85 | pem_all.o: ../../e_os.h ../../include/openssl/asn1.h |
| 84 | pem_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 86 | pem_all.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 85 | pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 87 | pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 86 | pem_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 87 | pem_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 88 | pem_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 88 | pem_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 89 | pem_all.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 89 | pem_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 90 | pem_all.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 90 | pem_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 91 | pem_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 92 | pem_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 93 | pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 91 | pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 94 | pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 92 | pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 95 | pem_all.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | 93 | pem_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h |
| 96 | pem_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | 94 | pem_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h |
| 97 | pem_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 95 | pem_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
| 98 | pem_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 96 | pem_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 99 | pem_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 97 | pem_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
| 100 | pem_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 98 | pem_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_all.c |
| 101 | pem_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 102 | pem_all.o: ../cryptlib.h | ||
| 103 | pem_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 99 | pem_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 104 | pem_err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 100 | pem_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
| 105 | pem_err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 101 | pem_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h |
| 106 | pem_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | 102 | pem_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 107 | pem_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 103 | pem_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 108 | pem_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 104 | pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 109 | pem_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
| 110 | pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
| 111 | pem_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
| 112 | pem_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
| 113 | pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 105 | pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 114 | pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h | 106 | pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 115 | pem_err.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | 107 | pem_err.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h |
| 116 | pem_err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 108 | pem_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h |
| 117 | pem_err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 109 | pem_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 118 | pem_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 110 | pem_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 119 | pem_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 111 | pem_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
| 120 | pem_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | 112 | pem_err.o: pem_err.c |
| 121 | pem_err.o: ../../include/openssl/x509_vfy.h | 113 | pem_info.o: ../../e_os.h ../../include/openssl/asn1.h |
| 122 | pem_info.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 114 | pem_info.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 123 | pem_info.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 115 | pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 124 | pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 125 | pem_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 126 | pem_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 116 | pem_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 127 | pem_info.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 117 | pem_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 128 | pem_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 118 | pem_info.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 129 | pem_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 130 | pem_info.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 131 | pem_info.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 132 | pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 119 | pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 133 | pem_info.o: ../../include/openssl/opensslconf.h | 120 | pem_info.o: ../../include/openssl/opensslconf.h |
| 134 | pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h | 121 | pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 135 | pem_info.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | 122 | pem_info.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h |
| 136 | pem_info.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 123 | pem_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h |
| 137 | pem_info.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 124 | pem_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 138 | pem_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 125 | pem_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 139 | pem_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 126 | pem_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
| 140 | pem_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | 127 | pem_info.o: ../cryptlib.h pem_info.c |
| 141 | pem_info.o: ../../include/openssl/x509_vfy.h ../cryptlib.h | 128 | pem_lib.o: ../../e_os.h ../../include/openssl/asn1.h |
| 142 | pem_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 129 | pem_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 143 | pem_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 130 | pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 144 | pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 131 | pem_lib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h |
| 145 | pem_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 146 | pem_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 132 | pem_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 147 | pem_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 133 | pem_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 148 | pem_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 134 | pem_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 149 | pem_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 150 | pem_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 151 | pem_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 152 | pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 135 | pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 153 | pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 136 | pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 154 | pem_lib.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | 137 | pem_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h |
| 155 | pem_lib.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | 138 | pem_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h |
| 156 | pem_lib.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 139 | pem_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h |
| 157 | pem_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 140 | pem_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
| 158 | pem_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 141 | pem_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 159 | pem_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 142 | pem_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h |
| 160 | pem_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 143 | pem_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h |
| 161 | pem_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 144 | pem_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_lib.c |
| 162 | pem_lib.o: ../cryptlib.h | 145 | pem_oth.o: ../../e_os.h ../../include/openssl/asn1.h |
| 163 | pem_seal.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 146 | pem_oth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 164 | pem_seal.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 147 | pem_oth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 165 | pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 148 | pem_oth.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 166 | pem_seal.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | 149 | pem_oth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 150 | pem_oth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 151 | pem_oth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 152 | pem_oth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 153 | pem_oth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 154 | pem_oth.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | ||
| 155 | pem_oth.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 156 | pem_oth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 157 | pem_oth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 158 | pem_oth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 159 | pem_oth.o: ../cryptlib.h pem_oth.c | ||
| 160 | pem_pk8.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 161 | pem_pk8.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 162 | pem_pk8.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 163 | pem_pk8.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 164 | pem_pk8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 165 | pem_pk8.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 166 | pem_pk8.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 167 | pem_pk8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 168 | pem_pk8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 169 | pem_pk8.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h | ||
| 170 | pem_pk8.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 171 | pem_pk8.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 172 | pem_pk8.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 173 | pem_pk8.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 174 | pem_pk8.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_pk8.c | ||
| 175 | pem_pkey.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 176 | pem_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 177 | pem_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 178 | pem_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 179 | pem_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 180 | pem_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 181 | pem_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 182 | pem_pkey.o: ../../include/openssl/opensslconf.h | ||
| 183 | pem_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 184 | pem_pkey.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 185 | pem_pkey.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | ||
| 186 | pem_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 187 | pem_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 188 | pem_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 189 | pem_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 190 | pem_pkey.o: ../cryptlib.h pem_pkey.c | ||
| 191 | pem_seal.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 192 | pem_seal.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 193 | pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 167 | pem_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 194 | pem_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 168 | pem_seal.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 195 | pem_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 169 | pem_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 196 | pem_seal.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 170 | pem_seal.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 171 | pem_seal.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 172 | pem_seal.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 173 | pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 197 | pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 174 | pem_seal.o: ../../include/openssl/opensslconf.h | 198 | pem_seal.o: ../../include/openssl/opensslconf.h |
| 175 | pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h | 199 | pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 176 | pem_seal.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | 200 | pem_seal.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h |
| 177 | pem_seal.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 201 | pem_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h |
| 178 | pem_seal.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 202 | pem_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
| 179 | pem_seal.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 203 | pem_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 180 | pem_seal.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 204 | pem_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
| 181 | pem_seal.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 205 | pem_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_seal.c |
| 182 | pem_seal.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 206 | pem_sign.o: ../../e_os.h ../../include/openssl/asn1.h |
| 183 | pem_seal.o: ../cryptlib.h | 207 | pem_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 184 | pem_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 208 | pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 185 | pem_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 186 | pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 187 | pem_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 188 | pem_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 209 | pem_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
| 189 | pem_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 210 | pem_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 190 | pem_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 211 | pem_sign.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 191 | pem_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 192 | pem_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 193 | pem_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 194 | pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 212 | pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 195 | pem_sign.o: ../../include/openssl/opensslconf.h | 213 | pem_sign.o: ../../include/openssl/opensslconf.h |
| 196 | pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h | 214 | pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 197 | pem_sign.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | 215 | pem_sign.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h |
| 198 | pem_sign.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 216 | pem_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h |
| 199 | pem_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 217 | pem_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
| 200 | pem_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 218 | pem_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 201 | pem_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 219 | pem_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
| 202 | pem_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 220 | pem_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_sign.c |
| 203 | pem_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 221 | pem_x509.o: ../../e_os.h ../../include/openssl/asn1.h |
| 204 | pem_sign.o: ../cryptlib.h | 222 | pem_x509.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 223 | pem_x509.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 224 | pem_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 225 | pem_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 226 | pem_x509.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 227 | pem_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 228 | pem_x509.o: ../../include/openssl/opensslconf.h | ||
| 229 | pem_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 230 | pem_x509.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 231 | pem_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 232 | pem_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 233 | pem_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 234 | pem_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 235 | pem_x509.o: ../cryptlib.h pem_x509.c | ||
| 236 | pem_xaux.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 237 | pem_xaux.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 238 | pem_xaux.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 239 | pem_xaux.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 240 | pem_xaux.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 241 | pem_xaux.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 242 | pem_xaux.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 243 | pem_xaux.o: ../../include/openssl/opensslconf.h | ||
| 244 | pem_xaux.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 245 | pem_xaux.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 246 | pem_xaux.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 247 | pem_xaux.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 248 | pem_xaux.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 249 | pem_xaux.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 250 | pem_xaux.o: ../cryptlib.h pem_xaux.c | ||
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h index 6d3c446577..3785fca77d 100644 --- a/src/lib/libcrypto/pem/pem.h +++ b/src/lib/libcrypto/pem/pem.h | |||
| @@ -59,15 +59,16 @@ | |||
| 59 | #ifndef HEADER_PEM_H | 59 | #ifndef HEADER_PEM_H |
| 60 | #define HEADER_PEM_H | 60 | #define HEADER_PEM_H |
| 61 | 61 | ||
| 62 | #ifndef NO_BIO | 62 | #ifndef OPENSSL_NO_BIO |
| 63 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
| 64 | #endif | 64 | #endif |
| 65 | #ifndef NO_STACK | 65 | #ifndef OPENSSL_NO_STACK |
| 66 | #include <openssl/stack.h> | 66 | #include <openssl/stack.h> |
| 67 | #endif | 67 | #endif |
| 68 | #include <openssl/evp.h> | 68 | #include <openssl/evp.h> |
| 69 | #include <openssl/x509.h> | 69 | #include <openssl/x509.h> |
| 70 | #include <openssl/pem2.h> | 70 | #include <openssl/pem2.h> |
| 71 | #include <openssl/e_os2.h> | ||
| 71 | 72 | ||
| 72 | #ifdef __cplusplus | 73 | #ifdef __cplusplus |
| 73 | extern "C" { | 74 | extern "C" { |
| @@ -126,7 +127,8 @@ extern "C" { | |||
| 126 | #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" | 127 | #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" |
| 127 | #define PEM_STRING_DSAPARAMS "DSA PARAMETERS" | 128 | #define PEM_STRING_DSAPARAMS "DSA PARAMETERS" |
| 128 | 129 | ||
| 129 | 130 | /* Note that this structure is initialised by PEM_SealInit and cleaned up | |
| 131 | by PEM_SealFinal (at least for now) */ | ||
| 130 | typedef struct PEM_Encode_Seal_st | 132 | typedef struct PEM_Encode_Seal_st |
| 131 | { | 133 | { |
| 132 | EVP_ENCODE_CTX encode; | 134 | EVP_ENCODE_CTX encode; |
| @@ -171,7 +173,7 @@ typedef struct pem_ctx_st | |||
| 171 | int num_recipient; | 173 | int num_recipient; |
| 172 | PEM_USER **recipient; | 174 | PEM_USER **recipient; |
| 173 | 175 | ||
| 174 | #ifndef NO_STACK | 176 | #ifndef OPENSSL_NO_STACK |
| 175 | STACK *x509_chain; /* certificate chain */ | 177 | STACK *x509_chain; /* certificate chain */ |
| 176 | #else | 178 | #else |
| 177 | char *x509_chain; /* certificate chain */ | 179 | char *x509_chain; /* certificate chain */ |
| @@ -198,7 +200,7 @@ typedef struct pem_ctx_st | |||
| 198 | * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) | 200 | * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) |
| 199 | */ | 201 | */ |
| 200 | 202 | ||
| 201 | #ifdef NO_FP_API | 203 | #ifdef OPENSSL_NO_FP_API |
| 202 | 204 | ||
| 203 | #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ | 205 | #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ |
| 204 | #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ | 206 | #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ |
| @@ -275,7 +277,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |||
| 275 | 277 | ||
| 276 | /* These are the same except they are for the declarations */ | 278 | /* These are the same except they are for the declarations */ |
| 277 | 279 | ||
| 278 | #if defined(WIN16) || defined(NO_FP_API) | 280 | #if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) |
| 279 | 281 | ||
| 280 | #define DECLARE_PEM_read_fp(name, type) /**/ | 282 | #define DECLARE_PEM_read_fp(name, type) /**/ |
| 281 | #define DECLARE_PEM_write_fp(name, type) /**/ | 283 | #define DECLARE_PEM_write_fp(name, type) /**/ |
| @@ -295,7 +297,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |||
| 295 | 297 | ||
| 296 | #endif | 298 | #endif |
| 297 | 299 | ||
| 298 | #ifndef NO_BIO | 300 | #ifndef OPENSSL_NO_BIO |
| 299 | #define DECLARE_PEM_read_bio(name, type) \ | 301 | #define DECLARE_PEM_read_bio(name, type) \ |
| 300 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); | 302 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); |
| 301 | 303 | ||
| @@ -483,11 +485,13 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); | |||
| 483 | int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, | 485 | int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, |
| 484 | pem_password_cb *callback,void *u); | 486 | pem_password_cb *callback,void *u); |
| 485 | 487 | ||
| 486 | #ifndef NO_BIO | 488 | #ifndef OPENSSL_NO_BIO |
| 487 | int PEM_read_bio(BIO *bp, char **name, char **header, | 489 | int PEM_read_bio(BIO *bp, char **name, char **header, |
| 488 | unsigned char **data,long *len); | 490 | unsigned char **data,long *len); |
| 489 | int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, | 491 | int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, |
| 490 | long len); | 492 | long len); |
| 493 | int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, | ||
| 494 | pem_password_cb *cb, void *u); | ||
| 491 | char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x, | 495 | char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x, |
| 492 | pem_password_cb *cb, void *u); | 496 | pem_password_cb *cb, void *u); |
| 493 | int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x, | 497 | int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x, |
| @@ -498,7 +502,7 @@ int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, | |||
| 498 | unsigned char *kstr, int klen, pem_password_cb *cd, void *u); | 502 | unsigned char *kstr, int klen, pem_password_cb *cd, void *u); |
| 499 | #endif | 503 | #endif |
| 500 | 504 | ||
| 501 | #ifndef WIN16 | 505 | #ifndef OPENSSL_SYS_WIN16 |
| 502 | int PEM_read(FILE *fp, char **name, char **header, | 506 | int PEM_read(FILE *fp, char **name, char **header, |
| 503 | unsigned char **data,long *len); | 507 | unsigned char **data,long *len); |
| 504 | int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); | 508 | int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); |
| @@ -524,8 +528,7 @@ void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); | |||
| 524 | int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, | 528 | int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, |
| 525 | unsigned int *siglen, EVP_PKEY *pkey); | 529 | unsigned int *siglen, EVP_PKEY *pkey); |
| 526 | 530 | ||
| 527 | void ERR_load_PEM_strings(void); | 531 | int PEM_def_callback(char *buf, int num, int w, void *key); |
| 528 | |||
| 529 | void PEM_proc_type(char *buf, int type); | 532 | void PEM_proc_type(char *buf, int type); |
| 530 | void PEM_dek_info(char *buf, const char *type, int len, char *str); | 533 | void PEM_dek_info(char *buf, const char *type, int len, char *str); |
| 531 | 534 | ||
| @@ -550,7 +553,7 @@ DECLARE_PEM_rw(PKCS8, X509_SIG) | |||
| 550 | 553 | ||
| 551 | DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) | 554 | DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) |
| 552 | 555 | ||
| 553 | #ifndef NO_RSA | 556 | #ifndef OPENSSL_NO_RSA |
| 554 | 557 | ||
| 555 | DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) | 558 | DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) |
| 556 | 559 | ||
| @@ -559,7 +562,7 @@ DECLARE_PEM_rw(RSA_PUBKEY, RSA) | |||
| 559 | 562 | ||
| 560 | #endif | 563 | #endif |
| 561 | 564 | ||
| 562 | #ifndef NO_DSA | 565 | #ifndef OPENSSL_NO_DSA |
| 563 | 566 | ||
| 564 | DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) | 567 | DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) |
| 565 | 568 | ||
| @@ -569,7 +572,7 @@ DECLARE_PEM_rw(DSAparams, DSA) | |||
| 569 | 572 | ||
| 570 | #endif | 573 | #endif |
| 571 | 574 | ||
| 572 | #ifndef NO_DH | 575 | #ifndef OPENSSL_NO_DH |
| 573 | 576 | ||
| 574 | DECLARE_PEM_rw(DHparams, DH) | 577 | DECLARE_PEM_rw(DHparams, DH) |
| 575 | 578 | ||
| @@ -614,6 +617,7 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, | |||
| 614 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 617 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 615 | * made after this point may be overwritten when the script is next run. | 618 | * made after this point may be overwritten when the script is next run. |
| 616 | */ | 619 | */ |
| 620 | void ERR_load_PEM_strings(void); | ||
| 617 | 621 | ||
| 618 | /* Error codes for the PEM functions. */ | 622 | /* Error codes for the PEM functions. */ |
| 619 | 623 | ||
| @@ -664,4 +668,3 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, | |||
| 664 | } | 668 | } |
| 665 | #endif | 669 | #endif |
| 666 | #endif | 670 | #endif |
| 667 | |||
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c index dc9c35b4b4..e72b7134ce 100644 --- a/src/lib/libcrypto/pem/pem_all.c +++ b/src/lib/libcrypto/pem/pem_all.c | |||
| @@ -65,17 +65,13 @@ | |||
| 65 | #include <openssl/pkcs7.h> | 65 | #include <openssl/pkcs7.h> |
| 66 | #include <openssl/pem.h> | 66 | #include <openssl/pem.h> |
| 67 | 67 | ||
| 68 | #ifndef NO_RSA | 68 | #ifndef OPENSSL_NO_RSA |
| 69 | static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa); | 69 | static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa); |
| 70 | #endif | 70 | #endif |
| 71 | #ifndef NO_DSA | 71 | #ifndef OPENSSL_NO_DSA |
| 72 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa); | 72 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa); |
| 73 | #endif | 73 | #endif |
| 74 | 74 | ||
| 75 | IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) | ||
| 76 | |||
| 77 | IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX) | ||
| 78 | |||
| 79 | IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) | 75 | IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) |
| 80 | 76 | ||
| 81 | IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) | 77 | IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) |
| @@ -87,11 +83,8 @@ IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) | |||
| 87 | IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE, | 83 | IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE, |
| 88 | PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE) | 84 | PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE) |
| 89 | 85 | ||
| 90 | IMPLEMENT_PEM_rw(PKCS8, X509_SIG, PEM_STRING_PKCS8, X509_SIG) | ||
| 91 | IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, | ||
| 92 | PKCS8_PRIV_KEY_INFO) | ||
| 93 | 86 | ||
| 94 | #ifndef NO_RSA | 87 | #ifndef OPENSSL_NO_RSA |
| 95 | 88 | ||
| 96 | /* We treat RSA or DSA private keys as a special case. | 89 | /* We treat RSA or DSA private keys as a special case. |
| 97 | * | 90 | * |
| @@ -123,7 +116,7 @@ RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, | |||
| 123 | return pkey_get_rsa(pktmp, rsa); | 116 | return pkey_get_rsa(pktmp, rsa); |
| 124 | } | 117 | } |
| 125 | 118 | ||
| 126 | #ifndef NO_FP_API | 119 | #ifndef OPENSSL_NO_FP_API |
| 127 | 120 | ||
| 128 | RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, | 121 | RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, |
| 129 | void *u) | 122 | void *u) |
| @@ -141,7 +134,7 @@ IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) | |||
| 141 | 134 | ||
| 142 | #endif | 135 | #endif |
| 143 | 136 | ||
| 144 | #ifndef NO_DSA | 137 | #ifndef OPENSSL_NO_DSA |
| 145 | 138 | ||
| 146 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa) | 139 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa) |
| 147 | { | 140 | { |
| @@ -168,7 +161,7 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, | |||
| 168 | IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) | 161 | IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) |
| 169 | IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) | 162 | IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) |
| 170 | 163 | ||
| 171 | #ifndef NO_FP_API | 164 | #ifndef OPENSSL_NO_FP_API |
| 172 | 165 | ||
| 173 | DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, | 166 | DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, |
| 174 | void *u) | 167 | void *u) |
| @@ -184,7 +177,7 @@ IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams) | |||
| 184 | 177 | ||
| 185 | #endif | 178 | #endif |
| 186 | 179 | ||
| 187 | #ifndef NO_DH | 180 | #ifndef OPENSSL_NO_DH |
| 188 | 181 | ||
| 189 | IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) | 182 | IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) |
| 190 | 183 | ||
| @@ -197,7 +190,7 @@ IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) | |||
| 197 | * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything | 190 | * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything |
| 198 | * appropriate.) | 191 | * appropriate.) |
| 199 | */ | 192 | */ |
| 200 | IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey) | ||
| 201 | IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) | 193 | IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) |
| 202 | 194 | ||
| 203 | IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) | 195 | IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) |
| 196 | |||
diff --git a/src/lib/libcrypto/pem/pem_err.c b/src/lib/libcrypto/pem/pem_err.c index 8b1789b11c..3b39b84d66 100644 --- a/src/lib/libcrypto/pem/pem_err.c +++ b/src/lib/libcrypto/pem/pem_err.c | |||
| @@ -63,7 +63,7 @@ | |||
| 63 | #include <openssl/pem.h> | 63 | #include <openssl/pem.h> |
| 64 | 64 | ||
| 65 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
| 66 | #ifndef NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
| 67 | static ERR_STRING_DATA PEM_str_functs[]= | 67 | static ERR_STRING_DATA PEM_str_functs[]= |
| 68 | { | 68 | { |
| 69 | {ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"}, | 69 | {ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"}, |
| @@ -122,7 +122,7 @@ void ERR_load_PEM_strings(void) | |||
| 122 | if (init) | 122 | if (init) |
| 123 | { | 123 | { |
| 124 | init=0; | 124 | init=0; |
| 125 | #ifndef NO_ERR | 125 | #ifndef OPENSSL_NO_ERR |
| 126 | ERR_load_strings(ERR_LIB_PEM,PEM_str_functs); | 126 | ERR_load_strings(ERR_LIB_PEM,PEM_str_functs); |
| 127 | ERR_load_strings(ERR_LIB_PEM,PEM_str_reasons); | 127 | ERR_load_strings(ERR_LIB_PEM,PEM_str_reasons); |
| 128 | #endif | 128 | #endif |
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c index f1694f1125..9a6dffb45c 100644 --- a/src/lib/libcrypto/pem/pem_info.c +++ b/src/lib/libcrypto/pem/pem_info.c | |||
| @@ -64,7 +64,7 @@ | |||
| 64 | #include <openssl/x509.h> | 64 | #include <openssl/x509.h> |
| 65 | #include <openssl/pem.h> | 65 | #include <openssl/pem.h> |
| 66 | 66 | ||
| 67 | #ifndef NO_FP_API | 67 | #ifndef OPENSSL_NO_FP_API |
| 68 | STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) | 68 | STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) |
| 69 | { | 69 | { |
| 70 | BIO *b; | 70 | BIO *b; |
| @@ -111,7 +111,7 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe | |||
| 111 | i=PEM_read_bio(bp,&name,&header,&data,&len); | 111 | i=PEM_read_bio(bp,&name,&header,&data,&len); |
| 112 | if (i == 0) | 112 | if (i == 0) |
| 113 | { | 113 | { |
| 114 | error=ERR_GET_REASON(ERR_peek_error()); | 114 | error=ERR_GET_REASON(ERR_peek_last_error()); |
| 115 | if (error == PEM_R_NO_START_LINE) | 115 | if (error == PEM_R_NO_START_LINE) |
| 116 | { | 116 | { |
| 117 | ERR_clear_error(); | 117 | ERR_clear_error(); |
| @@ -155,7 +155,7 @@ start: | |||
| 155 | pp=(char **)&(xi->crl); | 155 | pp=(char **)&(xi->crl); |
| 156 | } | 156 | } |
| 157 | else | 157 | else |
| 158 | #ifndef NO_RSA | 158 | #ifndef OPENSSL_NO_RSA |
| 159 | if (strcmp(name,PEM_STRING_RSA) == 0) | 159 | if (strcmp(name,PEM_STRING_RSA) == 0) |
| 160 | { | 160 | { |
| 161 | d2i=(char *(*)())d2i_RSAPrivateKey; | 161 | d2i=(char *(*)())d2i_RSAPrivateKey; |
| @@ -179,7 +179,7 @@ start: | |||
| 179 | } | 179 | } |
| 180 | else | 180 | else |
| 181 | #endif | 181 | #endif |
| 182 | #ifndef NO_DSA | 182 | #ifndef OPENSSL_NO_DSA |
| 183 | if (strcmp(name,PEM_STRING_DSA) == 0) | 183 | if (strcmp(name,PEM_STRING_DSA) == 0) |
| 184 | { | 184 | { |
| 185 | d2i=(char *(*)())d2i_DSAPrivateKey; | 185 | d2i=(char *(*)())d2i_DSAPrivateKey; |
| @@ -326,7 +326,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
| 326 | /* create the right magic header stuff */ | 326 | /* create the right magic header stuff */ |
| 327 | buf[0]='\0'; | 327 | buf[0]='\0'; |
| 328 | PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); | 328 | PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); |
| 329 | PEM_dek_info(buf,objstr,8,(char *)iv); | 329 | PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv); |
| 330 | 330 | ||
| 331 | /* use the normal code to write things out */ | 331 | /* use the normal code to write things out */ |
| 332 | i=PEM_write_bio(bp,PEM_STRING_RSA,buf,data,i); | 332 | i=PEM_write_bio(bp,PEM_STRING_RSA,buf,data,i); |
| @@ -335,7 +335,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
| 335 | else | 335 | else |
| 336 | { | 336 | { |
| 337 | /* Add DSA/DH */ | 337 | /* Add DSA/DH */ |
| 338 | #ifndef NO_RSA | 338 | #ifndef OPENSSL_NO_RSA |
| 339 | /* normal optionally encrypted stuff */ | 339 | /* normal optionally encrypted stuff */ |
| 340 | if (PEM_write_bio_RSAPrivateKey(bp, | 340 | if (PEM_write_bio_RSAPrivateKey(bp, |
| 341 | xi->x_pkey->dec_pkey->pkey.rsa, | 341 | xi->x_pkey->dec_pkey->pkey.rsa, |
| @@ -346,7 +346,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | /* if we have a certificate then write it out now */ | 348 | /* if we have a certificate then write it out now */ |
| 349 | if ((xi->x509 != NULL) || (PEM_write_bio_X509(bp,xi->x509) <= 0)) | 349 | if ((xi->x509 != NULL) && (PEM_write_bio_X509(bp,xi->x509) <= 0)) |
| 350 | goto err; | 350 | goto err; |
| 351 | 351 | ||
| 352 | /* we are ignoring anything else that is loaded into the X509_INFO | 352 | /* we are ignoring anything else that is loaded into the X509_INFO |
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index a17c3ed57f..18b751a91a 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c | |||
| @@ -65,7 +65,7 @@ | |||
| 65 | #include <openssl/x509.h> | 65 | #include <openssl/x509.h> |
| 66 | #include <openssl/pem.h> | 66 | #include <openssl/pem.h> |
| 67 | #include <openssl/pkcs12.h> | 67 | #include <openssl/pkcs12.h> |
| 68 | #ifndef NO_DES | 68 | #ifndef OPENSSL_NO_DES |
| 69 | #include <openssl/des.h> | 69 | #include <openssl/des.h> |
| 70 | #endif | 70 | #endif |
| 71 | 71 | ||
| @@ -73,21 +73,12 @@ const char *PEM_version="PEM" OPENSSL_VERSION_PTEXT; | |||
| 73 | 73 | ||
| 74 | #define MIN_LENGTH 4 | 74 | #define MIN_LENGTH 4 |
| 75 | 75 | ||
| 76 | static int def_callback(char *buf, int num, int w, void *userdata); | ||
| 77 | static int load_iv(unsigned char **fromp,unsigned char *to, int num); | 76 | static int load_iv(unsigned char **fromp,unsigned char *to, int num); |
| 78 | static int check_pem(const char *nm, const char *name); | 77 | static int check_pem(const char *nm, const char *name); |
| 79 | static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, | 78 | |
| 80 | int nid, const EVP_CIPHER *enc, | 79 | int PEM_def_callback(char *buf, int num, int w, void *key) |
| 81 | char *kstr, int klen, | ||
| 82 | pem_password_cb *cb, void *u); | ||
| 83 | static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, | ||
| 84 | int nid, const EVP_CIPHER *enc, | ||
| 85 | char *kstr, int klen, | ||
| 86 | pem_password_cb *cb, void *u); | ||
| 87 | |||
| 88 | static int def_callback(char *buf, int num, int w, void *key) | ||
| 89 | { | 80 | { |
| 90 | #ifdef NO_FP_API | 81 | #ifdef OPENSSL_NO_FP_API |
| 91 | /* We should not ever call the default callback routine from | 82 | /* We should not ever call the default callback routine from |
| 92 | * windows. */ | 83 | * windows. */ |
| 93 | PEMerr(PEM_F_DEF_CALLBACK,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 84 | PEMerr(PEM_F_DEF_CALLBACK,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| @@ -164,7 +155,7 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str) | |||
| 164 | buf[j+i*2+1]='\0'; | 155 | buf[j+i*2+1]='\0'; |
| 165 | } | 156 | } |
| 166 | 157 | ||
| 167 | #ifndef NO_FP_API | 158 | #ifndef OPENSSL_NO_FP_API |
| 168 | char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x, | 159 | char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x, |
| 169 | pem_password_cb *cb, void *u) | 160 | pem_password_cb *cb, void *u) |
| 170 | { | 161 | { |
| @@ -224,14 +215,14 @@ static int check_pem(const char *nm, const char *name) | |||
| 224 | return 0; | 215 | return 0; |
| 225 | } | 216 | } |
| 226 | 217 | ||
| 227 | char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, | 218 | int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, |
| 228 | pem_password_cb *cb, void *u) | 219 | pem_password_cb *cb, void *u) |
| 229 | { | 220 | { |
| 230 | EVP_CIPHER_INFO cipher; | 221 | EVP_CIPHER_INFO cipher; |
| 231 | char *nm=NULL,*header=NULL; | 222 | char *nm=NULL,*header=NULL; |
| 232 | unsigned char *p=NULL,*data=NULL; | 223 | unsigned char *data=NULL; |
| 233 | long len; | 224 | long len; |
| 234 | char *ret=NULL; | 225 | int ret = 0; |
| 235 | 226 | ||
| 236 | for (;;) | 227 | for (;;) |
| 237 | { | 228 | { |
| @@ -239,7 +230,7 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, | |||
| 239 | if(ERR_GET_REASON(ERR_peek_error()) == | 230 | if(ERR_GET_REASON(ERR_peek_error()) == |
| 240 | PEM_R_NO_START_LINE) | 231 | PEM_R_NO_START_LINE) |
| 241 | ERR_add_error_data(2, "Expecting: ", name); | 232 | ERR_add_error_data(2, "Expecting: ", name); |
| 242 | return(NULL); | 233 | return 0; |
| 243 | } | 234 | } |
| 244 | if(check_pem(nm, name)) break; | 235 | if(check_pem(nm, name)) break; |
| 245 | OPENSSL_free(nm); | 236 | OPENSSL_free(nm); |
| @@ -248,54 +239,23 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, | |||
| 248 | } | 239 | } |
| 249 | if (!PEM_get_EVP_CIPHER_INFO(header,&cipher)) goto err; | 240 | if (!PEM_get_EVP_CIPHER_INFO(header,&cipher)) goto err; |
| 250 | if (!PEM_do_header(&cipher,data,&len,cb,u)) goto err; | 241 | if (!PEM_do_header(&cipher,data,&len,cb,u)) goto err; |
| 251 | p=data; | 242 | |
| 252 | if (strcmp(name,PEM_STRING_EVP_PKEY) == 0) { | 243 | *pdata = data; |
| 253 | if (strcmp(nm,PEM_STRING_RSA) == 0) | 244 | *plen = len; |
| 254 | ret=d2i(EVP_PKEY_RSA,x,&p,len); | 245 | |
| 255 | else if (strcmp(nm,PEM_STRING_DSA) == 0) | 246 | if (pnm) |
| 256 | ret=d2i(EVP_PKEY_DSA,x,&p,len); | 247 | *pnm = nm; |
| 257 | else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) { | 248 | |
| 258 | PKCS8_PRIV_KEY_INFO *p8inf; | 249 | ret = 1; |
| 259 | p8inf=d2i_PKCS8_PRIV_KEY_INFO( | 250 | |
| 260 | (PKCS8_PRIV_KEY_INFO **) x, &p, len); | ||
| 261 | ret = (char *)EVP_PKCS82PKEY(p8inf); | ||
| 262 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 263 | } else if (strcmp(nm,PEM_STRING_PKCS8) == 0) { | ||
| 264 | PKCS8_PRIV_KEY_INFO *p8inf; | ||
| 265 | X509_SIG *p8; | ||
| 266 | int klen; | ||
| 267 | char psbuf[PEM_BUFSIZE]; | ||
| 268 | p8 = d2i_X509_SIG(NULL, &p, len); | ||
| 269 | if(!p8) goto p8err; | ||
| 270 | if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); | ||
| 271 | else klen=def_callback(psbuf,PEM_BUFSIZE,0,u); | ||
| 272 | if (klen <= 0) { | ||
| 273 | PEMerr(PEM_F_PEM_ASN1_READ_BIO, | ||
| 274 | PEM_R_BAD_PASSWORD_READ); | ||
| 275 | goto err; | ||
| 276 | } | ||
| 277 | p8inf = M_PKCS8_decrypt(p8, psbuf, klen); | ||
| 278 | X509_SIG_free(p8); | ||
| 279 | if(!p8inf) goto p8err; | ||
| 280 | ret = (char *)EVP_PKCS82PKEY(p8inf); | ||
| 281 | if(x) { | ||
| 282 | if(*x) EVP_PKEY_free((EVP_PKEY *)*x); | ||
| 283 | *x = ret; | ||
| 284 | } | ||
| 285 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 286 | } | ||
| 287 | } else ret=d2i(x,&p,len); | ||
| 288 | p8err: | ||
| 289 | if (ret == NULL) | ||
| 290 | PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB); | ||
| 291 | err: | 251 | err: |
| 292 | OPENSSL_free(nm); | 252 | if (!pnm) OPENSSL_free(nm); |
| 293 | OPENSSL_free(header); | 253 | OPENSSL_free(header); |
| 294 | OPENSSL_free(data); | 254 | if (!ret) OPENSSL_free(data); |
| 295 | return(ret); | 255 | return ret; |
| 296 | } | 256 | } |
| 297 | 257 | ||
| 298 | #ifndef NO_FP_API | 258 | #ifndef OPENSSL_NO_FP_API |
| 299 | int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x, | 259 | int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x, |
| 300 | const EVP_CIPHER *enc, unsigned char *kstr, int klen, | 260 | const EVP_CIPHER *enc, unsigned char *kstr, int klen, |
| 301 | pem_password_cb *callback, void *u) | 261 | pem_password_cb *callback, void *u) |
| @@ -358,7 +318,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x, | |||
| 358 | if (kstr == NULL) | 318 | if (kstr == NULL) |
| 359 | { | 319 | { |
| 360 | if (callback == NULL) | 320 | if (callback == NULL) |
| 361 | klen=def_callback(buf,PEM_BUFSIZE,1,u); | 321 | klen=PEM_def_callback(buf,PEM_BUFSIZE,1,u); |
| 362 | else | 322 | else |
| 363 | klen=(*callback)(buf,PEM_BUFSIZE,1,u); | 323 | klen=(*callback)(buf,PEM_BUFSIZE,1,u); |
| 364 | if (klen <= 0) | 324 | if (klen <= 0) |
| @@ -373,7 +333,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x, | |||
| 373 | kstr=(unsigned char *)buf; | 333 | kstr=(unsigned char *)buf; |
| 374 | } | 334 | } |
| 375 | RAND_add(data,i,0);/* put in the RSA key. */ | 335 | RAND_add(data,i,0);/* put in the RSA key. */ |
| 376 | if (RAND_pseudo_bytes(iv,8) < 0) /* Generate a salt */ | 336 | if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */ |
| 377 | goto err; | 337 | goto err; |
| 378 | /* The 'iv' is used as the iv and as a salt. It is | 338 | /* The 'iv' is used as the iv and as a salt. It is |
| 379 | * NOT taken from the BytesToKey function */ | 339 | * NOT taken from the BytesToKey function */ |
| @@ -383,12 +343,14 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x, | |||
| 383 | 343 | ||
| 384 | buf[0]='\0'; | 344 | buf[0]='\0'; |
| 385 | PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); | 345 | PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); |
| 386 | PEM_dek_info(buf,objstr,8,(char *)iv); | 346 | PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv); |
| 387 | /* k=strlen(buf); */ | 347 | /* k=strlen(buf); */ |
| 388 | 348 | ||
| 389 | EVP_EncryptInit(&ctx,enc,key,iv); | 349 | EVP_CIPHER_CTX_init(&ctx); |
| 350 | EVP_EncryptInit_ex(&ctx,enc,NULL,key,iv); | ||
| 390 | EVP_EncryptUpdate(&ctx,data,&j,data,i); | 351 | EVP_EncryptUpdate(&ctx,data,&j,data,i); |
| 391 | EVP_EncryptFinal(&ctx,&(data[j]),&i); | 352 | EVP_EncryptFinal_ex(&ctx,&(data[j]),&i); |
| 353 | EVP_CIPHER_CTX_cleanup(&ctx); | ||
| 392 | i+=j; | 354 | i+=j; |
| 393 | ret=1; | 355 | ret=1; |
| 394 | } | 356 | } |
| @@ -422,7 +384,7 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen, | |||
| 422 | 384 | ||
| 423 | if (cipher->cipher == NULL) return(1); | 385 | if (cipher->cipher == NULL) return(1); |
| 424 | if (callback == NULL) | 386 | if (callback == NULL) |
| 425 | klen=def_callback(buf,PEM_BUFSIZE,0,u); | 387 | klen=PEM_def_callback(buf,PEM_BUFSIZE,0,u); |
| 426 | else | 388 | else |
| 427 | klen=callback(buf,PEM_BUFSIZE,0,u); | 389 | klen=callback(buf,PEM_BUFSIZE,0,u); |
| 428 | if (klen <= 0) | 390 | if (klen <= 0) |
| @@ -439,9 +401,10 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen, | |||
| 439 | (unsigned char *)buf,klen,1,key,NULL); | 401 | (unsigned char *)buf,klen,1,key,NULL); |
| 440 | 402 | ||
| 441 | j=(int)len; | 403 | j=(int)len; |
| 442 | EVP_DecryptInit(&ctx,cipher->cipher,key,&(cipher->iv[0])); | 404 | EVP_CIPHER_CTX_init(&ctx); |
| 405 | EVP_DecryptInit_ex(&ctx,cipher->cipher,NULL, key,&(cipher->iv[0])); | ||
| 443 | EVP_DecryptUpdate(&ctx,data,&i,data,j); | 406 | EVP_DecryptUpdate(&ctx,data,&i,data,j); |
| 444 | o=EVP_DecryptFinal(&ctx,&(data[i]),&j); | 407 | o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); |
| 445 | EVP_CIPHER_CTX_cleanup(&ctx); | 408 | EVP_CIPHER_CTX_cleanup(&ctx); |
| 446 | memset((char *)buf,0,sizeof(buf)); | 409 | memset((char *)buf,0,sizeof(buf)); |
| 447 | memset((char *)key,0,sizeof(key)); | 410 | memset((char *)key,0,sizeof(key)); |
| @@ -506,7 +469,7 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) | |||
| 506 | PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO,PEM_R_UNSUPPORTED_ENCRYPTION); | 469 | PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO,PEM_R_UNSUPPORTED_ENCRYPTION); |
| 507 | return(0); | 470 | return(0); |
| 508 | } | 471 | } |
| 509 | if (!load_iv((unsigned char **)&header,&(cipher->iv[0]),8)) return(0); | 472 | if (!load_iv((unsigned char **)&header,&(cipher->iv[0]),enc->iv_len)) return(0); |
| 510 | 473 | ||
| 511 | return(1); | 474 | return(1); |
| 512 | } | 475 | } |
| @@ -540,7 +503,7 @@ static int load_iv(unsigned char **fromp, unsigned char *to, int num) | |||
| 540 | return(1); | 503 | return(1); |
| 541 | } | 504 | } |
| 542 | 505 | ||
| 543 | #ifndef NO_FP_API | 506 | #ifndef OPENSSL_NO_FP_API |
| 544 | int PEM_write(FILE *fp, char *name, char *header, unsigned char *data, | 507 | int PEM_write(FILE *fp, char *name, char *header, unsigned char *data, |
| 545 | long len) | 508 | long len) |
| 546 | { | 509 | { |
| @@ -614,7 +577,7 @@ err: | |||
| 614 | return(0); | 577 | return(0); |
| 615 | } | 578 | } |
| 616 | 579 | ||
| 617 | #ifndef NO_FP_API | 580 | #ifndef OPENSSL_NO_FP_API |
| 618 | int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, | 581 | int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, |
| 619 | long *len) | 582 | long *len) |
| 620 | { | 583 | { |
| @@ -794,170 +757,3 @@ err: | |||
| 794 | BUF_MEM_free(dataB); | 757 | BUF_MEM_free(dataB); |
| 795 | return(0); | 758 | return(0); |
| 796 | } | 759 | } |
| 797 | |||
| 798 | /* These functions write a private key in PKCS#8 format: it is a "drop in" | ||
| 799 | * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc' | ||
| 800 | * is NULL then it uses the unencrypted private key form. The 'nid' versions | ||
| 801 | * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0. | ||
| 802 | */ | ||
| 803 | |||
| 804 | int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, | ||
| 805 | char *kstr, int klen, | ||
| 806 | pem_password_cb *cb, void *u) | ||
| 807 | { | ||
| 808 | return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u); | ||
| 809 | } | ||
| 810 | |||
| 811 | int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 812 | char *kstr, int klen, | ||
| 813 | pem_password_cb *cb, void *u) | ||
| 814 | { | ||
| 815 | return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u); | ||
| 816 | } | ||
| 817 | |||
| 818 | int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 819 | char *kstr, int klen, | ||
| 820 | pem_password_cb *cb, void *u) | ||
| 821 | { | ||
| 822 | return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u); | ||
| 823 | } | ||
| 824 | |||
| 825 | int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, | ||
| 826 | char *kstr, int klen, | ||
| 827 | pem_password_cb *cb, void *u) | ||
| 828 | { | ||
| 829 | return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u); | ||
| 830 | } | ||
| 831 | |||
| 832 | static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, | ||
| 833 | char *kstr, int klen, | ||
| 834 | pem_password_cb *cb, void *u) | ||
| 835 | { | ||
| 836 | X509_SIG *p8; | ||
| 837 | PKCS8_PRIV_KEY_INFO *p8inf; | ||
| 838 | char buf[PEM_BUFSIZE]; | ||
| 839 | int ret; | ||
| 840 | if(!(p8inf = EVP_PKEY2PKCS8(x))) { | ||
| 841 | PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY, | ||
| 842 | PEM_R_ERROR_CONVERTING_PRIVATE_KEY); | ||
| 843 | return 0; | ||
| 844 | } | ||
| 845 | if(enc || (nid != -1)) { | ||
| 846 | if(!kstr) { | ||
| 847 | if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u); | ||
| 848 | else klen = cb(buf, PEM_BUFSIZE, 1, u); | ||
| 849 | if(klen <= 0) { | ||
| 850 | PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY, | ||
| 851 | PEM_R_READ_KEY); | ||
| 852 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 853 | return 0; | ||
| 854 | } | ||
| 855 | |||
| 856 | kstr = buf; | ||
| 857 | } | ||
| 858 | p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf); | ||
| 859 | if(kstr == buf) memset(buf, 0, klen); | ||
| 860 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 861 | if(isder) ret = i2d_PKCS8_bio(bp, p8); | ||
| 862 | else ret = PEM_write_bio_PKCS8(bp, p8); | ||
| 863 | X509_SIG_free(p8); | ||
| 864 | return ret; | ||
| 865 | } else { | ||
| 866 | if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf); | ||
| 867 | else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf); | ||
| 868 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 869 | return ret; | ||
| 870 | } | ||
| 871 | } | ||
| 872 | |||
| 873 | /* Finally the DER version to read PKCS#8 encrypted private keys. It has to be | ||
| 874 | * here to access the default callback. | ||
| 875 | */ | ||
| 876 | |||
| 877 | EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 878 | { | ||
| 879 | PKCS8_PRIV_KEY_INFO *p8inf = NULL; | ||
| 880 | X509_SIG *p8 = NULL; | ||
| 881 | int klen; | ||
| 882 | EVP_PKEY *ret; | ||
| 883 | char psbuf[PEM_BUFSIZE]; | ||
| 884 | p8 = d2i_PKCS8_bio(bp, NULL); | ||
| 885 | if(!p8) return NULL; | ||
| 886 | if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); | ||
| 887 | else klen=def_callback(psbuf,PEM_BUFSIZE,0,u); | ||
| 888 | if (klen <= 0) { | ||
| 889 | PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_BIO, PEM_R_BAD_PASSWORD_READ); | ||
| 890 | X509_SIG_free(p8); | ||
| 891 | return NULL; | ||
| 892 | } | ||
| 893 | p8inf = M_PKCS8_decrypt(p8, psbuf, klen); | ||
| 894 | X509_SIG_free(p8); | ||
| 895 | if(!p8inf) return NULL; | ||
| 896 | ret = EVP_PKCS82PKEY(p8inf); | ||
| 897 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 898 | if(!ret) return NULL; | ||
| 899 | if(x) { | ||
| 900 | if(*x) EVP_PKEY_free(*x); | ||
| 901 | *x = ret; | ||
| 902 | } | ||
| 903 | return ret; | ||
| 904 | } | ||
| 905 | |||
| 906 | #ifndef NO_FP_API | ||
| 907 | |||
| 908 | int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 909 | char *kstr, int klen, | ||
| 910 | pem_password_cb *cb, void *u) | ||
| 911 | { | ||
| 912 | return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u); | ||
| 913 | } | ||
| 914 | |||
| 915 | int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, | ||
| 916 | char *kstr, int klen, | ||
| 917 | pem_password_cb *cb, void *u) | ||
| 918 | { | ||
| 919 | return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u); | ||
| 920 | } | ||
| 921 | |||
| 922 | int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, | ||
| 923 | char *kstr, int klen, | ||
| 924 | pem_password_cb *cb, void *u) | ||
| 925 | { | ||
| 926 | return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u); | ||
| 927 | } | ||
| 928 | |||
| 929 | int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 930 | char *kstr, int klen, pem_password_cb *cb, void *u) | ||
| 931 | { | ||
| 932 | return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u); | ||
| 933 | } | ||
| 934 | |||
| 935 | static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, | ||
| 936 | char *kstr, int klen, | ||
| 937 | pem_password_cb *cb, void *u) | ||
| 938 | { | ||
| 939 | BIO *bp; | ||
| 940 | int ret; | ||
| 941 | if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 942 | PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB); | ||
| 943 | return(0); | ||
| 944 | } | ||
| 945 | ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u); | ||
| 946 | BIO_free(bp); | ||
| 947 | return ret; | ||
| 948 | } | ||
| 949 | |||
| 950 | EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 951 | { | ||
| 952 | BIO *bp; | ||
| 953 | EVP_PKEY *ret; | ||
| 954 | if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 955 | PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB); | ||
| 956 | return NULL; | ||
| 957 | } | ||
| 958 | ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u); | ||
| 959 | BIO_free(bp); | ||
| 960 | return ret; | ||
| 961 | } | ||
| 962 | |||
| 963 | #endif | ||
diff --git a/src/lib/libcrypto/pem/pem_oth.c b/src/lib/libcrypto/pem/pem_oth.c new file mode 100644 index 0000000000..8d9064ea7c --- /dev/null +++ b/src/lib/libcrypto/pem/pem_oth.c | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | /* crypto/pem/pem_oth.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/buffer.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/rand.h> | ||
| 65 | #include <openssl/x509.h> | ||
| 66 | #include <openssl/pem.h> | ||
| 67 | |||
| 68 | /* Handle 'other' PEMs: not private keys */ | ||
| 69 | |||
| 70 | char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, | ||
| 71 | pem_password_cb *cb, void *u) | ||
| 72 | { | ||
| 73 | unsigned char *p=NULL,*data=NULL; | ||
| 74 | long len; | ||
| 75 | char *ret=NULL; | ||
| 76 | |||
| 77 | if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u)) | ||
| 78 | return NULL; | ||
| 79 | p = data; | ||
| 80 | ret=d2i(x,&p,len); | ||
| 81 | if (ret == NULL) | ||
| 82 | PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB); | ||
| 83 | OPENSSL_free(data); | ||
| 84 | return(ret); | ||
| 85 | } | ||
diff --git a/src/lib/libcrypto/pem/pem_pk8.c b/src/lib/libcrypto/pem/pem_pk8.c new file mode 100644 index 0000000000..f44182ffb5 --- /dev/null +++ b/src/lib/libcrypto/pem/pem_pk8.c | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | /* crypto/pem/pem_pkey.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/buffer.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/rand.h> | ||
| 65 | #include <openssl/x509.h> | ||
| 66 | #include <openssl/pkcs12.h> | ||
| 67 | #include <openssl/pem.h> | ||
| 68 | |||
| 69 | static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, | ||
| 70 | int nid, const EVP_CIPHER *enc, | ||
| 71 | char *kstr, int klen, | ||
| 72 | pem_password_cb *cb, void *u); | ||
| 73 | static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, | ||
| 74 | int nid, const EVP_CIPHER *enc, | ||
| 75 | char *kstr, int klen, | ||
| 76 | pem_password_cb *cb, void *u); | ||
| 77 | |||
| 78 | /* These functions write a private key in PKCS#8 format: it is a "drop in" | ||
| 79 | * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc' | ||
| 80 | * is NULL then it uses the unencrypted private key form. The 'nid' versions | ||
| 81 | * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0. | ||
| 82 | */ | ||
| 83 | |||
| 84 | int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, | ||
| 85 | char *kstr, int klen, | ||
| 86 | pem_password_cb *cb, void *u) | ||
| 87 | { | ||
| 88 | return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u); | ||
| 89 | } | ||
| 90 | |||
| 91 | int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 92 | char *kstr, int klen, | ||
| 93 | pem_password_cb *cb, void *u) | ||
| 94 | { | ||
| 95 | return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u); | ||
| 96 | } | ||
| 97 | |||
| 98 | int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 99 | char *kstr, int klen, | ||
| 100 | pem_password_cb *cb, void *u) | ||
| 101 | { | ||
| 102 | return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u); | ||
| 103 | } | ||
| 104 | |||
| 105 | int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, | ||
| 106 | char *kstr, int klen, | ||
| 107 | pem_password_cb *cb, void *u) | ||
| 108 | { | ||
| 109 | return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u); | ||
| 110 | } | ||
| 111 | |||
| 112 | static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, | ||
| 113 | char *kstr, int klen, | ||
| 114 | pem_password_cb *cb, void *u) | ||
| 115 | { | ||
| 116 | X509_SIG *p8; | ||
| 117 | PKCS8_PRIV_KEY_INFO *p8inf; | ||
| 118 | char buf[PEM_BUFSIZE]; | ||
| 119 | int ret; | ||
| 120 | if(!(p8inf = EVP_PKEY2PKCS8(x))) { | ||
| 121 | PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY, | ||
| 122 | PEM_R_ERROR_CONVERTING_PRIVATE_KEY); | ||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | if(enc || (nid != -1)) { | ||
| 126 | if(!kstr) { | ||
| 127 | if(!cb) klen = PEM_def_callback(buf, PEM_BUFSIZE, 1, u); | ||
| 128 | else klen = cb(buf, PEM_BUFSIZE, 1, u); | ||
| 129 | if(klen <= 0) { | ||
| 130 | PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY, | ||
| 131 | PEM_R_READ_KEY); | ||
| 132 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 133 | return 0; | ||
| 134 | } | ||
| 135 | |||
| 136 | kstr = buf; | ||
| 137 | } | ||
| 138 | p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf); | ||
| 139 | if(kstr == buf) memset(buf, 0, klen); | ||
| 140 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 141 | if(isder) ret = i2d_PKCS8_bio(bp, p8); | ||
| 142 | else ret = PEM_write_bio_PKCS8(bp, p8); | ||
| 143 | X509_SIG_free(p8); | ||
| 144 | return ret; | ||
| 145 | } else { | ||
| 146 | if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf); | ||
| 147 | else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf); | ||
| 148 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 149 | return ret; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 154 | { | ||
| 155 | PKCS8_PRIV_KEY_INFO *p8inf = NULL; | ||
| 156 | X509_SIG *p8 = NULL; | ||
| 157 | int klen; | ||
| 158 | EVP_PKEY *ret; | ||
| 159 | char psbuf[PEM_BUFSIZE]; | ||
| 160 | p8 = d2i_PKCS8_bio(bp, NULL); | ||
| 161 | if(!p8) return NULL; | ||
| 162 | if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); | ||
| 163 | else klen=PEM_def_callback(psbuf,PEM_BUFSIZE,0,u); | ||
| 164 | if (klen <= 0) { | ||
| 165 | PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_BIO, PEM_R_BAD_PASSWORD_READ); | ||
| 166 | X509_SIG_free(p8); | ||
| 167 | return NULL; | ||
| 168 | } | ||
| 169 | p8inf = PKCS8_decrypt(p8, psbuf, klen); | ||
| 170 | X509_SIG_free(p8); | ||
| 171 | if(!p8inf) return NULL; | ||
| 172 | ret = EVP_PKCS82PKEY(p8inf); | ||
| 173 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 174 | if(!ret) return NULL; | ||
| 175 | if(x) { | ||
| 176 | if(*x) EVP_PKEY_free(*x); | ||
| 177 | *x = ret; | ||
| 178 | } | ||
| 179 | return ret; | ||
| 180 | } | ||
| 181 | |||
| 182 | #ifndef OPENSSL_NO_FP_API | ||
| 183 | |||
| 184 | int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 185 | char *kstr, int klen, | ||
| 186 | pem_password_cb *cb, void *u) | ||
| 187 | { | ||
| 188 | return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u); | ||
| 189 | } | ||
| 190 | |||
| 191 | int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, | ||
| 192 | char *kstr, int klen, | ||
| 193 | pem_password_cb *cb, void *u) | ||
| 194 | { | ||
| 195 | return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u); | ||
| 196 | } | ||
| 197 | |||
| 198 | int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, | ||
| 199 | char *kstr, int klen, | ||
| 200 | pem_password_cb *cb, void *u) | ||
| 201 | { | ||
| 202 | return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u); | ||
| 203 | } | ||
| 204 | |||
| 205 | int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 206 | char *kstr, int klen, pem_password_cb *cb, void *u) | ||
| 207 | { | ||
| 208 | return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u); | ||
| 209 | } | ||
| 210 | |||
| 211 | static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, | ||
| 212 | char *kstr, int klen, | ||
| 213 | pem_password_cb *cb, void *u) | ||
| 214 | { | ||
| 215 | BIO *bp; | ||
| 216 | int ret; | ||
| 217 | if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 218 | PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB); | ||
| 219 | return(0); | ||
| 220 | } | ||
| 221 | ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u); | ||
| 222 | BIO_free(bp); | ||
| 223 | return ret; | ||
| 224 | } | ||
| 225 | |||
| 226 | EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 227 | { | ||
| 228 | BIO *bp; | ||
| 229 | EVP_PKEY *ret; | ||
| 230 | if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 231 | PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB); | ||
| 232 | return NULL; | ||
| 233 | } | ||
| 234 | ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u); | ||
| 235 | BIO_free(bp); | ||
| 236 | return ret; | ||
| 237 | } | ||
| 238 | |||
| 239 | #endif | ||
| 240 | |||
| 241 | IMPLEMENT_PEM_rw(PKCS8, X509_SIG, PEM_STRING_PKCS8, X509_SIG) | ||
| 242 | IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, | ||
| 243 | PKCS8_PRIV_KEY_INFO) | ||
diff --git a/src/lib/libcrypto/pem/pem_pkey.c b/src/lib/libcrypto/pem/pem_pkey.c new file mode 100644 index 0000000000..270892d72b --- /dev/null +++ b/src/lib/libcrypto/pem/pem_pkey.c | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | /* crypto/pem/pem_pkey.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/buffer.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/rand.h> | ||
| 65 | #include <openssl/x509.h> | ||
| 66 | #include <openssl/pkcs12.h> | ||
| 67 | #include <openssl/pem.h> | ||
| 68 | |||
| 69 | |||
| 70 | EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 71 | { | ||
| 72 | char *nm=NULL; | ||
| 73 | unsigned char *p=NULL,*data=NULL; | ||
| 74 | long len; | ||
| 75 | EVP_PKEY *ret=NULL; | ||
| 76 | |||
| 77 | if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u)) | ||
| 78 | return NULL; | ||
| 79 | p = data; | ||
| 80 | |||
| 81 | if (strcmp(nm,PEM_STRING_RSA) == 0) | ||
| 82 | ret=d2i_PrivateKey(EVP_PKEY_RSA,x,&p,len); | ||
| 83 | else if (strcmp(nm,PEM_STRING_DSA) == 0) | ||
| 84 | ret=d2i_PrivateKey(EVP_PKEY_DSA,x,&p,len); | ||
| 85 | else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) { | ||
| 86 | PKCS8_PRIV_KEY_INFO *p8inf; | ||
| 87 | p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len); | ||
| 88 | ret = EVP_PKCS82PKEY(p8inf); | ||
| 89 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 90 | } else if (strcmp(nm,PEM_STRING_PKCS8) == 0) { | ||
| 91 | PKCS8_PRIV_KEY_INFO *p8inf; | ||
| 92 | X509_SIG *p8; | ||
| 93 | int klen; | ||
| 94 | char psbuf[PEM_BUFSIZE]; | ||
| 95 | p8 = d2i_X509_SIG(NULL, &p, len); | ||
| 96 | if(!p8) goto p8err; | ||
| 97 | if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u); | ||
| 98 | else klen=PEM_def_callback(psbuf,PEM_BUFSIZE,0,u); | ||
| 99 | if (klen <= 0) { | ||
| 100 | PEMerr(PEM_F_PEM_ASN1_READ_BIO, | ||
| 101 | PEM_R_BAD_PASSWORD_READ); | ||
| 102 | goto err; | ||
| 103 | } | ||
| 104 | p8inf = PKCS8_decrypt(p8, psbuf, klen); | ||
| 105 | X509_SIG_free(p8); | ||
| 106 | if(!p8inf) goto p8err; | ||
| 107 | ret = EVP_PKCS82PKEY(p8inf); | ||
| 108 | if(x) { | ||
| 109 | if(*x) EVP_PKEY_free((EVP_PKEY *)*x); | ||
| 110 | *x = ret; | ||
| 111 | } | ||
| 112 | PKCS8_PRIV_KEY_INFO_free(p8inf); | ||
| 113 | } | ||
| 114 | p8err: | ||
| 115 | if (ret == NULL) | ||
| 116 | PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB); | ||
| 117 | err: | ||
| 118 | OPENSSL_free(nm); | ||
| 119 | OPENSSL_free(data); | ||
| 120 | return(ret); | ||
| 121 | } | ||
| 122 | |||
| 123 | #ifndef OPENSSL_NO_FP_API | ||
| 124 | EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) | ||
| 125 | { | ||
| 126 | BIO *b; | ||
| 127 | EVP_PKEY *ret; | ||
| 128 | |||
| 129 | if ((b=BIO_new(BIO_s_file())) == NULL) | ||
| 130 | { | ||
| 131 | PEMerr(PEM_F_PEM_ASN1_READ,ERR_R_BUF_LIB); | ||
| 132 | return(0); | ||
| 133 | } | ||
| 134 | BIO_set_fp(b,fp,BIO_NOCLOSE); | ||
| 135 | ret=PEM_read_bio_PrivateKey(b,x,cb,u); | ||
| 136 | BIO_free(b); | ||
| 137 | return(ret); | ||
| 138 | } | ||
| 139 | #endif | ||
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c index 2a6c513348..ae463a301d 100644 --- a/src/lib/libcrypto/pem/pem_seal.c +++ b/src/lib/libcrypto/pem/pem_seal.c | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #ifndef NO_RSA | 59 | #ifndef OPENSSL_NO_RSA |
| 60 | #include <stdio.h> | 60 | #include <stdio.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
| @@ -91,10 +91,13 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, | |||
| 91 | goto err; | 91 | goto err; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | EVP_EncodeInit(&(ctx->encode)); | 94 | EVP_EncodeInit(&ctx->encode); |
| 95 | EVP_SignInit(&(ctx->md),md_type); | ||
| 96 | 95 | ||
| 97 | ret=EVP_SealInit(&(ctx->cipher),type,ek,ekl,iv,pubk,npubk); | 96 | EVP_MD_CTX_init(&ctx->md); |
| 97 | EVP_SignInit(&ctx->md,md_type); | ||
| 98 | |||
| 99 | EVP_CIPHER_CTX_init(&ctx->cipher); | ||
| 100 | ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk); | ||
| 98 | if (!ret) goto err; | 101 | if (!ret) goto err; |
| 99 | 102 | ||
| 100 | /* base64 encode the keys */ | 103 | /* base64 encode the keys */ |
| @@ -120,7 +123,7 @@ void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, | |||
| 120 | int i,j; | 123 | int i,j; |
| 121 | 124 | ||
| 122 | *outl=0; | 125 | *outl=0; |
| 123 | EVP_SignUpdate(&(ctx->md),in,inl); | 126 | EVP_SignUpdate(&ctx->md,in,inl); |
| 124 | for (;;) | 127 | for (;;) |
| 125 | { | 128 | { |
| 126 | if (inl <= 0) break; | 129 | if (inl <= 0) break; |
| @@ -128,8 +131,8 @@ void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, | |||
| 128 | i=1200; | 131 | i=1200; |
| 129 | else | 132 | else |
| 130 | i=inl; | 133 | i=inl; |
| 131 | EVP_EncryptUpdate(&(ctx->cipher),buffer,&j,in,i); | 134 | EVP_EncryptUpdate(&ctx->cipher,buffer,&j,in,i); |
| 132 | EVP_EncodeUpdate(&(ctx->encode),out,&j,buffer,j); | 135 | EVP_EncodeUpdate(&ctx->encode,out,&j,buffer,j); |
| 133 | *outl+=j; | 136 | *outl+=j; |
| 134 | out+=j; | 137 | out+=j; |
| 135 | in+=i; | 138 | in+=i; |
| @@ -158,24 +161,24 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl, | |||
| 158 | goto err; | 161 | goto err; |
| 159 | } | 162 | } |
| 160 | 163 | ||
| 161 | EVP_EncryptFinal(&(ctx->cipher),s,(int *)&i); | 164 | EVP_EncryptFinal_ex(&ctx->cipher,s,(int *)&i); |
| 162 | EVP_EncodeUpdate(&(ctx->encode),out,&j,s,i); | 165 | EVP_EncodeUpdate(&ctx->encode,out,&j,s,i); |
| 163 | *outl=j; | 166 | *outl=j; |
| 164 | out+=j; | 167 | out+=j; |
| 165 | EVP_EncodeFinal(&(ctx->encode),out,&j); | 168 | EVP_EncodeFinal(&ctx->encode,out,&j); |
| 166 | *outl+=j; | 169 | *outl+=j; |
| 167 | 170 | ||
| 168 | if (!EVP_SignFinal(&(ctx->md),s,&i,priv)) goto err; | 171 | if (!EVP_SignFinal(&ctx->md,s,&i,priv)) goto err; |
| 169 | *sigl=EVP_EncodeBlock(sig,s,i); | 172 | *sigl=EVP_EncodeBlock(sig,s,i); |
| 170 | 173 | ||
| 171 | ret=1; | 174 | ret=1; |
| 172 | err: | 175 | err: |
| 173 | memset((char *)&(ctx->md),0,sizeof(ctx->md)); | 176 | EVP_MD_CTX_cleanup(&ctx->md); |
| 174 | memset((char *)&(ctx->cipher),0,sizeof(ctx->cipher)); | 177 | EVP_CIPHER_CTX_cleanup(&ctx->cipher); |
| 175 | if (s != NULL) OPENSSL_free(s); | 178 | if (s != NULL) OPENSSL_free(s); |
| 176 | return(ret); | 179 | return(ret); |
| 177 | } | 180 | } |
| 178 | #else /* !NO_RSA */ | 181 | #else /* !OPENSSL_NO_RSA */ |
| 179 | 182 | ||
| 180 | # if PEDANTIC | 183 | # if PEDANTIC |
| 181 | static void *dummy=&dummy; | 184 | static void *dummy=&dummy; |
diff --git a/src/lib/libcrypto/pem/pem_sign.c b/src/lib/libcrypto/pem/pem_sign.c index 42d598dd78..c3b9808cb2 100644 --- a/src/lib/libcrypto/pem/pem_sign.c +++ b/src/lib/libcrypto/pem/pem_sign.c | |||
| @@ -66,7 +66,7 @@ | |||
| 66 | 66 | ||
| 67 | void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) | 67 | void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) |
| 68 | { | 68 | { |
| 69 | EVP_DigestInit(ctx,type); | 69 | EVP_DigestInit_ex(ctx, type, NULL); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, | 72 | void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, |
diff --git a/src/lib/libcrypto/pem/pem_x509.c b/src/lib/libcrypto/pem/pem_x509.c new file mode 100644 index 0000000000..19f88d8d3a --- /dev/null +++ b/src/lib/libcrypto/pem/pem_x509.c | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | /* pem_x509.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2001 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 | #undef SSLEAY_MACROS | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/bio.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | #include <openssl/pkcs7.h> | ||
| 66 | #include <openssl/pem.h> | ||
| 67 | |||
| 68 | IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) | ||
| 69 | |||
diff --git a/src/lib/libcrypto/pem/pem_xaux.c b/src/lib/libcrypto/pem/pem_xaux.c new file mode 100644 index 0000000000..2f579b5421 --- /dev/null +++ b/src/lib/libcrypto/pem/pem_xaux.c | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | /* pem_xaux.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2001 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 | #undef SSLEAY_MACROS | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/bio.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | #include <openssl/pkcs7.h> | ||
| 66 | #include <openssl/pem.h> | ||
| 67 | |||
| 68 | IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX) | ||
