diff options
| author | djm <> | 2010-10-01 22:59:01 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:59:01 +0000 |
| commit | 8922d4bc4a8b8893d72a48deb2cdf58215f98505 (patch) | |
| tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/pem | |
| parent | 76262f7bf9262f965142b1b2b2105cb279c5c696 (diff) | |
| download | openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.gz openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.bz2 openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.zip | |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/pem')
| -rw-r--r-- | src/lib/libcrypto/pem/Makefile.ssl | 336 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem.h | 255 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_all.c | 194 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_err.c | 28 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_info.c | 40 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_lib.c | 100 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_pkey.c | 109 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_seal.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_x509.c | 1 | ||||
| -rw-r--r-- | src/lib/libcrypto/pem/pem_xaux.c | 1 |
10 files changed, 299 insertions, 767 deletions
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl deleted file mode 100644 index d3043eb401..0000000000 --- a/src/lib/libcrypto/pem/Makefile.ssl +++ /dev/null | |||
| @@ -1,336 +0,0 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/pem/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= pem | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST= | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 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 | ||
| 28 | |||
| 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 | ||
| 31 | |||
| 32 | SRC= $(LIBSRC) | ||
| 33 | |||
| 34 | EXHEADER= pem.h pem2.h | ||
| 35 | HEADER= $(EXHEADER) | ||
| 36 | |||
| 37 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 38 | |||
| 39 | top: | ||
| 40 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 41 | |||
| 42 | all: lib | ||
| 43 | |||
| 44 | lib: $(LIBOBJ) | ||
| 45 | $(AR) $(LIB) $(LIBOBJ) | ||
| 46 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 47 | @touch lib | ||
| 48 | |||
| 49 | files: | ||
| 50 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 51 | |||
| 52 | links: $(EXHEADER) | ||
| 53 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 54 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 55 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 56 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 57 | |||
| 58 | install: | ||
| 59 | @for i in $(EXHEADER) ; \ | ||
| 60 | do \ | ||
| 61 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 62 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 63 | done; | ||
| 64 | |||
| 65 | tags: | ||
| 66 | ctags $(SRC) | ||
| 67 | |||
| 68 | tests: | ||
| 69 | |||
| 70 | lint: | ||
| 71 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 72 | |||
| 73 | depend: | ||
| 74 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC) | ||
| 75 | |||
| 76 | dclean: | ||
| 77 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 78 | mv -f Makefile.new $(MAKEFILE) | ||
| 79 | |||
| 80 | clean: | ||
| 81 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 82 | |||
| 83 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 84 | |||
| 85 | pem_all.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 86 | pem_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 87 | pem_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 88 | pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 89 | pem_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 90 | pem_all.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 91 | pem_all.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 92 | pem_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 93 | pem_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 94 | pem_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 95 | pem_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 96 | pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 97 | pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 98 | pem_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 99 | pem_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | ||
| 100 | pem_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 101 | pem_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 102 | pem_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 103 | pem_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 104 | pem_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 105 | pem_all.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
| 106 | pem_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_all.c | ||
| 107 | pem_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
| 108 | pem_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
| 109 | pem_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 110 | pem_err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
| 111 | pem_err.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
| 112 | pem_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 113 | pem_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 114 | pem_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
| 115 | pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
| 116 | pem_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
| 117 | pem_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
| 118 | pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 119 | pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 120 | pem_err.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 121 | pem_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
| 122 | pem_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 123 | pem_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 124 | pem_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 125 | pem_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 126 | pem_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 127 | pem_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 128 | pem_err.o: pem_err.c | ||
| 129 | pem_info.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 130 | pem_info.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 131 | pem_info.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 132 | pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 133 | pem_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 134 | pem_info.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 135 | pem_info.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 136 | pem_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 137 | pem_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 138 | pem_info.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 139 | pem_info.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 140 | pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 141 | pem_info.o: ../../include/openssl/opensslconf.h | ||
| 142 | pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 143 | pem_info.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 144 | pem_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
| 145 | pem_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 146 | pem_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 147 | pem_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 148 | pem_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 149 | pem_info.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 150 | pem_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 151 | pem_info.o: ../cryptlib.h pem_info.c | ||
| 152 | pem_lib.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 153 | pem_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 154 | pem_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 155 | pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 156 | pem_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 157 | pem_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 158 | pem_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 159 | pem_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 160 | pem_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 161 | pem_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 162 | pem_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 163 | pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 164 | pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 165 | pem_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 166 | pem_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h | ||
| 167 | pem_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 168 | pem_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 169 | pem_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 170 | pem_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 171 | pem_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 172 | pem_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 173 | pem_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
| 174 | pem_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_lib.c | ||
| 175 | pem_oth.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 176 | pem_oth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 177 | pem_oth.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 178 | pem_oth.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 179 | pem_oth.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 180 | pem_oth.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 181 | pem_oth.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 182 | pem_oth.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 183 | pem_oth.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 184 | pem_oth.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 185 | pem_oth.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 186 | pem_oth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 187 | pem_oth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 188 | pem_oth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 189 | pem_oth.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | ||
| 190 | pem_oth.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
| 191 | pem_oth.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 192 | pem_oth.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 193 | pem_oth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 194 | pem_oth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 195 | pem_oth.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 196 | pem_oth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 197 | pem_oth.o: ../cryptlib.h pem_oth.c | ||
| 198 | pem_pk8.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 199 | pem_pk8.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 200 | pem_pk8.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 201 | pem_pk8.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 202 | pem_pk8.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 203 | pem_pk8.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 204 | pem_pk8.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 205 | pem_pk8.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 206 | pem_pk8.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 207 | pem_pk8.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 208 | pem_pk8.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 209 | pem_pk8.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 210 | pem_pk8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 211 | pem_pk8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 212 | pem_pk8.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h | ||
| 213 | pem_pk8.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 214 | pem_pk8.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 215 | pem_pk8.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 216 | pem_pk8.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 217 | pem_pk8.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 218 | pem_pk8.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 219 | pem_pk8.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
| 220 | pem_pk8.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_pk8.c | ||
| 221 | pem_pkey.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 222 | pem_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 223 | pem_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 224 | pem_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 225 | pem_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 226 | pem_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 227 | pem_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 228 | pem_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 229 | pem_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 230 | pem_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 231 | pem_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 232 | pem_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 233 | pem_pkey.o: ../../include/openssl/opensslconf.h | ||
| 234 | pem_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 235 | pem_pkey.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 236 | pem_pkey.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | ||
| 237 | pem_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
| 238 | pem_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 239 | pem_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 240 | pem_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 241 | pem_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 242 | pem_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 243 | pem_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 244 | pem_pkey.o: ../cryptlib.h pem_pkey.c | ||
| 245 | pem_seal.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 246 | pem_seal.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 247 | pem_seal.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 248 | pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 249 | pem_seal.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 250 | pem_seal.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 251 | pem_seal.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 252 | pem_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 253 | pem_seal.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 254 | pem_seal.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 255 | pem_seal.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 256 | pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 257 | pem_seal.o: ../../include/openssl/opensslconf.h | ||
| 258 | pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 259 | pem_seal.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 260 | pem_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 261 | pem_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 262 | pem_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 263 | pem_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 264 | pem_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 265 | pem_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 266 | pem_seal.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
| 267 | pem_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_seal.c | ||
| 268 | pem_sign.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 269 | pem_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 270 | pem_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 271 | pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 272 | pem_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 273 | pem_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 274 | pem_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 275 | pem_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 276 | pem_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 277 | pem_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 278 | pem_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 279 | pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 280 | pem_sign.o: ../../include/openssl/opensslconf.h | ||
| 281 | pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 282 | pem_sign.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 283 | pem_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 284 | pem_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 285 | pem_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 286 | pem_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 287 | pem_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 288 | pem_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 289 | pem_sign.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
| 290 | pem_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_sign.c | ||
| 291 | pem_x509.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 292 | pem_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 293 | pem_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 294 | pem_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 295 | pem_x509.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 296 | pem_x509.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 297 | pem_x509.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 298 | pem_x509.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 299 | pem_x509.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 300 | pem_x509.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 301 | pem_x509.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 302 | pem_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 303 | pem_x509.o: ../../include/openssl/opensslconf.h | ||
| 304 | pem_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 305 | pem_x509.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 306 | pem_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
| 307 | pem_x509.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 308 | pem_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 309 | pem_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 310 | pem_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 311 | pem_x509.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 312 | pem_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 313 | pem_x509.o: ../cryptlib.h pem_x509.c | ||
| 314 | pem_xaux.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 315 | pem_xaux.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 316 | pem_xaux.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 317 | pem_xaux.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 318 | pem_xaux.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 319 | pem_xaux.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 320 | pem_xaux.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 321 | pem_xaux.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 322 | pem_xaux.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 323 | pem_xaux.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 324 | pem_xaux.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 325 | pem_xaux.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 326 | pem_xaux.o: ../../include/openssl/opensslconf.h | ||
| 327 | pem_xaux.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 328 | pem_xaux.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 329 | pem_xaux.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
| 330 | pem_xaux.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 331 | pem_xaux.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 332 | pem_xaux.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 333 | pem_xaux.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 334 | pem_xaux.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 335 | pem_xaux.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 336 | 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 6c193f1cbf..8a6ababe3a 100644 --- a/src/lib/libcrypto/pem/pem.h +++ b/src/lib/libcrypto/pem/pem.h | |||
| @@ -134,6 +134,7 @@ extern "C" { | |||
| 134 | #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" | 134 | #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" |
| 135 | #define PEM_STRING_ECPARAMETERS "EC PARAMETERS" | 135 | #define PEM_STRING_ECPARAMETERS "EC PARAMETERS" |
| 136 | #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" | 136 | #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" |
| 137 | #define PEM_STRING_PARAMETERS "PARAMETERS" | ||
| 137 | #define PEM_STRING_CMS "CMS" | 138 | #define PEM_STRING_CMS "CMS" |
| 138 | 139 | ||
| 139 | /* Note that this structure is initialised by PEM_SealInit and cleaned up | 140 | /* Note that this structure is initialised by PEM_SealInit and cleaned up |
| @@ -183,11 +184,8 @@ typedef struct pem_ctx_st | |||
| 183 | int num_recipient; | 184 | int num_recipient; |
| 184 | PEM_USER **recipient; | 185 | PEM_USER **recipient; |
| 185 | 186 | ||
| 186 | #ifndef OPENSSL_NO_STACK | 187 | /* XXX(ben): don#t think this is used! |
| 187 | STACK *x509_chain; /* certificate chain */ | 188 | STACK *x509_chain; / * certificate chain */ |
| 188 | #else | ||
| 189 | char *x509_chain; /* certificate chain */ | ||
| 190 | #endif | ||
| 191 | EVP_MD *md; /* signature type */ | 189 | EVP_MD *md; /* signature type */ |
| 192 | 190 | ||
| 193 | int md_enc; /* is the md encrypted or not? */ | 191 | int md_enc; /* is the md encrypted or not? */ |
| @@ -224,28 +222,19 @@ typedef struct pem_ctx_st | |||
| 224 | #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ | 222 | #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ |
| 225 | type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ | 223 | type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ |
| 226 | { \ | 224 | { \ |
| 227 | return (type*)PEM_ASN1_read(CHECKED_D2I_OF(type, d2i_##asn1), \ | 225 | return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ |
| 228 | str, fp, \ | ||
| 229 | CHECKED_PPTR_OF(type, x), \ | ||
| 230 | cb, u); \ | ||
| 231 | } | 226 | } |
| 232 | 227 | ||
| 233 | #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ | 228 | #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ |
| 234 | int PEM_write_##name(FILE *fp, type *x) \ | 229 | int PEM_write_##name(FILE *fp, type *x) \ |
| 235 | { \ | 230 | { \ |
| 236 | return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \ | 231 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ |
| 237 | str, fp, \ | ||
| 238 | CHECKED_PTR_OF(type, x), \ | ||
| 239 | NULL, NULL, 0, NULL, NULL); \ | ||
| 240 | } | 232 | } |
| 241 | 233 | ||
| 242 | #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ | 234 | #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ |
| 243 | int PEM_write_##name(FILE *fp, const type *x) \ | 235 | int PEM_write_##name(FILE *fp, const type *x) \ |
| 244 | { \ | 236 | { \ |
| 245 | return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \ | 237 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ |
| 246 | str, fp, \ | ||
| 247 | CHECKED_PTR_OF(const type, x), \ | ||
| 248 | NULL, NULL, 0, NULL, NULL); \ | ||
| 249 | } | 238 | } |
| 250 | 239 | ||
| 251 | #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ | 240 | #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ |
| @@ -253,10 +242,7 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ | |||
| 253 | unsigned char *kstr, int klen, pem_password_cb *cb, \ | 242 | unsigned char *kstr, int klen, pem_password_cb *cb, \ |
| 254 | void *u) \ | 243 | void *u) \ |
| 255 | { \ | 244 | { \ |
| 256 | return PEM_ASN1_write(CHECKED_I2D_OF(type, i2d_##asn1), \ | 245 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ |
| 257 | str, fp, \ | ||
| 258 | CHECKED_PTR_OF(type, x), \ | ||
| 259 | enc, kstr, klen, cb, u); \ | ||
| 260 | } | 246 | } |
| 261 | 247 | ||
| 262 | #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ | 248 | #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ |
| @@ -264,10 +250,7 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ | |||
| 264 | unsigned char *kstr, int klen, pem_password_cb *cb, \ | 250 | unsigned char *kstr, int klen, pem_password_cb *cb, \ |
| 265 | void *u) \ | 251 | void *u) \ |
| 266 | { \ | 252 | { \ |
| 267 | return PEM_ASN1_write(CHECKED_I2D_OF(const type, i2d_##asn1), \ | 253 | return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ |
| 268 | str, fp, \ | ||
| 269 | CHECKED_PTR_OF(const type, x), \ | ||
| 270 | enc, kstr, klen, cb, u); \ | ||
| 271 | } | 254 | } |
| 272 | 255 | ||
| 273 | #endif | 256 | #endif |
| @@ -275,48 +258,33 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ | |||
| 275 | #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ | 258 | #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ |
| 276 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ | 259 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ |
| 277 | { \ | 260 | { \ |
| 278 | return (type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i_##asn1), \ | 261 | return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ |
| 279 | str, bp, \ | ||
| 280 | CHECKED_PPTR_OF(type, x), \ | ||
| 281 | cb, u); \ | ||
| 282 | } | 262 | } |
| 283 | 263 | ||
| 284 | #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ | 264 | #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ |
| 285 | int PEM_write_bio_##name(BIO *bp, type *x) \ | 265 | int PEM_write_bio_##name(BIO *bp, type *x) \ |
| 286 | { \ | 266 | { \ |
| 287 | return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \ | 267 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ |
| 288 | str, bp, \ | ||
| 289 | CHECKED_PTR_OF(type, x), \ | ||
| 290 | NULL, NULL, 0, NULL, NULL); \ | ||
| 291 | } | 268 | } |
| 292 | 269 | ||
| 293 | #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ | 270 | #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ |
| 294 | int PEM_write_bio_##name(BIO *bp, const type *x) \ | 271 | int PEM_write_bio_##name(BIO *bp, const type *x) \ |
| 295 | { \ | 272 | { \ |
| 296 | return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \ | 273 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ |
| 297 | str, bp, \ | ||
| 298 | CHECKED_PTR_OF(const type, x), \ | ||
| 299 | NULL, NULL, 0, NULL, NULL); \ | ||
| 300 | } | 274 | } |
| 301 | 275 | ||
| 302 | #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ | 276 | #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ |
| 303 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | 277 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ |
| 304 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ | 278 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ |
| 305 | { \ | 279 | { \ |
| 306 | return PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d_##asn1), \ | 280 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ |
| 307 | str, bp, \ | ||
| 308 | CHECKED_PTR_OF(type, x), \ | ||
| 309 | enc, kstr, klen, cb, u); \ | ||
| 310 | } | 281 | } |
| 311 | 282 | ||
| 312 | #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ | 283 | #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ |
| 313 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | 284 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ |
| 314 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ | 285 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ |
| 315 | { \ | 286 | { \ |
| 316 | return PEM_ASN1_write_bio(CHECKED_I2D_OF(const type, i2d_##asn1), \ | 287 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ |
| 317 | str, bp, \ | ||
| 318 | CHECKED_PTR_OF(const type, x), \ | ||
| 319 | enc, kstr, klen, cb, u); \ | ||
| 320 | } | 288 | } |
| 321 | 289 | ||
| 322 | #define IMPLEMENT_PEM_write(name, type, str, asn1) \ | 290 | #define IMPLEMENT_PEM_write(name, type, str, asn1) \ |
| @@ -353,11 +321,10 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |||
| 353 | 321 | ||
| 354 | /* These are the same except they are for the declarations */ | 322 | /* These are the same except they are for the declarations */ |
| 355 | 323 | ||
| 356 | #if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) | 324 | #if defined(OPENSSL_NO_FP_API) |
| 357 | 325 | ||
| 358 | #define DECLARE_PEM_read_fp(name, type) /**/ | 326 | #define DECLARE_PEM_read_fp(name, type) /**/ |
| 359 | #define DECLARE_PEM_write_fp(name, type) /**/ | 327 | #define DECLARE_PEM_write_fp(name, type) /**/ |
| 360 | #define DECLARE_PEM_write_fp_const(name, type) /**/ | ||
| 361 | #define DECLARE_PEM_write_cb_fp(name, type) /**/ | 328 | #define DECLARE_PEM_write_cb_fp(name, type) /**/ |
| 362 | 329 | ||
| 363 | #else | 330 | #else |
| @@ -428,138 +395,6 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |||
| 428 | DECLARE_PEM_read(name, type) \ | 395 | DECLARE_PEM_read(name, type) \ |
| 429 | DECLARE_PEM_write_cb(name, type) | 396 | DECLARE_PEM_write_cb(name, type) |
| 430 | 397 | ||
| 431 | #ifdef SSLEAY_MACROS | ||
| 432 | |||
| 433 | #define PEM_write_SSL_SESSION(fp,x) \ | ||
| 434 | PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ | ||
| 435 | PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 436 | #define PEM_write_X509(fp,x) \ | ||
| 437 | PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ | ||
| 438 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 439 | #define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ | ||
| 440 | (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ | ||
| 441 | NULL,NULL,0,NULL,NULL) | ||
| 442 | #define PEM_write_X509_CRL(fp,x) \ | ||
| 443 | PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ | ||
| 444 | fp,(char *)x, NULL,NULL,0,NULL,NULL) | ||
| 445 | #define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ | ||
| 446 | PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ | ||
| 447 | (char *)x,enc,kstr,klen,cb,u) | ||
| 448 | #define PEM_write_RSAPublicKey(fp,x) \ | ||
| 449 | PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ | ||
| 450 | PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) | ||
| 451 | #define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ | ||
| 452 | PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ | ||
| 453 | (char *)x,enc,kstr,klen,cb,u) | ||
| 454 | #define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ | ||
| 455 | PEM_ASN1_write((int (*)())i2d_PrivateKey,\ | ||
| 456 | (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ | ||
| 457 | bp,(char *)x,enc,kstr,klen,cb,u) | ||
| 458 | #define PEM_write_PKCS7(fp,x) \ | ||
| 459 | PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ | ||
| 460 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 461 | #define PEM_write_DHparams(fp,x) \ | ||
| 462 | PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ | ||
| 463 | (char *)x,NULL,NULL,0,NULL,NULL) | ||
| 464 | |||
| 465 | #define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ | ||
| 466 | PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ | ||
| 467 | PEM_STRING_X509,fp, \ | ||
| 468 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 469 | |||
| 470 | #define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ | ||
| 471 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) | ||
| 472 | #define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ | ||
| 473 | (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) | ||
| 474 | #define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ | ||
| 475 | (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) | ||
| 476 | #define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ | ||
| 477 | (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) | ||
| 478 | #define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ | ||
| 479 | (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) | ||
| 480 | #define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ | ||
| 481 | (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) | ||
| 482 | #define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ | ||
| 483 | (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) | ||
| 484 | #define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ | ||
| 485 | (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) | ||
| 486 | #define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ | ||
| 487 | (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) | ||
| 488 | #define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ | ||
| 489 | (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) | ||
| 490 | |||
| 491 | #define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ | ||
| 492 | (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ | ||
| 493 | (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ | ||
| 494 | (char **)x,cb,u) | ||
| 495 | |||
| 496 | #define PEM_write_bio_X509(bp,x) \ | ||
| 497 | PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ | ||
| 498 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 499 | #define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ | ||
| 500 | (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ | ||
| 501 | NULL,NULL,0,NULL,NULL) | ||
| 502 | #define PEM_write_bio_X509_CRL(bp,x) \ | ||
| 503 | PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ | ||
| 504 | bp,(char *)x, NULL,NULL,0,NULL,NULL) | ||
| 505 | #define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ | ||
| 506 | PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ | ||
| 507 | bp,(char *)x,enc,kstr,klen,cb,u) | ||
| 508 | #define PEM_write_bio_RSAPublicKey(bp,x) \ | ||
| 509 | PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ | ||
| 510 | PEM_STRING_RSA_PUBLIC,\ | ||
| 511 | bp,(char *)x,NULL,NULL,0,NULL,NULL) | ||
| 512 | #define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ | ||
| 513 | PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ | ||
| 514 | bp,(char *)x,enc,kstr,klen,cb,u) | ||
| 515 | #define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ | ||
| 516 | PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ | ||
| 517 | (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ | ||
| 518 | bp,(char *)x,enc,kstr,klen,cb,u) | ||
| 519 | #define PEM_write_bio_PKCS7(bp,x) \ | ||
| 520 | PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ | ||
| 521 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 522 | #define PEM_write_bio_DHparams(bp,x) \ | ||
| 523 | PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ | ||
| 524 | bp,(char *)x,NULL,NULL,0,NULL,NULL) | ||
| 525 | #define PEM_write_bio_DSAparams(bp,x) \ | ||
| 526 | PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ | ||
| 527 | PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) | ||
| 528 | |||
| 529 | #define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ | ||
| 530 | PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ | ||
| 531 | PEM_STRING_X509,bp, \ | ||
| 532 | (char *)x, NULL,NULL,0,NULL,NULL) | ||
| 533 | |||
| 534 | #define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ | ||
| 535 | (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) | ||
| 536 | #define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ | ||
| 537 | (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) | ||
| 538 | #define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ | ||
| 539 | (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) | ||
| 540 | #define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ | ||
| 541 | (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) | ||
| 542 | #define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ | ||
| 543 | (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) | ||
| 544 | #define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ | ||
| 545 | (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) | ||
| 546 | #define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ | ||
| 547 | (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) | ||
| 548 | |||
| 549 | #define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ | ||
| 550 | (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) | ||
| 551 | #define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ | ||
| 552 | (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) | ||
| 553 | #define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ | ||
| 554 | (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) | ||
| 555 | |||
| 556 | #define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ | ||
| 557 | (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ | ||
| 558 | (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ | ||
| 559 | (char **)x,cb,u) | ||
| 560 | |||
| 561 | #endif | ||
| 562 | |||
| 563 | #if 1 | 398 | #if 1 |
| 564 | /* "userdata": new with OpenSSL 0.9.4 */ | 399 | /* "userdata": new with OpenSSL 0.9.4 */ |
| 565 | typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); | 400 | typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); |
| @@ -581,40 +416,25 @@ int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char | |||
| 581 | pem_password_cb *cb, void *u); | 416 | pem_password_cb *cb, void *u); |
| 582 | void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, | 417 | void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, |
| 583 | void **x, pem_password_cb *cb, void *u); | 418 | void **x, pem_password_cb *cb, void *u); |
| 584 | 419 | int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp, void *x, | |
| 585 | #define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ | ||
| 586 | ((type*)PEM_ASN1_read_bio(CHECKED_D2I_OF(type, d2i), \ | ||
| 587 | name, bp, \ | ||
| 588 | CHECKED_PPTR_OF(type, x), \ | ||
| 589 | cb, u)) | ||
| 590 | |||
| 591 | int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, | ||
| 592 | const EVP_CIPHER *enc,unsigned char *kstr,int klen, | 420 | const EVP_CIPHER *enc,unsigned char *kstr,int klen, |
| 593 | pem_password_cb *cb, void *u); | 421 | pem_password_cb *cb, void *u); |
| 594 | 422 | ||
| 595 | #define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ | ||
| 596 | (PEM_ASN1_write_bio(CHECKED_I2D_OF(type, i2d), \ | ||
| 597 | name, bp, \ | ||
| 598 | CHECKED_PTR_OF(type, x), \ | ||
| 599 | enc, kstr, klen, cb, u)) | ||
| 600 | |||
| 601 | STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); | 423 | STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); |
| 602 | int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, | 424 | int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, |
| 603 | unsigned char *kstr, int klen, pem_password_cb *cd, void *u); | 425 | unsigned char *kstr, int klen, pem_password_cb *cd, void *u); |
| 604 | #endif | 426 | #endif |
| 605 | 427 | ||
| 606 | #ifndef OPENSSL_SYS_WIN16 | ||
| 607 | int PEM_read(FILE *fp, char **name, char **header, | 428 | int PEM_read(FILE *fp, char **name, char **header, |
| 608 | unsigned char **data,long *len); | 429 | unsigned char **data,long *len); |
| 609 | int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); | 430 | int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); |
| 610 | void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, | 431 | void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, |
| 611 | pem_password_cb *cb, void *u); | 432 | pem_password_cb *cb, void *u); |
| 612 | int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, | 433 | int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, |
| 613 | char *x,const EVP_CIPHER *enc,unsigned char *kstr, | 434 | void *x,const EVP_CIPHER *enc,unsigned char *kstr, |
| 614 | int klen,pem_password_cb *callback, void *u); | 435 | int klen,pem_password_cb *callback, void *u); |
| 615 | STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, | 436 | STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, |
| 616 | pem_password_cb *cb, void *u); | 437 | pem_password_cb *cb, void *u); |
| 617 | #endif | ||
| 618 | 438 | ||
| 619 | int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, | 439 | int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, |
| 620 | EVP_MD *md_type, unsigned char **ek, int *ekl, | 440 | EVP_MD *md_type, unsigned char **ek, int *ekl, |
| @@ -633,7 +453,6 @@ int PEM_def_callback(char *buf, int num, int w, void *key); | |||
| 633 | void PEM_proc_type(char *buf, int type); | 453 | void PEM_proc_type(char *buf, int type); |
| 634 | void PEM_dek_info(char *buf, const char *type, int len, char *str); | 454 | void PEM_dek_info(char *buf, const char *type, int len, char *str); |
| 635 | 455 | ||
| 636 | #ifndef SSLEAY_MACROS | ||
| 637 | 456 | ||
| 638 | #include <openssl/symhacks.h> | 457 | #include <openssl/symhacks.h> |
| 639 | 458 | ||
| @@ -719,7 +538,21 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, vo | |||
| 719 | int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, | 538 | int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, |
| 720 | char *kstr,int klen, pem_password_cb *cd, void *u); | 539 | char *kstr,int klen, pem_password_cb *cd, void *u); |
| 721 | 540 | ||
| 722 | #endif /* SSLEAY_MACROS */ | 541 | EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); |
| 542 | int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); | ||
| 543 | |||
| 544 | |||
| 545 | EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); | ||
| 546 | EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); | ||
| 547 | EVP_PKEY *b2i_PrivateKey_bio(BIO *in); | ||
| 548 | EVP_PKEY *b2i_PublicKey_bio(BIO *in); | ||
| 549 | int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); | ||
| 550 | int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); | ||
| 551 | #ifndef OPENSSL_NO_RC4 | ||
| 552 | EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); | ||
| 553 | int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, | ||
| 554 | pem_password_cb *cb, void *u); | ||
| 555 | #endif | ||
| 723 | 556 | ||
| 724 | 557 | ||
| 725 | /* BEGIN ERROR CODES */ | 558 | /* BEGIN ERROR CODES */ |
| @@ -731,10 +564,22 @@ void ERR_load_PEM_strings(void); | |||
| 731 | /* Error codes for the PEM functions. */ | 564 | /* Error codes for the PEM functions. */ |
| 732 | 565 | ||
| 733 | /* Function codes. */ | 566 | /* Function codes. */ |
| 567 | #define PEM_F_B2I_DSS 127 | ||
| 568 | #define PEM_F_B2I_PVK_BIO 128 | ||
| 569 | #define PEM_F_B2I_RSA 129 | ||
| 570 | #define PEM_F_CHECK_BITLEN_DSA 130 | ||
| 571 | #define PEM_F_CHECK_BITLEN_RSA 131 | ||
| 734 | #define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 | 572 | #define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 |
| 735 | #define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 | 573 | #define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 |
| 574 | #define PEM_F_DO_B2I 132 | ||
| 575 | #define PEM_F_DO_B2I_BIO 133 | ||
| 576 | #define PEM_F_DO_BLOB_HEADER 134 | ||
| 736 | #define PEM_F_DO_PK8PKEY 126 | 577 | #define PEM_F_DO_PK8PKEY 126 |
| 737 | #define PEM_F_DO_PK8PKEY_FP 125 | 578 | #define PEM_F_DO_PK8PKEY_FP 125 |
| 579 | #define PEM_F_DO_PVK_BODY 135 | ||
| 580 | #define PEM_F_DO_PVK_HEADER 136 | ||
| 581 | #define PEM_F_I2B_PVK 137 | ||
| 582 | #define PEM_F_I2B_PVK_BIO 138 | ||
| 738 | #define PEM_F_LOAD_IV 101 | 583 | #define PEM_F_LOAD_IV 101 |
| 739 | #define PEM_F_PEM_ASN1_READ 102 | 584 | #define PEM_F_PEM_ASN1_READ 102 |
| 740 | #define PEM_F_PEM_ASN1_READ_BIO 103 | 585 | #define PEM_F_PEM_ASN1_READ_BIO 103 |
| @@ -747,6 +592,7 @@ void ERR_load_PEM_strings(void); | |||
| 747 | #define PEM_F_PEM_PK8PKEY 119 | 592 | #define PEM_F_PEM_PK8PKEY 119 |
| 748 | #define PEM_F_PEM_READ 108 | 593 | #define PEM_F_PEM_READ 108 |
| 749 | #define PEM_F_PEM_READ_BIO 109 | 594 | #define PEM_F_PEM_READ_BIO 109 |
| 595 | #define PEM_F_PEM_READ_BIO_PARAMETERS 140 | ||
| 750 | #define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 | 596 | #define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 |
| 751 | #define PEM_F_PEM_READ_PRIVATEKEY 124 | 597 | #define PEM_F_PEM_READ_PRIVATEKEY 124 |
| 752 | #define PEM_F_PEM_SEALFINAL 110 | 598 | #define PEM_F_PEM_SEALFINAL 110 |
| @@ -754,6 +600,7 @@ void ERR_load_PEM_strings(void); | |||
| 754 | #define PEM_F_PEM_SIGNFINAL 112 | 600 | #define PEM_F_PEM_SIGNFINAL 112 |
| 755 | #define PEM_F_PEM_WRITE 113 | 601 | #define PEM_F_PEM_WRITE 113 |
| 756 | #define PEM_F_PEM_WRITE_BIO 114 | 602 | #define PEM_F_PEM_WRITE_BIO 114 |
| 603 | #define PEM_F_PEM_WRITE_PRIVATEKEY 139 | ||
| 757 | #define PEM_F_PEM_X509_INFO_READ 115 | 604 | #define PEM_F_PEM_X509_INFO_READ 115 |
| 758 | #define PEM_F_PEM_X509_INFO_READ_BIO 116 | 605 | #define PEM_F_PEM_X509_INFO_READ_BIO 116 |
| 759 | #define PEM_F_PEM_X509_INFO_WRITE_BIO 117 | 606 | #define PEM_F_PEM_X509_INFO_WRITE_BIO 117 |
| @@ -763,18 +610,30 @@ void ERR_load_PEM_strings(void); | |||
| 763 | #define PEM_R_BAD_DECRYPT 101 | 610 | #define PEM_R_BAD_DECRYPT 101 |
| 764 | #define PEM_R_BAD_END_LINE 102 | 611 | #define PEM_R_BAD_END_LINE 102 |
| 765 | #define PEM_R_BAD_IV_CHARS 103 | 612 | #define PEM_R_BAD_IV_CHARS 103 |
| 613 | #define PEM_R_BAD_MAGIC_NUMBER 116 | ||
| 766 | #define PEM_R_BAD_PASSWORD_READ 104 | 614 | #define PEM_R_BAD_PASSWORD_READ 104 |
| 615 | #define PEM_R_BAD_VERSION_NUMBER 117 | ||
| 616 | #define PEM_R_BIO_WRITE_FAILURE 118 | ||
| 617 | #define PEM_R_CIPHER_IS_NULL 127 | ||
| 767 | #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 | 618 | #define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 |
| 619 | #define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 | ||
| 620 | #define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 | ||
| 621 | #define PEM_R_INCONSISTENT_HEADER 121 | ||
| 622 | #define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 | ||
| 623 | #define PEM_R_KEYBLOB_TOO_SHORT 123 | ||
| 768 | #define PEM_R_NOT_DEK_INFO 105 | 624 | #define PEM_R_NOT_DEK_INFO 105 |
| 769 | #define PEM_R_NOT_ENCRYPTED 106 | 625 | #define PEM_R_NOT_ENCRYPTED 106 |
| 770 | #define PEM_R_NOT_PROC_TYPE 107 | 626 | #define PEM_R_NOT_PROC_TYPE 107 |
| 771 | #define PEM_R_NO_START_LINE 108 | 627 | #define PEM_R_NO_START_LINE 108 |
| 772 | #define PEM_R_PROBLEMS_GETTING_PASSWORD 109 | 628 | #define PEM_R_PROBLEMS_GETTING_PASSWORD 109 |
| 773 | #define PEM_R_PUBLIC_KEY_NO_RSA 110 | 629 | #define PEM_R_PUBLIC_KEY_NO_RSA 110 |
| 630 | #define PEM_R_PVK_DATA_TOO_SHORT 124 | ||
| 631 | #define PEM_R_PVK_TOO_SHORT 125 | ||
| 774 | #define PEM_R_READ_KEY 111 | 632 | #define PEM_R_READ_KEY 111 |
| 775 | #define PEM_R_SHORT_HEADER 112 | 633 | #define PEM_R_SHORT_HEADER 112 |
| 776 | #define PEM_R_UNSUPPORTED_CIPHER 113 | 634 | #define PEM_R_UNSUPPORTED_CIPHER 113 |
| 777 | #define PEM_R_UNSUPPORTED_ENCRYPTION 114 | 635 | #define PEM_R_UNSUPPORTED_ENCRYPTION 114 |
| 636 | #define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 | ||
| 778 | 637 | ||
| 779 | #ifdef __cplusplus | 638 | #ifdef __cplusplus |
| 780 | } | 639 | } |
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c index 69dd19bf2e..3e7a6093ad 100644 --- a/src/lib/libcrypto/pem/pem_all.c +++ b/src/lib/libcrypto/pem/pem_all.c | |||
| @@ -110,7 +110,6 @@ | |||
| 110 | */ | 110 | */ |
| 111 | 111 | ||
| 112 | #include <stdio.h> | 112 | #include <stdio.h> |
| 113 | #undef SSLEAY_MACROS | ||
| 114 | #include "cryptlib.h" | 113 | #include "cryptlib.h" |
| 115 | #include <openssl/bio.h> | 114 | #include <openssl/bio.h> |
| 116 | #include <openssl/evp.h> | 115 | #include <openssl/evp.h> |
| @@ -194,49 +193,7 @@ RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, | |||
| 194 | 193 | ||
| 195 | #endif | 194 | #endif |
| 196 | 195 | ||
| 197 | #ifdef OPENSSL_FIPS | ||
| 198 | |||
| 199 | int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc, | ||
| 200 | unsigned char *kstr, int klen, | ||
| 201 | pem_password_cb *cb, void *u) | ||
| 202 | { | ||
| 203 | EVP_PKEY *k; | ||
| 204 | int ret; | ||
| 205 | k = EVP_PKEY_new(); | ||
| 206 | if (!k) | ||
| 207 | return 0; | ||
| 208 | EVP_PKEY_set1_RSA(k, x); | ||
| 209 | |||
| 210 | ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u); | ||
| 211 | EVP_PKEY_free(k); | ||
| 212 | return ret; | ||
| 213 | } | ||
| 214 | |||
| 215 | #ifndef OPENSSL_NO_FP_API | ||
| 216 | int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc, | ||
| 217 | unsigned char *kstr, int klen, | ||
| 218 | pem_password_cb *cb, void *u) | ||
| 219 | { | ||
| 220 | EVP_PKEY *k; | ||
| 221 | int ret; | ||
| 222 | k = EVP_PKEY_new(); | ||
| 223 | if (!k) | ||
| 224 | return 0; | ||
| 225 | |||
| 226 | EVP_PKEY_set1_RSA(k, x); | ||
| 227 | |||
| 228 | ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u); | ||
| 229 | EVP_PKEY_free(k); | ||
| 230 | return ret; | ||
| 231 | } | ||
| 232 | #endif | ||
| 233 | |||
| 234 | #else | ||
| 235 | |||
| 236 | IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) | 196 | IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) |
| 237 | |||
| 238 | #endif | ||
| 239 | |||
| 240 | IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) | 197 | IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) |
| 241 | IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) | 198 | IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) |
| 242 | 199 | ||
| @@ -263,50 +220,10 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, | |||
| 263 | { | 220 | { |
| 264 | EVP_PKEY *pktmp; | 221 | EVP_PKEY *pktmp; |
| 265 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); | 222 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); |
| 266 | return pkey_get_dsa(pktmp, dsa); | 223 | return pkey_get_dsa(pktmp, dsa); /* will free pktmp */ |
| 267 | } | 224 | } |
| 268 | 225 | ||
| 269 | #ifdef OPENSSL_FIPS | ||
| 270 | |||
| 271 | int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc, | ||
| 272 | unsigned char *kstr, int klen, | ||
| 273 | pem_password_cb *cb, void *u) | ||
| 274 | { | ||
| 275 | EVP_PKEY *k; | ||
| 276 | int ret; | ||
| 277 | k = EVP_PKEY_new(); | ||
| 278 | if (!k) | ||
| 279 | return 0; | ||
| 280 | EVP_PKEY_set1_DSA(k, x); | ||
| 281 | |||
| 282 | ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u); | ||
| 283 | EVP_PKEY_free(k); | ||
| 284 | return ret; | ||
| 285 | } | ||
| 286 | |||
| 287 | #ifndef OPENSSL_NO_FP_API | ||
| 288 | int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc, | ||
| 289 | unsigned char *kstr, int klen, | ||
| 290 | pem_password_cb *cb, void *u) | ||
| 291 | { | ||
| 292 | EVP_PKEY *k; | ||
| 293 | int ret; | ||
| 294 | k = EVP_PKEY_new(); | ||
| 295 | if (!k) | ||
| 296 | return 0; | ||
| 297 | EVP_PKEY_set1_DSA(k, x); | ||
| 298 | ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u); | ||
| 299 | EVP_PKEY_free(k); | ||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | #endif | ||
| 303 | |||
| 304 | #else | ||
| 305 | |||
| 306 | IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) | 226 | IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) |
| 307 | |||
| 308 | #endif | ||
| 309 | |||
| 310 | IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) | 227 | IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) |
| 311 | 228 | ||
| 312 | #ifndef OPENSSL_NO_FP_API | 229 | #ifndef OPENSSL_NO_FP_API |
| @@ -316,7 +233,7 @@ DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, | |||
| 316 | { | 233 | { |
| 317 | EVP_PKEY *pktmp; | 234 | EVP_PKEY *pktmp; |
| 318 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); | 235 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); |
| 319 | return pkey_get_dsa(pktmp, dsa); | 236 | return pkey_get_dsa(pktmp, dsa); /* will free pktmp */ |
| 320 | } | 237 | } |
| 321 | 238 | ||
| 322 | #endif | 239 | #endif |
| @@ -347,54 +264,13 @@ EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, | |||
| 347 | { | 264 | { |
| 348 | EVP_PKEY *pktmp; | 265 | EVP_PKEY *pktmp; |
| 349 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); | 266 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); |
| 350 | return pkey_get_eckey(pktmp, key); | 267 | return pkey_get_eckey(pktmp, key); /* will free pktmp */ |
| 351 | } | 268 | } |
| 352 | 269 | ||
| 353 | IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters) | 270 | IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters) |
| 354 | 271 | ||
| 355 | |||
| 356 | |||
| 357 | #ifdef OPENSSL_FIPS | ||
| 358 | |||
| 359 | int PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x, const EVP_CIPHER *enc, | ||
| 360 | unsigned char *kstr, int klen, | ||
| 361 | pem_password_cb *cb, void *u) | ||
| 362 | { | ||
| 363 | EVP_PKEY *k; | ||
| 364 | int ret; | ||
| 365 | k = EVP_PKEY_new(); | ||
| 366 | if (!k) | ||
| 367 | return 0; | ||
| 368 | EVP_PKEY_set1_EC_KEY(k, x); | ||
| 369 | |||
| 370 | ret = PEM_write_bio_PrivateKey(bp, k, enc, kstr, klen, cb, u); | ||
| 371 | EVP_PKEY_free(k); | ||
| 372 | return ret; | ||
| 373 | } | ||
| 374 | |||
| 375 | #ifndef OPENSSL_NO_FP_API | ||
| 376 | int PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc, | ||
| 377 | unsigned char *kstr, int klen, | ||
| 378 | pem_password_cb *cb, void *u) | ||
| 379 | { | ||
| 380 | EVP_PKEY *k; | ||
| 381 | int ret; | ||
| 382 | k = EVP_PKEY_new(); | ||
| 383 | if (!k) | ||
| 384 | return 0; | ||
| 385 | EVP_PKEY_set1_EC_KEY(k, x); | ||
| 386 | ret = PEM_write_PrivateKey(fp, k, enc, kstr, klen, cb, u); | ||
| 387 | EVP_PKEY_free(k); | ||
| 388 | return ret; | ||
| 389 | } | ||
| 390 | #endif | ||
| 391 | |||
| 392 | #else | ||
| 393 | |||
| 394 | IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey) | 272 | IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey) |
| 395 | 273 | ||
| 396 | #endif | ||
| 397 | |||
| 398 | IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY) | 274 | IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY) |
| 399 | 275 | ||
| 400 | #ifndef OPENSSL_NO_FP_API | 276 | #ifndef OPENSSL_NO_FP_API |
| @@ -404,7 +280,7 @@ EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, | |||
| 404 | { | 280 | { |
| 405 | EVP_PKEY *pktmp; | 281 | EVP_PKEY *pktmp; |
| 406 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); | 282 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); |
| 407 | return pkey_get_eckey(pktmp, eckey); | 283 | return pkey_get_eckey(pktmp, eckey); /* will free pktmp */ |
| 408 | } | 284 | } |
| 409 | 285 | ||
| 410 | #endif | 286 | #endif |
| @@ -417,66 +293,4 @@ IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) | |||
| 417 | 293 | ||
| 418 | #endif | 294 | #endif |
| 419 | 295 | ||
| 420 | |||
| 421 | /* The PrivateKey case is not that straightforward. | ||
| 422 | * IMPLEMENT_PEM_rw_cb(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey) | ||
| 423 | * does not work, RSA and DSA keys have specific strings. | ||
| 424 | * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything | ||
| 425 | * appropriate.) | ||
| 426 | */ | ||
| 427 | |||
| 428 | #ifdef OPENSSL_FIPS | ||
| 429 | |||
| 430 | static const char *pkey_str(EVP_PKEY *x) | ||
| 431 | { | ||
| 432 | switch (x->type) | ||
| 433 | { | ||
| 434 | case EVP_PKEY_RSA: | ||
| 435 | return PEM_STRING_RSA; | ||
| 436 | |||
| 437 | case EVP_PKEY_DSA: | ||
| 438 | return PEM_STRING_DSA; | ||
| 439 | |||
| 440 | case EVP_PKEY_EC: | ||
| 441 | return PEM_STRING_ECPRIVATEKEY; | ||
| 442 | |||
| 443 | default: | ||
| 444 | return NULL; | ||
| 445 | } | ||
| 446 | } | ||
| 447 | |||
| 448 | |||
| 449 | int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 450 | unsigned char *kstr, int klen, | ||
| 451 | pem_password_cb *cb, void *u) | ||
| 452 | { | ||
| 453 | if (FIPS_mode()) | ||
| 454 | return PEM_write_bio_PKCS8PrivateKey(bp, x, enc, | ||
| 455 | (char *)kstr, klen, cb, u); | ||
| 456 | else | ||
| 457 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey, | ||
| 458 | pkey_str(x), bp,(char *)x,enc,kstr,klen,cb,u); | ||
| 459 | } | ||
| 460 | |||
| 461 | #ifndef OPENSSL_NO_FP_API | ||
| 462 | int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 463 | unsigned char *kstr, int klen, | ||
| 464 | pem_password_cb *cb, void *u) | ||
| 465 | { | ||
| 466 | if (FIPS_mode()) | ||
| 467 | return PEM_write_PKCS8PrivateKey(fp, x, enc, | ||
| 468 | (char *)kstr, klen, cb, u); | ||
| 469 | else | ||
| 470 | return PEM_ASN1_write((i2d_of_void *)i2d_PrivateKey, | ||
| 471 | pkey_str(x), fp,(char *)x,enc,kstr,klen,cb,u); | ||
| 472 | } | ||
| 473 | #endif | ||
| 474 | |||
| 475 | #else | ||
| 476 | IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:\ | ||
| 477 | (x->type == EVP_PKEY_RSA)?PEM_STRING_RSA:PEM_STRING_ECPRIVATEKEY), PrivateKey) | ||
| 478 | |||
| 479 | #endif | ||
| 480 | |||
| 481 | IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) | 296 | IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) |
| 482 | |||
diff --git a/src/lib/libcrypto/pem/pem_err.c b/src/lib/libcrypto/pem/pem_err.c index 3133563d77..d644aeedd4 100644 --- a/src/lib/libcrypto/pem/pem_err.c +++ b/src/lib/libcrypto/pem/pem_err.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* crypto/pem/pem_err.c */ | 1 | /* crypto/pem/pem_err.c */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
| @@ -70,10 +70,22 @@ | |||
| 70 | 70 | ||
| 71 | static ERR_STRING_DATA PEM_str_functs[]= | 71 | static ERR_STRING_DATA PEM_str_functs[]= |
| 72 | { | 72 | { |
| 73 | {ERR_FUNC(PEM_F_B2I_DSS), "B2I_DSS"}, | ||
| 74 | {ERR_FUNC(PEM_F_B2I_PVK_BIO), "b2i_PVK_bio"}, | ||
| 75 | {ERR_FUNC(PEM_F_B2I_RSA), "B2I_RSA"}, | ||
| 76 | {ERR_FUNC(PEM_F_CHECK_BITLEN_DSA), "CHECK_BITLEN_DSA"}, | ||
| 77 | {ERR_FUNC(PEM_F_CHECK_BITLEN_RSA), "CHECK_BITLEN_RSA"}, | ||
| 73 | {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_BIO), "d2i_PKCS8PrivateKey_bio"}, | 78 | {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_BIO), "d2i_PKCS8PrivateKey_bio"}, |
| 74 | {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_FP), "d2i_PKCS8PrivateKey_fp"}, | 79 | {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_FP), "d2i_PKCS8PrivateKey_fp"}, |
| 80 | {ERR_FUNC(PEM_F_DO_B2I), "DO_B2I"}, | ||
| 81 | {ERR_FUNC(PEM_F_DO_B2I_BIO), "DO_B2I_BIO"}, | ||
| 82 | {ERR_FUNC(PEM_F_DO_BLOB_HEADER), "DO_BLOB_HEADER"}, | ||
| 75 | {ERR_FUNC(PEM_F_DO_PK8PKEY), "DO_PK8PKEY"}, | 83 | {ERR_FUNC(PEM_F_DO_PK8PKEY), "DO_PK8PKEY"}, |
| 76 | {ERR_FUNC(PEM_F_DO_PK8PKEY_FP), "DO_PK8PKEY_FP"}, | 84 | {ERR_FUNC(PEM_F_DO_PK8PKEY_FP), "DO_PK8PKEY_FP"}, |
| 85 | {ERR_FUNC(PEM_F_DO_PVK_BODY), "DO_PVK_BODY"}, | ||
| 86 | {ERR_FUNC(PEM_F_DO_PVK_HEADER), "DO_PVK_HEADER"}, | ||
| 87 | {ERR_FUNC(PEM_F_I2B_PVK), "I2B_PVK"}, | ||
| 88 | {ERR_FUNC(PEM_F_I2B_PVK_BIO), "i2b_PVK_bio"}, | ||
| 77 | {ERR_FUNC(PEM_F_LOAD_IV), "LOAD_IV"}, | 89 | {ERR_FUNC(PEM_F_LOAD_IV), "LOAD_IV"}, |
| 78 | {ERR_FUNC(PEM_F_PEM_ASN1_READ), "PEM_ASN1_read"}, | 90 | {ERR_FUNC(PEM_F_PEM_ASN1_READ), "PEM_ASN1_read"}, |
| 79 | {ERR_FUNC(PEM_F_PEM_ASN1_READ_BIO), "PEM_ASN1_read_bio"}, | 91 | {ERR_FUNC(PEM_F_PEM_ASN1_READ_BIO), "PEM_ASN1_read_bio"}, |
| @@ -86,6 +98,7 @@ static ERR_STRING_DATA PEM_str_functs[]= | |||
| 86 | {ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"}, | 98 | {ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"}, |
| 87 | {ERR_FUNC(PEM_F_PEM_READ), "PEM_read"}, | 99 | {ERR_FUNC(PEM_F_PEM_READ), "PEM_read"}, |
| 88 | {ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"}, | 100 | {ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"}, |
| 101 | {ERR_FUNC(PEM_F_PEM_READ_BIO_PARAMETERS), "PEM_read_bio_Parameters"}, | ||
| 89 | {ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BIO_PRIVATEKEY"}, | 102 | {ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BIO_PRIVATEKEY"}, |
| 90 | {ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVATEKEY"}, | 103 | {ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVATEKEY"}, |
| 91 | {ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"}, | 104 | {ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"}, |
| @@ -93,6 +106,7 @@ static ERR_STRING_DATA PEM_str_functs[]= | |||
| 93 | {ERR_FUNC(PEM_F_PEM_SIGNFINAL), "PEM_SignFinal"}, | 106 | {ERR_FUNC(PEM_F_PEM_SIGNFINAL), "PEM_SignFinal"}, |
| 94 | {ERR_FUNC(PEM_F_PEM_WRITE), "PEM_write"}, | 107 | {ERR_FUNC(PEM_F_PEM_WRITE), "PEM_write"}, |
| 95 | {ERR_FUNC(PEM_F_PEM_WRITE_BIO), "PEM_write_bio"}, | 108 | {ERR_FUNC(PEM_F_PEM_WRITE_BIO), "PEM_write_bio"}, |
| 109 | {ERR_FUNC(PEM_F_PEM_WRITE_PRIVATEKEY), "PEM_WRITE_PRIVATEKEY"}, | ||
| 96 | {ERR_FUNC(PEM_F_PEM_X509_INFO_READ), "PEM_X509_INFO_read"}, | 110 | {ERR_FUNC(PEM_F_PEM_X509_INFO_READ), "PEM_X509_INFO_read"}, |
| 97 | {ERR_FUNC(PEM_F_PEM_X509_INFO_READ_BIO), "PEM_X509_INFO_read_bio"}, | 111 | {ERR_FUNC(PEM_F_PEM_X509_INFO_READ_BIO), "PEM_X509_INFO_read_bio"}, |
| 98 | {ERR_FUNC(PEM_F_PEM_X509_INFO_WRITE_BIO), "PEM_X509_INFO_write_bio"}, | 112 | {ERR_FUNC(PEM_F_PEM_X509_INFO_WRITE_BIO), "PEM_X509_INFO_write_bio"}, |
| @@ -105,18 +119,30 @@ static ERR_STRING_DATA PEM_str_reasons[]= | |||
| 105 | {ERR_REASON(PEM_R_BAD_DECRYPT) ,"bad decrypt"}, | 119 | {ERR_REASON(PEM_R_BAD_DECRYPT) ,"bad decrypt"}, |
| 106 | {ERR_REASON(PEM_R_BAD_END_LINE) ,"bad end line"}, | 120 | {ERR_REASON(PEM_R_BAD_END_LINE) ,"bad end line"}, |
| 107 | {ERR_REASON(PEM_R_BAD_IV_CHARS) ,"bad iv chars"}, | 121 | {ERR_REASON(PEM_R_BAD_IV_CHARS) ,"bad iv chars"}, |
| 122 | {ERR_REASON(PEM_R_BAD_MAGIC_NUMBER) ,"bad magic number"}, | ||
| 108 | {ERR_REASON(PEM_R_BAD_PASSWORD_READ) ,"bad password read"}, | 123 | {ERR_REASON(PEM_R_BAD_PASSWORD_READ) ,"bad password read"}, |
| 124 | {ERR_REASON(PEM_R_BAD_VERSION_NUMBER) ,"bad version number"}, | ||
| 125 | {ERR_REASON(PEM_R_BIO_WRITE_FAILURE) ,"bio write failure"}, | ||
| 126 | {ERR_REASON(PEM_R_CIPHER_IS_NULL) ,"cipher is null"}, | ||
| 109 | {ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY),"error converting private key"}, | 127 | {ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY),"error converting private key"}, |
| 128 | {ERR_REASON(PEM_R_EXPECTING_PRIVATE_KEY_BLOB),"expecting private key blob"}, | ||
| 129 | {ERR_REASON(PEM_R_EXPECTING_PUBLIC_KEY_BLOB),"expecting public key blob"}, | ||
| 130 | {ERR_REASON(PEM_R_INCONSISTENT_HEADER) ,"inconsistent header"}, | ||
| 131 | {ERR_REASON(PEM_R_KEYBLOB_HEADER_PARSE_ERROR),"keyblob header parse error"}, | ||
| 132 | {ERR_REASON(PEM_R_KEYBLOB_TOO_SHORT) ,"keyblob too short"}, | ||
| 110 | {ERR_REASON(PEM_R_NOT_DEK_INFO) ,"not dek info"}, | 133 | {ERR_REASON(PEM_R_NOT_DEK_INFO) ,"not dek info"}, |
| 111 | {ERR_REASON(PEM_R_NOT_ENCRYPTED) ,"not encrypted"}, | 134 | {ERR_REASON(PEM_R_NOT_ENCRYPTED) ,"not encrypted"}, |
| 112 | {ERR_REASON(PEM_R_NOT_PROC_TYPE) ,"not proc type"}, | 135 | {ERR_REASON(PEM_R_NOT_PROC_TYPE) ,"not proc type"}, |
| 113 | {ERR_REASON(PEM_R_NO_START_LINE) ,"no start line"}, | 136 | {ERR_REASON(PEM_R_NO_START_LINE) ,"no start line"}, |
| 114 | {ERR_REASON(PEM_R_PROBLEMS_GETTING_PASSWORD),"problems getting password"}, | 137 | {ERR_REASON(PEM_R_PROBLEMS_GETTING_PASSWORD),"problems getting password"}, |
| 115 | {ERR_REASON(PEM_R_PUBLIC_KEY_NO_RSA) ,"public key no rsa"}, | 138 | {ERR_REASON(PEM_R_PUBLIC_KEY_NO_RSA) ,"public key no rsa"}, |
| 139 | {ERR_REASON(PEM_R_PVK_DATA_TOO_SHORT) ,"pvk data too short"}, | ||
| 140 | {ERR_REASON(PEM_R_PVK_TOO_SHORT) ,"pvk too short"}, | ||
| 116 | {ERR_REASON(PEM_R_READ_KEY) ,"read key"}, | 141 | {ERR_REASON(PEM_R_READ_KEY) ,"read key"}, |
| 117 | {ERR_REASON(PEM_R_SHORT_HEADER) ,"short header"}, | 142 | {ERR_REASON(PEM_R_SHORT_HEADER) ,"short header"}, |
| 118 | {ERR_REASON(PEM_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, | 143 | {ERR_REASON(PEM_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, |
| 119 | {ERR_REASON(PEM_R_UNSUPPORTED_ENCRYPTION),"unsupported encryption"}, | 144 | {ERR_REASON(PEM_R_UNSUPPORTED_ENCRYPTION),"unsupported encryption"}, |
| 145 | {ERR_REASON(PEM_R_UNSUPPORTED_KEY_COMPONENTS),"unsupported key components"}, | ||
| 120 | {0,NULL} | 146 | {0,NULL} |
| 121 | }; | 147 | }; |
| 122 | 148 | ||
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c index 3a273f6f70..1b2be527ed 100644 --- a/src/lib/libcrypto/pem/pem_info.c +++ b/src/lib/libcrypto/pem/pem_info.c | |||
| @@ -98,8 +98,8 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe | |||
| 98 | long len,error=0; | 98 | long len,error=0; |
| 99 | int ok=0; | 99 | int ok=0; |
| 100 | STACK_OF(X509_INFO) *ret=NULL; | 100 | STACK_OF(X509_INFO) *ret=NULL; |
| 101 | unsigned int i,raw; | 101 | unsigned int i,raw,ptype; |
| 102 | d2i_of_void *d2i; | 102 | d2i_of_void *d2i = 0; |
| 103 | 103 | ||
| 104 | if (sk == NULL) | 104 | if (sk == NULL) |
| 105 | { | 105 | { |
| @@ -116,6 +116,7 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe | |||
| 116 | for (;;) | 116 | for (;;) |
| 117 | { | 117 | { |
| 118 | raw=0; | 118 | raw=0; |
| 119 | ptype = 0; | ||
| 119 | i=PEM_read_bio(bp,&name,&header,&data,&len); | 120 | i=PEM_read_bio(bp,&name,&header,&data,&len); |
| 120 | if (i == 0) | 121 | if (i == 0) |
| 121 | { | 122 | { |
| @@ -166,7 +167,6 @@ start: | |||
| 166 | #ifndef OPENSSL_NO_RSA | 167 | #ifndef OPENSSL_NO_RSA |
| 167 | if (strcmp(name,PEM_STRING_RSA) == 0) | 168 | if (strcmp(name,PEM_STRING_RSA) == 0) |
| 168 | { | 169 | { |
| 169 | d2i=(D2I_OF(void))d2i_RSAPrivateKey; | ||
| 170 | if (xi->x_pkey != NULL) | 170 | if (xi->x_pkey != NULL) |
| 171 | { | 171 | { |
| 172 | if (!sk_X509_INFO_push(ret,xi)) goto err; | 172 | if (!sk_X509_INFO_push(ret,xi)) goto err; |
| @@ -178,10 +178,8 @@ start: | |||
| 178 | xi->enc_len=0; | 178 | xi->enc_len=0; |
| 179 | 179 | ||
| 180 | xi->x_pkey=X509_PKEY_new(); | 180 | xi->x_pkey=X509_PKEY_new(); |
| 181 | if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) | 181 | ptype=EVP_PKEY_RSA; |
| 182 | goto err; | 182 | pp=&xi->x_pkey->dec_pkey; |
| 183 | xi->x_pkey->dec_pkey->type=EVP_PKEY_RSA; | ||
| 184 | pp=&(xi->x_pkey->dec_pkey->pkey.rsa); | ||
| 185 | if ((int)strlen(header) > 10) /* assume encrypted */ | 183 | if ((int)strlen(header) > 10) /* assume encrypted */ |
| 186 | raw=1; | 184 | raw=1; |
| 187 | } | 185 | } |
| @@ -202,10 +200,8 @@ start: | |||
| 202 | xi->enc_len=0; | 200 | xi->enc_len=0; |
| 203 | 201 | ||
| 204 | xi->x_pkey=X509_PKEY_new(); | 202 | xi->x_pkey=X509_PKEY_new(); |
| 205 | if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) | 203 | ptype = EVP_PKEY_DSA; |
| 206 | goto err; | 204 | pp=&xi->x_pkey->dec_pkey; |
| 207 | xi->x_pkey->dec_pkey->type=EVP_PKEY_DSA; | ||
| 208 | pp=&xi->x_pkey->dec_pkey->pkey.dsa; | ||
| 209 | if ((int)strlen(header) > 10) /* assume encrypted */ | 205 | if ((int)strlen(header) > 10) /* assume encrypted */ |
| 210 | raw=1; | 206 | raw=1; |
| 211 | } | 207 | } |
| @@ -226,10 +222,8 @@ start: | |||
| 226 | xi->enc_len=0; | 222 | xi->enc_len=0; |
| 227 | 223 | ||
| 228 | xi->x_pkey=X509_PKEY_new(); | 224 | xi->x_pkey=X509_PKEY_new(); |
| 229 | if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) | 225 | ptype = EVP_PKEY_EC; |
| 230 | goto err; | 226 | pp=&xi->x_pkey->dec_pkey; |
| 231 | xi->x_pkey->dec_pkey->type=EVP_PKEY_EC; | ||
| 232 | pp=&(xi->x_pkey->dec_pkey->pkey.ec); | ||
| 233 | if ((int)strlen(header) > 10) /* assume encrypted */ | 227 | if ((int)strlen(header) > 10) /* assume encrypted */ |
| 234 | raw=1; | 228 | raw=1; |
| 235 | } | 229 | } |
| @@ -251,7 +245,15 @@ start: | |||
| 251 | if (!PEM_do_header(&cipher,data,&len,cb,u)) | 245 | if (!PEM_do_header(&cipher,data,&len,cb,u)) |
| 252 | goto err; | 246 | goto err; |
| 253 | p=data; | 247 | p=data; |
| 254 | if (d2i(pp,&p,len) == NULL) | 248 | if (ptype) |
| 249 | { | ||
| 250 | if (!d2i_PrivateKey(ptype, pp, &p, len)) | ||
| 251 | { | ||
| 252 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB); | ||
| 253 | goto err; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | else if (d2i(pp,&p,len) == NULL) | ||
| 255 | { | 257 | { |
| 256 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB); | 258 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO,ERR_R_ASN1_LIB); |
| 257 | goto err; | 259 | goto err; |
| @@ -337,6 +339,12 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
| 337 | { | 339 | { |
| 338 | if ( (xi->enc_data!=NULL) && (xi->enc_len>0) ) | 340 | if ( (xi->enc_data!=NULL) && (xi->enc_len>0) ) |
| 339 | { | 341 | { |
| 342 | if (enc == NULL) | ||
| 343 | { | ||
| 344 | PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_CIPHER_IS_NULL); | ||
| 345 | goto err; | ||
| 346 | } | ||
| 347 | |||
| 340 | /* copy from weirdo names into more normal things */ | 348 | /* copy from weirdo names into more normal things */ |
| 341 | iv=xi->enc_cipher.iv; | 349 | iv=xi->enc_cipher.iv; |
| 342 | data=(unsigned char *)xi->enc_data; | 350 | data=(unsigned char *)xi->enc_data; |
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index cbafefe416..42e4861bc1 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c | |||
| @@ -57,6 +57,7 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <ctype.h> | ||
| 60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 61 | #include <openssl/buffer.h> | 62 | #include <openssl/buffer.h> |
| 62 | #include <openssl/objects.h> | 63 | #include <openssl/objects.h> |
| @@ -65,9 +66,13 @@ | |||
| 65 | #include <openssl/x509.h> | 66 | #include <openssl/x509.h> |
| 66 | #include <openssl/pem.h> | 67 | #include <openssl/pem.h> |
| 67 | #include <openssl/pkcs12.h> | 68 | #include <openssl/pkcs12.h> |
| 69 | #include "asn1_locl.h" | ||
| 68 | #ifndef OPENSSL_NO_DES | 70 | #ifndef OPENSSL_NO_DES |
| 69 | #include <openssl/des.h> | 71 | #include <openssl/des.h> |
| 70 | #endif | 72 | #endif |
| 73 | #ifndef OPENSSL_NO_ENGINE | ||
| 74 | #include <openssl/engine.h> | ||
| 75 | #endif | ||
| 71 | 76 | ||
| 72 | const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT; | 77 | const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT; |
| 73 | 78 | ||
| @@ -75,6 +80,7 @@ const char PEM_version[]="PEM" OPENSSL_VERSION_PTEXT; | |||
| 75 | 80 | ||
| 76 | static int load_iv(char **fromp,unsigned char *to, int num); | 81 | static int load_iv(char **fromp,unsigned char *to, int num); |
| 77 | static int check_pem(const char *nm, const char *name); | 82 | static int check_pem(const char *nm, const char *name); |
| 83 | int pem_check_suffix(const char *pem_str, const char *suffix); | ||
| 78 | 84 | ||
| 79 | int PEM_def_callback(char *buf, int num, int w, void *key) | 85 | int PEM_def_callback(char *buf, int num, int w, void *key) |
| 80 | { | 86 | { |
| @@ -99,7 +105,7 @@ int PEM_def_callback(char *buf, int num, int w, void *key) | |||
| 99 | 105 | ||
| 100 | for (;;) | 106 | for (;;) |
| 101 | { | 107 | { |
| 102 | i=EVP_read_pw_string(buf,num,prompt,w); | 108 | i=EVP_read_pw_string_min(buf,MIN_LENGTH,num,prompt,w); |
| 103 | if (i != 0) | 109 | if (i != 0) |
| 104 | { | 110 | { |
| 105 | PEMerr(PEM_F_PEM_DEF_CALLBACK,PEM_R_PROBLEMS_GETTING_PASSWORD); | 111 | PEMerr(PEM_F_PEM_DEF_CALLBACK,PEM_R_PROBLEMS_GETTING_PASSWORD); |
| @@ -183,20 +189,54 @@ static int check_pem(const char *nm, const char *name) | |||
| 183 | 189 | ||
| 184 | /* Make PEM_STRING_EVP_PKEY match any private key */ | 190 | /* Make PEM_STRING_EVP_PKEY match any private key */ |
| 185 | 191 | ||
| 186 | if(!strcmp(nm,PEM_STRING_PKCS8) && | 192 | if(!strcmp(name,PEM_STRING_EVP_PKEY)) |
| 187 | !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; | 193 | { |
| 188 | 194 | int slen; | |
| 189 | if(!strcmp(nm,PEM_STRING_PKCS8INF) && | 195 | const EVP_PKEY_ASN1_METHOD *ameth; |
| 190 | !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; | 196 | if(!strcmp(nm,PEM_STRING_PKCS8)) |
| 191 | 197 | return 1; | |
| 192 | if(!strcmp(nm,PEM_STRING_RSA) && | 198 | if(!strcmp(nm,PEM_STRING_PKCS8INF)) |
| 193 | !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; | 199 | return 1; |
| 200 | slen = pem_check_suffix(nm, "PRIVATE KEY"); | ||
| 201 | if (slen > 0) | ||
| 202 | { | ||
| 203 | /* NB: ENGINE implementations wont contain | ||
| 204 | * a deprecated old private key decode function | ||
| 205 | * so don't look for them. | ||
| 206 | */ | ||
| 207 | ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen); | ||
| 208 | if (ameth && ameth->old_priv_decode) | ||
| 209 | return 1; | ||
| 210 | } | ||
| 211 | return 0; | ||
| 212 | } | ||
| 194 | 213 | ||
| 195 | if(!strcmp(nm,PEM_STRING_DSA) && | 214 | if(!strcmp(name,PEM_STRING_PARAMETERS)) |
| 196 | !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; | 215 | { |
| 216 | int slen; | ||
| 217 | const EVP_PKEY_ASN1_METHOD *ameth; | ||
| 218 | slen = pem_check_suffix(nm, "PARAMETERS"); | ||
| 219 | if (slen > 0) | ||
| 220 | { | ||
| 221 | ENGINE *e; | ||
| 222 | ameth = EVP_PKEY_asn1_find_str(&e, nm, slen); | ||
| 223 | if (ameth) | ||
| 224 | { | ||
| 225 | int r; | ||
| 226 | if (ameth->param_decode) | ||
| 227 | r = 1; | ||
| 228 | else | ||
| 229 | r = 0; | ||
| 230 | #ifndef OPENSSL_NO_ENGINE | ||
| 231 | if (e) | ||
| 232 | ENGINE_finish(e); | ||
| 233 | #endif | ||
| 234 | return r; | ||
| 235 | } | ||
| 236 | } | ||
| 237 | return 0; | ||
| 238 | } | ||
| 197 | 239 | ||
| 198 | if(!strcmp(nm,PEM_STRING_ECPRIVATEKEY) && | ||
| 199 | !strcmp(name,PEM_STRING_EVP_PKEY)) return 1; | ||
| 200 | /* Permit older strings */ | 240 | /* Permit older strings */ |
| 201 | 241 | ||
| 202 | if(!strcmp(nm,PEM_STRING_X509_OLD) && | 242 | if(!strcmp(nm,PEM_STRING_X509_OLD) && |
| @@ -219,6 +259,14 @@ static int check_pem(const char *nm, const char *name) | |||
| 219 | if(!strcmp(nm, PEM_STRING_PKCS7_SIGNED) && | 259 | if(!strcmp(nm, PEM_STRING_PKCS7_SIGNED) && |
| 220 | !strcmp(name, PEM_STRING_PKCS7)) return 1; | 260 | !strcmp(name, PEM_STRING_PKCS7)) return 1; |
| 221 | 261 | ||
| 262 | #ifndef OPENSSL_NO_CMS | ||
| 263 | if(!strcmp(nm, PEM_STRING_X509) && | ||
| 264 | !strcmp(name, PEM_STRING_CMS)) return 1; | ||
| 265 | /* Allow CMS to be read from PKCS#7 headers */ | ||
| 266 | if(!strcmp(nm, PEM_STRING_PKCS7) && | ||
| 267 | !strcmp(name, PEM_STRING_CMS)) return 1; | ||
| 268 | #endif | ||
| 269 | |||
| 222 | return 0; | 270 | return 0; |
| 223 | } | 271 | } |
| 224 | 272 | ||
| @@ -264,7 +312,7 @@ err: | |||
| 264 | 312 | ||
| 265 | #ifndef OPENSSL_NO_FP_API | 313 | #ifndef OPENSSL_NO_FP_API |
| 266 | int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, | 314 | int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, |
| 267 | char *x, const EVP_CIPHER *enc, unsigned char *kstr, | 315 | void *x, const EVP_CIPHER *enc, unsigned char *kstr, |
| 268 | int klen, pem_password_cb *callback, void *u) | 316 | int klen, pem_password_cb *callback, void *u) |
| 269 | { | 317 | { |
| 270 | BIO *b; | 318 | BIO *b; |
| @@ -283,7 +331,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, | |||
| 283 | #endif | 331 | #endif |
| 284 | 332 | ||
| 285 | int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, | 333 | int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, |
| 286 | char *x, const EVP_CIPHER *enc, unsigned char *kstr, | 334 | void *x, const EVP_CIPHER *enc, unsigned char *kstr, |
| 287 | int klen, pem_password_cb *callback, void *u) | 335 | int klen, pem_password_cb *callback, void *u) |
| 288 | { | 336 | { |
| 289 | EVP_CIPHER_CTX ctx; | 337 | EVP_CIPHER_CTX ctx; |
| @@ -782,3 +830,25 @@ err: | |||
| 782 | BUF_MEM_free(dataB); | 830 | BUF_MEM_free(dataB); |
| 783 | return(0); | 831 | return(0); |
| 784 | } | 832 | } |
| 833 | |||
| 834 | /* Check pem string and return prefix length. | ||
| 835 | * If for example the pem_str == "RSA PRIVATE KEY" and suffix = "PRIVATE KEY" | ||
| 836 | * the return value is 3 for the string "RSA". | ||
| 837 | */ | ||
| 838 | |||
| 839 | int pem_check_suffix(const char *pem_str, const char *suffix) | ||
| 840 | { | ||
| 841 | int pem_len = strlen(pem_str); | ||
| 842 | int suffix_len = strlen(suffix); | ||
| 843 | const char *p; | ||
| 844 | if (suffix_len + 1 >= pem_len) | ||
| 845 | return 0; | ||
| 846 | p = pem_str + pem_len - suffix_len; | ||
| 847 | if (strcmp(p, suffix)) | ||
| 848 | return 0; | ||
| 849 | p--; | ||
| 850 | if (*p != ' ') | ||
| 851 | return 0; | ||
| 852 | return p - pem_str; | ||
| 853 | } | ||
| 854 | |||
diff --git a/src/lib/libcrypto/pem/pem_pkey.c b/src/lib/libcrypto/pem/pem_pkey.c index 4da4c31ce5..8ecf24903b 100644 --- a/src/lib/libcrypto/pem/pem_pkey.c +++ b/src/lib/libcrypto/pem/pem_pkey.c | |||
| @@ -65,7 +65,12 @@ | |||
| 65 | #include <openssl/x509.h> | 65 | #include <openssl/x509.h> |
| 66 | #include <openssl/pkcs12.h> | 66 | #include <openssl/pkcs12.h> |
| 67 | #include <openssl/pem.h> | 67 | #include <openssl/pem.h> |
| 68 | #ifndef OPENSSL_NO_ENGINE | ||
| 69 | #include <openssl/engine.h> | ||
| 70 | #endif | ||
| 71 | #include "asn1_locl.h" | ||
| 68 | 72 | ||
| 73 | int pem_check_suffix(const char *pem_str, const char *suffix); | ||
| 69 | 74 | ||
| 70 | EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) | 75 | EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) |
| 71 | { | 76 | { |
| @@ -73,19 +78,14 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo | |||
| 73 | const unsigned char *p=NULL; | 78 | const unsigned char *p=NULL; |
| 74 | unsigned char *data=NULL; | 79 | unsigned char *data=NULL; |
| 75 | long len; | 80 | long len; |
| 81 | int slen; | ||
| 76 | EVP_PKEY *ret=NULL; | 82 | EVP_PKEY *ret=NULL; |
| 77 | 83 | ||
| 78 | if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u)) | 84 | if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u)) |
| 79 | return NULL; | 85 | return NULL; |
| 80 | p = data; | 86 | p = data; |
| 81 | 87 | ||
| 82 | if (strcmp(nm,PEM_STRING_RSA) == 0) | 88 | if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) { |
| 83 | ret=d2i_PrivateKey(EVP_PKEY_RSA,x,&p,len); | ||
| 84 | else if (strcmp(nm,PEM_STRING_DSA) == 0) | ||
| 85 | ret=d2i_PrivateKey(EVP_PKEY_DSA,x,&p,len); | ||
| 86 | else if (strcmp(nm,PEM_STRING_ECPRIVATEKEY) == 0) | ||
| 87 | ret=d2i_PrivateKey(EVP_PKEY_EC,x,&p,len); | ||
| 88 | else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) { | ||
| 89 | PKCS8_PRIV_KEY_INFO *p8inf; | 89 | PKCS8_PRIV_KEY_INFO *p8inf; |
| 90 | p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len); | 90 | p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len); |
| 91 | if(!p8inf) goto p8err; | 91 | if(!p8inf) goto p8err; |
| @@ -119,7 +119,14 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo | |||
| 119 | *x = ret; | 119 | *x = ret; |
| 120 | } | 120 | } |
| 121 | PKCS8_PRIV_KEY_INFO_free(p8inf); | 121 | PKCS8_PRIV_KEY_INFO_free(p8inf); |
| 122 | } | 122 | } else if ((slen = pem_check_suffix(nm, "PRIVATE KEY")) > 0) |
| 123 | { | ||
| 124 | const EVP_PKEY_ASN1_METHOD *ameth; | ||
| 125 | ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen); | ||
| 126 | if (!ameth || !ameth->old_priv_decode) | ||
| 127 | goto p8err; | ||
| 128 | ret=d2i_PrivateKey(ameth->pkey_id,x,&p,len); | ||
| 129 | } | ||
| 123 | p8err: | 130 | p8err: |
| 124 | if (ret == NULL) | 131 | if (ret == NULL) |
| 125 | PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY,ERR_R_ASN1_LIB); | 132 | PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY,ERR_R_ASN1_LIB); |
| @@ -130,6 +137,74 @@ err: | |||
| 130 | return(ret); | 137 | return(ret); |
| 131 | } | 138 | } |
| 132 | 139 | ||
| 140 | int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 141 | unsigned char *kstr, int klen, | ||
| 142 | pem_password_cb *cb, void *u) | ||
| 143 | { | ||
| 144 | char pem_str[80]; | ||
| 145 | if (!x->ameth || x->ameth->priv_encode) | ||
| 146 | return PEM_write_bio_PKCS8PrivateKey(bp, x, enc, | ||
| 147 | (char *)kstr, klen, | ||
| 148 | cb, u); | ||
| 149 | |||
| 150 | BIO_snprintf(pem_str, 80, "%s PRIVATE KEY", x->ameth->pem_str); | ||
| 151 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey, | ||
| 152 | pem_str,bp,x,enc,kstr,klen,cb,u); | ||
| 153 | } | ||
| 154 | |||
| 155 | EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) | ||
| 156 | { | ||
| 157 | char *nm=NULL; | ||
| 158 | const unsigned char *p=NULL; | ||
| 159 | unsigned char *data=NULL; | ||
| 160 | long len; | ||
| 161 | int slen; | ||
| 162 | EVP_PKEY *ret=NULL; | ||
| 163 | |||
| 164 | if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_PARAMETERS, | ||
| 165 | bp, 0, NULL)) | ||
| 166 | return NULL; | ||
| 167 | p = data; | ||
| 168 | |||
| 169 | if ((slen = pem_check_suffix(nm, "PARAMETERS")) > 0) | ||
| 170 | { | ||
| 171 | ret = EVP_PKEY_new(); | ||
| 172 | if (!ret) | ||
| 173 | goto err; | ||
| 174 | if (!EVP_PKEY_set_type_str(ret, nm, slen) | ||
| 175 | || !ret->ameth->param_decode | ||
| 176 | || !ret->ameth->param_decode(ret, &p, len)) | ||
| 177 | { | ||
| 178 | EVP_PKEY_free(ret); | ||
| 179 | ret = NULL; | ||
| 180 | goto err; | ||
| 181 | } | ||
| 182 | if(x) | ||
| 183 | { | ||
| 184 | if(*x) EVP_PKEY_free((EVP_PKEY *)*x); | ||
| 185 | *x = ret; | ||
| 186 | } | ||
| 187 | } | ||
| 188 | err: | ||
| 189 | if (ret == NULL) | ||
| 190 | PEMerr(PEM_F_PEM_READ_BIO_PARAMETERS,ERR_R_ASN1_LIB); | ||
| 191 | OPENSSL_free(nm); | ||
| 192 | OPENSSL_free(data); | ||
| 193 | return(ret); | ||
| 194 | } | ||
| 195 | |||
| 196 | int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x) | ||
| 197 | { | ||
| 198 | char pem_str[80]; | ||
| 199 | if (!x->ameth || !x->ameth->param_encode) | ||
| 200 | return 0; | ||
| 201 | |||
| 202 | BIO_snprintf(pem_str, 80, "%s PARAMETERS", x->ameth->pem_str); | ||
| 203 | return PEM_ASN1_write_bio( | ||
| 204 | (i2d_of_void *)x->ameth->param_encode, | ||
| 205 | pem_str,bp,x,NULL,NULL,0,0,NULL); | ||
| 206 | } | ||
| 207 | |||
| 133 | #ifndef OPENSSL_NO_FP_API | 208 | #ifndef OPENSSL_NO_FP_API |
| 134 | EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) | 209 | EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) |
| 135 | { | 210 | { |
| @@ -146,4 +221,22 @@ EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void | |||
| 146 | BIO_free(b); | 221 | BIO_free(b); |
| 147 | return(ret); | 222 | return(ret); |
| 148 | } | 223 | } |
| 224 | |||
| 225 | int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, | ||
| 226 | unsigned char *kstr, int klen, | ||
| 227 | pem_password_cb *cb, void *u) | ||
| 228 | { | ||
| 229 | BIO *b; | ||
| 230 | int ret; | ||
| 231 | |||
| 232 | if ((b=BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) | ||
| 233 | { | ||
| 234 | PEMerr(PEM_F_PEM_WRITE_PRIVATEKEY,ERR_R_BUF_LIB); | ||
| 235 | return 0; | ||
| 236 | } | ||
| 237 | ret=PEM_write_bio_PrivateKey(b, x, enc, kstr, klen, cb, u); | ||
| 238 | BIO_free(b); | ||
| 239 | return ret; | ||
| 240 | } | ||
| 241 | |||
| 149 | #endif | 242 | #endif |
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c index 4e554e5481..59690b56ae 100644 --- a/src/lib/libcrypto/pem/pem_seal.c +++ b/src/lib/libcrypto/pem/pem_seal.c | |||
| @@ -100,7 +100,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, | |||
| 100 | 100 | ||
| 101 | EVP_CIPHER_CTX_init(&ctx->cipher); | 101 | EVP_CIPHER_CTX_init(&ctx->cipher); |
| 102 | ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk); | 102 | ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk); |
| 103 | if (!ret) goto err; | 103 | if (ret <= 0) goto err; |
| 104 | 104 | ||
| 105 | /* base64 encode the keys */ | 105 | /* base64 encode the keys */ |
| 106 | for (i=0; i<npubk; i++) | 106 | for (i=0; i<npubk; i++) |
diff --git a/src/lib/libcrypto/pem/pem_x509.c b/src/lib/libcrypto/pem/pem_x509.c index 3f709f13e6..b531057dc9 100644 --- a/src/lib/libcrypto/pem/pem_x509.c +++ b/src/lib/libcrypto/pem/pem_x509.c | |||
| @@ -57,7 +57,6 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #undef SSLEAY_MACROS | ||
| 61 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 62 | #include <openssl/bio.h> | 61 | #include <openssl/bio.h> |
| 63 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
diff --git a/src/lib/libcrypto/pem/pem_xaux.c b/src/lib/libcrypto/pem/pem_xaux.c index 7cc7491009..328f796200 100644 --- a/src/lib/libcrypto/pem/pem_xaux.c +++ b/src/lib/libcrypto/pem/pem_xaux.c | |||
| @@ -57,7 +57,6 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #undef SSLEAY_MACROS | ||
| 61 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 62 | #include <openssl/bio.h> | 61 | #include <openssl/bio.h> |
| 63 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
