diff options
Diffstat (limited to 'src/lib/libcrypto/x509v3')
26 files changed, 6610 insertions, 0 deletions
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl new file mode 100644 index 0000000000..40fe46f983 --- /dev/null +++ b/src/lib/libcrypto/x509v3/Makefile.ssl | |||
| @@ -0,0 +1,420 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/x509v3/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= x509v3 | ||
| 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 README | ||
| 22 | TEST= | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \ | ||
| 27 | v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c \ | ||
| 28 | v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \ | ||
| 29 | v3_ocsp.c v3_akeya.c | ||
| 30 | LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \ | ||
| 31 | v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o \ | ||
| 32 | v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o \ | ||
| 33 | v3_ocsp.o v3_akeya.o | ||
| 34 | |||
| 35 | SRC= $(LIBSRC) | ||
| 36 | |||
| 37 | EXHEADER= x509v3.h | ||
| 38 | HEADER= $(EXHEADER) | ||
| 39 | |||
| 40 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 41 | |||
| 42 | top: | ||
| 43 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 44 | |||
| 45 | all: lib | ||
| 46 | |||
| 47 | lib: $(LIBOBJ) | ||
| 48 | $(AR) $(LIB) $(LIBOBJ) | ||
| 49 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 50 | @touch lib | ||
| 51 | |||
| 52 | files: | ||
| 53 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 54 | |||
| 55 | links: | ||
| 56 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 57 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 58 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 59 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 60 | |||
| 61 | install: | ||
| 62 | @for i in $(EXHEADER) ; \ | ||
| 63 | do \ | ||
| 64 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 65 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 66 | done; | ||
| 67 | |||
| 68 | tags: | ||
| 69 | ctags $(SRC) | ||
| 70 | |||
| 71 | tests: | ||
| 72 | |||
| 73 | lint: | ||
| 74 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 75 | |||
| 76 | depend: | ||
| 77 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) | ||
| 78 | |||
| 79 | dclean: | ||
| 80 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 81 | mv -f Makefile.new $(MAKEFILE) | ||
| 82 | |||
| 83 | clean: | ||
| 84 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 85 | |||
| 86 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 87 | |||
| 88 | v3_akey.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 89 | v3_akey.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 90 | v3_akey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 91 | v3_akey.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 92 | v3_akey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 93 | v3_akey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 94 | v3_akey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 95 | v3_akey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 96 | v3_akey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 97 | v3_akey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 98 | v3_akey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 99 | v3_akey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 100 | v3_akey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 101 | v3_akey.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 102 | v3_akey.o: ../cryptlib.h v3_akey.c | ||
| 103 | v3_akeya.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 104 | v3_akeya.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 105 | v3_akeya.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 106 | v3_akeya.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 107 | v3_akeya.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 108 | v3_akeya.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 109 | v3_akeya.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 110 | v3_akeya.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 111 | v3_akeya.o: ../../include/openssl/opensslconf.h | ||
| 112 | v3_akeya.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 113 | v3_akeya.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 114 | v3_akeya.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 115 | v3_akeya.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 116 | v3_akeya.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 117 | v3_akeya.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_akeya.c | ||
| 118 | v3_alt.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 119 | v3_alt.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 120 | v3_alt.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 121 | v3_alt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 122 | v3_alt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 123 | v3_alt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 124 | v3_alt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 125 | v3_alt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 126 | v3_alt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 127 | v3_alt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 128 | v3_alt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 129 | v3_alt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 130 | v3_alt.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 131 | v3_alt.o: ../cryptlib.h v3_alt.c | ||
| 132 | v3_bcons.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 133 | v3_bcons.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 134 | v3_bcons.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 135 | v3_bcons.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 136 | v3_bcons.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 137 | v3_bcons.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 138 | v3_bcons.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 139 | v3_bcons.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 140 | v3_bcons.o: ../../include/openssl/opensslconf.h | ||
| 141 | v3_bcons.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 142 | v3_bcons.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 143 | v3_bcons.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 144 | v3_bcons.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 145 | v3_bcons.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 146 | v3_bcons.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bcons.c | ||
| 147 | v3_bitst.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 148 | v3_bitst.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 149 | v3_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 150 | v3_bitst.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 151 | v3_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 152 | v3_bitst.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 153 | v3_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 154 | v3_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 155 | v3_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 156 | v3_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 157 | v3_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 158 | v3_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 159 | v3_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 160 | v3_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bitst.c | ||
| 161 | v3_conf.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 162 | v3_conf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 163 | v3_conf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 164 | v3_conf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 165 | v3_conf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 166 | v3_conf.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 167 | v3_conf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 168 | v3_conf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 169 | v3_conf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 170 | v3_conf.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 171 | v3_conf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 172 | v3_conf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 173 | v3_conf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 174 | v3_conf.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_conf.c | ||
| 175 | v3_cpols.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 176 | v3_cpols.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 177 | v3_cpols.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 178 | v3_cpols.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 179 | v3_cpols.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 180 | v3_cpols.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 181 | v3_cpols.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 182 | v3_cpols.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 183 | v3_cpols.o: ../../include/openssl/opensslconf.h | ||
| 184 | v3_cpols.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 185 | v3_cpols.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 186 | v3_cpols.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 187 | v3_cpols.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 188 | v3_cpols.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 189 | v3_cpols.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_cpols.c | ||
| 190 | v3_crld.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 191 | v3_crld.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 192 | v3_crld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 193 | v3_crld.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 194 | v3_crld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 195 | v3_crld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 196 | v3_crld.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 197 | v3_crld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 198 | v3_crld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 199 | v3_crld.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 200 | v3_crld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 201 | v3_crld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 202 | v3_crld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 203 | v3_crld.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 204 | v3_crld.o: ../cryptlib.h v3_crld.c | ||
| 205 | v3_enum.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 206 | v3_enum.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 207 | v3_enum.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 208 | v3_enum.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 209 | v3_enum.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 210 | v3_enum.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 211 | v3_enum.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 212 | v3_enum.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 213 | v3_enum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 214 | v3_enum.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 215 | v3_enum.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 216 | v3_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 217 | v3_enum.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 218 | v3_enum.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_enum.c | ||
| 219 | v3_extku.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 220 | v3_extku.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 221 | v3_extku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 222 | v3_extku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 223 | v3_extku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 224 | v3_extku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 225 | v3_extku.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 226 | v3_extku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 227 | v3_extku.o: ../../include/openssl/opensslconf.h | ||
| 228 | v3_extku.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 229 | v3_extku.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 230 | v3_extku.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 231 | v3_extku.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 232 | v3_extku.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 233 | v3_extku.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_extku.c | ||
| 234 | v3_genn.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 235 | v3_genn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 236 | v3_genn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 237 | v3_genn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 238 | v3_genn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 239 | v3_genn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 240 | v3_genn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 241 | v3_genn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 242 | v3_genn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 243 | v3_genn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 244 | v3_genn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 245 | v3_genn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 246 | v3_genn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 247 | v3_genn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 248 | v3_genn.o: ../cryptlib.h v3_genn.c | ||
| 249 | v3_ia5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 250 | v3_ia5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 251 | v3_ia5.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 252 | v3_ia5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 253 | v3_ia5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 254 | v3_ia5.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 255 | v3_ia5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 256 | v3_ia5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 257 | v3_ia5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 258 | v3_ia5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 259 | v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 260 | v3_ia5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 261 | v3_ia5.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 262 | v3_ia5.o: ../cryptlib.h v3_ia5.c | ||
| 263 | v3_info.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 264 | v3_info.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 265 | v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 266 | v3_info.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 267 | v3_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 268 | v3_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 269 | v3_info.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 270 | v3_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 271 | v3_info.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 272 | v3_info.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 273 | v3_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 274 | v3_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 275 | v3_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 276 | v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 277 | v3_info.o: ../cryptlib.h v3_info.c | ||
| 278 | v3_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 279 | v3_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 280 | v3_int.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 281 | v3_int.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 282 | v3_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 283 | v3_int.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 284 | v3_int.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 285 | v3_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 286 | v3_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 287 | v3_int.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 288 | v3_int.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 289 | v3_int.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 290 | v3_int.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 291 | v3_int.o: ../cryptlib.h v3_int.c | ||
| 292 | v3_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 293 | v3_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 294 | v3_lib.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 295 | v3_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 296 | v3_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 297 | v3_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 298 | v3_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 299 | v3_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 300 | v3_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 301 | v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 302 | v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 303 | v3_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 304 | v3_lib.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 305 | v3_lib.o: ../cryptlib.h ext_dat.h v3_lib.c | ||
| 306 | v3_ocsp.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 307 | v3_ocsp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 308 | v3_ocsp.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 309 | v3_ocsp.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 310 | v3_ocsp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 311 | v3_ocsp.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 312 | v3_ocsp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 313 | v3_ocsp.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h | ||
| 314 | v3_ocsp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 315 | v3_ocsp.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 316 | v3_ocsp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 317 | v3_ocsp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 318 | v3_ocsp.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 319 | v3_ocsp.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 320 | v3_ocsp.o: ../cryptlib.h v3_ocsp.c | ||
| 321 | v3_pku.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 322 | v3_pku.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 323 | v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 324 | v3_pku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 325 | v3_pku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 326 | v3_pku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 327 | v3_pku.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 328 | v3_pku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 329 | v3_pku.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 330 | v3_pku.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 331 | v3_pku.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 332 | v3_pku.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 333 | v3_pku.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 334 | v3_pku.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 335 | v3_pku.o: ../cryptlib.h v3_pku.c | ||
| 336 | v3_prn.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 337 | v3_prn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 338 | v3_prn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 339 | v3_prn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 340 | v3_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 341 | v3_prn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 342 | v3_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 343 | v3_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 344 | v3_prn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 345 | v3_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 346 | v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 347 | v3_prn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 348 | v3_prn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 349 | v3_prn.o: ../cryptlib.h v3_prn.c | ||
| 350 | v3_purp.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 351 | v3_purp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 352 | v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 353 | v3_purp.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 354 | v3_purp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 355 | v3_purp.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 356 | v3_purp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 357 | v3_purp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 358 | v3_purp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 359 | v3_purp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 360 | v3_purp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 361 | v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 362 | v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 363 | v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_purp.c | ||
| 364 | v3_skey.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 365 | v3_skey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 366 | v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 367 | v3_skey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 368 | v3_skey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 369 | v3_skey.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 370 | v3_skey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 371 | v3_skey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 372 | v3_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 373 | v3_skey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 374 | v3_skey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 375 | v3_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 376 | v3_skey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 377 | v3_skey.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_skey.c | ||
| 378 | v3_sxnet.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 379 | v3_sxnet.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 380 | v3_sxnet.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 381 | v3_sxnet.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 382 | v3_sxnet.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 383 | v3_sxnet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 384 | v3_sxnet.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 385 | v3_sxnet.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 386 | v3_sxnet.o: ../../include/openssl/opensslconf.h | ||
| 387 | v3_sxnet.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 388 | v3_sxnet.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 389 | v3_sxnet.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 390 | v3_sxnet.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 391 | v3_sxnet.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 392 | v3_sxnet.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_sxnet.c | ||
| 393 | v3_utl.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 394 | v3_utl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 395 | v3_utl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 396 | v3_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 397 | v3_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 398 | v3_utl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 399 | v3_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 400 | v3_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 401 | v3_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 402 | v3_utl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 403 | v3_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 404 | v3_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 405 | v3_utl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 406 | v3_utl.o: ../cryptlib.h v3_utl.c | ||
| 407 | v3err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 408 | v3err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 409 | v3err.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 410 | v3err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 411 | v3err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 412 | v3err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 413 | v3err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 414 | v3err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 415 | v3err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 416 | v3err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 417 | v3err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 418 | v3err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 419 | v3err.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | ||
| 420 | v3err.o: v3err.c | ||
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h new file mode 100644 index 0000000000..586f116db5 --- /dev/null +++ b/src/lib/libcrypto/x509v3/ext_dat.h | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | /* ext_dat.h */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* This file contains a table of "standard" extensions */ | ||
| 59 | |||
| 60 | extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; | ||
| 61 | extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info, v3_sinfo; | ||
| 62 | extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; | ||
| 63 | extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate, v3_cpols, v3_crld; | ||
| 64 | extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff; | ||
| 65 | extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc; | ||
| 66 | extern X509V3_EXT_METHOD v3_crl_hold; | ||
| 67 | |||
| 68 | /* This table will be searched using OBJ_bsearch so it *must* kept in | ||
| 69 | * order of the ext_nid values. | ||
| 70 | */ | ||
| 71 | |||
| 72 | static X509V3_EXT_METHOD *standard_exts[] = { | ||
| 73 | &v3_nscert, | ||
| 74 | &v3_ns_ia5_list[0], | ||
| 75 | &v3_ns_ia5_list[1], | ||
| 76 | &v3_ns_ia5_list[2], | ||
| 77 | &v3_ns_ia5_list[3], | ||
| 78 | &v3_ns_ia5_list[4], | ||
| 79 | &v3_ns_ia5_list[5], | ||
| 80 | &v3_ns_ia5_list[6], | ||
| 81 | &v3_skey_id, | ||
| 82 | &v3_key_usage, | ||
| 83 | &v3_pkey_usage_period, | ||
| 84 | &v3_alt[0], | ||
| 85 | &v3_alt[1], | ||
| 86 | &v3_bcons, | ||
| 87 | &v3_crl_num, | ||
| 88 | &v3_cpols, | ||
| 89 | &v3_akey_id, | ||
| 90 | &v3_crld, | ||
| 91 | &v3_ext_ku, | ||
| 92 | &v3_crl_reason, | ||
| 93 | &v3_crl_invdate, | ||
| 94 | &v3_sxnet, | ||
| 95 | &v3_info, | ||
| 96 | &v3_ocsp_nonce, | ||
| 97 | &v3_ocsp_crlid, | ||
| 98 | &v3_ocsp_accresp, | ||
| 99 | &v3_ocsp_nocheck, | ||
| 100 | &v3_ocsp_acutoff, | ||
| 101 | &v3_ocsp_serviceloc, | ||
| 102 | &v3_crl_hold, | ||
| 103 | &v3_sinfo | ||
| 104 | }; | ||
| 105 | |||
| 106 | /* Number of standard extensions */ | ||
| 107 | |||
| 108 | #define STANDARD_EXTENSION_COUNT (sizeof(standard_exts)/sizeof(X509V3_EXT_METHOD *)) | ||
| 109 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_akey.c b/src/lib/libcrypto/x509v3/v3_akey.c new file mode 100644 index 0000000000..97e686f97a --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_akey.c | |||
| @@ -0,0 +1,190 @@ | |||
| 1 | /* v3_akey.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, | ||
| 67 | AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist); | ||
| 68 | static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, | ||
| 69 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); | ||
| 70 | |||
| 71 | X509V3_EXT_METHOD v3_akey_id = { | ||
| 72 | NID_authority_key_identifier, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_KEYID), | ||
| 73 | 0,0,0,0, | ||
| 74 | 0,0, | ||
| 75 | (X509V3_EXT_I2V)i2v_AUTHORITY_KEYID, | ||
| 76 | (X509V3_EXT_V2I)v2i_AUTHORITY_KEYID, | ||
| 77 | 0,0, | ||
| 78 | NULL | ||
| 79 | }; | ||
| 80 | |||
| 81 | static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, | ||
| 82 | AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist) | ||
| 83 | { | ||
| 84 | char *tmp; | ||
| 85 | if(akeyid->keyid) { | ||
| 86 | tmp = hex_to_string(akeyid->keyid->data, akeyid->keyid->length); | ||
| 87 | X509V3_add_value("keyid", tmp, &extlist); | ||
| 88 | OPENSSL_free(tmp); | ||
| 89 | } | ||
| 90 | if(akeyid->issuer) | ||
| 91 | extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); | ||
| 92 | if(akeyid->serial) { | ||
| 93 | tmp = hex_to_string(akeyid->serial->data, | ||
| 94 | akeyid->serial->length); | ||
| 95 | X509V3_add_value("serial", tmp, &extlist); | ||
| 96 | OPENSSL_free(tmp); | ||
| 97 | } | ||
| 98 | return extlist; | ||
| 99 | } | ||
| 100 | |||
| 101 | /* Currently two options: | ||
| 102 | * keyid: use the issuers subject keyid, the value 'always' means its is | ||
| 103 | * an error if the issuer certificate doesn't have a key id. | ||
| 104 | * issuer: use the issuers cert issuer and serial number. The default is | ||
| 105 | * to only use this if keyid is not present. With the option 'always' | ||
| 106 | * this is always included. | ||
| 107 | */ | ||
| 108 | |||
| 109 | static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, | ||
| 110 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) | ||
| 111 | { | ||
| 112 | char keyid=0, issuer=0; | ||
| 113 | int i; | ||
| 114 | CONF_VALUE *cnf; | ||
| 115 | ASN1_OCTET_STRING *ikeyid = NULL; | ||
| 116 | X509_NAME *isname = NULL; | ||
| 117 | GENERAL_NAMES * gens = NULL; | ||
| 118 | GENERAL_NAME *gen = NULL; | ||
| 119 | ASN1_INTEGER *serial = NULL; | ||
| 120 | X509_EXTENSION *ext; | ||
| 121 | X509 *cert; | ||
| 122 | AUTHORITY_KEYID *akeyid; | ||
| 123 | for(i = 0; i < sk_CONF_VALUE_num(values); i++) { | ||
| 124 | cnf = sk_CONF_VALUE_value(values, i); | ||
| 125 | if(!strcmp(cnf->name, "keyid")) { | ||
| 126 | keyid = 1; | ||
| 127 | if(cnf->value && !strcmp(cnf->value, "always")) keyid = 2; | ||
| 128 | } else if(!strcmp(cnf->name, "issuer")) { | ||
| 129 | issuer = 1; | ||
| 130 | if(cnf->value && !strcmp(cnf->value, "always")) issuer = 2; | ||
| 131 | } else { | ||
| 132 | X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNKNOWN_OPTION); | ||
| 133 | ERR_add_error_data(2, "name=", cnf->name); | ||
| 134 | return NULL; | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | if(!ctx || !ctx->issuer_cert) { | ||
| 139 | if(ctx && (ctx->flags==CTX_TEST)) return AUTHORITY_KEYID_new(); | ||
| 140 | X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_NO_ISSUER_CERTIFICATE); | ||
| 141 | return NULL; | ||
| 142 | } | ||
| 143 | |||
| 144 | cert = ctx->issuer_cert; | ||
| 145 | |||
| 146 | if(keyid) { | ||
| 147 | i = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1); | ||
| 148 | if((i >= 0) && (ext = X509_get_ext(cert, i))) | ||
| 149 | ikeyid = X509V3_EXT_d2i(ext); | ||
| 150 | if(keyid==2 && !ikeyid) { | ||
| 151 | X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_KEYID); | ||
| 152 | return NULL; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | if((issuer && !ikeyid) || (issuer == 2)) { | ||
| 157 | isname = X509_NAME_dup(X509_get_issuer_name(cert)); | ||
| 158 | serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(cert)); | ||
| 159 | if(!isname || !serial) { | ||
| 160 | X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS); | ||
| 161 | goto err; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | if(!(akeyid = AUTHORITY_KEYID_new())) goto err; | ||
| 166 | |||
| 167 | if(isname) { | ||
| 168 | if(!(gens = sk_GENERAL_NAME_new_null()) || !(gen = GENERAL_NAME_new()) | ||
| 169 | || !sk_GENERAL_NAME_push(gens, gen)) { | ||
| 170 | X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,ERR_R_MALLOC_FAILURE); | ||
| 171 | goto err; | ||
| 172 | } | ||
| 173 | gen->type = GEN_DIRNAME; | ||
| 174 | gen->d.dirn = isname; | ||
| 175 | } | ||
| 176 | |||
| 177 | akeyid->issuer = gens; | ||
| 178 | akeyid->serial = serial; | ||
| 179 | akeyid->keyid = ikeyid; | ||
| 180 | |||
| 181 | return akeyid; | ||
| 182 | |||
| 183 | err: | ||
| 184 | X509_NAME_free(isname); | ||
| 185 | M_ASN1_INTEGER_free(serial); | ||
| 186 | M_ASN1_OCTET_STRING_free(ikeyid); | ||
| 187 | return NULL; | ||
| 188 | |||
| 189 | } | ||
| 190 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_akeya.c b/src/lib/libcrypto/x509v3/v3_akeya.c new file mode 100644 index 0000000000..2aafa26ba7 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_akeya.c | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* v3_akey_asn1.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | ASN1_SEQUENCE(AUTHORITY_KEYID) = { | ||
| 67 | ASN1_IMP_OPT(AUTHORITY_KEYID, keyid, ASN1_OCTET_STRING, 0), | ||
| 68 | ASN1_IMP_SEQUENCE_OF_OPT(AUTHORITY_KEYID, issuer, GENERAL_NAME, 1), | ||
| 69 | ASN1_IMP_OPT(AUTHORITY_KEYID, serial, ASN1_INTEGER, 2) | ||
| 70 | } ASN1_SEQUENCE_END(AUTHORITY_KEYID) | ||
| 71 | |||
| 72 | IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_KEYID) | ||
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c new file mode 100644 index 0000000000..0e9e7dcb4f --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_alt.c | |||
| @@ -0,0 +1,457 @@ | |||
| 1 | /* v3_alt.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/x509v3.h> | ||
| 63 | |||
| 64 | static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 65 | static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 66 | static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p); | ||
| 67 | static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens); | ||
| 68 | X509V3_EXT_METHOD v3_alt[] = { | ||
| 69 | { NID_subject_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES), | ||
| 70 | 0,0,0,0, | ||
| 71 | 0,0, | ||
| 72 | (X509V3_EXT_I2V)i2v_GENERAL_NAMES, | ||
| 73 | (X509V3_EXT_V2I)v2i_subject_alt, | ||
| 74 | NULL, NULL, NULL}, | ||
| 75 | |||
| 76 | { NID_issuer_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES), | ||
| 77 | 0,0,0,0, | ||
| 78 | 0,0, | ||
| 79 | (X509V3_EXT_I2V)i2v_GENERAL_NAMES, | ||
| 80 | (X509V3_EXT_V2I)v2i_issuer_alt, | ||
| 81 | NULL, NULL, NULL}, | ||
| 82 | }; | ||
| 83 | |||
| 84 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, | ||
| 85 | GENERAL_NAMES *gens, STACK_OF(CONF_VALUE) *ret) | ||
| 86 | { | ||
| 87 | int i; | ||
| 88 | GENERAL_NAME *gen; | ||
| 89 | for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) { | ||
| 90 | gen = sk_GENERAL_NAME_value(gens, i); | ||
| 91 | ret = i2v_GENERAL_NAME(method, gen, ret); | ||
| 92 | } | ||
| 93 | if(!ret) return sk_CONF_VALUE_new_null(); | ||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | |||
| 97 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, | ||
| 98 | GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret) | ||
| 99 | { | ||
| 100 | unsigned char *p; | ||
| 101 | char oline[256]; | ||
| 102 | switch (gen->type) | ||
| 103 | { | ||
| 104 | case GEN_OTHERNAME: | ||
| 105 | X509V3_add_value("othername","<unsupported>", &ret); | ||
| 106 | break; | ||
| 107 | |||
| 108 | case GEN_X400: | ||
| 109 | X509V3_add_value("X400Name","<unsupported>", &ret); | ||
| 110 | break; | ||
| 111 | |||
| 112 | case GEN_EDIPARTY: | ||
| 113 | X509V3_add_value("EdiPartyName","<unsupported>", &ret); | ||
| 114 | break; | ||
| 115 | |||
| 116 | case GEN_EMAIL: | ||
| 117 | X509V3_add_value_uchar("email",gen->d.ia5->data, &ret); | ||
| 118 | break; | ||
| 119 | |||
| 120 | case GEN_DNS: | ||
| 121 | X509V3_add_value_uchar("DNS",gen->d.ia5->data, &ret); | ||
| 122 | break; | ||
| 123 | |||
| 124 | case GEN_URI: | ||
| 125 | X509V3_add_value_uchar("URI",gen->d.ia5->data, &ret); | ||
| 126 | break; | ||
| 127 | |||
| 128 | case GEN_DIRNAME: | ||
| 129 | X509_NAME_oneline(gen->d.dirn, oline, 256); | ||
| 130 | X509V3_add_value("DirName",oline, &ret); | ||
| 131 | break; | ||
| 132 | |||
| 133 | case GEN_IPADD: | ||
| 134 | p = gen->d.ip->data; | ||
| 135 | /* BUG: doesn't support IPV6 */ | ||
| 136 | if(gen->d.ip->length != 4) { | ||
| 137 | X509V3_add_value("IP Address","<invalid>", &ret); | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | sprintf(oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); | ||
| 141 | X509V3_add_value("IP Address",oline, &ret); | ||
| 142 | break; | ||
| 143 | |||
| 144 | case GEN_RID: | ||
| 145 | i2t_ASN1_OBJECT(oline, 256, gen->d.rid); | ||
| 146 | X509V3_add_value("Registered ID",oline, &ret); | ||
| 147 | break; | ||
| 148 | } | ||
| 149 | return ret; | ||
| 150 | } | ||
| 151 | |||
| 152 | int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen) | ||
| 153 | { | ||
| 154 | unsigned char *p; | ||
| 155 | switch (gen->type) | ||
| 156 | { | ||
| 157 | case GEN_OTHERNAME: | ||
| 158 | BIO_printf(out, "othername:<unsupported>"); | ||
| 159 | break; | ||
| 160 | |||
| 161 | case GEN_X400: | ||
| 162 | BIO_printf(out, "X400Name:<unsupported>"); | ||
| 163 | break; | ||
| 164 | |||
| 165 | case GEN_EDIPARTY: | ||
| 166 | /* Maybe fix this: it is supported now */ | ||
| 167 | BIO_printf(out, "EdiPartyName:<unsupported>"); | ||
| 168 | break; | ||
| 169 | |||
| 170 | case GEN_EMAIL: | ||
| 171 | BIO_printf(out, "email:%s",gen->d.ia5->data); | ||
| 172 | break; | ||
| 173 | |||
| 174 | case GEN_DNS: | ||
| 175 | BIO_printf(out, "DNS:%s",gen->d.ia5->data); | ||
| 176 | break; | ||
| 177 | |||
| 178 | case GEN_URI: | ||
| 179 | BIO_printf(out, "URI:%s",gen->d.ia5->data); | ||
| 180 | break; | ||
| 181 | |||
| 182 | case GEN_DIRNAME: | ||
| 183 | BIO_printf(out, "DirName: "); | ||
| 184 | X509_NAME_print_ex(out, gen->d.dirn, 0, XN_FLAG_ONELINE); | ||
| 185 | break; | ||
| 186 | |||
| 187 | case GEN_IPADD: | ||
| 188 | p = gen->d.ip->data; | ||
| 189 | /* BUG: doesn't support IPV6 */ | ||
| 190 | if(gen->d.ip->length != 4) { | ||
| 191 | BIO_printf(out,"IP Address:<invalid>"); | ||
| 192 | break; | ||
| 193 | } | ||
| 194 | BIO_printf(out, "IP Address:%d.%d.%d.%d", p[0], p[1], p[2], p[3]); | ||
| 195 | break; | ||
| 196 | |||
| 197 | case GEN_RID: | ||
| 198 | BIO_printf(out, "Registered ID"); | ||
| 199 | i2a_ASN1_OBJECT(out, gen->d.rid); | ||
| 200 | break; | ||
| 201 | } | ||
| 202 | return 1; | ||
| 203 | } | ||
| 204 | |||
| 205 | static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, | ||
| 206 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 207 | { | ||
| 208 | GENERAL_NAMES *gens = NULL; | ||
| 209 | CONF_VALUE *cnf; | ||
| 210 | int i; | ||
| 211 | if(!(gens = sk_GENERAL_NAME_new_null())) { | ||
| 212 | X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); | ||
| 213 | return NULL; | ||
| 214 | } | ||
| 215 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 216 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 217 | if(!name_cmp(cnf->name, "issuer") && cnf->value && | ||
| 218 | !strcmp(cnf->value, "copy")) { | ||
| 219 | if(!copy_issuer(ctx, gens)) goto err; | ||
| 220 | } else { | ||
| 221 | GENERAL_NAME *gen; | ||
| 222 | if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) | ||
| 223 | goto err; | ||
| 224 | sk_GENERAL_NAME_push(gens, gen); | ||
| 225 | } | ||
| 226 | } | ||
| 227 | return gens; | ||
| 228 | err: | ||
| 229 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | ||
| 230 | return NULL; | ||
| 231 | } | ||
| 232 | |||
| 233 | /* Append subject altname of issuer to issuer alt name of subject */ | ||
| 234 | |||
| 235 | static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens) | ||
| 236 | { | ||
| 237 | GENERAL_NAMES *ialt; | ||
| 238 | GENERAL_NAME *gen; | ||
| 239 | X509_EXTENSION *ext; | ||
| 240 | int i; | ||
| 241 | if(ctx && (ctx->flags == CTX_TEST)) return 1; | ||
| 242 | if(!ctx || !ctx->issuer_cert) { | ||
| 243 | X509V3err(X509V3_F_COPY_ISSUER,X509V3_R_NO_ISSUER_DETAILS); | ||
| 244 | goto err; | ||
| 245 | } | ||
| 246 | i = X509_get_ext_by_NID(ctx->issuer_cert, NID_subject_alt_name, -1); | ||
| 247 | if(i < 0) return 1; | ||
| 248 | if(!(ext = X509_get_ext(ctx->issuer_cert, i)) || | ||
| 249 | !(ialt = X509V3_EXT_d2i(ext)) ) { | ||
| 250 | X509V3err(X509V3_F_COPY_ISSUER,X509V3_R_ISSUER_DECODE_ERROR); | ||
| 251 | goto err; | ||
| 252 | } | ||
| 253 | |||
| 254 | for(i = 0; i < sk_GENERAL_NAME_num(ialt); i++) { | ||
| 255 | gen = sk_GENERAL_NAME_value(ialt, i); | ||
| 256 | if(!sk_GENERAL_NAME_push(gens, gen)) { | ||
| 257 | X509V3err(X509V3_F_COPY_ISSUER,ERR_R_MALLOC_FAILURE); | ||
| 258 | goto err; | ||
| 259 | } | ||
| 260 | } | ||
| 261 | sk_GENERAL_NAME_free(ialt); | ||
| 262 | |||
| 263 | return 1; | ||
| 264 | |||
| 265 | err: | ||
| 266 | return 0; | ||
| 267 | |||
| 268 | } | ||
| 269 | |||
| 270 | static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method, | ||
| 271 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 272 | { | ||
| 273 | GENERAL_NAMES *gens = NULL; | ||
| 274 | CONF_VALUE *cnf; | ||
| 275 | int i; | ||
| 276 | if(!(gens = sk_GENERAL_NAME_new_null())) { | ||
| 277 | X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); | ||
| 278 | return NULL; | ||
| 279 | } | ||
| 280 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 281 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 282 | if(!name_cmp(cnf->name, "email") && cnf->value && | ||
| 283 | !strcmp(cnf->value, "copy")) { | ||
| 284 | if(!copy_email(ctx, gens, 0)) goto err; | ||
| 285 | } else if(!name_cmp(cnf->name, "email") && cnf->value && | ||
| 286 | !strcmp(cnf->value, "move")) { | ||
| 287 | if(!copy_email(ctx, gens, 1)) goto err; | ||
| 288 | } else { | ||
| 289 | GENERAL_NAME *gen; | ||
| 290 | if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) | ||
| 291 | goto err; | ||
| 292 | sk_GENERAL_NAME_push(gens, gen); | ||
| 293 | } | ||
| 294 | } | ||
| 295 | return gens; | ||
| 296 | err: | ||
| 297 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | ||
| 298 | return NULL; | ||
| 299 | } | ||
| 300 | |||
| 301 | /* Copy any email addresses in a certificate or request to | ||
| 302 | * GENERAL_NAMES | ||
| 303 | */ | ||
| 304 | |||
| 305 | static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p) | ||
| 306 | { | ||
| 307 | X509_NAME *nm; | ||
| 308 | ASN1_IA5STRING *email = NULL; | ||
| 309 | X509_NAME_ENTRY *ne; | ||
| 310 | GENERAL_NAME *gen = NULL; | ||
| 311 | int i; | ||
| 312 | if(ctx->flags == CTX_TEST) return 1; | ||
| 313 | if(!ctx || (!ctx->subject_cert && !ctx->subject_req)) { | ||
| 314 | X509V3err(X509V3_F_COPY_EMAIL,X509V3_R_NO_SUBJECT_DETAILS); | ||
| 315 | goto err; | ||
| 316 | } | ||
| 317 | /* Find the subject name */ | ||
| 318 | if(ctx->subject_cert) nm = X509_get_subject_name(ctx->subject_cert); | ||
| 319 | else nm = X509_REQ_get_subject_name(ctx->subject_req); | ||
| 320 | |||
| 321 | /* Now add any email address(es) to STACK */ | ||
| 322 | i = -1; | ||
| 323 | while((i = X509_NAME_get_index_by_NID(nm, | ||
| 324 | NID_pkcs9_emailAddress, i)) >= 0) { | ||
| 325 | ne = X509_NAME_get_entry(nm, i); | ||
| 326 | email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne)); | ||
| 327 | if (move_p) | ||
| 328 | { | ||
| 329 | X509_NAME_delete_entry(nm, i); | ||
| 330 | i--; | ||
| 331 | } | ||
| 332 | if(!email || !(gen = GENERAL_NAME_new())) { | ||
| 333 | X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); | ||
| 334 | goto err; | ||
| 335 | } | ||
| 336 | gen->d.ia5 = email; | ||
| 337 | email = NULL; | ||
| 338 | gen->type = GEN_EMAIL; | ||
| 339 | if(!sk_GENERAL_NAME_push(gens, gen)) { | ||
| 340 | X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); | ||
| 341 | goto err; | ||
| 342 | } | ||
| 343 | gen = NULL; | ||
| 344 | } | ||
| 345 | |||
| 346 | |||
| 347 | return 1; | ||
| 348 | |||
| 349 | err: | ||
| 350 | GENERAL_NAME_free(gen); | ||
| 351 | M_ASN1_IA5STRING_free(email); | ||
| 352 | return 0; | ||
| 353 | |||
| 354 | } | ||
| 355 | |||
| 356 | GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, | ||
| 357 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 358 | { | ||
| 359 | GENERAL_NAME *gen; | ||
| 360 | GENERAL_NAMES *gens = NULL; | ||
| 361 | CONF_VALUE *cnf; | ||
| 362 | int i; | ||
| 363 | if(!(gens = sk_GENERAL_NAME_new_null())) { | ||
| 364 | X509V3err(X509V3_F_V2I_GENERAL_NAMES,ERR_R_MALLOC_FAILURE); | ||
| 365 | return NULL; | ||
| 366 | } | ||
| 367 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 368 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 369 | if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; | ||
| 370 | sk_GENERAL_NAME_push(gens, gen); | ||
| 371 | } | ||
| 372 | return gens; | ||
| 373 | err: | ||
| 374 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | ||
| 375 | return NULL; | ||
| 376 | } | ||
| 377 | |||
| 378 | GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, | ||
| 379 | CONF_VALUE *cnf) | ||
| 380 | { | ||
| 381 | char is_string = 0; | ||
| 382 | int type; | ||
| 383 | GENERAL_NAME *gen = NULL; | ||
| 384 | |||
| 385 | char *name, *value; | ||
| 386 | |||
| 387 | name = cnf->name; | ||
| 388 | value = cnf->value; | ||
| 389 | |||
| 390 | if(!value) { | ||
| 391 | X509V3err(X509V3_F_V2I_GENERAL_NAME,X509V3_R_MISSING_VALUE); | ||
| 392 | return NULL; | ||
| 393 | } | ||
| 394 | |||
| 395 | if(!(gen = GENERAL_NAME_new())) { | ||
| 396 | X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); | ||
| 397 | return NULL; | ||
| 398 | } | ||
| 399 | |||
| 400 | if(!name_cmp(name, "email")) { | ||
| 401 | is_string = 1; | ||
| 402 | type = GEN_EMAIL; | ||
| 403 | } else if(!name_cmp(name, "URI")) { | ||
| 404 | is_string = 1; | ||
| 405 | type = GEN_URI; | ||
| 406 | } else if(!name_cmp(name, "DNS")) { | ||
| 407 | is_string = 1; | ||
| 408 | type = GEN_DNS; | ||
| 409 | } else if(!name_cmp(name, "RID")) { | ||
| 410 | ASN1_OBJECT *obj; | ||
| 411 | if(!(obj = OBJ_txt2obj(value,0))) { | ||
| 412 | X509V3err(X509V3_F_V2I_GENERAL_NAME,X509V3_R_BAD_OBJECT); | ||
| 413 | ERR_add_error_data(2, "value=", value); | ||
| 414 | goto err; | ||
| 415 | } | ||
| 416 | gen->d.rid = obj; | ||
| 417 | type = GEN_RID; | ||
| 418 | } else if(!name_cmp(name, "IP")) { | ||
| 419 | int i1,i2,i3,i4; | ||
| 420 | unsigned char ip[4]; | ||
| 421 | if((sscanf(value, "%d.%d.%d.%d",&i1,&i2,&i3,&i4) != 4) || | ||
| 422 | (i1 < 0) || (i1 > 255) || (i2 < 0) || (i2 > 255) || | ||
| 423 | (i3 < 0) || (i3 > 255) || (i4 < 0) || (i4 > 255) ) { | ||
| 424 | X509V3err(X509V3_F_V2I_GENERAL_NAME,X509V3_R_BAD_IP_ADDRESS); | ||
| 425 | ERR_add_error_data(2, "value=", value); | ||
| 426 | goto err; | ||
| 427 | } | ||
| 428 | ip[0] = i1; ip[1] = i2 ; ip[2] = i3 ; ip[3] = i4; | ||
| 429 | if(!(gen->d.ip = M_ASN1_OCTET_STRING_new()) || | ||
| 430 | !ASN1_STRING_set(gen->d.ip, ip, 4)) { | ||
| 431 | X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); | ||
| 432 | goto err; | ||
| 433 | } | ||
| 434 | type = GEN_IPADD; | ||
| 435 | } else { | ||
| 436 | X509V3err(X509V3_F_V2I_GENERAL_NAME,X509V3_R_UNSUPPORTED_OPTION); | ||
| 437 | ERR_add_error_data(2, "name=", name); | ||
| 438 | goto err; | ||
| 439 | } | ||
| 440 | |||
| 441 | if(is_string) { | ||
| 442 | if(!(gen->d.ia5 = M_ASN1_IA5STRING_new()) || | ||
| 443 | !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, | ||
| 444 | strlen(value))) { | ||
| 445 | X509V3err(X509V3_F_V2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); | ||
| 446 | goto err; | ||
| 447 | } | ||
| 448 | } | ||
| 449 | |||
| 450 | gen->type = type; | ||
| 451 | |||
| 452 | return gen; | ||
| 453 | |||
| 454 | err: | ||
| 455 | GENERAL_NAME_free(gen); | ||
| 456 | return NULL; | ||
| 457 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_bcons.c b/src/lib/libcrypto/x509v3/v3_bcons.c new file mode 100644 index 0000000000..cbb012715e --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_bcons.c | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | /* v3_bcons.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/conf.h> | ||
| 65 | #include <openssl/x509v3.h> | ||
| 66 | |||
| 67 | static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist); | ||
| 68 | static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); | ||
| 69 | |||
| 70 | X509V3_EXT_METHOD v3_bcons = { | ||
| 71 | NID_basic_constraints, 0, | ||
| 72 | ASN1_ITEM_ref(BASIC_CONSTRAINTS), | ||
| 73 | 0,0,0,0, | ||
| 74 | 0,0, | ||
| 75 | (X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS, | ||
| 76 | (X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS, | ||
| 77 | NULL,NULL, | ||
| 78 | NULL | ||
| 79 | }; | ||
| 80 | |||
| 81 | ASN1_SEQUENCE(BASIC_CONSTRAINTS) = { | ||
| 82 | ASN1_OPT(BASIC_CONSTRAINTS, ca, ASN1_FBOOLEAN), | ||
| 83 | ASN1_OPT(BASIC_CONSTRAINTS, pathlen, ASN1_INTEGER) | ||
| 84 | } ASN1_SEQUENCE_END(BASIC_CONSTRAINTS) | ||
| 85 | |||
| 86 | IMPLEMENT_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) | ||
| 87 | |||
| 88 | |||
| 89 | static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, | ||
| 90 | BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist) | ||
| 91 | { | ||
| 92 | X509V3_add_value_bool("CA", bcons->ca, &extlist); | ||
| 93 | X509V3_add_value_int("pathlen", bcons->pathlen, &extlist); | ||
| 94 | return extlist; | ||
| 95 | } | ||
| 96 | |||
| 97 | static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, | ||
| 98 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) | ||
| 99 | { | ||
| 100 | BASIC_CONSTRAINTS *bcons=NULL; | ||
| 101 | CONF_VALUE *val; | ||
| 102 | int i; | ||
| 103 | if(!(bcons = BASIC_CONSTRAINTS_new())) { | ||
| 104 | X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE); | ||
| 105 | return NULL; | ||
| 106 | } | ||
| 107 | for(i = 0; i < sk_CONF_VALUE_num(values); i++) { | ||
| 108 | val = sk_CONF_VALUE_value(values, i); | ||
| 109 | if(!strcmp(val->name, "CA")) { | ||
| 110 | if(!X509V3_get_value_bool(val, &bcons->ca)) goto err; | ||
| 111 | } else if(!strcmp(val->name, "pathlen")) { | ||
| 112 | if(!X509V3_get_value_int(val, &bcons->pathlen)) goto err; | ||
| 113 | } else { | ||
| 114 | X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, X509V3_R_INVALID_NAME); | ||
| 115 | X509V3_conf_err(val); | ||
| 116 | goto err; | ||
| 117 | } | ||
| 118 | } | ||
| 119 | return bcons; | ||
| 120 | err: | ||
| 121 | BASIC_CONSTRAINTS_free(bcons); | ||
| 122 | return NULL; | ||
| 123 | } | ||
| 124 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_bitst.c b/src/lib/libcrypto/x509v3/v3_bitst.c new file mode 100644 index 0000000000..16cf125562 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_bitst.c | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | /* v3_bitst.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/x509v3.h> | ||
| 63 | |||
| 64 | static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | ||
| 65 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 66 | static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | ||
| 67 | ASN1_BIT_STRING *bits, | ||
| 68 | STACK_OF(CONF_VALUE) *extlist); | ||
| 69 | |||
| 70 | static BIT_STRING_BITNAME ns_cert_type_table[] = { | ||
| 71 | {0, "SSL Client", "client"}, | ||
| 72 | {1, "SSL Server", "server"}, | ||
| 73 | {2, "S/MIME", "email"}, | ||
| 74 | {3, "Object Signing", "objsign"}, | ||
| 75 | {4, "Unused", "reserved"}, | ||
| 76 | {5, "SSL CA", "sslCA"}, | ||
| 77 | {6, "S/MIME CA", "emailCA"}, | ||
| 78 | {7, "Object Signing CA", "objCA"}, | ||
| 79 | {-1, NULL, NULL} | ||
| 80 | }; | ||
| 81 | |||
| 82 | static BIT_STRING_BITNAME key_usage_type_table[] = { | ||
| 83 | {0, "Digital Signature", "digitalSignature"}, | ||
| 84 | {1, "Non Repudiation", "nonRepudiation"}, | ||
| 85 | {2, "Key Encipherment", "keyEncipherment"}, | ||
| 86 | {3, "Data Encipherment", "dataEncipherment"}, | ||
| 87 | {4, "Key Agreement", "keyAgreement"}, | ||
| 88 | {5, "Certificate Sign", "keyCertSign"}, | ||
| 89 | {6, "CRL Sign", "cRLSign"}, | ||
| 90 | {7, "Encipher Only", "encipherOnly"}, | ||
| 91 | {8, "Decipher Only", "decipherOnly"}, | ||
| 92 | {-1, NULL, NULL} | ||
| 93 | }; | ||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); | ||
| 98 | X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table); | ||
| 99 | |||
| 100 | static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | ||
| 101 | ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret) | ||
| 102 | { | ||
| 103 | BIT_STRING_BITNAME *bnam; | ||
| 104 | for(bnam =method->usr_data; bnam->lname; bnam++) { | ||
| 105 | if(ASN1_BIT_STRING_get_bit(bits, bnam->bitnum)) | ||
| 106 | X509V3_add_value(bnam->lname, NULL, &ret); | ||
| 107 | } | ||
| 108 | return ret; | ||
| 109 | } | ||
| 110 | |||
| 111 | static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, | ||
| 112 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 113 | { | ||
| 114 | CONF_VALUE *val; | ||
| 115 | ASN1_BIT_STRING *bs; | ||
| 116 | int i; | ||
| 117 | BIT_STRING_BITNAME *bnam; | ||
| 118 | if(!(bs = M_ASN1_BIT_STRING_new())) { | ||
| 119 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,ERR_R_MALLOC_FAILURE); | ||
| 120 | return NULL; | ||
| 121 | } | ||
| 122 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 123 | val = sk_CONF_VALUE_value(nval, i); | ||
| 124 | for(bnam = method->usr_data; bnam->lname; bnam++) { | ||
| 125 | if(!strcmp(bnam->sname, val->name) || | ||
| 126 | !strcmp(bnam->lname, val->name) ) { | ||
| 127 | ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1); | ||
| 128 | break; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | if(!bnam->lname) { | ||
| 132 | X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, | ||
| 133 | X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); | ||
| 134 | X509V3_conf_err(val); | ||
| 135 | M_ASN1_BIT_STRING_free(bs); | ||
| 136 | return NULL; | ||
| 137 | } | ||
| 138 | } | ||
| 139 | return bs; | ||
| 140 | } | ||
| 141 | |||
| 142 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c new file mode 100644 index 0000000000..1a3448e121 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_conf.c | |||
| @@ -0,0 +1,485 @@ | |||
| 1 | /* v3_conf.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* extension creation utilities */ | ||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | #include <stdio.h> | ||
| 63 | #include <ctype.h> | ||
| 64 | #include "cryptlib.h" | ||
| 65 | #include <openssl/conf.h> | ||
| 66 | #include <openssl/x509.h> | ||
| 67 | #include <openssl/x509v3.h> | ||
| 68 | |||
| 69 | static int v3_check_critical(char **value); | ||
| 70 | static int v3_check_generic(char **value); | ||
| 71 | static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value); | ||
| 72 | static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type); | ||
| 73 | static char *conf_lhash_get_string(void *db, char *section, char *value); | ||
| 74 | static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section); | ||
| 75 | static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, | ||
| 76 | int crit, void *ext_struc); | ||
| 77 | /* CONF *conf: Config file */ | ||
| 78 | /* char *name: Name */ | ||
| 79 | /* char *value: Value */ | ||
| 80 | X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, | ||
| 81 | char *value) | ||
| 82 | { | ||
| 83 | int crit; | ||
| 84 | int ext_type; | ||
| 85 | X509_EXTENSION *ret; | ||
| 86 | crit = v3_check_critical(&value); | ||
| 87 | if ((ext_type = v3_check_generic(&value))) | ||
| 88 | return v3_generic_extension(name, value, crit, ext_type); | ||
| 89 | ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value); | ||
| 90 | if (!ret) | ||
| 91 | { | ||
| 92 | X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_ERROR_IN_EXTENSION); | ||
| 93 | ERR_add_error_data(4,"name=", name, ", value=", value); | ||
| 94 | } | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | |||
| 98 | /* CONF *conf: Config file */ | ||
| 99 | /* char *value: Value */ | ||
| 100 | X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, | ||
| 101 | char *value) | ||
| 102 | { | ||
| 103 | int crit; | ||
| 104 | int ext_type; | ||
| 105 | crit = v3_check_critical(&value); | ||
| 106 | if ((ext_type = v3_check_generic(&value))) | ||
| 107 | return v3_generic_extension(OBJ_nid2sn(ext_nid), | ||
| 108 | value, crit, ext_type); | ||
| 109 | return do_ext_nconf(conf, ctx, ext_nid, crit, value); | ||
| 110 | } | ||
| 111 | |||
| 112 | /* CONF *conf: Config file */ | ||
| 113 | /* char *value: Value */ | ||
| 114 | static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, | ||
| 115 | int crit, char *value) | ||
| 116 | { | ||
| 117 | X509V3_EXT_METHOD *method; | ||
| 118 | X509_EXTENSION *ext; | ||
| 119 | STACK_OF(CONF_VALUE) *nval; | ||
| 120 | void *ext_struc; | ||
| 121 | if (ext_nid == NID_undef) | ||
| 122 | { | ||
| 123 | X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION_NAME); | ||
| 124 | return NULL; | ||
| 125 | } | ||
| 126 | if (!(method = X509V3_EXT_get_nid(ext_nid))) | ||
| 127 | { | ||
| 128 | X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION); | ||
| 129 | return NULL; | ||
| 130 | } | ||
| 131 | /* Now get internal extension representation based on type */ | ||
| 132 | if (method->v2i) | ||
| 133 | { | ||
| 134 | if(*value == '@') nval = NCONF_get_section(conf, value + 1); | ||
| 135 | else nval = X509V3_parse_list(value); | ||
| 136 | if(!nval) | ||
| 137 | { | ||
| 138 | X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_INVALID_EXTENSION_STRING); | ||
| 139 | ERR_add_error_data(4, "name=", OBJ_nid2sn(ext_nid), ",section=", value); | ||
| 140 | return NULL; | ||
| 141 | } | ||
| 142 | ext_struc = method->v2i(method, ctx, nval); | ||
| 143 | if(*value != '@') sk_CONF_VALUE_pop_free(nval, | ||
| 144 | X509V3_conf_free); | ||
| 145 | if(!ext_struc) return NULL; | ||
| 146 | } | ||
| 147 | else if(method->s2i) | ||
| 148 | { | ||
| 149 | if(!(ext_struc = method->s2i(method, ctx, value))) return NULL; | ||
| 150 | } | ||
| 151 | else if(method->r2i) | ||
| 152 | { | ||
| 153 | if(!ctx->db) | ||
| 154 | { | ||
| 155 | X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_NO_CONFIG_DATABASE); | ||
| 156 | return NULL; | ||
| 157 | } | ||
| 158 | if(!(ext_struc = method->r2i(method, ctx, value))) return NULL; | ||
| 159 | } | ||
| 160 | else | ||
| 161 | { | ||
| 162 | X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED); | ||
| 163 | ERR_add_error_data(2, "name=", OBJ_nid2sn(ext_nid)); | ||
| 164 | return NULL; | ||
| 165 | } | ||
| 166 | |||
| 167 | ext = do_ext_i2d(method, ext_nid, crit, ext_struc); | ||
| 168 | if(method->it) ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it)); | ||
| 169 | else method->ext_free(ext_struc); | ||
| 170 | return ext; | ||
| 171 | |||
| 172 | } | ||
| 173 | |||
| 174 | static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, | ||
| 175 | int crit, void *ext_struc) | ||
| 176 | { | ||
| 177 | unsigned char *ext_der; | ||
| 178 | int ext_len; | ||
| 179 | ASN1_OCTET_STRING *ext_oct; | ||
| 180 | X509_EXTENSION *ext; | ||
| 181 | /* Convert internal representation to DER */ | ||
| 182 | if (method->it) | ||
| 183 | { | ||
| 184 | ext_der = NULL; | ||
| 185 | ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it)); | ||
| 186 | if (ext_len < 0) goto merr; | ||
| 187 | } | ||
| 188 | else | ||
| 189 | { | ||
| 190 | unsigned char *p; | ||
| 191 | ext_len = method->i2d(ext_struc, NULL); | ||
| 192 | if(!(ext_der = OPENSSL_malloc(ext_len))) goto merr; | ||
| 193 | p = ext_der; | ||
| 194 | method->i2d(ext_struc, &p); | ||
| 195 | } | ||
| 196 | if (!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr; | ||
| 197 | ext_oct->data = ext_der; | ||
| 198 | ext_oct->length = ext_len; | ||
| 199 | |||
| 200 | ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct); | ||
| 201 | if (!ext) goto merr; | ||
| 202 | M_ASN1_OCTET_STRING_free(ext_oct); | ||
| 203 | |||
| 204 | return ext; | ||
| 205 | |||
| 206 | merr: | ||
| 207 | X509V3err(X509V3_F_DO_EXT_I2D,ERR_R_MALLOC_FAILURE); | ||
| 208 | return NULL; | ||
| 209 | |||
| 210 | } | ||
| 211 | |||
| 212 | /* Given an internal structure, nid and critical flag create an extension */ | ||
| 213 | |||
| 214 | X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) | ||
| 215 | { | ||
| 216 | X509V3_EXT_METHOD *method; | ||
| 217 | if (!(method = X509V3_EXT_get_nid(ext_nid))) { | ||
| 218 | X509V3err(X509V3_F_X509V3_EXT_I2D,X509V3_R_UNKNOWN_EXTENSION); | ||
| 219 | return NULL; | ||
| 220 | } | ||
| 221 | return do_ext_i2d(method, ext_nid, crit, ext_struc); | ||
| 222 | } | ||
| 223 | |||
| 224 | /* Check the extension string for critical flag */ | ||
| 225 | static int v3_check_critical(char **value) | ||
| 226 | { | ||
| 227 | char *p = *value; | ||
| 228 | if ((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0; | ||
| 229 | p+=9; | ||
| 230 | while(isspace((unsigned char)*p)) p++; | ||
| 231 | *value = p; | ||
| 232 | return 1; | ||
| 233 | } | ||
| 234 | |||
| 235 | /* Check extension string for generic extension and return the type */ | ||
| 236 | static int v3_check_generic(char **value) | ||
| 237 | { | ||
| 238 | char *p = *value; | ||
| 239 | if ((strlen(p) < 4) || strncmp(p, "DER:,", 4)) return 0; | ||
| 240 | p+=4; | ||
| 241 | while (isspace((unsigned char)*p)) p++; | ||
| 242 | *value = p; | ||
| 243 | return 1; | ||
| 244 | } | ||
| 245 | |||
| 246 | /* Create a generic extension: for now just handle DER type */ | ||
| 247 | static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, | ||
| 248 | int crit, int type) | ||
| 249 | { | ||
| 250 | unsigned char *ext_der=NULL; | ||
| 251 | long ext_len; | ||
| 252 | ASN1_OBJECT *obj=NULL; | ||
| 253 | ASN1_OCTET_STRING *oct=NULL; | ||
| 254 | X509_EXTENSION *extension=NULL; | ||
| 255 | if (!(obj = OBJ_txt2obj(ext, 0))) | ||
| 256 | { | ||
| 257 | X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_NAME_ERROR); | ||
| 258 | ERR_add_error_data(2, "name=", ext); | ||
| 259 | goto err; | ||
| 260 | } | ||
| 261 | |||
| 262 | if (!(ext_der = string_to_hex(value, &ext_len))) | ||
| 263 | { | ||
| 264 | X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_VALUE_ERROR); | ||
| 265 | ERR_add_error_data(2, "value=", value); | ||
| 266 | goto err; | ||
| 267 | } | ||
| 268 | |||
| 269 | if (!(oct = M_ASN1_OCTET_STRING_new())) | ||
| 270 | { | ||
| 271 | X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE); | ||
| 272 | goto err; | ||
| 273 | } | ||
| 274 | |||
| 275 | oct->data = ext_der; | ||
| 276 | oct->length = ext_len; | ||
| 277 | ext_der = NULL; | ||
| 278 | |||
| 279 | extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct); | ||
| 280 | |||
| 281 | err: | ||
| 282 | ASN1_OBJECT_free(obj); | ||
| 283 | M_ASN1_OCTET_STRING_free(oct); | ||
| 284 | if(ext_der) OPENSSL_free(ext_der); | ||
| 285 | return extension; | ||
| 286 | |||
| 287 | } | ||
| 288 | |||
| 289 | |||
| 290 | /* This is the main function: add a bunch of extensions based on a config file | ||
| 291 | * section to an extension STACK. | ||
| 292 | */ | ||
| 293 | |||
| 294 | |||
| 295 | int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, | ||
| 296 | STACK_OF(X509_EXTENSION) **sk) | ||
| 297 | { | ||
| 298 | X509_EXTENSION *ext; | ||
| 299 | STACK_OF(CONF_VALUE) *nval; | ||
| 300 | CONF_VALUE *val; | ||
| 301 | int i; | ||
| 302 | if (!(nval = NCONF_get_section(conf, section))) return 0; | ||
| 303 | for (i = 0; i < sk_CONF_VALUE_num(nval); i++) | ||
| 304 | { | ||
| 305 | val = sk_CONF_VALUE_value(nval, i); | ||
| 306 | if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value))) | ||
| 307 | return 0; | ||
| 308 | if (sk) X509v3_add_ext(sk, ext, -1); | ||
| 309 | X509_EXTENSION_free(ext); | ||
| 310 | } | ||
| 311 | return 1; | ||
| 312 | } | ||
| 313 | |||
| 314 | /* Convenience functions to add extensions to a certificate, CRL and request */ | ||
| 315 | |||
| 316 | int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | ||
| 317 | X509 *cert) | ||
| 318 | { | ||
| 319 | STACK_OF(X509_EXTENSION) **sk = NULL; | ||
| 320 | if (cert) | ||
| 321 | sk = &cert->cert_info->extensions; | ||
| 322 | return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); | ||
| 323 | } | ||
| 324 | |||
| 325 | /* Same as above but for a CRL */ | ||
| 326 | |||
| 327 | int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | ||
| 328 | X509_CRL *crl) | ||
| 329 | { | ||
| 330 | STACK_OF(X509_EXTENSION) **sk = NULL; | ||
| 331 | if (crl) | ||
| 332 | sk = &crl->crl->extensions; | ||
| 333 | return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); | ||
| 334 | } | ||
| 335 | |||
| 336 | /* Add extensions to certificate request */ | ||
| 337 | |||
| 338 | int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, | ||
| 339 | X509_REQ *req) | ||
| 340 | { | ||
| 341 | STACK_OF(X509_EXTENSION) *extlist = NULL, **sk = NULL; | ||
| 342 | int i; | ||
| 343 | if (req) | ||
| 344 | sk = &extlist; | ||
| 345 | i = X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); | ||
| 346 | if (!i || !sk) | ||
| 347 | return i; | ||
| 348 | i = X509_REQ_add_extensions(req, extlist); | ||
| 349 | sk_X509_EXTENSION_pop_free(extlist, X509_EXTENSION_free); | ||
| 350 | return i; | ||
| 351 | } | ||
| 352 | |||
| 353 | /* Config database functions */ | ||
| 354 | |||
| 355 | char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) | ||
| 356 | { | ||
| 357 | if (ctx->db_meth->get_string) | ||
| 358 | return ctx->db_meth->get_string(ctx->db, name, section); | ||
| 359 | return NULL; | ||
| 360 | } | ||
| 361 | |||
| 362 | STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section) | ||
| 363 | { | ||
| 364 | if (ctx->db_meth->get_section) | ||
| 365 | return ctx->db_meth->get_section(ctx->db, section); | ||
| 366 | return NULL; | ||
| 367 | } | ||
| 368 | |||
| 369 | void X509V3_string_free(X509V3_CTX *ctx, char *str) | ||
| 370 | { | ||
| 371 | if (!str) return; | ||
| 372 | if (ctx->db_meth->free_string) | ||
| 373 | ctx->db_meth->free_string(ctx->db, str); | ||
| 374 | } | ||
| 375 | |||
| 376 | void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) | ||
| 377 | { | ||
| 378 | if (!section) return; | ||
| 379 | if (ctx->db_meth->free_section) | ||
| 380 | ctx->db_meth->free_section(ctx->db, section); | ||
| 381 | } | ||
| 382 | |||
| 383 | static char *nconf_get_string(void *db, char *section, char *value) | ||
| 384 | { | ||
| 385 | return NCONF_get_string(db, section, value); | ||
| 386 | } | ||
| 387 | |||
| 388 | static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, char *section) | ||
| 389 | { | ||
| 390 | return NCONF_get_section(db, section); | ||
| 391 | } | ||
| 392 | |||
| 393 | static X509V3_CONF_METHOD nconf_method = { | ||
| 394 | nconf_get_string, | ||
| 395 | nconf_get_section, | ||
| 396 | NULL, | ||
| 397 | NULL | ||
| 398 | }; | ||
| 399 | |||
| 400 | void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf) | ||
| 401 | { | ||
| 402 | ctx->db_meth = &nconf_method; | ||
| 403 | ctx->db = conf; | ||
| 404 | } | ||
| 405 | |||
| 406 | void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, | ||
| 407 | X509_CRL *crl, int flags) | ||
| 408 | { | ||
| 409 | ctx->issuer_cert = issuer; | ||
| 410 | ctx->subject_cert = subj; | ||
| 411 | ctx->crl = crl; | ||
| 412 | ctx->subject_req = req; | ||
| 413 | ctx->flags = flags; | ||
| 414 | } | ||
| 415 | |||
| 416 | /* Old conf compatibility functions */ | ||
| 417 | |||
| 418 | X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, | ||
| 419 | char *value) | ||
| 420 | { | ||
| 421 | CONF ctmp; | ||
| 422 | CONF_set_nconf(&ctmp, conf); | ||
| 423 | return X509V3_EXT_nconf(&ctmp, ctx, name, value); | ||
| 424 | } | ||
| 425 | |||
| 426 | /* LHASH *conf: Config file */ | ||
| 427 | /* char *value: Value */ | ||
| 428 | X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, | ||
| 429 | char *value) | ||
| 430 | { | ||
| 431 | CONF ctmp; | ||
| 432 | CONF_set_nconf(&ctmp, conf); | ||
| 433 | return X509V3_EXT_nconf_nid(&ctmp, ctx, ext_nid, value); | ||
| 434 | } | ||
| 435 | |||
| 436 | static char *conf_lhash_get_string(void *db, char *section, char *value) | ||
| 437 | { | ||
| 438 | return CONF_get_string(db, section, value); | ||
| 439 | } | ||
| 440 | |||
| 441 | static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section) | ||
| 442 | { | ||
| 443 | return CONF_get_section(db, section); | ||
| 444 | } | ||
| 445 | |||
| 446 | static X509V3_CONF_METHOD conf_lhash_method = { | ||
| 447 | conf_lhash_get_string, | ||
| 448 | conf_lhash_get_section, | ||
| 449 | NULL, | ||
| 450 | NULL | ||
| 451 | }; | ||
| 452 | |||
| 453 | void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash) | ||
| 454 | { | ||
| 455 | ctx->db_meth = &conf_lhash_method; | ||
| 456 | ctx->db = lhash; | ||
| 457 | } | ||
| 458 | |||
| 459 | int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, | ||
| 460 | X509 *cert) | ||
| 461 | { | ||
| 462 | CONF ctmp; | ||
| 463 | CONF_set_nconf(&ctmp, conf); | ||
| 464 | return X509V3_EXT_add_nconf(&ctmp, ctx, section, cert); | ||
| 465 | } | ||
| 466 | |||
| 467 | /* Same as above but for a CRL */ | ||
| 468 | |||
| 469 | int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, | ||
| 470 | X509_CRL *crl) | ||
| 471 | { | ||
| 472 | CONF ctmp; | ||
| 473 | CONF_set_nconf(&ctmp, conf); | ||
| 474 | return X509V3_EXT_CRL_add_nconf(&ctmp, ctx, section, crl); | ||
| 475 | } | ||
| 476 | |||
| 477 | /* Add extensions to certificate request */ | ||
| 478 | |||
| 479 | int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, | ||
| 480 | X509_REQ *req) | ||
| 481 | { | ||
| 482 | CONF ctmp; | ||
| 483 | CONF_set_nconf(&ctmp, conf); | ||
| 484 | return X509V3_EXT_REQ_add_nconf(&ctmp, ctx, section, req); | ||
| 485 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c new file mode 100644 index 0000000000..0d4ab1f680 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_cpols.c | |||
| @@ -0,0 +1,422 @@ | |||
| 1 | /* v3_cpols.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | /* Certificate policies extension support: this one is a bit complex... */ | ||
| 67 | |||
| 68 | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, BIO *out, int indent); | ||
| 69 | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value); | ||
| 70 | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, int indent); | ||
| 71 | static void print_notice(BIO *out, USERNOTICE *notice, int indent); | ||
| 72 | static POLICYINFO *policy_section(X509V3_CTX *ctx, | ||
| 73 | STACK_OF(CONF_VALUE) *polstrs, int ia5org); | ||
| 74 | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, | ||
| 75 | STACK_OF(CONF_VALUE) *unot, int ia5org); | ||
| 76 | static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos); | ||
| 77 | |||
| 78 | X509V3_EXT_METHOD v3_cpols = { | ||
| 79 | NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES), | ||
| 80 | 0,0,0,0, | ||
| 81 | 0,0, | ||
| 82 | 0,0, | ||
| 83 | (X509V3_EXT_I2R)i2r_certpol, | ||
| 84 | (X509V3_EXT_R2I)r2i_certpol, | ||
| 85 | NULL | ||
| 86 | }; | ||
| 87 | |||
| 88 | ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = | ||
| 89 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO) | ||
| 90 | ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES) | ||
| 91 | |||
| 92 | IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) | ||
| 93 | |||
| 94 | ASN1_SEQUENCE(POLICYINFO) = { | ||
| 95 | ASN1_SIMPLE(POLICYINFO, policyid, ASN1_OBJECT), | ||
| 96 | ASN1_SEQUENCE_OF_OPT(POLICYINFO, qualifiers, POLICYQUALINFO) | ||
| 97 | } ASN1_SEQUENCE_END(POLICYINFO) | ||
| 98 | |||
| 99 | IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO) | ||
| 100 | |||
| 101 | ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY); | ||
| 102 | |||
| 103 | ASN1_ADB(POLICYQUALINFO) = { | ||
| 104 | ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)), | ||
| 105 | ADB_ENTRY(NID_id_qt_unotice, ASN1_SIMPLE(POLICYQUALINFO, d.usernotice, USERNOTICE)) | ||
| 106 | } ASN1_ADB_END(POLICYQUALINFO, 0, pqualid, 0, &policydefault_tt, NULL); | ||
| 107 | |||
| 108 | ASN1_SEQUENCE(POLICYQUALINFO) = { | ||
| 109 | ASN1_SIMPLE(POLICYQUALINFO, pqualid, ASN1_OBJECT), | ||
| 110 | ASN1_ADB_OBJECT(POLICYQUALINFO) | ||
| 111 | } ASN1_SEQUENCE_END(POLICYQUALINFO) | ||
| 112 | |||
| 113 | IMPLEMENT_ASN1_FUNCTIONS(POLICYQUALINFO) | ||
| 114 | |||
| 115 | ASN1_SEQUENCE(USERNOTICE) = { | ||
| 116 | ASN1_OPT(USERNOTICE, noticeref, NOTICEREF), | ||
| 117 | ASN1_OPT(USERNOTICE, exptext, DISPLAYTEXT) | ||
| 118 | } ASN1_SEQUENCE_END(USERNOTICE) | ||
| 119 | |||
| 120 | IMPLEMENT_ASN1_FUNCTIONS(USERNOTICE) | ||
| 121 | |||
| 122 | ASN1_SEQUENCE(NOTICEREF) = { | ||
| 123 | ASN1_SIMPLE(NOTICEREF, organization, DISPLAYTEXT), | ||
| 124 | ASN1_SEQUENCE_OF(NOTICEREF, noticenos, ASN1_INTEGER) | ||
| 125 | } ASN1_SEQUENCE_END(NOTICEREF) | ||
| 126 | |||
| 127 | IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF) | ||
| 128 | |||
| 129 | static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, | ||
| 130 | X509V3_CTX *ctx, char *value) | ||
| 131 | { | ||
| 132 | STACK_OF(POLICYINFO) *pols = NULL; | ||
| 133 | char *pstr; | ||
| 134 | POLICYINFO *pol; | ||
| 135 | ASN1_OBJECT *pobj; | ||
| 136 | STACK_OF(CONF_VALUE) *vals; | ||
| 137 | CONF_VALUE *cnf; | ||
| 138 | int i, ia5org; | ||
| 139 | pols = sk_POLICYINFO_new_null(); | ||
| 140 | vals = X509V3_parse_list(value); | ||
| 141 | ia5org = 0; | ||
| 142 | for(i = 0; i < sk_CONF_VALUE_num(vals); i++) { | ||
| 143 | cnf = sk_CONF_VALUE_value(vals, i); | ||
| 144 | if(cnf->value || !cnf->name ) { | ||
| 145 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_POLICY_IDENTIFIER); | ||
| 146 | X509V3_conf_err(cnf); | ||
| 147 | goto err; | ||
| 148 | } | ||
| 149 | pstr = cnf->name; | ||
| 150 | if(!strcmp(pstr,"ia5org")) { | ||
| 151 | ia5org = 1; | ||
| 152 | continue; | ||
| 153 | } else if(*pstr == '@') { | ||
| 154 | STACK_OF(CONF_VALUE) *polsect; | ||
| 155 | polsect = X509V3_get_section(ctx, pstr + 1); | ||
| 156 | if(!polsect) { | ||
| 157 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_SECTION); | ||
| 158 | |||
| 159 | X509V3_conf_err(cnf); | ||
| 160 | goto err; | ||
| 161 | } | ||
| 162 | pol = policy_section(ctx, polsect, ia5org); | ||
| 163 | X509V3_section_free(ctx, polsect); | ||
| 164 | if(!pol) goto err; | ||
| 165 | } else { | ||
| 166 | if(!(pobj = OBJ_txt2obj(cnf->name, 0))) { | ||
| 167 | X509V3err(X509V3_F_R2I_CERTPOL,X509V3_R_INVALID_OBJECT_IDENTIFIER); | ||
| 168 | X509V3_conf_err(cnf); | ||
| 169 | goto err; | ||
| 170 | } | ||
| 171 | pol = POLICYINFO_new(); | ||
| 172 | pol->policyid = pobj; | ||
| 173 | } | ||
| 174 | sk_POLICYINFO_push(pols, pol); | ||
| 175 | } | ||
| 176 | sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); | ||
| 177 | return pols; | ||
| 178 | err: | ||
| 179 | sk_POLICYINFO_pop_free(pols, POLICYINFO_free); | ||
| 180 | return NULL; | ||
| 181 | } | ||
| 182 | |||
| 183 | static POLICYINFO *policy_section(X509V3_CTX *ctx, | ||
| 184 | STACK_OF(CONF_VALUE) *polstrs, int ia5org) | ||
| 185 | { | ||
| 186 | int i; | ||
| 187 | CONF_VALUE *cnf; | ||
| 188 | POLICYINFO *pol; | ||
| 189 | POLICYQUALINFO *qual; | ||
| 190 | if(!(pol = POLICYINFO_new())) goto merr; | ||
| 191 | for(i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { | ||
| 192 | cnf = sk_CONF_VALUE_value(polstrs, i); | ||
| 193 | if(!strcmp(cnf->name, "policyIdentifier")) { | ||
| 194 | ASN1_OBJECT *pobj; | ||
| 195 | if(!(pobj = OBJ_txt2obj(cnf->value, 0))) { | ||
| 196 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_OBJECT_IDENTIFIER); | ||
| 197 | X509V3_conf_err(cnf); | ||
| 198 | goto err; | ||
| 199 | } | ||
| 200 | pol->policyid = pobj; | ||
| 201 | |||
| 202 | } else if(!name_cmp(cnf->name, "CPS")) { | ||
| 203 | if(!pol->qualifiers) pol->qualifiers = | ||
| 204 | sk_POLICYQUALINFO_new_null(); | ||
| 205 | if(!(qual = POLICYQUALINFO_new())) goto merr; | ||
| 206 | if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) | ||
| 207 | goto merr; | ||
| 208 | qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); | ||
| 209 | qual->d.cpsuri = M_ASN1_IA5STRING_new(); | ||
| 210 | if(!ASN1_STRING_set(qual->d.cpsuri, cnf->value, | ||
| 211 | strlen(cnf->value))) goto merr; | ||
| 212 | } else if(!name_cmp(cnf->name, "userNotice")) { | ||
| 213 | STACK_OF(CONF_VALUE) *unot; | ||
| 214 | if(*cnf->value != '@') { | ||
| 215 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_EXPECTED_A_SECTION_NAME); | ||
| 216 | X509V3_conf_err(cnf); | ||
| 217 | goto err; | ||
| 218 | } | ||
| 219 | unot = X509V3_get_section(ctx, cnf->value + 1); | ||
| 220 | if(!unot) { | ||
| 221 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_SECTION); | ||
| 222 | |||
| 223 | X509V3_conf_err(cnf); | ||
| 224 | goto err; | ||
| 225 | } | ||
| 226 | qual = notice_section(ctx, unot, ia5org); | ||
| 227 | X509V3_section_free(ctx, unot); | ||
| 228 | if(!qual) goto err; | ||
| 229 | if(!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) | ||
| 230 | goto merr; | ||
| 231 | } else { | ||
| 232 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_INVALID_OPTION); | ||
| 233 | |||
| 234 | X509V3_conf_err(cnf); | ||
| 235 | goto err; | ||
| 236 | } | ||
| 237 | } | ||
| 238 | if(!pol->policyid) { | ||
| 239 | X509V3err(X509V3_F_POLICY_SECTION,X509V3_R_NO_POLICY_IDENTIFIER); | ||
| 240 | goto err; | ||
| 241 | } | ||
| 242 | |||
| 243 | return pol; | ||
| 244 | |||
| 245 | merr: | ||
| 246 | X509V3err(X509V3_F_POLICY_SECTION,ERR_R_MALLOC_FAILURE); | ||
| 247 | |||
| 248 | err: | ||
| 249 | POLICYINFO_free(pol); | ||
| 250 | return NULL; | ||
| 251 | |||
| 252 | |||
| 253 | } | ||
| 254 | |||
| 255 | static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, | ||
| 256 | STACK_OF(CONF_VALUE) *unot, int ia5org) | ||
| 257 | { | ||
| 258 | int i; | ||
| 259 | CONF_VALUE *cnf; | ||
| 260 | USERNOTICE *not; | ||
| 261 | POLICYQUALINFO *qual; | ||
| 262 | if(!(qual = POLICYQUALINFO_new())) goto merr; | ||
| 263 | qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice); | ||
| 264 | if(!(not = USERNOTICE_new())) goto merr; | ||
| 265 | qual->d.usernotice = not; | ||
| 266 | for(i = 0; i < sk_CONF_VALUE_num(unot); i++) { | ||
| 267 | cnf = sk_CONF_VALUE_value(unot, i); | ||
| 268 | if(!strcmp(cnf->name, "explicitText")) { | ||
| 269 | not->exptext = M_ASN1_VISIBLESTRING_new(); | ||
| 270 | if(!ASN1_STRING_set(not->exptext, cnf->value, | ||
| 271 | strlen(cnf->value))) goto merr; | ||
| 272 | } else if(!strcmp(cnf->name, "organization")) { | ||
| 273 | NOTICEREF *nref; | ||
| 274 | if(!not->noticeref) { | ||
| 275 | if(!(nref = NOTICEREF_new())) goto merr; | ||
| 276 | not->noticeref = nref; | ||
| 277 | } else nref = not->noticeref; | ||
| 278 | if(ia5org) nref->organization = M_ASN1_IA5STRING_new(); | ||
| 279 | else nref->organization = M_ASN1_VISIBLESTRING_new(); | ||
| 280 | if(!ASN1_STRING_set(nref->organization, cnf->value, | ||
| 281 | strlen(cnf->value))) goto merr; | ||
| 282 | } else if(!strcmp(cnf->name, "noticeNumbers")) { | ||
| 283 | NOTICEREF *nref; | ||
| 284 | STACK_OF(CONF_VALUE) *nos; | ||
| 285 | if(!not->noticeref) { | ||
| 286 | if(!(nref = NOTICEREF_new())) goto merr; | ||
| 287 | not->noticeref = nref; | ||
| 288 | } else nref = not->noticeref; | ||
| 289 | nos = X509V3_parse_list(cnf->value); | ||
| 290 | if(!nos || !sk_CONF_VALUE_num(nos)) { | ||
| 291 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_NUMBERS); | ||
| 292 | X509V3_conf_err(cnf); | ||
| 293 | goto err; | ||
| 294 | } | ||
| 295 | nref->noticenos = nref_nos(nos); | ||
| 296 | sk_CONF_VALUE_pop_free(nos, X509V3_conf_free); | ||
| 297 | if(!nref->noticenos) goto err; | ||
| 298 | } else { | ||
| 299 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_INVALID_OPTION); | ||
| 300 | |||
| 301 | X509V3_conf_err(cnf); | ||
| 302 | goto err; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | |||
| 306 | if(not->noticeref && | ||
| 307 | (!not->noticeref->noticenos || !not->noticeref->organization)) { | ||
| 308 | X509V3err(X509V3_F_NOTICE_SECTION,X509V3_R_NEED_ORGANIZATION_AND_NUMBERS); | ||
| 309 | goto err; | ||
| 310 | } | ||
| 311 | |||
| 312 | return qual; | ||
| 313 | |||
| 314 | merr: | ||
| 315 | X509V3err(X509V3_F_NOTICE_SECTION,ERR_R_MALLOC_FAILURE); | ||
| 316 | |||
| 317 | err: | ||
| 318 | POLICYQUALINFO_free(qual); | ||
| 319 | return NULL; | ||
| 320 | } | ||
| 321 | |||
| 322 | static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos) | ||
| 323 | { | ||
| 324 | STACK_OF(ASN1_INTEGER) *nnums; | ||
| 325 | CONF_VALUE *cnf; | ||
| 326 | ASN1_INTEGER *aint; | ||
| 327 | |||
| 328 | int i; | ||
| 329 | |||
| 330 | if(!(nnums = sk_ASN1_INTEGER_new_null())) goto merr; | ||
| 331 | for(i = 0; i < sk_CONF_VALUE_num(nos); i++) { | ||
| 332 | cnf = sk_CONF_VALUE_value(nos, i); | ||
| 333 | if(!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { | ||
| 334 | X509V3err(X509V3_F_NREF_NOS,X509V3_R_INVALID_NUMBER); | ||
| 335 | goto err; | ||
| 336 | } | ||
| 337 | if(!sk_ASN1_INTEGER_push(nnums, aint)) goto merr; | ||
| 338 | } | ||
| 339 | return nnums; | ||
| 340 | |||
| 341 | merr: | ||
| 342 | X509V3err(X509V3_F_NOTICE_SECTION,ERR_R_MALLOC_FAILURE); | ||
| 343 | |||
| 344 | err: | ||
| 345 | sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free); | ||
| 346 | return NULL; | ||
| 347 | } | ||
| 348 | |||
| 349 | |||
| 350 | static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, | ||
| 351 | BIO *out, int indent) | ||
| 352 | { | ||
| 353 | int i; | ||
| 354 | POLICYINFO *pinfo; | ||
| 355 | /* First print out the policy OIDs */ | ||
| 356 | for(i = 0; i < sk_POLICYINFO_num(pol); i++) { | ||
| 357 | pinfo = sk_POLICYINFO_value(pol, i); | ||
| 358 | BIO_printf(out, "%*sPolicy: ", indent, ""); | ||
| 359 | i2a_ASN1_OBJECT(out, pinfo->policyid); | ||
| 360 | BIO_puts(out, "\n"); | ||
| 361 | if(pinfo->qualifiers) | ||
| 362 | print_qualifiers(out, pinfo->qualifiers, indent + 2); | ||
| 363 | } | ||
| 364 | return 1; | ||
| 365 | } | ||
| 366 | |||
| 367 | static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, | ||
| 368 | int indent) | ||
| 369 | { | ||
| 370 | POLICYQUALINFO *qualinfo; | ||
| 371 | int i; | ||
| 372 | for(i = 0; i < sk_POLICYQUALINFO_num(quals); i++) { | ||
| 373 | qualinfo = sk_POLICYQUALINFO_value(quals, i); | ||
| 374 | switch(OBJ_obj2nid(qualinfo->pqualid)) | ||
| 375 | { | ||
| 376 | case NID_id_qt_cps: | ||
| 377 | BIO_printf(out, "%*sCPS: %s\n", indent, "", | ||
| 378 | qualinfo->d.cpsuri->data); | ||
| 379 | break; | ||
| 380 | |||
| 381 | case NID_id_qt_unotice: | ||
| 382 | BIO_printf(out, "%*sUser Notice:\n", indent, ""); | ||
| 383 | print_notice(out, qualinfo->d.usernotice, indent + 2); | ||
| 384 | break; | ||
| 385 | |||
| 386 | default: | ||
| 387 | BIO_printf(out, "%*sUnknown Qualifier: ", | ||
| 388 | indent + 2, ""); | ||
| 389 | |||
| 390 | i2a_ASN1_OBJECT(out, qualinfo->pqualid); | ||
| 391 | BIO_puts(out, "\n"); | ||
| 392 | break; | ||
| 393 | } | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | static void print_notice(BIO *out, USERNOTICE *notice, int indent) | ||
| 398 | { | ||
| 399 | int i; | ||
| 400 | if(notice->noticeref) { | ||
| 401 | NOTICEREF *ref; | ||
| 402 | ref = notice->noticeref; | ||
| 403 | BIO_printf(out, "%*sOrganization: %s\n", indent, "", | ||
| 404 | ref->organization->data); | ||
| 405 | BIO_printf(out, "%*sNumber%s: ", indent, "", | ||
| 406 | sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); | ||
| 407 | for(i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) { | ||
| 408 | ASN1_INTEGER *num; | ||
| 409 | char *tmp; | ||
| 410 | num = sk_ASN1_INTEGER_value(ref->noticenos, i); | ||
| 411 | if(i) BIO_puts(out, ", "); | ||
| 412 | tmp = i2s_ASN1_INTEGER(NULL, num); | ||
| 413 | BIO_puts(out, tmp); | ||
| 414 | OPENSSL_free(tmp); | ||
| 415 | } | ||
| 416 | BIO_puts(out, "\n"); | ||
| 417 | } | ||
| 418 | if(notice->exptext) | ||
| 419 | BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", | ||
| 420 | notice->exptext->data); | ||
| 421 | } | ||
| 422 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c new file mode 100644 index 0000000000..894a8b94d8 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_crld.c | |||
| @@ -0,0 +1,162 @@ | |||
| 1 | /* v3_crld.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, | ||
| 67 | STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *extlist); | ||
| 68 | static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | ||
| 69 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 70 | |||
| 71 | X509V3_EXT_METHOD v3_crld = { | ||
| 72 | NID_crl_distribution_points, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(CRL_DIST_POINTS), | ||
| 73 | 0,0,0,0, | ||
| 74 | 0,0, | ||
| 75 | (X509V3_EXT_I2V)i2v_crld, | ||
| 76 | (X509V3_EXT_V2I)v2i_crld, | ||
| 77 | 0,0, | ||
| 78 | NULL | ||
| 79 | }; | ||
| 80 | |||
| 81 | static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, | ||
| 82 | STACK_OF(DIST_POINT) *crld, STACK_OF(CONF_VALUE) *exts) | ||
| 83 | { | ||
| 84 | DIST_POINT *point; | ||
| 85 | int i; | ||
| 86 | for(i = 0; i < sk_DIST_POINT_num(crld); i++) { | ||
| 87 | point = sk_DIST_POINT_value(crld, i); | ||
| 88 | if(point->distpoint) { | ||
| 89 | if(point->distpoint->type == 0) | ||
| 90 | exts = i2v_GENERAL_NAMES(NULL, | ||
| 91 | point->distpoint->name.fullname, exts); | ||
| 92 | else X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts); | ||
| 93 | } | ||
| 94 | if(point->reasons) | ||
| 95 | X509V3_add_value("reasons","<UNSUPPORTED>", &exts); | ||
| 96 | if(point->CRLissuer) | ||
| 97 | X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); | ||
| 98 | } | ||
| 99 | return exts; | ||
| 100 | } | ||
| 101 | |||
| 102 | static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method, | ||
| 103 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 104 | { | ||
| 105 | STACK_OF(DIST_POINT) *crld = NULL; | ||
| 106 | GENERAL_NAMES *gens = NULL; | ||
| 107 | GENERAL_NAME *gen = NULL; | ||
| 108 | CONF_VALUE *cnf; | ||
| 109 | int i; | ||
| 110 | if(!(crld = sk_DIST_POINT_new_null())) goto merr; | ||
| 111 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 112 | DIST_POINT *point; | ||
| 113 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 114 | if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; | ||
| 115 | if(!(gens = GENERAL_NAMES_new())) goto merr; | ||
| 116 | if(!sk_GENERAL_NAME_push(gens, gen)) goto merr; | ||
| 117 | gen = NULL; | ||
| 118 | if(!(point = DIST_POINT_new())) goto merr; | ||
| 119 | if(!sk_DIST_POINT_push(crld, point)) { | ||
| 120 | DIST_POINT_free(point); | ||
| 121 | goto merr; | ||
| 122 | } | ||
| 123 | if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; | ||
| 124 | point->distpoint->name.fullname = gens; | ||
| 125 | point->distpoint->type = 0; | ||
| 126 | gens = NULL; | ||
| 127 | } | ||
| 128 | return crld; | ||
| 129 | |||
| 130 | merr: | ||
| 131 | X509V3err(X509V3_F_V2I_CRLD,ERR_R_MALLOC_FAILURE); | ||
| 132 | err: | ||
| 133 | GENERAL_NAME_free(gen); | ||
| 134 | GENERAL_NAMES_free(gens); | ||
| 135 | sk_DIST_POINT_pop_free(crld, DIST_POINT_free); | ||
| 136 | return NULL; | ||
| 137 | } | ||
| 138 | |||
| 139 | IMPLEMENT_STACK_OF(DIST_POINT) | ||
| 140 | IMPLEMENT_ASN1_SET_OF(DIST_POINT) | ||
| 141 | |||
| 142 | |||
| 143 | ASN1_CHOICE(DIST_POINT_NAME) = { | ||
| 144 | ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), | ||
| 145 | ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) | ||
| 146 | } ASN1_CHOICE_END(DIST_POINT_NAME) | ||
| 147 | |||
| 148 | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) | ||
| 149 | |||
| 150 | ASN1_SEQUENCE(DIST_POINT) = { | ||
| 151 | ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0), | ||
| 152 | ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1), | ||
| 153 | ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2) | ||
| 154 | } ASN1_SEQUENCE_END(DIST_POINT) | ||
| 155 | |||
| 156 | IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT) | ||
| 157 | |||
| 158 | ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) = | ||
| 159 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, DIST_POINT, DIST_POINT) | ||
| 160 | ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS) | ||
| 161 | |||
| 162 | IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) | ||
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c new file mode 100644 index 0000000000..010c9d6260 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_enum.c | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* v3_enum.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/x509v3.h> | ||
| 62 | |||
| 63 | static ENUMERATED_NAMES crl_reasons[] = { | ||
| 64 | {0, "Unspecified", "unspecified"}, | ||
| 65 | {1, "Key Compromise", "keyCompromise"}, | ||
| 66 | {2, "CA Compromise", "CACompromise"}, | ||
| 67 | {3, "Affiliation Changed", "affiliationChanged"}, | ||
| 68 | {4, "Superseded", "superseded"}, | ||
| 69 | {5, "Cessation Of Operation", "cessationOfOperation"}, | ||
| 70 | {6, "Certificate Hold", "certificateHold"}, | ||
| 71 | {8, "Remove From CRL", "removeFromCRL"}, | ||
| 72 | {-1, NULL, NULL} | ||
| 73 | }; | ||
| 74 | |||
| 75 | X509V3_EXT_METHOD v3_crl_reason = { | ||
| 76 | NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), | ||
| 77 | 0,0,0,0, | ||
| 78 | (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, | ||
| 79 | 0, | ||
| 80 | 0,0,0,0, | ||
| 81 | crl_reasons}; | ||
| 82 | |||
| 83 | |||
| 84 | char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, | ||
| 85 | ASN1_ENUMERATED *e) | ||
| 86 | { | ||
| 87 | ENUMERATED_NAMES *enam; | ||
| 88 | long strval; | ||
| 89 | strval = ASN1_ENUMERATED_get(e); | ||
| 90 | for(enam = method->usr_data; enam->lname; enam++) { | ||
| 91 | if(strval == enam->bitnum) return BUF_strdup(enam->lname); | ||
| 92 | } | ||
| 93 | return i2s_ASN1_ENUMERATED(method, e); | ||
| 94 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_extku.c b/src/lib/libcrypto/x509v3/v3_extku.c new file mode 100644 index 0000000000..b1cfaba1aa --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_extku.c | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | /* v3_extku.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/asn1t.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, | ||
| 67 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 68 | static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, | ||
| 69 | void *eku, STACK_OF(CONF_VALUE) *extlist); | ||
| 70 | |||
| 71 | X509V3_EXT_METHOD v3_ext_ku = { | ||
| 72 | NID_ext_key_usage, 0, | ||
| 73 | ASN1_ITEM_ref(EXTENDED_KEY_USAGE), | ||
| 74 | 0,0,0,0, | ||
| 75 | 0,0, | ||
| 76 | i2v_EXTENDED_KEY_USAGE, | ||
| 77 | v2i_EXTENDED_KEY_USAGE, | ||
| 78 | 0,0, | ||
| 79 | NULL | ||
| 80 | }; | ||
| 81 | |||
| 82 | /* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */ | ||
| 83 | X509V3_EXT_METHOD v3_ocsp_accresp = { | ||
| 84 | NID_id_pkix_OCSP_acceptableResponses, 0, | ||
| 85 | ASN1_ITEM_ref(EXTENDED_KEY_USAGE), | ||
| 86 | 0,0,0,0, | ||
| 87 | 0,0, | ||
| 88 | i2v_EXTENDED_KEY_USAGE, | ||
| 89 | v2i_EXTENDED_KEY_USAGE, | ||
| 90 | 0,0, | ||
| 91 | NULL | ||
| 92 | }; | ||
| 93 | |||
| 94 | ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = | ||
| 95 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT) | ||
| 96 | ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE) | ||
| 97 | |||
| 98 | IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) | ||
| 99 | |||
| 100 | static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, | ||
| 101 | void *a, STACK_OF(CONF_VALUE) *ext_list) | ||
| 102 | { | ||
| 103 | EXTENDED_KEY_USAGE *eku = a; | ||
| 104 | int i; | ||
| 105 | ASN1_OBJECT *obj; | ||
| 106 | char obj_tmp[80]; | ||
| 107 | for(i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { | ||
| 108 | obj = sk_ASN1_OBJECT_value(eku, i); | ||
| 109 | i2t_ASN1_OBJECT(obj_tmp, 80, obj); | ||
| 110 | X509V3_add_value(NULL, obj_tmp, &ext_list); | ||
| 111 | } | ||
| 112 | return ext_list; | ||
| 113 | } | ||
| 114 | |||
| 115 | static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method, | ||
| 116 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 117 | { | ||
| 118 | EXTENDED_KEY_USAGE *extku; | ||
| 119 | char *extval; | ||
| 120 | ASN1_OBJECT *objtmp; | ||
| 121 | CONF_VALUE *val; | ||
| 122 | int i; | ||
| 123 | |||
| 124 | if(!(extku = sk_ASN1_OBJECT_new_null())) { | ||
| 125 | X509V3err(X509V3_F_V2I_EXT_KU,ERR_R_MALLOC_FAILURE); | ||
| 126 | return NULL; | ||
| 127 | } | ||
| 128 | |||
| 129 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 130 | val = sk_CONF_VALUE_value(nval, i); | ||
| 131 | if(val->value) extval = val->value; | ||
| 132 | else extval = val->name; | ||
| 133 | if(!(objtmp = OBJ_txt2obj(extval, 0))) { | ||
| 134 | sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); | ||
| 135 | X509V3err(X509V3_F_V2I_EXT_KU,X509V3_R_INVALID_OBJECT_IDENTIFIER); | ||
| 136 | X509V3_conf_err(val); | ||
| 137 | return NULL; | ||
| 138 | } | ||
| 139 | sk_ASN1_OBJECT_push(extku, objtmp); | ||
| 140 | } | ||
| 141 | return extku; | ||
| 142 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c new file mode 100644 index 0000000000..650b510980 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_genn.c | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /* v3_genn.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/asn1t.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | ASN1_SEQUENCE(OTHERNAME) = { | ||
| 67 | ASN1_SIMPLE(OTHERNAME, type_id, ASN1_OBJECT), | ||
| 68 | /* Maybe have a true ANY DEFINED BY later */ | ||
| 69 | ASN1_EXP(OTHERNAME, value, ASN1_ANY, 0) | ||
| 70 | } ASN1_SEQUENCE_END(OTHERNAME) | ||
| 71 | |||
| 72 | IMPLEMENT_ASN1_FUNCTIONS(OTHERNAME) | ||
| 73 | |||
| 74 | ASN1_SEQUENCE(EDIPARTYNAME) = { | ||
| 75 | ASN1_IMP_OPT(EDIPARTYNAME, nameAssigner, DIRECTORYSTRING, 0), | ||
| 76 | ASN1_IMP_OPT(EDIPARTYNAME, partyName, DIRECTORYSTRING, 1) | ||
| 77 | } ASN1_SEQUENCE_END(EDIPARTYNAME) | ||
| 78 | |||
| 79 | IMPLEMENT_ASN1_FUNCTIONS(EDIPARTYNAME) | ||
| 80 | |||
| 81 | ASN1_CHOICE(GENERAL_NAME) = { | ||
| 82 | ASN1_IMP(GENERAL_NAME, d.otherName, OTHERNAME, GEN_OTHERNAME), | ||
| 83 | ASN1_IMP(GENERAL_NAME, d.rfc822Name, ASN1_IA5STRING, GEN_EMAIL), | ||
| 84 | ASN1_IMP(GENERAL_NAME, d.dNSName, ASN1_IA5STRING, GEN_DNS), | ||
| 85 | /* Don't decode this */ | ||
| 86 | ASN1_IMP(GENERAL_NAME, d.x400Address, ASN1_SEQUENCE, GEN_X400), | ||
| 87 | /* X509_NAME is a CHOICE type so use EXPLICIT */ | ||
| 88 | ASN1_EXP(GENERAL_NAME, d.directoryName, X509_NAME, GEN_DIRNAME), | ||
| 89 | ASN1_IMP(GENERAL_NAME, d.ediPartyName, EDIPARTYNAME, GEN_EDIPARTY), | ||
| 90 | ASN1_IMP(GENERAL_NAME, d.uniformResourceIdentifier, ASN1_IA5STRING, GEN_URI), | ||
| 91 | ASN1_IMP(GENERAL_NAME, d.iPAddress, ASN1_OCTET_STRING, GEN_IPADD), | ||
| 92 | ASN1_IMP(GENERAL_NAME, d.registeredID, ASN1_OBJECT, GEN_RID) | ||
| 93 | } ASN1_CHOICE_END(GENERAL_NAME) | ||
| 94 | |||
| 95 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) | ||
| 96 | |||
| 97 | ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = | ||
| 98 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) | ||
| 99 | ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) | ||
| 100 | |||
| 101 | IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) | ||
diff --git a/src/lib/libcrypto/x509v3/v3_ia5.c b/src/lib/libcrypto/x509v3/v3_ia5.c new file mode 100644 index 0000000000..f9414456de --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_ia5.c | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | /* v3_ia5.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); | ||
| 67 | static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); | ||
| 68 | X509V3_EXT_METHOD v3_ns_ia5_list[] = { | ||
| 69 | EXT_IA5STRING(NID_netscape_base_url), | ||
| 70 | EXT_IA5STRING(NID_netscape_revocation_url), | ||
| 71 | EXT_IA5STRING(NID_netscape_ca_revocation_url), | ||
| 72 | EXT_IA5STRING(NID_netscape_renewal_url), | ||
| 73 | EXT_IA5STRING(NID_netscape_ca_policy_url), | ||
| 74 | EXT_IA5STRING(NID_netscape_ssl_server_name), | ||
| 75 | EXT_IA5STRING(NID_netscape_comment), | ||
| 76 | EXT_END | ||
| 77 | }; | ||
| 78 | |||
| 79 | |||
| 80 | static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, | ||
| 81 | ASN1_IA5STRING *ia5) | ||
| 82 | { | ||
| 83 | char *tmp; | ||
| 84 | if(!ia5 || !ia5->length) return NULL; | ||
| 85 | if (!(tmp = OPENSSL_malloc(ia5->length + 1))) return NULL; | ||
| 86 | memcpy(tmp, ia5->data, ia5->length); | ||
| 87 | tmp[ia5->length] = 0; | ||
| 88 | return tmp; | ||
| 89 | } | ||
| 90 | |||
| 91 | static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, | ||
| 92 | X509V3_CTX *ctx, char *str) | ||
| 93 | { | ||
| 94 | ASN1_IA5STRING *ia5; | ||
| 95 | if(!str) { | ||
| 96 | X509V3err(X509V3_F_S2I_ASN1_IA5STRING,X509V3_R_INVALID_NULL_ARGUMENT); | ||
| 97 | return NULL; | ||
| 98 | } | ||
| 99 | if(!(ia5 = M_ASN1_IA5STRING_new())) goto err; | ||
| 100 | if(!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str, | ||
| 101 | strlen(str))) { | ||
| 102 | M_ASN1_IA5STRING_free(ia5); | ||
| 103 | goto err; | ||
| 104 | } | ||
| 105 | #ifdef CHARSET_EBCDIC | ||
| 106 | ebcdic2ascii(ia5->data, ia5->data, ia5->length); | ||
| 107 | #endif /*CHARSET_EBCDIC*/ | ||
| 108 | return ia5; | ||
| 109 | err: | ||
| 110 | X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); | ||
| 111 | return NULL; | ||
| 112 | } | ||
| 113 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c new file mode 100644 index 0000000000..7f17f3231d --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_info.c | |||
| @@ -0,0 +1,192 @@ | |||
| 1 | /* v3_info.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, | ||
| 67 | AUTHORITY_INFO_ACCESS *ainfo, | ||
| 68 | STACK_OF(CONF_VALUE) *ret); | ||
| 69 | static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, | ||
| 70 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 71 | |||
| 72 | X509V3_EXT_METHOD v3_info = | ||
| 73 | { NID_info_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS), | ||
| 74 | 0,0,0,0, | ||
| 75 | 0,0, | ||
| 76 | (X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS, | ||
| 77 | (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS, | ||
| 78 | 0,0, | ||
| 79 | NULL}; | ||
| 80 | |||
| 81 | X509V3_EXT_METHOD v3_sinfo = | ||
| 82 | { NID_sinfo_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS), | ||
| 83 | 0,0,0,0, | ||
| 84 | 0,0, | ||
| 85 | (X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS, | ||
| 86 | (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS, | ||
| 87 | 0,0, | ||
| 88 | NULL}; | ||
| 89 | |||
| 90 | ASN1_SEQUENCE(ACCESS_DESCRIPTION) = { | ||
| 91 | ASN1_SIMPLE(ACCESS_DESCRIPTION, method, ASN1_OBJECT), | ||
| 92 | ASN1_SIMPLE(ACCESS_DESCRIPTION, location, GENERAL_NAME) | ||
| 93 | } ASN1_SEQUENCE_END(ACCESS_DESCRIPTION) | ||
| 94 | |||
| 95 | IMPLEMENT_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) | ||
| 96 | |||
| 97 | ASN1_ITEM_TEMPLATE(AUTHORITY_INFO_ACCESS) = | ||
| 98 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, ACCESS_DESCRIPTION) | ||
| 99 | ASN1_ITEM_TEMPLATE_END(AUTHORITY_INFO_ACCESS) | ||
| 100 | |||
| 101 | IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) | ||
| 102 | |||
| 103 | static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, | ||
| 104 | AUTHORITY_INFO_ACCESS *ainfo, | ||
| 105 | STACK_OF(CONF_VALUE) *ret) | ||
| 106 | { | ||
| 107 | ACCESS_DESCRIPTION *desc; | ||
| 108 | int i; | ||
| 109 | char objtmp[80], *ntmp; | ||
| 110 | CONF_VALUE *vtmp; | ||
| 111 | for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) { | ||
| 112 | desc = sk_ACCESS_DESCRIPTION_value(ainfo, i); | ||
| 113 | ret = i2v_GENERAL_NAME(method, desc->location, ret); | ||
| 114 | if(!ret) break; | ||
| 115 | vtmp = sk_CONF_VALUE_value(ret, i); | ||
| 116 | i2t_ASN1_OBJECT(objtmp, 80, desc->method); | ||
| 117 | ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5); | ||
| 118 | if(!ntmp) { | ||
| 119 | X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, | ||
| 120 | ERR_R_MALLOC_FAILURE); | ||
| 121 | return NULL; | ||
| 122 | } | ||
| 123 | strcpy(ntmp, objtmp); | ||
| 124 | strcat(ntmp, " - "); | ||
| 125 | strcat(ntmp, vtmp->name); | ||
| 126 | OPENSSL_free(vtmp->name); | ||
| 127 | vtmp->name = ntmp; | ||
| 128 | |||
| 129 | } | ||
| 130 | if(!ret) return sk_CONF_VALUE_new_null(); | ||
| 131 | return ret; | ||
| 132 | } | ||
| 133 | |||
| 134 | static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, | ||
| 135 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | ||
| 136 | { | ||
| 137 | AUTHORITY_INFO_ACCESS *ainfo = NULL; | ||
| 138 | CONF_VALUE *cnf, ctmp; | ||
| 139 | ACCESS_DESCRIPTION *acc; | ||
| 140 | int i, objlen; | ||
| 141 | char *objtmp, *ptmp; | ||
| 142 | if(!(ainfo = sk_ACCESS_DESCRIPTION_new_null())) { | ||
| 143 | X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE); | ||
| 144 | return NULL; | ||
| 145 | } | ||
| 146 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 147 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 148 | if(!(acc = ACCESS_DESCRIPTION_new()) | ||
| 149 | || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) { | ||
| 150 | X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE); | ||
| 151 | goto err; | ||
| 152 | } | ||
| 153 | ptmp = strchr(cnf->name, ';'); | ||
| 154 | if(!ptmp) { | ||
| 155 | X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_INVALID_SYNTAX); | ||
| 156 | goto err; | ||
| 157 | } | ||
| 158 | objlen = ptmp - cnf->name; | ||
| 159 | ctmp.name = ptmp + 1; | ||
| 160 | ctmp.value = cnf->value; | ||
| 161 | if(!(acc->location = v2i_GENERAL_NAME(method, ctx, &ctmp))) | ||
| 162 | goto err; | ||
| 163 | if(!(objtmp = OPENSSL_malloc(objlen + 1))) { | ||
| 164 | X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,ERR_R_MALLOC_FAILURE); | ||
| 165 | goto err; | ||
| 166 | } | ||
| 167 | strncpy(objtmp, cnf->name, objlen); | ||
| 168 | objtmp[objlen] = 0; | ||
| 169 | acc->method = OBJ_txt2obj(objtmp, 0); | ||
| 170 | if(!acc->method) { | ||
| 171 | X509V3err(X509V3_F_V2I_ACCESS_DESCRIPTION,X509V3_R_BAD_OBJECT); | ||
| 172 | ERR_add_error_data(2, "value=", objtmp); | ||
| 173 | OPENSSL_free(objtmp); | ||
| 174 | goto err; | ||
| 175 | } | ||
| 176 | OPENSSL_free(objtmp); | ||
| 177 | |||
| 178 | } | ||
| 179 | return ainfo; | ||
| 180 | err: | ||
| 181 | sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free); | ||
| 182 | return NULL; | ||
| 183 | } | ||
| 184 | |||
| 185 | int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a) | ||
| 186 | { | ||
| 187 | i2a_ASN1_OBJECT(bp, a->method); | ||
| 188 | #ifdef UNDEF | ||
| 189 | i2a_GENERAL_NAME(bp, a->location); | ||
| 190 | #endif | ||
| 191 | return 2; | ||
| 192 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_int.c b/src/lib/libcrypto/x509v3/v3_int.c new file mode 100644 index 0000000000..f34cbfb731 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_int.c | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | /* v3_int.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/x509v3.h> | ||
| 62 | |||
| 63 | X509V3_EXT_METHOD v3_crl_num = { | ||
| 64 | NID_crl_number, 0, ASN1_ITEM_ref(ASN1_INTEGER), | ||
| 65 | 0,0,0,0, | ||
| 66 | (X509V3_EXT_I2S)i2s_ASN1_INTEGER, | ||
| 67 | 0, | ||
| 68 | 0,0,0,0, NULL}; | ||
| 69 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c new file mode 100644 index 0000000000..482ca8ccf5 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_lib.c | |||
| @@ -0,0 +1,301 @@ | |||
| 1 | /* v3_lib.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* X509 v3 extension utilities */ | ||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/conf.h> | ||
| 63 | #include <openssl/x509v3.h> | ||
| 64 | |||
| 65 | #include "ext_dat.h" | ||
| 66 | |||
| 67 | static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL; | ||
| 68 | |||
| 69 | static int ext_cmp(const X509V3_EXT_METHOD * const *a, | ||
| 70 | const X509V3_EXT_METHOD * const *b); | ||
| 71 | static void ext_list_free(X509V3_EXT_METHOD *ext); | ||
| 72 | |||
| 73 | int X509V3_EXT_add(X509V3_EXT_METHOD *ext) | ||
| 74 | { | ||
| 75 | if(!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp))) { | ||
| 76 | X509V3err(X509V3_F_X509V3_EXT_ADD,ERR_R_MALLOC_FAILURE); | ||
| 77 | return 0; | ||
| 78 | } | ||
| 79 | if(!sk_X509V3_EXT_METHOD_push(ext_list, ext)) { | ||
| 80 | X509V3err(X509V3_F_X509V3_EXT_ADD,ERR_R_MALLOC_FAILURE); | ||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | return 1; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int ext_cmp(const X509V3_EXT_METHOD * const *a, | ||
| 87 | const X509V3_EXT_METHOD * const *b) | ||
| 88 | { | ||
| 89 | return ((*a)->ext_nid - (*b)->ext_nid); | ||
| 90 | } | ||
| 91 | |||
| 92 | X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) | ||
| 93 | { | ||
| 94 | X509V3_EXT_METHOD tmp, *t = &tmp, **ret; | ||
| 95 | int idx; | ||
| 96 | if(nid < 0) return NULL; | ||
| 97 | tmp.ext_nid = nid; | ||
| 98 | ret = (X509V3_EXT_METHOD **) OBJ_bsearch((char *)&t, | ||
| 99 | (char *)standard_exts, STANDARD_EXTENSION_COUNT, | ||
| 100 | sizeof(X509V3_EXT_METHOD *), (int (*)(const void *, const void *))ext_cmp); | ||
| 101 | if(ret) return *ret; | ||
| 102 | if(!ext_list) return NULL; | ||
| 103 | idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); | ||
| 104 | if(idx == -1) return NULL; | ||
| 105 | return sk_X509V3_EXT_METHOD_value(ext_list, idx); | ||
| 106 | } | ||
| 107 | |||
| 108 | X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext) | ||
| 109 | { | ||
| 110 | int nid; | ||
| 111 | if((nid = OBJ_obj2nid(ext->object)) == NID_undef) return NULL; | ||
| 112 | return X509V3_EXT_get_nid(nid); | ||
| 113 | } | ||
| 114 | |||
| 115 | |||
| 116 | int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) | ||
| 117 | { | ||
| 118 | for(;extlist->ext_nid!=-1;extlist++) | ||
| 119 | if(!X509V3_EXT_add(extlist)) return 0; | ||
| 120 | return 1; | ||
| 121 | } | ||
| 122 | |||
| 123 | int X509V3_EXT_add_alias(int nid_to, int nid_from) | ||
| 124 | { | ||
| 125 | X509V3_EXT_METHOD *ext, *tmpext; | ||
| 126 | if(!(ext = X509V3_EXT_get_nid(nid_from))) { | ||
| 127 | X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,X509V3_R_EXTENSION_NOT_FOUND); | ||
| 128 | return 0; | ||
| 129 | } | ||
| 130 | if(!(tmpext = (X509V3_EXT_METHOD *)OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) { | ||
| 131 | X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,ERR_R_MALLOC_FAILURE); | ||
| 132 | return 0; | ||
| 133 | } | ||
| 134 | *tmpext = *ext; | ||
| 135 | tmpext->ext_nid = nid_to; | ||
| 136 | tmpext->ext_flags |= X509V3_EXT_DYNAMIC; | ||
| 137 | return X509V3_EXT_add(tmpext); | ||
| 138 | } | ||
| 139 | |||
| 140 | void X509V3_EXT_cleanup(void) | ||
| 141 | { | ||
| 142 | sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); | ||
| 143 | ext_list = NULL; | ||
| 144 | } | ||
| 145 | |||
| 146 | static void ext_list_free(X509V3_EXT_METHOD *ext) | ||
| 147 | { | ||
| 148 | if(ext->ext_flags & X509V3_EXT_DYNAMIC) OPENSSL_free(ext); | ||
| 149 | } | ||
| 150 | |||
| 151 | /* Legacy function: we don't need to add standard extensions | ||
| 152 | * any more because they are now kept in ext_dat.h. | ||
| 153 | */ | ||
| 154 | |||
| 155 | int X509V3_add_standard_extensions(void) | ||
| 156 | { | ||
| 157 | return 1; | ||
| 158 | } | ||
| 159 | |||
| 160 | /* Return an extension internal structure */ | ||
| 161 | |||
| 162 | void *X509V3_EXT_d2i(X509_EXTENSION *ext) | ||
| 163 | { | ||
| 164 | X509V3_EXT_METHOD *method; | ||
| 165 | unsigned char *p; | ||
| 166 | if(!(method = X509V3_EXT_get(ext))) return NULL; | ||
| 167 | p = ext->value->data; | ||
| 168 | if(method->it) return ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); | ||
| 169 | return method->d2i(NULL, &p, ext->value->length); | ||
| 170 | } | ||
| 171 | |||
| 172 | /* Get critical flag and decoded version of extension from a NID. | ||
| 173 | * The "idx" variable returns the last found extension and can | ||
| 174 | * be used to retrieve multiple extensions of the same NID. | ||
| 175 | * However multiple extensions with the same NID is usually | ||
| 176 | * due to a badly encoded certificate so if idx is NULL we | ||
| 177 | * choke if multiple extensions exist. | ||
| 178 | * The "crit" variable is set to the critical value. | ||
| 179 | * The return value is the decoded extension or NULL on | ||
| 180 | * error. The actual error can have several different causes, | ||
| 181 | * the value of *crit reflects the cause: | ||
| 182 | * >= 0, extension found but not decoded (reflects critical value). | ||
| 183 | * -1 extension not found. | ||
| 184 | * -2 extension occurs more than once. | ||
| 185 | */ | ||
| 186 | |||
| 187 | void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | ||
| 188 | { | ||
| 189 | int lastpos, i; | ||
| 190 | X509_EXTENSION *ex, *found_ex = NULL; | ||
| 191 | if(!x) { | ||
| 192 | if(idx) *idx = -1; | ||
| 193 | if(crit) *crit = -1; | ||
| 194 | return NULL; | ||
| 195 | } | ||
| 196 | if(idx) lastpos = *idx + 1; | ||
| 197 | else lastpos = 0; | ||
| 198 | if(lastpos < 0) lastpos = 0; | ||
| 199 | for(i = lastpos; i < sk_X509_EXTENSION_num(x); i++) | ||
| 200 | { | ||
| 201 | ex = sk_X509_EXTENSION_value(x, i); | ||
| 202 | if(OBJ_obj2nid(ex->object) == nid) { | ||
| 203 | if(idx) { | ||
| 204 | *idx = i; | ||
| 205 | break; | ||
| 206 | } else if(found_ex) { | ||
| 207 | /* Found more than one */ | ||
| 208 | if(crit) *crit = -2; | ||
| 209 | return NULL; | ||
| 210 | } | ||
| 211 | found_ex = ex; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | if(found_ex) { | ||
| 215 | /* Found it */ | ||
| 216 | if(crit) *crit = X509_EXTENSION_get_critical(found_ex); | ||
| 217 | return X509V3_EXT_d2i(found_ex); | ||
| 218 | } | ||
| 219 | |||
| 220 | /* Extension not found */ | ||
| 221 | if(idx) *idx = -1; | ||
| 222 | if(crit) *crit = -1; | ||
| 223 | return NULL; | ||
| 224 | } | ||
| 225 | |||
| 226 | /* This function is a general extension append, replace and delete utility. | ||
| 227 | * The precise operation is governed by the 'flags' value. The 'crit' and | ||
| 228 | * 'value' arguments (if relevant) are the extensions internal structure. | ||
| 229 | */ | ||
| 230 | |||
| 231 | int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | ||
| 232 | int crit, unsigned long flags) | ||
| 233 | { | ||
| 234 | int extidx = -1; | ||
| 235 | int errcode; | ||
| 236 | X509_EXTENSION *ext, *extmp; | ||
| 237 | unsigned long ext_op = flags & X509V3_ADD_OP_MASK; | ||
| 238 | |||
| 239 | /* If appending we don't care if it exists, otherwise | ||
| 240 | * look for existing extension. | ||
| 241 | */ | ||
| 242 | if(ext_op != X509V3_ADD_APPEND) | ||
| 243 | extidx = X509v3_get_ext_by_NID(*x, nid, -1); | ||
| 244 | |||
| 245 | /* See if extension exists */ | ||
| 246 | if(extidx >= 0) { | ||
| 247 | /* If keep existing, nothing to do */ | ||
| 248 | if(ext_op == X509V3_ADD_KEEP_EXISTING) | ||
| 249 | return 1; | ||
| 250 | /* If default then its an error */ | ||
| 251 | if(ext_op == X509V3_ADD_DEFAULT) { | ||
| 252 | errcode = X509V3_R_EXTENSION_EXISTS; | ||
| 253 | goto err; | ||
| 254 | } | ||
| 255 | /* If delete, just delete it */ | ||
| 256 | if(ext_op == X509V3_ADD_DELETE) { | ||
| 257 | if(!sk_X509_EXTENSION_delete(*x, extidx)) return -1; | ||
| 258 | return 1; | ||
| 259 | } | ||
| 260 | } else { | ||
| 261 | /* If replace existing or delete, error since | ||
| 262 | * extension must exist | ||
| 263 | */ | ||
| 264 | if((ext_op == X509V3_ADD_REPLACE_EXISTING) || | ||
| 265 | (ext_op == X509V3_ADD_DELETE)) { | ||
| 266 | errcode = X509V3_R_EXTENSION_NOT_FOUND; | ||
| 267 | goto err; | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | /* If we get this far then we have to create an extension: | ||
| 272 | * could have some flags for alternative encoding schemes... | ||
| 273 | */ | ||
| 274 | |||
| 275 | ext = X509V3_EXT_i2d(nid, crit, value); | ||
| 276 | |||
| 277 | if(!ext) { | ||
| 278 | X509V3err(X509V3_F_X509V3_ADD_I2D, X509V3_R_ERROR_CREATING_EXTENSION); | ||
| 279 | return 0; | ||
| 280 | } | ||
| 281 | |||
| 282 | /* If extension exists replace it.. */ | ||
| 283 | if(extidx >= 0) { | ||
| 284 | extmp = sk_X509_EXTENSION_value(*x, extidx); | ||
| 285 | X509_EXTENSION_free(extmp); | ||
| 286 | if(!sk_X509_EXTENSION_set(*x, extidx, ext)) return -1; | ||
| 287 | return 1; | ||
| 288 | } | ||
| 289 | |||
| 290 | if(!*x && !(*x = sk_X509_EXTENSION_new_null())) return -1; | ||
| 291 | if(!sk_X509_EXTENSION_push(*x, ext)) return -1; | ||
| 292 | |||
| 293 | return 1; | ||
| 294 | |||
| 295 | err: | ||
| 296 | if(!(flags & X509V3_ADD_SILENT)) | ||
| 297 | X509V3err(X509V3_F_X509V3_ADD_I2D, errcode); | ||
| 298 | return 0; | ||
| 299 | } | ||
| 300 | |||
| 301 | IMPLEMENT_STACK_OF(X509V3_EXT_METHOD) | ||
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c new file mode 100644 index 0000000000..083112314e --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_ocsp.c | |||
| @@ -0,0 +1,272 @@ | |||
| 1 | /* v3_ocsp.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/ocsp.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | /* OCSP extensions and a couple of CRL entry extensions | ||
| 67 | */ | ||
| 68 | |||
| 69 | static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); | ||
| 70 | static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); | ||
| 71 | static int i2r_object(X509V3_EXT_METHOD *method, void *obj, BIO *out, int indent); | ||
| 72 | |||
| 73 | static void *ocsp_nonce_new(void); | ||
| 74 | static int i2d_ocsp_nonce(void *a, unsigned char **pp); | ||
| 75 | static void *d2i_ocsp_nonce(void *a, unsigned char **pp, long length); | ||
| 76 | static void ocsp_nonce_free(void *a); | ||
| 77 | static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); | ||
| 78 | |||
| 79 | static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent); | ||
| 80 | static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); | ||
| 81 | static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind); | ||
| 82 | |||
| 83 | X509V3_EXT_METHOD v3_ocsp_crlid = { | ||
| 84 | NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID), | ||
| 85 | 0,0,0,0, | ||
| 86 | 0,0, | ||
| 87 | 0,0, | ||
| 88 | i2r_ocsp_crlid,0, | ||
| 89 | NULL | ||
| 90 | }; | ||
| 91 | |||
| 92 | X509V3_EXT_METHOD v3_ocsp_acutoff = { | ||
| 93 | NID_id_pkix_OCSP_archiveCutoff, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), | ||
| 94 | 0,0,0,0, | ||
| 95 | 0,0, | ||
| 96 | 0,0, | ||
| 97 | i2r_ocsp_acutoff,0, | ||
| 98 | NULL | ||
| 99 | }; | ||
| 100 | |||
| 101 | X509V3_EXT_METHOD v3_crl_invdate = { | ||
| 102 | NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), | ||
| 103 | 0,0,0,0, | ||
| 104 | 0,0, | ||
| 105 | 0,0, | ||
| 106 | i2r_ocsp_acutoff,0, | ||
| 107 | NULL | ||
| 108 | }; | ||
| 109 | |||
| 110 | X509V3_EXT_METHOD v3_crl_hold = { | ||
| 111 | NID_hold_instruction_code, 0, ASN1_ITEM_ref(ASN1_OBJECT), | ||
| 112 | 0,0,0,0, | ||
| 113 | 0,0, | ||
| 114 | 0,0, | ||
| 115 | i2r_object,0, | ||
| 116 | NULL | ||
| 117 | }; | ||
| 118 | |||
| 119 | X509V3_EXT_METHOD v3_ocsp_nonce = { | ||
| 120 | NID_id_pkix_OCSP_Nonce, 0, NULL, | ||
| 121 | ocsp_nonce_new, | ||
| 122 | ocsp_nonce_free, | ||
| 123 | d2i_ocsp_nonce, | ||
| 124 | i2d_ocsp_nonce, | ||
| 125 | 0,0, | ||
| 126 | 0,0, | ||
| 127 | i2r_ocsp_nonce,0, | ||
| 128 | NULL | ||
| 129 | }; | ||
| 130 | |||
| 131 | X509V3_EXT_METHOD v3_ocsp_nocheck = { | ||
| 132 | NID_id_pkix_OCSP_noCheck, 0, ASN1_ITEM_ref(ASN1_NULL), | ||
| 133 | 0,0,0,0, | ||
| 134 | 0,s2i_ocsp_nocheck, | ||
| 135 | 0,0, | ||
| 136 | i2r_ocsp_nocheck,0, | ||
| 137 | NULL | ||
| 138 | }; | ||
| 139 | |||
| 140 | X509V3_EXT_METHOD v3_ocsp_serviceloc = { | ||
| 141 | NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC), | ||
| 142 | 0,0,0,0, | ||
| 143 | 0,0, | ||
| 144 | 0,0, | ||
| 145 | i2r_ocsp_serviceloc,0, | ||
| 146 | NULL | ||
| 147 | }; | ||
| 148 | |||
| 149 | static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) | ||
| 150 | { | ||
| 151 | OCSP_CRLID *a = in; | ||
| 152 | if (a->crlUrl) | ||
| 153 | { | ||
| 154 | if (!BIO_printf(bp, "%*scrlUrl: ", ind, "")) goto err; | ||
| 155 | if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err; | ||
| 156 | if (!BIO_write(bp, "\n", 1)) goto err; | ||
| 157 | } | ||
| 158 | if (a->crlNum) | ||
| 159 | { | ||
| 160 | if (!BIO_printf(bp, "%*scrlNum: ", ind, "")) goto err; | ||
| 161 | if (!i2a_ASN1_INTEGER(bp, a->crlNum)) goto err; | ||
| 162 | if (!BIO_write(bp, "\n", 1)) goto err; | ||
| 163 | } | ||
| 164 | if (a->crlTime) | ||
| 165 | { | ||
| 166 | if (!BIO_printf(bp, "%*scrlTime: ", ind, "")) goto err; | ||
| 167 | if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err; | ||
| 168 | if (!BIO_write(bp, "\n", 1)) goto err; | ||
| 169 | } | ||
| 170 | return 1; | ||
| 171 | err: | ||
| 172 | return 0; | ||
| 173 | } | ||
| 174 | |||
| 175 | static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *cutoff, BIO *bp, int ind) | ||
| 176 | { | ||
| 177 | if (!BIO_printf(bp, "%*s", ind, "")) return 0; | ||
| 178 | if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0; | ||
| 179 | return 1; | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 183 | static int i2r_object(X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind) | ||
| 184 | { | ||
| 185 | if (!BIO_printf(bp, "%*s", ind, "")) return 0; | ||
| 186 | if(!i2a_ASN1_OBJECT(bp, oid)) return 0; | ||
| 187 | return 1; | ||
| 188 | } | ||
| 189 | |||
| 190 | /* OCSP nonce. This is needs special treatment because it doesn't have | ||
| 191 | * an ASN1 encoding at all: it just contains arbitrary data. | ||
| 192 | */ | ||
| 193 | |||
| 194 | static void *ocsp_nonce_new(void) | ||
| 195 | { | ||
| 196 | return ASN1_OCTET_STRING_new(); | ||
| 197 | } | ||
| 198 | |||
| 199 | static int i2d_ocsp_nonce(void *a, unsigned char **pp) | ||
| 200 | { | ||
| 201 | ASN1_OCTET_STRING *os = a; | ||
| 202 | if(pp) { | ||
| 203 | memcpy(*pp, os->data, os->length); | ||
| 204 | *pp += os->length; | ||
| 205 | } | ||
| 206 | return os->length; | ||
| 207 | } | ||
| 208 | |||
| 209 | static void *d2i_ocsp_nonce(void *a, unsigned char **pp, long length) | ||
| 210 | { | ||
| 211 | ASN1_OCTET_STRING *os, **pos; | ||
| 212 | pos = a; | ||
| 213 | if(!pos || !*pos) os = ASN1_OCTET_STRING_new(); | ||
| 214 | else os = *pos; | ||
| 215 | if(!ASN1_OCTET_STRING_set(os, *pp, length)) goto err; | ||
| 216 | |||
| 217 | *pp += length; | ||
| 218 | |||
| 219 | if(pos) *pos = os; | ||
| 220 | return os; | ||
| 221 | |||
| 222 | err: | ||
| 223 | if(os && (!pos || (*pos != os))) M_ASN1_OCTET_STRING_free(os); | ||
| 224 | OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); | ||
| 225 | return NULL; | ||
| 226 | } | ||
| 227 | |||
| 228 | static void ocsp_nonce_free(void *a) | ||
| 229 | { | ||
| 230 | M_ASN1_OCTET_STRING_free(a); | ||
| 231 | } | ||
| 232 | |||
| 233 | static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent) | ||
| 234 | { | ||
| 235 | if(BIO_printf(out, "%*s", indent, "") <= 0) return 0; | ||
| 236 | if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0; | ||
| 237 | return 1; | ||
| 238 | } | ||
| 239 | |||
| 240 | /* Nocheck is just a single NULL. Don't print anything and always set it */ | ||
| 241 | |||
| 242 | static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent) | ||
| 243 | { | ||
| 244 | return 1; | ||
| 245 | } | ||
| 246 | |||
| 247 | static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) | ||
| 248 | { | ||
| 249 | return ASN1_NULL_new(); | ||
| 250 | } | ||
| 251 | |||
| 252 | static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) | ||
| 253 | { | ||
| 254 | int i; | ||
| 255 | OCSP_SERVICELOC *a = in; | ||
| 256 | ACCESS_DESCRIPTION *ad; | ||
| 257 | |||
| 258 | if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0) goto err; | ||
| 259 | if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0) goto err; | ||
| 260 | for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) | ||
| 261 | { | ||
| 262 | ad = sk_ACCESS_DESCRIPTION_value(a->locator,i); | ||
| 263 | if (BIO_printf(bp, "\n%*s", (2*ind), "") <= 0) | ||
| 264 | goto err; | ||
| 265 | if(i2a_ASN1_OBJECT(bp, ad->method) <= 0) goto err; | ||
| 266 | if(BIO_puts(bp, " - ") <= 0) goto err; | ||
| 267 | if(GENERAL_NAME_print(bp, ad->location) <= 0) goto err; | ||
| 268 | } | ||
| 269 | return 1; | ||
| 270 | err: | ||
| 271 | return 0; | ||
| 272 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_pku.c b/src/lib/libcrypto/x509v3/v3_pku.c new file mode 100644 index 0000000000..49a2e4697a --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_pku.c | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | /* v3_pku.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/asn1.h> | ||
| 62 | #include <openssl/asn1t.h> | ||
| 63 | #include <openssl/x509v3.h> | ||
| 64 | |||
| 65 | static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent); | ||
| 66 | /* | ||
| 67 | static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); | ||
| 68 | */ | ||
| 69 | X509V3_EXT_METHOD v3_pkey_usage_period = { | ||
| 70 | NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD), | ||
| 71 | 0,0,0,0, | ||
| 72 | 0,0,0,0, | ||
| 73 | (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL, | ||
| 74 | NULL | ||
| 75 | }; | ||
| 76 | |||
| 77 | ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = { | ||
| 78 | ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0), | ||
| 79 | ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1) | ||
| 80 | } ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD) | ||
| 81 | |||
| 82 | IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) | ||
| 83 | |||
| 84 | static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, | ||
| 85 | PKEY_USAGE_PERIOD *usage, BIO *out, int indent) | ||
| 86 | { | ||
| 87 | BIO_printf(out, "%*s", indent, ""); | ||
| 88 | if(usage->notBefore) { | ||
| 89 | BIO_write(out, "Not Before: ", 12); | ||
| 90 | ASN1_GENERALIZEDTIME_print(out, usage->notBefore); | ||
| 91 | if(usage->notAfter) BIO_write(out, ", ", 2); | ||
| 92 | } | ||
| 93 | if(usage->notAfter) { | ||
| 94 | BIO_write(out, "Not After: ", 11); | ||
| 95 | ASN1_GENERALIZEDTIME_print(out, usage->notAfter); | ||
| 96 | } | ||
| 97 | return 1; | ||
| 98 | } | ||
| 99 | |||
| 100 | /* | ||
| 101 | static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(method, ctx, values) | ||
| 102 | X509V3_EXT_METHOD *method; | ||
| 103 | X509V3_CTX *ctx; | ||
| 104 | STACK_OF(CONF_VALUE) *values; | ||
| 105 | { | ||
| 106 | return NULL; | ||
| 107 | } | ||
| 108 | */ | ||
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c new file mode 100644 index 0000000000..aeaf6170fe --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_prn.c | |||
| @@ -0,0 +1,233 @@ | |||
| 1 | /* v3_prn.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* X509 v3 extension utilities */ | ||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/conf.h> | ||
| 63 | #include <openssl/x509v3.h> | ||
| 64 | |||
| 65 | /* Extension printing routines */ | ||
| 66 | |||
| 67 | static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported); | ||
| 68 | |||
| 69 | /* Print out a name+value stack */ | ||
| 70 | |||
| 71 | void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml) | ||
| 72 | { | ||
| 73 | int i; | ||
| 74 | CONF_VALUE *nval; | ||
| 75 | if(!val) return; | ||
| 76 | if(!ml || !sk_CONF_VALUE_num(val)) { | ||
| 77 | BIO_printf(out, "%*s", indent, ""); | ||
| 78 | if(!sk_CONF_VALUE_num(val)) BIO_puts(out, "<EMPTY>\n"); | ||
| 79 | } | ||
| 80 | for(i = 0; i < sk_CONF_VALUE_num(val); i++) { | ||
| 81 | if(ml) BIO_printf(out, "%*s", indent, ""); | ||
| 82 | else if(i > 0) BIO_printf(out, ", "); | ||
| 83 | nval = sk_CONF_VALUE_value(val, i); | ||
| 84 | if(!nval->name) BIO_puts(out, nval->value); | ||
| 85 | else if(!nval->value) BIO_puts(out, nval->name); | ||
| 86 | #ifndef CHARSET_EBCDIC | ||
| 87 | else BIO_printf(out, "%s:%s", nval->name, nval->value); | ||
| 88 | #else | ||
| 89 | else { | ||
| 90 | int len; | ||
| 91 | char *tmp; | ||
| 92 | len = strlen(nval->value)+1; | ||
| 93 | tmp = OPENSSL_malloc(len); | ||
| 94 | if (tmp) | ||
| 95 | { | ||
| 96 | ascii2ebcdic(tmp, nval->value, len); | ||
| 97 | BIO_printf(out, "%s:%s", nval->name, tmp); | ||
| 98 | OPENSSL_free(tmp); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | #endif | ||
| 102 | if(ml) BIO_puts(out, "\n"); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | /* Main routine: print out a general extension */ | ||
| 107 | |||
| 108 | int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent) | ||
| 109 | { | ||
| 110 | void *ext_str = NULL; | ||
| 111 | char *value = NULL; | ||
| 112 | unsigned char *p; | ||
| 113 | X509V3_EXT_METHOD *method; | ||
| 114 | STACK_OF(CONF_VALUE) *nval = NULL; | ||
| 115 | int ok = 1; | ||
| 116 | if(!(method = X509V3_EXT_get(ext))) | ||
| 117 | return unknown_ext_print(out, ext, flag, indent, 0); | ||
| 118 | p = ext->value->data; | ||
| 119 | if(method->it) ext_str = ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); | ||
| 120 | else ext_str = method->d2i(NULL, &p, ext->value->length); | ||
| 121 | |||
| 122 | if(!ext_str) return unknown_ext_print(out, ext, flag, indent, 1); | ||
| 123 | |||
| 124 | if(method->i2s) { | ||
| 125 | if(!(value = method->i2s(method, ext_str))) { | ||
| 126 | ok = 0; | ||
| 127 | goto err; | ||
| 128 | } | ||
| 129 | #ifndef CHARSET_EBCDIC | ||
| 130 | BIO_printf(out, "%*s%s", indent, "", value); | ||
| 131 | #else | ||
| 132 | { | ||
| 133 | int len; | ||
| 134 | char *tmp; | ||
| 135 | len = strlen(value)+1; | ||
| 136 | tmp = OPENSSL_malloc(len); | ||
| 137 | if (tmp) | ||
| 138 | { | ||
| 139 | ascii2ebcdic(tmp, value, len); | ||
| 140 | BIO_printf(out, "%*s%s", indent, "", tmp); | ||
| 141 | OPENSSL_free(tmp); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | #endif | ||
| 145 | } else if(method->i2v) { | ||
| 146 | if(!(nval = method->i2v(method, ext_str, NULL))) { | ||
| 147 | ok = 0; | ||
| 148 | goto err; | ||
| 149 | } | ||
| 150 | X509V3_EXT_val_prn(out, nval, indent, | ||
| 151 | method->ext_flags & X509V3_EXT_MULTILINE); | ||
| 152 | } else if(method->i2r) { | ||
| 153 | if(!method->i2r(method, ext_str, out, indent)) ok = 0; | ||
| 154 | } else ok = 0; | ||
| 155 | |||
| 156 | err: | ||
| 157 | sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); | ||
| 158 | if(value) OPENSSL_free(value); | ||
| 159 | if(method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); | ||
| 160 | else method->ext_free(ext_str); | ||
| 161 | return ok; | ||
| 162 | } | ||
| 163 | |||
| 164 | int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent) | ||
| 165 | { | ||
| 166 | int i, j; | ||
| 167 | |||
| 168 | if(sk_X509_EXTENSION_num(exts) <= 0) return 1; | ||
| 169 | |||
| 170 | if(title) | ||
| 171 | { | ||
| 172 | BIO_printf(bp,"%*s%s:\n",indent, "", title); | ||
| 173 | indent += 4; | ||
| 174 | } | ||
| 175 | |||
| 176 | for (i=0; i<sk_X509_EXTENSION_num(exts); i++) | ||
| 177 | { | ||
| 178 | ASN1_OBJECT *obj; | ||
| 179 | X509_EXTENSION *ex; | ||
| 180 | ex=sk_X509_EXTENSION_value(exts, i); | ||
| 181 | if (BIO_printf(bp,"%*s",indent, "") <= 0) return 0; | ||
| 182 | obj=X509_EXTENSION_get_object(ex); | ||
| 183 | i2a_ASN1_OBJECT(bp,obj); | ||
| 184 | j=X509_EXTENSION_get_critical(ex); | ||
| 185 | if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0) | ||
| 186 | return 0; | ||
| 187 | if(!X509V3_EXT_print(bp, ex, flag, 12)) | ||
| 188 | { | ||
| 189 | BIO_printf(bp, "%*s", indent + 4, ""); | ||
| 190 | M_ASN1_OCTET_STRING_print(bp,ex->value); | ||
| 191 | } | ||
| 192 | if (BIO_write(bp,"\n",1) <= 0) return 0; | ||
| 193 | } | ||
| 194 | return 1; | ||
| 195 | } | ||
| 196 | |||
| 197 | static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported) | ||
| 198 | { | ||
| 199 | switch(flag & X509V3_EXT_UNKNOWN_MASK) { | ||
| 200 | |||
| 201 | case X509V3_EXT_DEFAULT: | ||
| 202 | return 0; | ||
| 203 | |||
| 204 | case X509V3_EXT_ERROR_UNKNOWN: | ||
| 205 | if(supported) | ||
| 206 | BIO_printf(out, "%*s<Parse Error>", indent, ""); | ||
| 207 | else | ||
| 208 | BIO_printf(out, "%*s<Not Supported>", indent, ""); | ||
| 209 | return 1; | ||
| 210 | |||
| 211 | case X509V3_EXT_PARSE_UNKNOWN: | ||
| 212 | return ASN1_parse_dump(out, | ||
| 213 | ext->value->data, ext->value->length, indent, -1); | ||
| 214 | case X509V3_EXT_DUMP_UNKNOWN: | ||
| 215 | return BIO_dump_indent(out, (char *)ext->value->data, ext->value->length, indent); | ||
| 216 | |||
| 217 | default: | ||
| 218 | return 1; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | |||
| 223 | #ifndef OPENSSL_NO_FP_API | ||
| 224 | int X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent) | ||
| 225 | { | ||
| 226 | BIO *bio_tmp; | ||
| 227 | int ret; | ||
| 228 | if(!(bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE))) return 0; | ||
| 229 | ret = X509V3_EXT_print(bio_tmp, ext, flag, indent); | ||
| 230 | BIO_free(bio_tmp); | ||
| 231 | return ret; | ||
| 232 | } | ||
| 233 | #endif | ||
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c new file mode 100644 index 0000000000..b739e4fd83 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_purp.c | |||
| @@ -0,0 +1,625 @@ | |||
| 1 | /* v3_purp.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 2001. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999-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 | #include "cryptlib.h" | ||
| 61 | #include <openssl/x509v3.h> | ||
| 62 | #include <openssl/x509_vfy.h> | ||
| 63 | |||
| 64 | static void x509v3_cache_extensions(X509 *x); | ||
| 65 | |||
| 66 | static int ca_check(const X509 *x); | ||
| 67 | static int check_ssl_ca(const X509 *x); | ||
| 68 | static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 69 | static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 70 | static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 71 | static int purpose_smime(const X509 *x, int ca); | ||
| 72 | static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 73 | static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 74 | static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 75 | static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 76 | static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); | ||
| 77 | |||
| 78 | static int xp_cmp(const X509_PURPOSE * const *a, | ||
| 79 | const X509_PURPOSE * const *b); | ||
| 80 | static void xptable_free(X509_PURPOSE *p); | ||
| 81 | |||
| 82 | static X509_PURPOSE xstandard[] = { | ||
| 83 | {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_client, "SSL client", "sslclient", NULL}, | ||
| 84 | {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_server, "SSL server", "sslserver", NULL}, | ||
| 85 | {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ssl_server, "Netscape SSL server", "nssslserver", NULL}, | ||
| 86 | {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL}, | ||
| 87 | {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL}, | ||
| 88 | {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL}, | ||
| 89 | {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL}, | ||
| 90 | {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP helper", "ocsphelper", NULL}, | ||
| 91 | }; | ||
| 92 | |||
| 93 | #define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE)) | ||
| 94 | |||
| 95 | IMPLEMENT_STACK_OF(X509_PURPOSE) | ||
| 96 | |||
| 97 | static STACK_OF(X509_PURPOSE) *xptable = NULL; | ||
| 98 | |||
| 99 | static int xp_cmp(const X509_PURPOSE * const *a, | ||
| 100 | const X509_PURPOSE * const *b) | ||
| 101 | { | ||
| 102 | return (*a)->purpose - (*b)->purpose; | ||
| 103 | } | ||
| 104 | |||
| 105 | /* As much as I'd like to make X509_check_purpose use a "const" X509* | ||
| 106 | * I really can't because it does recalculate hashes and do other non-const | ||
| 107 | * things. */ | ||
| 108 | int X509_check_purpose(X509 *x, int id, int ca) | ||
| 109 | { | ||
| 110 | int idx; | ||
| 111 | const X509_PURPOSE *pt; | ||
| 112 | if(!(x->ex_flags & EXFLAG_SET)) { | ||
| 113 | CRYPTO_w_lock(CRYPTO_LOCK_X509); | ||
| 114 | x509v3_cache_extensions(x); | ||
| 115 | CRYPTO_w_unlock(CRYPTO_LOCK_X509); | ||
| 116 | } | ||
| 117 | if(id == -1) return 1; | ||
| 118 | idx = X509_PURPOSE_get_by_id(id); | ||
| 119 | if(idx == -1) return -1; | ||
| 120 | pt = X509_PURPOSE_get0(idx); | ||
| 121 | return pt->check_purpose(pt, x, ca); | ||
| 122 | } | ||
| 123 | |||
| 124 | int X509_PURPOSE_set(int *p, int purpose) | ||
| 125 | { | ||
| 126 | if(X509_PURPOSE_get_by_id(purpose) == -1) { | ||
| 127 | X509V3err(X509V3_F_X509_PURPOSE_SET, X509V3_R_INVALID_PURPOSE); | ||
| 128 | return 0; | ||
| 129 | } | ||
| 130 | *p = purpose; | ||
| 131 | return 1; | ||
| 132 | } | ||
| 133 | |||
| 134 | int X509_PURPOSE_get_count(void) | ||
| 135 | { | ||
| 136 | if(!xptable) return X509_PURPOSE_COUNT; | ||
| 137 | return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT; | ||
| 138 | } | ||
| 139 | |||
| 140 | X509_PURPOSE * X509_PURPOSE_get0(int idx) | ||
| 141 | { | ||
| 142 | if(idx < 0) return NULL; | ||
| 143 | if(idx < X509_PURPOSE_COUNT) return xstandard + idx; | ||
| 144 | return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT); | ||
| 145 | } | ||
| 146 | |||
| 147 | int X509_PURPOSE_get_by_sname(char *sname) | ||
| 148 | { | ||
| 149 | int i; | ||
| 150 | X509_PURPOSE *xptmp; | ||
| 151 | for(i = 0; i < X509_PURPOSE_get_count(); i++) { | ||
| 152 | xptmp = X509_PURPOSE_get0(i); | ||
| 153 | if(!strcmp(xptmp->sname, sname)) return i; | ||
| 154 | } | ||
| 155 | return -1; | ||
| 156 | } | ||
| 157 | |||
| 158 | int X509_PURPOSE_get_by_id(int purpose) | ||
| 159 | { | ||
| 160 | X509_PURPOSE tmp; | ||
| 161 | int idx; | ||
| 162 | if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX)) | ||
| 163 | return purpose - X509_PURPOSE_MIN; | ||
| 164 | tmp.purpose = purpose; | ||
| 165 | if(!xptable) return -1; | ||
| 166 | idx = sk_X509_PURPOSE_find(xptable, &tmp); | ||
| 167 | if(idx == -1) return -1; | ||
| 168 | return idx + X509_PURPOSE_COUNT; | ||
| 169 | } | ||
| 170 | |||
| 171 | int X509_PURPOSE_add(int id, int trust, int flags, | ||
| 172 | int (*ck)(const X509_PURPOSE *, const X509 *, int), | ||
| 173 | char *name, char *sname, void *arg) | ||
| 174 | { | ||
| 175 | int idx; | ||
| 176 | X509_PURPOSE *ptmp; | ||
| 177 | /* This is set according to what we change: application can't set it */ | ||
| 178 | flags &= ~X509_PURPOSE_DYNAMIC; | ||
| 179 | /* This will always be set for application modified trust entries */ | ||
| 180 | flags |= X509_PURPOSE_DYNAMIC_NAME; | ||
| 181 | /* Get existing entry if any */ | ||
| 182 | idx = X509_PURPOSE_get_by_id(id); | ||
| 183 | /* Need a new entry */ | ||
| 184 | if(idx == -1) { | ||
| 185 | if(!(ptmp = OPENSSL_malloc(sizeof(X509_PURPOSE)))) { | ||
| 186 | X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE); | ||
| 187 | return 0; | ||
| 188 | } | ||
| 189 | ptmp->flags = X509_PURPOSE_DYNAMIC; | ||
| 190 | } else ptmp = X509_PURPOSE_get0(idx); | ||
| 191 | |||
| 192 | /* OPENSSL_free existing name if dynamic */ | ||
| 193 | if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) { | ||
| 194 | OPENSSL_free(ptmp->name); | ||
| 195 | OPENSSL_free(ptmp->sname); | ||
| 196 | } | ||
| 197 | /* dup supplied name */ | ||
| 198 | ptmp->name = BUF_strdup(name); | ||
| 199 | ptmp->sname = BUF_strdup(sname); | ||
| 200 | if(!ptmp->name || !ptmp->sname) { | ||
| 201 | X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE); | ||
| 202 | return 0; | ||
| 203 | } | ||
| 204 | /* Keep the dynamic flag of existing entry */ | ||
| 205 | ptmp->flags &= X509_PURPOSE_DYNAMIC; | ||
| 206 | /* Set all other flags */ | ||
| 207 | ptmp->flags |= flags; | ||
| 208 | |||
| 209 | ptmp->purpose = id; | ||
| 210 | ptmp->trust = trust; | ||
| 211 | ptmp->check_purpose = ck; | ||
| 212 | ptmp->usr_data = arg; | ||
| 213 | |||
| 214 | /* If its a new entry manage the dynamic table */ | ||
| 215 | if(idx == -1) { | ||
| 216 | if(!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) { | ||
| 217 | X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE); | ||
| 218 | return 0; | ||
| 219 | } | ||
| 220 | if (!sk_X509_PURPOSE_push(xptable, ptmp)) { | ||
| 221 | X509V3err(X509V3_F_X509_PURPOSE_ADD,ERR_R_MALLOC_FAILURE); | ||
| 222 | return 0; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | return 1; | ||
| 226 | } | ||
| 227 | |||
| 228 | static void xptable_free(X509_PURPOSE *p) | ||
| 229 | { | ||
| 230 | if(!p) return; | ||
| 231 | if (p->flags & X509_PURPOSE_DYNAMIC) | ||
| 232 | { | ||
| 233 | if (p->flags & X509_PURPOSE_DYNAMIC_NAME) { | ||
| 234 | OPENSSL_free(p->name); | ||
| 235 | OPENSSL_free(p->sname); | ||
| 236 | } | ||
| 237 | OPENSSL_free(p); | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | void X509_PURPOSE_cleanup(void) | ||
| 242 | { | ||
| 243 | int i; | ||
| 244 | sk_X509_PURPOSE_pop_free(xptable, xptable_free); | ||
| 245 | for(i = 0; i < X509_PURPOSE_COUNT; i++) xptable_free(xstandard + i); | ||
| 246 | xptable = NULL; | ||
| 247 | } | ||
| 248 | |||
| 249 | int X509_PURPOSE_get_id(X509_PURPOSE *xp) | ||
| 250 | { | ||
| 251 | return xp->purpose; | ||
| 252 | } | ||
| 253 | |||
| 254 | char *X509_PURPOSE_get0_name(X509_PURPOSE *xp) | ||
| 255 | { | ||
| 256 | return xp->name; | ||
| 257 | } | ||
| 258 | |||
| 259 | char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp) | ||
| 260 | { | ||
| 261 | return xp->sname; | ||
| 262 | } | ||
| 263 | |||
| 264 | int X509_PURPOSE_get_trust(X509_PURPOSE *xp) | ||
| 265 | { | ||
| 266 | return xp->trust; | ||
| 267 | } | ||
| 268 | |||
| 269 | static int nid_cmp(int *a, int *b) | ||
| 270 | { | ||
| 271 | return *a - *b; | ||
| 272 | } | ||
| 273 | |||
| 274 | int X509_supported_extension(X509_EXTENSION *ex) | ||
| 275 | { | ||
| 276 | /* This table is a list of the NIDs of supported extensions: | ||
| 277 | * that is those which are used by the verify process. If | ||
| 278 | * an extension is critical and doesn't appear in this list | ||
| 279 | * then the verify process will normally reject the certificate. | ||
| 280 | * The list must be kept in numerical order because it will be | ||
| 281 | * searched using bsearch. | ||
| 282 | */ | ||
| 283 | |||
| 284 | static int supported_nids[] = { | ||
| 285 | NID_netscape_cert_type, /* 71 */ | ||
| 286 | NID_key_usage, /* 83 */ | ||
| 287 | NID_subject_alt_name, /* 85 */ | ||
| 288 | NID_basic_constraints, /* 87 */ | ||
| 289 | NID_ext_key_usage /* 126 */ | ||
| 290 | }; | ||
| 291 | |||
| 292 | int ex_nid; | ||
| 293 | |||
| 294 | ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex)); | ||
| 295 | |||
| 296 | if (ex_nid == NID_undef) | ||
| 297 | return 0; | ||
| 298 | |||
| 299 | if (OBJ_bsearch((char *)&ex_nid, (char *)supported_nids, | ||
| 300 | sizeof(supported_nids)/sizeof(int), sizeof(int), | ||
| 301 | (int (*)(const void *, const void *))nid_cmp)) | ||
| 302 | return 1; | ||
| 303 | return 0; | ||
| 304 | } | ||
| 305 | |||
| 306 | |||
| 307 | static void x509v3_cache_extensions(X509 *x) | ||
| 308 | { | ||
| 309 | BASIC_CONSTRAINTS *bs; | ||
| 310 | ASN1_BIT_STRING *usage; | ||
| 311 | ASN1_BIT_STRING *ns; | ||
| 312 | EXTENDED_KEY_USAGE *extusage; | ||
| 313 | X509_EXTENSION *ex; | ||
| 314 | |||
| 315 | int i; | ||
| 316 | if(x->ex_flags & EXFLAG_SET) return; | ||
| 317 | #ifndef OPENSSL_NO_SHA | ||
| 318 | X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); | ||
| 319 | #endif | ||
| 320 | /* Does subject name match issuer ? */ | ||
| 321 | if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) | ||
| 322 | x->ex_flags |= EXFLAG_SS; | ||
| 323 | /* V1 should mean no extensions ... */ | ||
| 324 | if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; | ||
| 325 | /* Handle basic constraints */ | ||
| 326 | if((bs=X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) { | ||
| 327 | if(bs->ca) x->ex_flags |= EXFLAG_CA; | ||
| 328 | if(bs->pathlen) { | ||
| 329 | if((bs->pathlen->type == V_ASN1_NEG_INTEGER) | ||
| 330 | || !bs->ca) { | ||
| 331 | x->ex_flags |= EXFLAG_INVALID; | ||
| 332 | x->ex_pathlen = 0; | ||
| 333 | } else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen); | ||
| 334 | } else x->ex_pathlen = -1; | ||
| 335 | BASIC_CONSTRAINTS_free(bs); | ||
| 336 | x->ex_flags |= EXFLAG_BCONS; | ||
| 337 | } | ||
| 338 | /* Handle key usage */ | ||
| 339 | if((usage=X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) { | ||
| 340 | if(usage->length > 0) { | ||
| 341 | x->ex_kusage = usage->data[0]; | ||
| 342 | if(usage->length > 1) | ||
| 343 | x->ex_kusage |= usage->data[1] << 8; | ||
| 344 | } else x->ex_kusage = 0; | ||
| 345 | x->ex_flags |= EXFLAG_KUSAGE; | ||
| 346 | ASN1_BIT_STRING_free(usage); | ||
| 347 | } | ||
| 348 | x->ex_xkusage = 0; | ||
| 349 | if((extusage=X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) { | ||
| 350 | x->ex_flags |= EXFLAG_XKUSAGE; | ||
| 351 | for(i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { | ||
| 352 | switch(OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage,i))) { | ||
| 353 | case NID_server_auth: | ||
| 354 | x->ex_xkusage |= XKU_SSL_SERVER; | ||
| 355 | break; | ||
| 356 | |||
| 357 | case NID_client_auth: | ||
| 358 | x->ex_xkusage |= XKU_SSL_CLIENT; | ||
| 359 | break; | ||
| 360 | |||
| 361 | case NID_email_protect: | ||
| 362 | x->ex_xkusage |= XKU_SMIME; | ||
| 363 | break; | ||
| 364 | |||
| 365 | case NID_code_sign: | ||
| 366 | x->ex_xkusage |= XKU_CODE_SIGN; | ||
| 367 | break; | ||
| 368 | |||
| 369 | case NID_ms_sgc: | ||
| 370 | case NID_ns_sgc: | ||
| 371 | x->ex_xkusage |= XKU_SGC; | ||
| 372 | break; | ||
| 373 | |||
| 374 | case NID_OCSP_sign: | ||
| 375 | x->ex_xkusage |= XKU_OCSP_SIGN; | ||
| 376 | break; | ||
| 377 | |||
| 378 | case NID_time_stamp: | ||
| 379 | x->ex_xkusage |= XKU_TIMESTAMP; | ||
| 380 | break; | ||
| 381 | } | ||
| 382 | } | ||
| 383 | sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); | ||
| 384 | } | ||
| 385 | |||
| 386 | if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { | ||
| 387 | if(ns->length > 0) x->ex_nscert = ns->data[0]; | ||
| 388 | else x->ex_nscert = 0; | ||
| 389 | x->ex_flags |= EXFLAG_NSCERT; | ||
| 390 | ASN1_BIT_STRING_free(ns); | ||
| 391 | } | ||
| 392 | x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); | ||
| 393 | x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); | ||
| 394 | for (i = 0; i < X509_get_ext_count(x); i++) | ||
| 395 | { | ||
| 396 | ex = X509_get_ext(x, i); | ||
| 397 | if (!X509_EXTENSION_get_critical(ex)) | ||
| 398 | continue; | ||
| 399 | if (!X509_supported_extension(ex)) | ||
| 400 | { | ||
| 401 | x->ex_flags |= EXFLAG_CRITICAL; | ||
| 402 | break; | ||
| 403 | } | ||
| 404 | } | ||
| 405 | x->ex_flags |= EXFLAG_SET; | ||
| 406 | } | ||
| 407 | |||
| 408 | /* CA checks common to all purposes | ||
| 409 | * return codes: | ||
| 410 | * 0 not a CA | ||
| 411 | * 1 is a CA | ||
| 412 | * 2 basicConstraints absent so "maybe" a CA | ||
| 413 | * 3 basicConstraints absent but self signed V1. | ||
| 414 | */ | ||
| 415 | |||
| 416 | #define V1_ROOT (EXFLAG_V1|EXFLAG_SS) | ||
| 417 | #define ku_reject(x, usage) \ | ||
| 418 | (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) | ||
| 419 | #define xku_reject(x, usage) \ | ||
| 420 | (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) | ||
| 421 | #define ns_reject(x, usage) \ | ||
| 422 | (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) | ||
| 423 | |||
| 424 | static int ca_check(const X509 *x) | ||
| 425 | { | ||
| 426 | /* keyUsage if present should allow cert signing */ | ||
| 427 | if(ku_reject(x, KU_KEY_CERT_SIGN)) return 0; | ||
| 428 | if(x->ex_flags & EXFLAG_BCONS) { | ||
| 429 | if(x->ex_flags & EXFLAG_CA) return 1; | ||
| 430 | /* If basicConstraints says not a CA then say so */ | ||
| 431 | else return 0; | ||
| 432 | } else { | ||
| 433 | if((x->ex_flags & V1_ROOT) == V1_ROOT) return 3; | ||
| 434 | /* If key usage present it must have certSign so tolerate it */ | ||
| 435 | else if (x->ex_flags & EXFLAG_KUSAGE) return 3; | ||
| 436 | else return 2; | ||
| 437 | } | ||
| 438 | } | ||
| 439 | |||
| 440 | /* Check SSL CA: common checks for SSL client and server */ | ||
| 441 | static int check_ssl_ca(const X509 *x) | ||
| 442 | { | ||
| 443 | int ca_ret; | ||
| 444 | ca_ret = ca_check(x); | ||
| 445 | if(!ca_ret) return 0; | ||
| 446 | /* check nsCertType if present */ | ||
| 447 | if(x->ex_flags & EXFLAG_NSCERT) { | ||
| 448 | if(x->ex_nscert & NS_SSL_CA) return ca_ret; | ||
| 449 | return 0; | ||
| 450 | } | ||
| 451 | if(ca_ret != 2) return ca_ret; | ||
| 452 | else return 0; | ||
| 453 | } | ||
| 454 | |||
| 455 | |||
| 456 | static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 457 | { | ||
| 458 | if(xku_reject(x,XKU_SSL_CLIENT)) return 0; | ||
| 459 | if(ca) return check_ssl_ca(x); | ||
| 460 | /* We need to do digital signatures with it */ | ||
| 461 | if(ku_reject(x,KU_DIGITAL_SIGNATURE)) return 0; | ||
| 462 | /* nsCertType if present should allow SSL client use */ | ||
| 463 | if(ns_reject(x, NS_SSL_CLIENT)) return 0; | ||
| 464 | return 1; | ||
| 465 | } | ||
| 466 | |||
| 467 | static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 468 | { | ||
| 469 | if(xku_reject(x,XKU_SSL_SERVER|XKU_SGC)) return 0; | ||
| 470 | if(ca) return check_ssl_ca(x); | ||
| 471 | |||
| 472 | if(ns_reject(x, NS_SSL_SERVER)) return 0; | ||
| 473 | /* Now as for keyUsage: we'll at least need to sign OR encipher */ | ||
| 474 | if(ku_reject(x, KU_DIGITAL_SIGNATURE|KU_KEY_ENCIPHERMENT)) return 0; | ||
| 475 | |||
| 476 | return 1; | ||
| 477 | |||
| 478 | } | ||
| 479 | |||
| 480 | static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 481 | { | ||
| 482 | int ret; | ||
| 483 | ret = check_purpose_ssl_server(xp, x, ca); | ||
| 484 | if(!ret || ca) return ret; | ||
| 485 | /* We need to encipher or Netscape complains */ | ||
| 486 | if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0; | ||
| 487 | return ret; | ||
| 488 | } | ||
| 489 | |||
| 490 | /* common S/MIME checks */ | ||
| 491 | static int purpose_smime(const X509 *x, int ca) | ||
| 492 | { | ||
| 493 | if(xku_reject(x,XKU_SMIME)) return 0; | ||
| 494 | if(ca) { | ||
| 495 | int ca_ret; | ||
| 496 | ca_ret = ca_check(x); | ||
| 497 | if(!ca_ret) return 0; | ||
| 498 | /* check nsCertType if present */ | ||
| 499 | if(x->ex_flags & EXFLAG_NSCERT) { | ||
| 500 | if(x->ex_nscert & NS_SMIME_CA) return ca_ret; | ||
| 501 | return 0; | ||
| 502 | } | ||
| 503 | if(ca_ret != 2) return ca_ret; | ||
| 504 | else return 0; | ||
| 505 | } | ||
| 506 | if(x->ex_flags & EXFLAG_NSCERT) { | ||
| 507 | if(x->ex_nscert & NS_SMIME) return 1; | ||
| 508 | /* Workaround for some buggy certificates */ | ||
| 509 | if(x->ex_nscert & NS_SSL_CLIENT) return 2; | ||
| 510 | return 0; | ||
| 511 | } | ||
| 512 | return 1; | ||
| 513 | } | ||
| 514 | |||
| 515 | static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 516 | { | ||
| 517 | int ret; | ||
| 518 | ret = purpose_smime(x, ca); | ||
| 519 | if(!ret || ca) return ret; | ||
| 520 | if(ku_reject(x, KU_DIGITAL_SIGNATURE|KU_NON_REPUDIATION)) return 0; | ||
| 521 | return ret; | ||
| 522 | } | ||
| 523 | |||
| 524 | static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 525 | { | ||
| 526 | int ret; | ||
| 527 | ret = purpose_smime(x, ca); | ||
| 528 | if(!ret || ca) return ret; | ||
| 529 | if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0; | ||
| 530 | return ret; | ||
| 531 | } | ||
| 532 | |||
| 533 | static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 534 | { | ||
| 535 | if(ca) { | ||
| 536 | int ca_ret; | ||
| 537 | if((ca_ret = ca_check(x)) != 2) return ca_ret; | ||
| 538 | else return 0; | ||
| 539 | } | ||
| 540 | if(ku_reject(x, KU_CRL_SIGN)) return 0; | ||
| 541 | return 1; | ||
| 542 | } | ||
| 543 | |||
| 544 | /* OCSP helper: this is *not* a full OCSP check. It just checks that | ||
| 545 | * each CA is valid. Additional checks must be made on the chain. | ||
| 546 | */ | ||
| 547 | |||
| 548 | static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 549 | { | ||
| 550 | /* Must be a valid CA */ | ||
| 551 | if(ca) { | ||
| 552 | int ca_ret; | ||
| 553 | ca_ret = ca_check(x); | ||
| 554 | if(ca_ret != 2) return ca_ret; | ||
| 555 | if(x->ex_flags & EXFLAG_NSCERT) { | ||
| 556 | if(x->ex_nscert & NS_ANY_CA) return ca_ret; | ||
| 557 | return 0; | ||
| 558 | } | ||
| 559 | return 0; | ||
| 560 | } | ||
| 561 | /* leaf certificate is checked in OCSP_verify() */ | ||
| 562 | return 1; | ||
| 563 | } | ||
| 564 | |||
| 565 | static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca) | ||
| 566 | { | ||
| 567 | return 1; | ||
| 568 | } | ||
| 569 | |||
| 570 | /* Various checks to see if one certificate issued the second. | ||
| 571 | * This can be used to prune a set of possible issuer certificates | ||
| 572 | * which have been looked up using some simple method such as by | ||
| 573 | * subject name. | ||
| 574 | * These are: | ||
| 575 | * 1. Check issuer_name(subject) == subject_name(issuer) | ||
| 576 | * 2. If akid(subject) exists check it matches issuer | ||
| 577 | * 3. If key_usage(issuer) exists check it supports certificate signing | ||
| 578 | * returns 0 for OK, positive for reason for mismatch, reasons match | ||
| 579 | * codes for X509_verify_cert() | ||
| 580 | */ | ||
| 581 | |||
| 582 | int X509_check_issued(X509 *issuer, X509 *subject) | ||
| 583 | { | ||
| 584 | if(X509_NAME_cmp(X509_get_subject_name(issuer), | ||
| 585 | X509_get_issuer_name(subject))) | ||
| 586 | return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; | ||
| 587 | x509v3_cache_extensions(issuer); | ||
| 588 | x509v3_cache_extensions(subject); | ||
| 589 | if(subject->akid) { | ||
| 590 | /* Check key ids (if present) */ | ||
| 591 | if(subject->akid->keyid && issuer->skid && | ||
| 592 | ASN1_OCTET_STRING_cmp(subject->akid->keyid, issuer->skid) ) | ||
| 593 | return X509_V_ERR_AKID_SKID_MISMATCH; | ||
| 594 | /* Check serial number */ | ||
| 595 | if(subject->akid->serial && | ||
| 596 | ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), | ||
| 597 | subject->akid->serial)) | ||
| 598 | return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH; | ||
| 599 | /* Check issuer name */ | ||
| 600 | if(subject->akid->issuer) { | ||
| 601 | /* Ugh, for some peculiar reason AKID includes | ||
| 602 | * SEQUENCE OF GeneralName. So look for a DirName. | ||
| 603 | * There may be more than one but we only take any | ||
| 604 | * notice of the first. | ||
| 605 | */ | ||
| 606 | GENERAL_NAMES *gens; | ||
| 607 | GENERAL_NAME *gen; | ||
| 608 | X509_NAME *nm = NULL; | ||
| 609 | int i; | ||
| 610 | gens = subject->akid->issuer; | ||
| 611 | for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) { | ||
| 612 | gen = sk_GENERAL_NAME_value(gens, i); | ||
| 613 | if(gen->type == GEN_DIRNAME) { | ||
| 614 | nm = gen->d.dirn; | ||
| 615 | break; | ||
| 616 | } | ||
| 617 | } | ||
| 618 | if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer))) | ||
| 619 | return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH; | ||
| 620 | } | ||
| 621 | } | ||
| 622 | if(ku_reject(issuer, KU_KEY_CERT_SIGN)) return X509_V_ERR_KEYUSAGE_NO_CERTSIGN; | ||
| 623 | return X509_V_OK; | ||
| 624 | } | ||
| 625 | |||
diff --git a/src/lib/libcrypto/x509v3/v3_skey.c b/src/lib/libcrypto/x509v3/v3_skey.c new file mode 100644 index 0000000000..c0f044ac1b --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_skey.c | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | /* v3_skey.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | |||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/x509v3.h> | ||
| 63 | |||
| 64 | static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); | ||
| 65 | X509V3_EXT_METHOD v3_skey_id = { | ||
| 66 | NID_subject_key_identifier, 0, ASN1_ITEM_ref(ASN1_OCTET_STRING), | ||
| 67 | 0,0,0,0, | ||
| 68 | (X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING, | ||
| 69 | (X509V3_EXT_S2I)s2i_skey_id, | ||
| 70 | 0,0,0,0, | ||
| 71 | NULL}; | ||
| 72 | |||
| 73 | char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, | ||
| 74 | ASN1_OCTET_STRING *oct) | ||
| 75 | { | ||
| 76 | return hex_to_string(oct->data, oct->length); | ||
| 77 | } | ||
| 78 | |||
| 79 | ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, | ||
| 80 | X509V3_CTX *ctx, char *str) | ||
| 81 | { | ||
| 82 | ASN1_OCTET_STRING *oct; | ||
| 83 | long length; | ||
| 84 | |||
| 85 | if(!(oct = M_ASN1_OCTET_STRING_new())) { | ||
| 86 | X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE); | ||
| 87 | return NULL; | ||
| 88 | } | ||
| 89 | |||
| 90 | if(!(oct->data = string_to_hex(str, &length))) { | ||
| 91 | M_ASN1_OCTET_STRING_free(oct); | ||
| 92 | return NULL; | ||
| 93 | } | ||
| 94 | |||
| 95 | oct->length = length; | ||
| 96 | |||
| 97 | return oct; | ||
| 98 | |||
| 99 | } | ||
| 100 | |||
| 101 | static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, | ||
| 102 | X509V3_CTX *ctx, char *str) | ||
| 103 | { | ||
| 104 | ASN1_OCTET_STRING *oct; | ||
| 105 | ASN1_BIT_STRING *pk; | ||
| 106 | unsigned char pkey_dig[EVP_MAX_MD_SIZE]; | ||
| 107 | unsigned int diglen; | ||
| 108 | |||
| 109 | if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); | ||
| 110 | |||
| 111 | if(!(oct = M_ASN1_OCTET_STRING_new())) { | ||
| 112 | X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); | ||
| 113 | return NULL; | ||
| 114 | } | ||
| 115 | |||
| 116 | if(ctx && (ctx->flags == CTX_TEST)) return oct; | ||
| 117 | |||
| 118 | if(!ctx || (!ctx->subject_req && !ctx->subject_cert)) { | ||
| 119 | X509V3err(X509V3_F_S2I_ASN1_SKEY_ID,X509V3_R_NO_PUBLIC_KEY); | ||
| 120 | goto err; | ||
| 121 | } | ||
| 122 | |||
| 123 | if(ctx->subject_req) | ||
| 124 | pk = ctx->subject_req->req_info->pubkey->public_key; | ||
| 125 | else pk = ctx->subject_cert->cert_info->key->public_key; | ||
| 126 | |||
| 127 | if(!pk) { | ||
| 128 | X509V3err(X509V3_F_S2I_ASN1_SKEY_ID,X509V3_R_NO_PUBLIC_KEY); | ||
| 129 | goto err; | ||
| 130 | } | ||
| 131 | |||
| 132 | EVP_Digest(pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL); | ||
| 133 | |||
| 134 | if(!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) { | ||
| 135 | X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); | ||
| 136 | goto err; | ||
| 137 | } | ||
| 138 | |||
| 139 | return oct; | ||
| 140 | |||
| 141 | err: | ||
| 142 | M_ASN1_OCTET_STRING_free(oct); | ||
| 143 | return NULL; | ||
| 144 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c new file mode 100644 index 0000000000..d3f4ba3a72 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_sxnet.c | |||
| @@ -0,0 +1,262 @@ | |||
| 1 | /* v3_sxnet.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/conf.h> | ||
| 62 | #include <openssl/asn1.h> | ||
| 63 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/x509v3.h> | ||
| 65 | |||
| 66 | /* Support for Thawte strong extranet extension */ | ||
| 67 | |||
| 68 | #define SXNET_TEST | ||
| 69 | |||
| 70 | static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, int indent); | ||
| 71 | #ifdef SXNET_TEST | ||
| 72 | static SXNET * sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, | ||
| 73 | STACK_OF(CONF_VALUE) *nval); | ||
| 74 | #endif | ||
| 75 | X509V3_EXT_METHOD v3_sxnet = { | ||
| 76 | NID_sxnet, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(SXNET), | ||
| 77 | 0,0,0,0, | ||
| 78 | 0,0, | ||
| 79 | 0, | ||
| 80 | #ifdef SXNET_TEST | ||
| 81 | (X509V3_EXT_V2I)sxnet_v2i, | ||
| 82 | #else | ||
| 83 | 0, | ||
| 84 | #endif | ||
| 85 | (X509V3_EXT_I2R)sxnet_i2r, | ||
| 86 | 0, | ||
| 87 | NULL | ||
| 88 | }; | ||
| 89 | |||
| 90 | ASN1_SEQUENCE(SXNETID) = { | ||
| 91 | ASN1_SIMPLE(SXNETID, zone, ASN1_INTEGER), | ||
| 92 | ASN1_SIMPLE(SXNETID, user, ASN1_OCTET_STRING) | ||
| 93 | } ASN1_SEQUENCE_END(SXNETID) | ||
| 94 | |||
| 95 | IMPLEMENT_ASN1_FUNCTIONS(SXNETID) | ||
| 96 | |||
| 97 | ASN1_SEQUENCE(SXNET) = { | ||
| 98 | ASN1_SIMPLE(SXNET, version, ASN1_INTEGER), | ||
| 99 | ASN1_SEQUENCE_OF(SXNET, ids, SXNETID) | ||
| 100 | } ASN1_SEQUENCE_END(SXNET) | ||
| 101 | |||
| 102 | IMPLEMENT_ASN1_FUNCTIONS(SXNET) | ||
| 103 | |||
| 104 | static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, | ||
| 105 | int indent) | ||
| 106 | { | ||
| 107 | long v; | ||
| 108 | char *tmp; | ||
| 109 | SXNETID *id; | ||
| 110 | int i; | ||
| 111 | v = ASN1_INTEGER_get(sx->version); | ||
| 112 | BIO_printf(out, "%*sVersion: %d (0x%X)", indent, "", v + 1, v); | ||
| 113 | for(i = 0; i < sk_SXNETID_num(sx->ids); i++) { | ||
| 114 | id = sk_SXNETID_value(sx->ids, i); | ||
| 115 | tmp = i2s_ASN1_INTEGER(NULL, id->zone); | ||
| 116 | BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp); | ||
| 117 | OPENSSL_free(tmp); | ||
| 118 | M_ASN1_OCTET_STRING_print(out, id->user); | ||
| 119 | } | ||
| 120 | return 1; | ||
| 121 | } | ||
| 122 | |||
| 123 | #ifdef SXNET_TEST | ||
| 124 | |||
| 125 | /* NBB: this is used for testing only. It should *not* be used for anything | ||
| 126 | * else because it will just take static IDs from the configuration file and | ||
| 127 | * they should really be separate values for each user. | ||
| 128 | */ | ||
| 129 | |||
| 130 | |||
| 131 | static SXNET * sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, | ||
| 132 | STACK_OF(CONF_VALUE) *nval) | ||
| 133 | { | ||
| 134 | CONF_VALUE *cnf; | ||
| 135 | SXNET *sx = NULL; | ||
| 136 | int i; | ||
| 137 | for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { | ||
| 138 | cnf = sk_CONF_VALUE_value(nval, i); | ||
| 139 | if(!SXNET_add_id_asc(&sx, cnf->name, cnf->value, -1)) | ||
| 140 | return NULL; | ||
| 141 | } | ||
| 142 | return sx; | ||
| 143 | } | ||
| 144 | |||
| 145 | |||
| 146 | #endif | ||
| 147 | |||
| 148 | /* Strong Extranet utility functions */ | ||
| 149 | |||
| 150 | /* Add an id given the zone as an ASCII number */ | ||
| 151 | |||
| 152 | int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, | ||
| 153 | int userlen) | ||
| 154 | { | ||
| 155 | ASN1_INTEGER *izone = NULL; | ||
| 156 | if(!(izone = s2i_ASN1_INTEGER(NULL, zone))) { | ||
| 157 | X509V3err(X509V3_F_SXNET_ADD_ASC,X509V3_R_ERROR_CONVERTING_ZONE); | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | return SXNET_add_id_INTEGER(psx, izone, user, userlen); | ||
| 161 | } | ||
| 162 | |||
| 163 | /* Add an id given the zone as an unsigned long */ | ||
| 164 | |||
| 165 | int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, | ||
| 166 | int userlen) | ||
| 167 | { | ||
| 168 | ASN1_INTEGER *izone = NULL; | ||
| 169 | if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { | ||
| 170 | X509V3err(X509V3_F_SXNET_ADD_ID_ULONG,ERR_R_MALLOC_FAILURE); | ||
| 171 | M_ASN1_INTEGER_free(izone); | ||
| 172 | return 0; | ||
| 173 | } | ||
| 174 | return SXNET_add_id_INTEGER(psx, izone, user, userlen); | ||
| 175 | |||
| 176 | } | ||
| 177 | |||
| 178 | /* Add an id given the zone as an ASN1_INTEGER. | ||
| 179 | * Note this version uses the passed integer and doesn't make a copy so don't | ||
| 180 | * free it up afterwards. | ||
| 181 | */ | ||
| 182 | |||
| 183 | int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, char *user, | ||
| 184 | int userlen) | ||
| 185 | { | ||
| 186 | SXNET *sx = NULL; | ||
| 187 | SXNETID *id = NULL; | ||
| 188 | if(!psx || !zone || !user) { | ||
| 189 | X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER,X509V3_R_INVALID_NULL_ARGUMENT); | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | if(userlen == -1) userlen = strlen(user); | ||
| 193 | if(userlen > 64) { | ||
| 194 | X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER,X509V3_R_USER_TOO_LONG); | ||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | if(!*psx) { | ||
| 198 | if(!(sx = SXNET_new())) goto err; | ||
| 199 | if(!ASN1_INTEGER_set(sx->version, 0)) goto err; | ||
| 200 | *psx = sx; | ||
| 201 | } else sx = *psx; | ||
| 202 | if(SXNET_get_id_INTEGER(sx, zone)) { | ||
| 203 | X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER,X509V3_R_DUPLICATE_ZONE_ID); | ||
| 204 | return 0; | ||
| 205 | } | ||
| 206 | |||
| 207 | if(!(id = SXNETID_new())) goto err; | ||
| 208 | if(userlen == -1) userlen = strlen(user); | ||
| 209 | |||
| 210 | if(!M_ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err; | ||
| 211 | if(!sk_SXNETID_push(sx->ids, id)) goto err; | ||
| 212 | id->zone = zone; | ||
| 213 | return 1; | ||
| 214 | |||
| 215 | err: | ||
| 216 | X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER,ERR_R_MALLOC_FAILURE); | ||
| 217 | SXNETID_free(id); | ||
| 218 | SXNET_free(sx); | ||
| 219 | *psx = NULL; | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | |||
| 223 | ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone) | ||
| 224 | { | ||
| 225 | ASN1_INTEGER *izone = NULL; | ||
| 226 | ASN1_OCTET_STRING *oct; | ||
| 227 | if(!(izone = s2i_ASN1_INTEGER(NULL, zone))) { | ||
| 228 | X509V3err(X509V3_F_SXNET_GET_ID_ASC,X509V3_R_ERROR_CONVERTING_ZONE); | ||
| 229 | return NULL; | ||
| 230 | } | ||
| 231 | oct = SXNET_get_id_INTEGER(sx, izone); | ||
| 232 | M_ASN1_INTEGER_free(izone); | ||
| 233 | return oct; | ||
| 234 | } | ||
| 235 | |||
| 236 | ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) | ||
| 237 | { | ||
| 238 | ASN1_INTEGER *izone = NULL; | ||
| 239 | ASN1_OCTET_STRING *oct; | ||
| 240 | if(!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { | ||
| 241 | X509V3err(X509V3_F_SXNET_GET_ID_ULONG,ERR_R_MALLOC_FAILURE); | ||
| 242 | M_ASN1_INTEGER_free(izone); | ||
| 243 | return NULL; | ||
| 244 | } | ||
| 245 | oct = SXNET_get_id_INTEGER(sx, izone); | ||
| 246 | M_ASN1_INTEGER_free(izone); | ||
| 247 | return oct; | ||
| 248 | } | ||
| 249 | |||
| 250 | ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) | ||
| 251 | { | ||
| 252 | SXNETID *id; | ||
| 253 | int i; | ||
| 254 | for(i = 0; i < sk_SXNETID_num(sx->ids); i++) { | ||
| 255 | id = sk_SXNETID_value(sx->ids, i); | ||
| 256 | if(!M_ASN1_INTEGER_cmp(id->zone, zone)) return id->user; | ||
| 257 | } | ||
| 258 | return NULL; | ||
| 259 | } | ||
| 260 | |||
| 261 | IMPLEMENT_STACK_OF(SXNETID) | ||
| 262 | IMPLEMENT_ASN1_SET_OF(SXNETID) | ||
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c new file mode 100644 index 0000000000..283e943e46 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_utl.c | |||
| @@ -0,0 +1,535 @@ | |||
| 1 | /* v3_utl.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* X509 v3 extension utilities */ | ||
| 59 | |||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <ctype.h> | ||
| 63 | #include "cryptlib.h" | ||
| 64 | #include <openssl/conf.h> | ||
| 65 | #include <openssl/x509v3.h> | ||
| 66 | |||
| 67 | static char *strip_spaces(char *name); | ||
| 68 | static int sk_strcmp(const char * const *a, const char * const *b); | ||
| 69 | static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens); | ||
| 70 | static void str_free(void *str); | ||
| 71 | static int append_ia5(STACK **sk, ASN1_IA5STRING *email); | ||
| 72 | |||
| 73 | /* Add a CONF_VALUE name value pair to stack */ | ||
| 74 | |||
| 75 | int X509V3_add_value(const char *name, const char *value, | ||
| 76 | STACK_OF(CONF_VALUE) **extlist) | ||
| 77 | { | ||
| 78 | CONF_VALUE *vtmp = NULL; | ||
| 79 | char *tname = NULL, *tvalue = NULL; | ||
| 80 | if(name && !(tname = BUF_strdup(name))) goto err; | ||
| 81 | if(value && !(tvalue = BUF_strdup(value))) goto err;; | ||
| 82 | if(!(vtmp = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) goto err; | ||
| 83 | if(!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) goto err; | ||
| 84 | vtmp->section = NULL; | ||
| 85 | vtmp->name = tname; | ||
| 86 | vtmp->value = tvalue; | ||
| 87 | if(!sk_CONF_VALUE_push(*extlist, vtmp)) goto err; | ||
| 88 | return 1; | ||
| 89 | err: | ||
| 90 | X509V3err(X509V3_F_X509V3_ADD_VALUE,ERR_R_MALLOC_FAILURE); | ||
| 91 | if(vtmp) OPENSSL_free(vtmp); | ||
| 92 | if(tname) OPENSSL_free(tname); | ||
| 93 | if(tvalue) OPENSSL_free(tvalue); | ||
| 94 | return 0; | ||
| 95 | } | ||
| 96 | |||
| 97 | int X509V3_add_value_uchar(const char *name, const unsigned char *value, | ||
| 98 | STACK_OF(CONF_VALUE) **extlist) | ||
| 99 | { | ||
| 100 | return X509V3_add_value(name,(const char *)value,extlist); | ||
| 101 | } | ||
| 102 | |||
| 103 | /* Free function for STACK_OF(CONF_VALUE) */ | ||
| 104 | |||
| 105 | void X509V3_conf_free(CONF_VALUE *conf) | ||
| 106 | { | ||
| 107 | if(!conf) return; | ||
| 108 | if(conf->name) OPENSSL_free(conf->name); | ||
| 109 | if(conf->value) OPENSSL_free(conf->value); | ||
| 110 | if(conf->section) OPENSSL_free(conf->section); | ||
| 111 | OPENSSL_free(conf); | ||
| 112 | } | ||
| 113 | |||
| 114 | int X509V3_add_value_bool(const char *name, int asn1_bool, | ||
| 115 | STACK_OF(CONF_VALUE) **extlist) | ||
| 116 | { | ||
| 117 | if(asn1_bool) return X509V3_add_value(name, "TRUE", extlist); | ||
| 118 | return X509V3_add_value(name, "FALSE", extlist); | ||
| 119 | } | ||
| 120 | |||
| 121 | int X509V3_add_value_bool_nf(char *name, int asn1_bool, | ||
| 122 | STACK_OF(CONF_VALUE) **extlist) | ||
| 123 | { | ||
| 124 | if(asn1_bool) return X509V3_add_value(name, "TRUE", extlist); | ||
| 125 | return 1; | ||
| 126 | } | ||
| 127 | |||
| 128 | |||
| 129 | char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *a) | ||
| 130 | { | ||
| 131 | BIGNUM *bntmp = NULL; | ||
| 132 | char *strtmp = NULL; | ||
| 133 | if(!a) return NULL; | ||
| 134 | if(!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) || | ||
| 135 | !(strtmp = BN_bn2dec(bntmp)) ) | ||
| 136 | X509V3err(X509V3_F_I2S_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE); | ||
| 137 | BN_free(bntmp); | ||
| 138 | return strtmp; | ||
| 139 | } | ||
| 140 | |||
| 141 | char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, ASN1_INTEGER *a) | ||
| 142 | { | ||
| 143 | BIGNUM *bntmp = NULL; | ||
| 144 | char *strtmp = NULL; | ||
| 145 | if(!a) return NULL; | ||
| 146 | if(!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || | ||
| 147 | !(strtmp = BN_bn2dec(bntmp)) ) | ||
| 148 | X509V3err(X509V3_F_I2S_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); | ||
| 149 | BN_free(bntmp); | ||
| 150 | return strtmp; | ||
| 151 | } | ||
| 152 | |||
| 153 | ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) | ||
| 154 | { | ||
| 155 | BIGNUM *bn = NULL; | ||
| 156 | ASN1_INTEGER *aint; | ||
| 157 | int isneg, ishex; | ||
| 158 | int ret; | ||
| 159 | bn = BN_new(); | ||
| 160 | if (!value) { | ||
| 161 | X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE); | ||
| 162 | return 0; | ||
| 163 | } | ||
| 164 | if (value[0] == '-') { | ||
| 165 | value++; | ||
| 166 | isneg = 1; | ||
| 167 | } else isneg = 0; | ||
| 168 | |||
| 169 | if (value[0] == '0' && ((value[1] == 'x') || (value[1] == 'X'))) { | ||
| 170 | value += 2; | ||
| 171 | ishex = 1; | ||
| 172 | } else ishex = 0; | ||
| 173 | |||
| 174 | if (ishex) ret = BN_hex2bn(&bn, value); | ||
| 175 | else ret = BN_dec2bn(&bn, value); | ||
| 176 | |||
| 177 | if (!ret) { | ||
| 178 | X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR); | ||
| 179 | return 0; | ||
| 180 | } | ||
| 181 | |||
| 182 | if (isneg && BN_is_zero(bn)) isneg = 0; | ||
| 183 | |||
| 184 | aint = BN_to_ASN1_INTEGER(bn, NULL); | ||
| 185 | BN_free(bn); | ||
| 186 | if (!aint) { | ||
| 187 | X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_TO_ASN1_INTEGER_ERROR); | ||
| 188 | return 0; | ||
| 189 | } | ||
| 190 | if (isneg) aint->type |= V_ASN1_NEG; | ||
| 191 | return aint; | ||
| 192 | } | ||
| 193 | |||
| 194 | int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, | ||
| 195 | STACK_OF(CONF_VALUE) **extlist) | ||
| 196 | { | ||
| 197 | char *strtmp; | ||
| 198 | int ret; | ||
| 199 | if(!aint) return 1; | ||
| 200 | if(!(strtmp = i2s_ASN1_INTEGER(NULL, aint))) return 0; | ||
| 201 | ret = X509V3_add_value(name, strtmp, extlist); | ||
| 202 | OPENSSL_free(strtmp); | ||
| 203 | return ret; | ||
| 204 | } | ||
| 205 | |||
| 206 | int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool) | ||
| 207 | { | ||
| 208 | char *btmp; | ||
| 209 | if(!(btmp = value->value)) goto err; | ||
| 210 | if(!strcmp(btmp, "TRUE") || !strcmp(btmp, "true") | ||
| 211 | || !strcmp(btmp, "Y") || !strcmp(btmp, "y") | ||
| 212 | || !strcmp(btmp, "YES") || !strcmp(btmp, "yes")) { | ||
| 213 | *asn1_bool = 0xff; | ||
| 214 | return 1; | ||
| 215 | } else if(!strcmp(btmp, "FALSE") || !strcmp(btmp, "false") | ||
| 216 | || !strcmp(btmp, "N") || !strcmp(btmp, "n") | ||
| 217 | || !strcmp(btmp, "NO") || !strcmp(btmp, "no")) { | ||
| 218 | *asn1_bool = 0; | ||
| 219 | return 1; | ||
| 220 | } | ||
| 221 | err: | ||
| 222 | X509V3err(X509V3_F_X509V3_GET_VALUE_BOOL,X509V3_R_INVALID_BOOLEAN_STRING); | ||
| 223 | X509V3_conf_err(value); | ||
| 224 | return 0; | ||
| 225 | } | ||
| 226 | |||
| 227 | int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint) | ||
| 228 | { | ||
| 229 | ASN1_INTEGER *itmp; | ||
| 230 | if(!(itmp = s2i_ASN1_INTEGER(NULL, value->value))) { | ||
| 231 | X509V3_conf_err(value); | ||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | *aint = itmp; | ||
| 235 | return 1; | ||
| 236 | } | ||
| 237 | |||
| 238 | #define HDR_NAME 1 | ||
| 239 | #define HDR_VALUE 2 | ||
| 240 | |||
| 241 | /*#define DEBUG*/ | ||
| 242 | |||
| 243 | STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line) | ||
| 244 | { | ||
| 245 | char *p, *q, c; | ||
| 246 | char *ntmp, *vtmp; | ||
| 247 | STACK_OF(CONF_VALUE) *values = NULL; | ||
| 248 | char *linebuf; | ||
| 249 | int state; | ||
| 250 | /* We are going to modify the line so copy it first */ | ||
| 251 | linebuf = BUF_strdup(line); | ||
| 252 | state = HDR_NAME; | ||
| 253 | ntmp = NULL; | ||
| 254 | /* Go through all characters */ | ||
| 255 | for(p = linebuf, q = linebuf; (c = *p) && (c!='\r') && (c!='\n'); p++) { | ||
| 256 | |||
| 257 | switch(state) { | ||
| 258 | case HDR_NAME: | ||
| 259 | if(c == ':') { | ||
| 260 | state = HDR_VALUE; | ||
| 261 | *p = 0; | ||
| 262 | ntmp = strip_spaces(q); | ||
| 263 | if(!ntmp) { | ||
| 264 | X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); | ||
| 265 | goto err; | ||
| 266 | } | ||
| 267 | q = p + 1; | ||
| 268 | } else if(c == ',') { | ||
| 269 | *p = 0; | ||
| 270 | ntmp = strip_spaces(q); | ||
| 271 | q = p + 1; | ||
| 272 | #if 0 | ||
| 273 | printf("%s\n", ntmp); | ||
| 274 | #endif | ||
| 275 | if(!ntmp) { | ||
| 276 | X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); | ||
| 277 | goto err; | ||
| 278 | } | ||
| 279 | X509V3_add_value(ntmp, NULL, &values); | ||
| 280 | } | ||
| 281 | break ; | ||
| 282 | |||
| 283 | case HDR_VALUE: | ||
| 284 | if(c == ',') { | ||
| 285 | state = HDR_NAME; | ||
| 286 | *p = 0; | ||
| 287 | vtmp = strip_spaces(q); | ||
| 288 | #if 0 | ||
| 289 | printf("%s\n", ntmp); | ||
| 290 | #endif | ||
| 291 | if(!vtmp) { | ||
| 292 | X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_VALUE); | ||
| 293 | goto err; | ||
| 294 | } | ||
| 295 | X509V3_add_value(ntmp, vtmp, &values); | ||
| 296 | ntmp = NULL; | ||
| 297 | q = p + 1; | ||
| 298 | } | ||
| 299 | |||
| 300 | } | ||
| 301 | } | ||
| 302 | |||
| 303 | if(state == HDR_VALUE) { | ||
| 304 | vtmp = strip_spaces(q); | ||
| 305 | #if 0 | ||
| 306 | printf("%s=%s\n", ntmp, vtmp); | ||
| 307 | #endif | ||
| 308 | if(!vtmp) { | ||
| 309 | X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_VALUE); | ||
| 310 | goto err; | ||
| 311 | } | ||
| 312 | X509V3_add_value(ntmp, vtmp, &values); | ||
| 313 | } else { | ||
| 314 | ntmp = strip_spaces(q); | ||
| 315 | #if 0 | ||
| 316 | printf("%s\n", ntmp); | ||
| 317 | #endif | ||
| 318 | if(!ntmp) { | ||
| 319 | X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); | ||
| 320 | goto err; | ||
| 321 | } | ||
| 322 | X509V3_add_value(ntmp, NULL, &values); | ||
| 323 | } | ||
| 324 | OPENSSL_free(linebuf); | ||
| 325 | return values; | ||
| 326 | |||
| 327 | err: | ||
| 328 | OPENSSL_free(linebuf); | ||
| 329 | sk_CONF_VALUE_pop_free(values, X509V3_conf_free); | ||
| 330 | return NULL; | ||
| 331 | |||
| 332 | } | ||
| 333 | |||
| 334 | /* Delete leading and trailing spaces from a string */ | ||
| 335 | static char *strip_spaces(char *name) | ||
| 336 | { | ||
| 337 | char *p, *q; | ||
| 338 | /* Skip over leading spaces */ | ||
| 339 | p = name; | ||
| 340 | while(*p && isspace((unsigned char)*p)) p++; | ||
| 341 | if(!*p) return NULL; | ||
| 342 | q = p + strlen(p) - 1; | ||
| 343 | while((q != p) && isspace((unsigned char)*q)) q--; | ||
| 344 | if(p != q) q[1] = 0; | ||
| 345 | if(!*p) return NULL; | ||
| 346 | return p; | ||
| 347 | } | ||
| 348 | |||
| 349 | /* hex string utilities */ | ||
| 350 | |||
| 351 | /* Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its | ||
| 352 | * hex representation | ||
| 353 | * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) | ||
| 354 | */ | ||
| 355 | |||
| 356 | char *hex_to_string(unsigned char *buffer, long len) | ||
| 357 | { | ||
| 358 | char *tmp, *q; | ||
| 359 | unsigned char *p; | ||
| 360 | int i; | ||
| 361 | static char hexdig[] = "0123456789ABCDEF"; | ||
| 362 | if(!buffer || !len) return NULL; | ||
| 363 | if(!(tmp = OPENSSL_malloc(len * 3 + 1))) { | ||
| 364 | X509V3err(X509V3_F_HEX_TO_STRING,ERR_R_MALLOC_FAILURE); | ||
| 365 | return NULL; | ||
| 366 | } | ||
| 367 | q = tmp; | ||
| 368 | for(i = 0, p = buffer; i < len; i++,p++) { | ||
| 369 | *q++ = hexdig[(*p >> 4) & 0xf]; | ||
| 370 | *q++ = hexdig[*p & 0xf]; | ||
| 371 | *q++ = ':'; | ||
| 372 | } | ||
| 373 | q[-1] = 0; | ||
| 374 | #ifdef CHARSET_EBCDIC | ||
| 375 | ebcdic2ascii(tmp, tmp, q - tmp - 1); | ||
| 376 | #endif | ||
| 377 | |||
| 378 | return tmp; | ||
| 379 | } | ||
| 380 | |||
| 381 | /* Give a string of hex digits convert to | ||
| 382 | * a buffer | ||
| 383 | */ | ||
| 384 | |||
| 385 | unsigned char *string_to_hex(char *str, long *len) | ||
| 386 | { | ||
| 387 | unsigned char *hexbuf, *q; | ||
| 388 | unsigned char ch, cl, *p; | ||
| 389 | if(!str) { | ||
| 390 | X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_INVALID_NULL_ARGUMENT); | ||
| 391 | return NULL; | ||
| 392 | } | ||
| 393 | if(!(hexbuf = OPENSSL_malloc(strlen(str) >> 1))) goto err; | ||
| 394 | for(p = (unsigned char *)str, q = hexbuf; *p;) { | ||
| 395 | ch = *p++; | ||
| 396 | #ifdef CHARSET_EBCDIC | ||
| 397 | ch = os_toebcdic[ch]; | ||
| 398 | #endif | ||
| 399 | if(ch == ':') continue; | ||
| 400 | cl = *p++; | ||
| 401 | #ifdef CHARSET_EBCDIC | ||
| 402 | cl = os_toebcdic[cl]; | ||
| 403 | #endif | ||
| 404 | if(!cl) { | ||
| 405 | X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ODD_NUMBER_OF_DIGITS); | ||
| 406 | OPENSSL_free(hexbuf); | ||
| 407 | return NULL; | ||
| 408 | } | ||
| 409 | if(isupper(ch)) ch = tolower(ch); | ||
| 410 | if(isupper(cl)) cl = tolower(cl); | ||
| 411 | |||
| 412 | if((ch >= '0') && (ch <= '9')) ch -= '0'; | ||
| 413 | else if ((ch >= 'a') && (ch <= 'f')) ch -= 'a' - 10; | ||
| 414 | else goto badhex; | ||
| 415 | |||
| 416 | if((cl >= '0') && (cl <= '9')) cl -= '0'; | ||
| 417 | else if ((cl >= 'a') && (cl <= 'f')) cl -= 'a' - 10; | ||
| 418 | else goto badhex; | ||
| 419 | |||
| 420 | *q++ = (ch << 4) | cl; | ||
| 421 | } | ||
| 422 | |||
| 423 | if(len) *len = q - hexbuf; | ||
| 424 | |||
| 425 | return hexbuf; | ||
| 426 | |||
| 427 | err: | ||
| 428 | if(hexbuf) OPENSSL_free(hexbuf); | ||
| 429 | X509V3err(X509V3_F_STRING_TO_HEX,ERR_R_MALLOC_FAILURE); | ||
| 430 | return NULL; | ||
| 431 | |||
| 432 | badhex: | ||
| 433 | OPENSSL_free(hexbuf); | ||
| 434 | X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ILLEGAL_HEX_DIGIT); | ||
| 435 | return NULL; | ||
| 436 | |||
| 437 | } | ||
| 438 | |||
| 439 | /* V2I name comparison function: returns zero if 'name' matches | ||
| 440 | * cmp or cmp.* | ||
| 441 | */ | ||
| 442 | |||
| 443 | int name_cmp(const char *name, const char *cmp) | ||
| 444 | { | ||
| 445 | int len, ret; | ||
| 446 | char c; | ||
| 447 | len = strlen(cmp); | ||
| 448 | if((ret = strncmp(name, cmp, len))) return ret; | ||
| 449 | c = name[len]; | ||
| 450 | if(!c || (c=='.')) return 0; | ||
| 451 | return 1; | ||
| 452 | } | ||
| 453 | |||
| 454 | static int sk_strcmp(const char * const *a, const char * const *b) | ||
| 455 | { | ||
| 456 | return strcmp(*a, *b); | ||
| 457 | } | ||
| 458 | |||
| 459 | STACK *X509_get1_email(X509 *x) | ||
| 460 | { | ||
| 461 | GENERAL_NAMES *gens; | ||
| 462 | STACK *ret; | ||
| 463 | gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); | ||
| 464 | ret = get_email(X509_get_subject_name(x), gens); | ||
| 465 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | ||
| 466 | return ret; | ||
| 467 | } | ||
| 468 | |||
| 469 | STACK *X509_REQ_get1_email(X509_REQ *x) | ||
| 470 | { | ||
| 471 | GENERAL_NAMES *gens; | ||
| 472 | STACK_OF(X509_EXTENSION) *exts; | ||
| 473 | STACK *ret; | ||
| 474 | exts = X509_REQ_get_extensions(x); | ||
| 475 | gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL); | ||
| 476 | ret = get_email(X509_REQ_get_subject_name(x), gens); | ||
| 477 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | ||
| 478 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); | ||
| 479 | return ret; | ||
| 480 | } | ||
| 481 | |||
| 482 | |||
| 483 | static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens) | ||
| 484 | { | ||
| 485 | STACK *ret = NULL; | ||
| 486 | X509_NAME_ENTRY *ne; | ||
| 487 | ASN1_IA5STRING *email; | ||
| 488 | GENERAL_NAME *gen; | ||
| 489 | int i; | ||
| 490 | /* Now add any email address(es) to STACK */ | ||
| 491 | i = -1; | ||
| 492 | /* First supplied X509_NAME */ | ||
| 493 | while((i = X509_NAME_get_index_by_NID(name, | ||
| 494 | NID_pkcs9_emailAddress, i)) > 0) { | ||
| 495 | ne = X509_NAME_get_entry(name, i); | ||
| 496 | email = X509_NAME_ENTRY_get_data(ne); | ||
| 497 | if(!append_ia5(&ret, email)) return NULL; | ||
| 498 | } | ||
| 499 | for(i = 0; i < sk_GENERAL_NAME_num(gens); i++) | ||
| 500 | { | ||
| 501 | gen = sk_GENERAL_NAME_value(gens, i); | ||
| 502 | if(gen->type != GEN_EMAIL) continue; | ||
| 503 | if(!append_ia5(&ret, gen->d.ia5)) return NULL; | ||
| 504 | } | ||
| 505 | return ret; | ||
| 506 | } | ||
| 507 | |||
| 508 | static void str_free(void *str) | ||
| 509 | { | ||
| 510 | OPENSSL_free(str); | ||
| 511 | } | ||
| 512 | |||
| 513 | static int append_ia5(STACK **sk, ASN1_IA5STRING *email) | ||
| 514 | { | ||
| 515 | char *emtmp; | ||
| 516 | /* First some sanity checks */ | ||
| 517 | if(email->type != V_ASN1_IA5STRING) return 1; | ||
| 518 | if(!email->data || !email->length) return 1; | ||
| 519 | if(!*sk) *sk = sk_new(sk_strcmp); | ||
| 520 | if(!*sk) return 0; | ||
| 521 | /* Don't add duplicates */ | ||
| 522 | if(sk_find(*sk, (char *)email->data) != -1) return 1; | ||
| 523 | emtmp = BUF_strdup((char *)email->data); | ||
| 524 | if(!emtmp || !sk_push(*sk, emtmp)) { | ||
| 525 | X509_email_free(*sk); | ||
| 526 | *sk = NULL; | ||
| 527 | return 0; | ||
| 528 | } | ||
| 529 | return 1; | ||
| 530 | } | ||
| 531 | |||
| 532 | void X509_email_free(STACK *sk) | ||
| 533 | { | ||
| 534 | sk_pop_free(sk, str_free); | ||
| 535 | } | ||
diff --git a/src/lib/libcrypto/x509v3/v3err.c b/src/lib/libcrypto/x509v3/v3err.c new file mode 100644 index 0000000000..6458e95bb9 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3err.c | |||
| @@ -0,0 +1,181 @@ | |||
| 1 | /* crypto/x509v3/v3err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/x509v3.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | static ERR_STRING_DATA X509V3_str_functs[]= | ||
| 68 | { | ||
| 69 | {ERR_PACK(0,X509V3_F_COPY_EMAIL,0), "COPY_EMAIL"}, | ||
| 70 | {ERR_PACK(0,X509V3_F_COPY_ISSUER,0), "COPY_ISSUER"}, | ||
| 71 | {ERR_PACK(0,X509V3_F_DO_EXT_CONF,0), "DO_EXT_CONF"}, | ||
| 72 | {ERR_PACK(0,X509V3_F_DO_EXT_I2D,0), "DO_EXT_I2D"}, | ||
| 73 | {ERR_PACK(0,X509V3_F_HEX_TO_STRING,0), "hex_to_string"}, | ||
| 74 | {ERR_PACK(0,X509V3_F_I2S_ASN1_ENUMERATED,0), "i2s_ASN1_ENUMERATED"}, | ||
| 75 | {ERR_PACK(0,X509V3_F_I2S_ASN1_INTEGER,0), "i2s_ASN1_INTEGER"}, | ||
| 76 | {ERR_PACK(0,X509V3_F_I2V_AUTHORITY_INFO_ACCESS,0), "I2V_AUTHORITY_INFO_ACCESS"}, | ||
| 77 | {ERR_PACK(0,X509V3_F_NOTICE_SECTION,0), "NOTICE_SECTION"}, | ||
| 78 | {ERR_PACK(0,X509V3_F_NREF_NOS,0), "NREF_NOS"}, | ||
| 79 | {ERR_PACK(0,X509V3_F_POLICY_SECTION,0), "POLICY_SECTION"}, | ||
| 80 | {ERR_PACK(0,X509V3_F_R2I_CERTPOL,0), "R2I_CERTPOL"}, | ||
| 81 | {ERR_PACK(0,X509V3_F_S2I_ASN1_IA5STRING,0), "S2I_ASN1_IA5STRING"}, | ||
| 82 | {ERR_PACK(0,X509V3_F_S2I_ASN1_INTEGER,0), "s2i_ASN1_INTEGER"}, | ||
| 83 | {ERR_PACK(0,X509V3_F_S2I_ASN1_OCTET_STRING,0), "s2i_ASN1_OCTET_STRING"}, | ||
| 84 | {ERR_PACK(0,X509V3_F_S2I_ASN1_SKEY_ID,0), "S2I_ASN1_SKEY_ID"}, | ||
| 85 | {ERR_PACK(0,X509V3_F_S2I_S2I_SKEY_ID,0), "S2I_S2I_SKEY_ID"}, | ||
| 86 | {ERR_PACK(0,X509V3_F_STRING_TO_HEX,0), "string_to_hex"}, | ||
| 87 | {ERR_PACK(0,X509V3_F_SXNET_ADD_ASC,0), "SXNET_ADD_ASC"}, | ||
| 88 | {ERR_PACK(0,X509V3_F_SXNET_ADD_ID_INTEGER,0), "SXNET_add_id_INTEGER"}, | ||
| 89 | {ERR_PACK(0,X509V3_F_SXNET_ADD_ID_ULONG,0), "SXNET_add_id_ulong"}, | ||
| 90 | {ERR_PACK(0,X509V3_F_SXNET_GET_ID_ASC,0), "SXNET_get_id_asc"}, | ||
| 91 | {ERR_PACK(0,X509V3_F_SXNET_GET_ID_ULONG,0), "SXNET_get_id_ulong"}, | ||
| 92 | {ERR_PACK(0,X509V3_F_V2I_ACCESS_DESCRIPTION,0), "V2I_ACCESS_DESCRIPTION"}, | ||
| 93 | {ERR_PACK(0,X509V3_F_V2I_ASN1_BIT_STRING,0), "V2I_ASN1_BIT_STRING"}, | ||
| 94 | {ERR_PACK(0,X509V3_F_V2I_AUTHORITY_KEYID,0), "V2I_AUTHORITY_KEYID"}, | ||
| 95 | {ERR_PACK(0,X509V3_F_V2I_BASIC_CONSTRAINTS,0), "V2I_BASIC_CONSTRAINTS"}, | ||
| 96 | {ERR_PACK(0,X509V3_F_V2I_CRLD,0), "V2I_CRLD"}, | ||
| 97 | {ERR_PACK(0,X509V3_F_V2I_EXT_KU,0), "V2I_EXT_KU"}, | ||
| 98 | {ERR_PACK(0,X509V3_F_V2I_GENERAL_NAME,0), "v2i_GENERAL_NAME"}, | ||
| 99 | {ERR_PACK(0,X509V3_F_V2I_GENERAL_NAMES,0), "v2i_GENERAL_NAMES"}, | ||
| 100 | {ERR_PACK(0,X509V3_F_V3_GENERIC_EXTENSION,0), "V3_GENERIC_EXTENSION"}, | ||
| 101 | {ERR_PACK(0,X509V3_F_X509V3_ADD_I2D,0), "X509V3_ADD_I2D"}, | ||
| 102 | {ERR_PACK(0,X509V3_F_X509V3_ADD_VALUE,0), "X509V3_add_value"}, | ||
| 103 | {ERR_PACK(0,X509V3_F_X509V3_EXT_ADD,0), "X509V3_EXT_add"}, | ||
| 104 | {ERR_PACK(0,X509V3_F_X509V3_EXT_ADD_ALIAS,0), "X509V3_EXT_add_alias"}, | ||
| 105 | {ERR_PACK(0,X509V3_F_X509V3_EXT_CONF,0), "X509V3_EXT_conf"}, | ||
| 106 | {ERR_PACK(0,X509V3_F_X509V3_EXT_I2D,0), "X509V3_EXT_i2d"}, | ||
| 107 | {ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"}, | ||
| 108 | {ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"}, | ||
| 109 | {ERR_PACK(0,X509V3_F_X509_PURPOSE_ADD,0), "X509_PURPOSE_add"}, | ||
| 110 | {ERR_PACK(0,X509V3_F_X509_PURPOSE_SET,0), "X509_PURPOSE_set"}, | ||
| 111 | {0,NULL} | ||
| 112 | }; | ||
| 113 | |||
| 114 | static ERR_STRING_DATA X509V3_str_reasons[]= | ||
| 115 | { | ||
| 116 | {X509V3_R_BAD_IP_ADDRESS ,"bad ip address"}, | ||
| 117 | {X509V3_R_BAD_OBJECT ,"bad object"}, | ||
| 118 | {X509V3_R_BN_DEC2BN_ERROR ,"bn dec2bn error"}, | ||
| 119 | {X509V3_R_BN_TO_ASN1_INTEGER_ERROR ,"bn to asn1 integer error"}, | ||
| 120 | {X509V3_R_DUPLICATE_ZONE_ID ,"duplicate zone id"}, | ||
| 121 | {X509V3_R_ERROR_CONVERTING_ZONE ,"error converting zone"}, | ||
| 122 | {X509V3_R_ERROR_CREATING_EXTENSION ,"error creating extension"}, | ||
| 123 | {X509V3_R_ERROR_IN_EXTENSION ,"error in extension"}, | ||
| 124 | {X509V3_R_EXPECTED_A_SECTION_NAME ,"expected a section name"}, | ||
| 125 | {X509V3_R_EXTENSION_EXISTS ,"extension exists"}, | ||
| 126 | {X509V3_R_EXTENSION_NAME_ERROR ,"extension name error"}, | ||
| 127 | {X509V3_R_EXTENSION_NOT_FOUND ,"extension not found"}, | ||
| 128 | {X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED,"extension setting not supported"}, | ||
| 129 | {X509V3_R_EXTENSION_VALUE_ERROR ,"extension value error"}, | ||
| 130 | {X509V3_R_ILLEGAL_HEX_DIGIT ,"illegal hex digit"}, | ||
| 131 | {X509V3_R_INVALID_BOOLEAN_STRING ,"invalid boolean string"}, | ||
| 132 | {X509V3_R_INVALID_EXTENSION_STRING ,"invalid extension string"}, | ||
| 133 | {X509V3_R_INVALID_NAME ,"invalid name"}, | ||
| 134 | {X509V3_R_INVALID_NULL_ARGUMENT ,"invalid null argument"}, | ||
| 135 | {X509V3_R_INVALID_NULL_NAME ,"invalid null name"}, | ||
| 136 | {X509V3_R_INVALID_NULL_VALUE ,"invalid null value"}, | ||
| 137 | {X509V3_R_INVALID_NUMBER ,"invalid number"}, | ||
| 138 | {X509V3_R_INVALID_NUMBERS ,"invalid numbers"}, | ||
| 139 | {X509V3_R_INVALID_OBJECT_IDENTIFIER ,"invalid object identifier"}, | ||
| 140 | {X509V3_R_INVALID_OPTION ,"invalid option"}, | ||
| 141 | {X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"}, | ||
| 142 | {X509V3_R_INVALID_PURPOSE ,"invalid purpose"}, | ||
| 143 | {X509V3_R_INVALID_SECTION ,"invalid section"}, | ||
| 144 | {X509V3_R_INVALID_SYNTAX ,"invalid syntax"}, | ||
| 145 | {X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"}, | ||
| 146 | {X509V3_R_MISSING_VALUE ,"missing value"}, | ||
| 147 | {X509V3_R_NEED_ORGANIZATION_AND_NUMBERS ,"need organization and numbers"}, | ||
| 148 | {X509V3_R_NO_CONFIG_DATABASE ,"no config database"}, | ||
| 149 | {X509V3_R_NO_ISSUER_CERTIFICATE ,"no issuer certificate"}, | ||
| 150 | {X509V3_R_NO_ISSUER_DETAILS ,"no issuer details"}, | ||
| 151 | {X509V3_R_NO_POLICY_IDENTIFIER ,"no policy identifier"}, | ||
| 152 | {X509V3_R_NO_PUBLIC_KEY ,"no public key"}, | ||
| 153 | {X509V3_R_NO_SUBJECT_DETAILS ,"no subject details"}, | ||
| 154 | {X509V3_R_ODD_NUMBER_OF_DIGITS ,"odd number of digits"}, | ||
| 155 | {X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS ,"unable to get issuer details"}, | ||
| 156 | {X509V3_R_UNABLE_TO_GET_ISSUER_KEYID ,"unable to get issuer keyid"}, | ||
| 157 | {X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT ,"unknown bit string argument"}, | ||
| 158 | {X509V3_R_UNKNOWN_EXTENSION ,"unknown extension"}, | ||
| 159 | {X509V3_R_UNKNOWN_EXTENSION_NAME ,"unknown extension name"}, | ||
| 160 | {X509V3_R_UNKNOWN_OPTION ,"unknown option"}, | ||
| 161 | {X509V3_R_UNSUPPORTED_OPTION ,"unsupported option"}, | ||
| 162 | {X509V3_R_USER_TOO_LONG ,"user too long"}, | ||
| 163 | {0,NULL} | ||
| 164 | }; | ||
| 165 | |||
| 166 | #endif | ||
| 167 | |||
| 168 | void ERR_load_X509V3_strings(void) | ||
| 169 | { | ||
| 170 | static int init=1; | ||
| 171 | |||
| 172 | if (init) | ||
| 173 | { | ||
| 174 | init=0; | ||
| 175 | #ifndef OPENSSL_NO_ERR | ||
| 176 | ERR_load_strings(ERR_LIB_X509V3,X509V3_str_functs); | ||
| 177 | ERR_load_strings(ERR_LIB_X509V3,X509V3_str_reasons); | ||
| 178 | #endif | ||
| 179 | |||
| 180 | } | ||
| 181 | } | ||
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h new file mode 100644 index 0000000000..daecc55271 --- /dev/null +++ b/src/lib/libcrypto/x509v3/x509v3.h | |||
| @@ -0,0 +1,655 @@ | |||
| 1 | /* x509v3.h */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | #ifndef HEADER_X509V3_H | ||
| 59 | #define HEADER_X509V3_H | ||
| 60 | |||
| 61 | #include <openssl/bio.h> | ||
| 62 | #include <openssl/x509.h> | ||
| 63 | #include <openssl/conf.h> | ||
| 64 | |||
| 65 | #ifdef __cplusplus | ||
| 66 | extern "C" { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /* Forward reference */ | ||
| 70 | struct v3_ext_method; | ||
| 71 | struct v3_ext_ctx; | ||
| 72 | |||
| 73 | /* Useful typedefs */ | ||
| 74 | |||
| 75 | typedef void * (*X509V3_EXT_NEW)(void); | ||
| 76 | typedef void (*X509V3_EXT_FREE)(void *); | ||
| 77 | typedef void * (*X509V3_EXT_D2I)(void *, unsigned char ** , long); | ||
| 78 | typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); | ||
| 79 | typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); | ||
| 80 | typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); | ||
| 81 | typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); | ||
| 82 | typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); | ||
| 83 | typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); | ||
| 84 | typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); | ||
| 85 | |||
| 86 | /* V3 extension structure */ | ||
| 87 | |||
| 88 | struct v3_ext_method { | ||
| 89 | int ext_nid; | ||
| 90 | int ext_flags; | ||
| 91 | /* If this is set the following four fields are ignored */ | ||
| 92 | ASN1_ITEM_EXP *it; | ||
| 93 | /* Old style ASN1 calls */ | ||
| 94 | X509V3_EXT_NEW ext_new; | ||
| 95 | X509V3_EXT_FREE ext_free; | ||
| 96 | X509V3_EXT_D2I d2i; | ||
| 97 | X509V3_EXT_I2D i2d; | ||
| 98 | |||
| 99 | /* The following pair is used for string extensions */ | ||
| 100 | X509V3_EXT_I2S i2s; | ||
| 101 | X509V3_EXT_S2I s2i; | ||
| 102 | |||
| 103 | /* The following pair is used for multi-valued extensions */ | ||
| 104 | X509V3_EXT_I2V i2v; | ||
| 105 | X509V3_EXT_V2I v2i; | ||
| 106 | |||
| 107 | /* The following are used for raw extensions */ | ||
| 108 | X509V3_EXT_I2R i2r; | ||
| 109 | X509V3_EXT_R2I r2i; | ||
| 110 | |||
| 111 | void *usr_data; /* Any extension specific data */ | ||
| 112 | }; | ||
| 113 | |||
| 114 | typedef struct X509V3_CONF_METHOD_st { | ||
| 115 | char * (*get_string)(void *db, char *section, char *value); | ||
| 116 | STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); | ||
| 117 | void (*free_string)(void *db, char * string); | ||
| 118 | void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); | ||
| 119 | } X509V3_CONF_METHOD; | ||
| 120 | |||
| 121 | /* Context specific info */ | ||
| 122 | struct v3_ext_ctx { | ||
| 123 | #define CTX_TEST 0x1 | ||
| 124 | int flags; | ||
| 125 | X509 *issuer_cert; | ||
| 126 | X509 *subject_cert; | ||
| 127 | X509_REQ *subject_req; | ||
| 128 | X509_CRL *crl; | ||
| 129 | X509V3_CONF_METHOD *db_meth; | ||
| 130 | void *db; | ||
| 131 | /* Maybe more here */ | ||
| 132 | }; | ||
| 133 | |||
| 134 | typedef struct v3_ext_method X509V3_EXT_METHOD; | ||
| 135 | typedef struct v3_ext_ctx X509V3_CTX; | ||
| 136 | |||
| 137 | DECLARE_STACK_OF(X509V3_EXT_METHOD) | ||
| 138 | |||
| 139 | /* ext_flags values */ | ||
| 140 | #define X509V3_EXT_DYNAMIC 0x1 | ||
| 141 | #define X509V3_EXT_CTX_DEP 0x2 | ||
| 142 | #define X509V3_EXT_MULTILINE 0x4 | ||
| 143 | |||
| 144 | typedef BIT_STRING_BITNAME ENUMERATED_NAMES; | ||
| 145 | |||
| 146 | typedef struct BASIC_CONSTRAINTS_st { | ||
| 147 | int ca; | ||
| 148 | ASN1_INTEGER *pathlen; | ||
| 149 | } BASIC_CONSTRAINTS; | ||
| 150 | |||
| 151 | |||
| 152 | typedef struct PKEY_USAGE_PERIOD_st { | ||
| 153 | ASN1_GENERALIZEDTIME *notBefore; | ||
| 154 | ASN1_GENERALIZEDTIME *notAfter; | ||
| 155 | } PKEY_USAGE_PERIOD; | ||
| 156 | |||
| 157 | typedef struct otherName_st { | ||
| 158 | ASN1_OBJECT *type_id; | ||
| 159 | ASN1_TYPE *value; | ||
| 160 | } OTHERNAME; | ||
| 161 | |||
| 162 | typedef struct EDIPartyName_st { | ||
| 163 | ASN1_STRING *nameAssigner; | ||
| 164 | ASN1_STRING *partyName; | ||
| 165 | } EDIPARTYNAME; | ||
| 166 | |||
| 167 | typedef struct GENERAL_NAME_st { | ||
| 168 | |||
| 169 | #define GEN_OTHERNAME 0 | ||
| 170 | #define GEN_EMAIL 1 | ||
| 171 | #define GEN_DNS 2 | ||
| 172 | #define GEN_X400 3 | ||
| 173 | #define GEN_DIRNAME 4 | ||
| 174 | #define GEN_EDIPARTY 5 | ||
| 175 | #define GEN_URI 6 | ||
| 176 | #define GEN_IPADD 7 | ||
| 177 | #define GEN_RID 8 | ||
| 178 | |||
| 179 | int type; | ||
| 180 | union { | ||
| 181 | char *ptr; | ||
| 182 | OTHERNAME *otherName; /* otherName */ | ||
| 183 | ASN1_IA5STRING *rfc822Name; | ||
| 184 | ASN1_IA5STRING *dNSName; | ||
| 185 | ASN1_TYPE *x400Address; | ||
| 186 | X509_NAME *directoryName; | ||
| 187 | EDIPARTYNAME *ediPartyName; | ||
| 188 | ASN1_IA5STRING *uniformResourceIdentifier; | ||
| 189 | ASN1_OCTET_STRING *iPAddress; | ||
| 190 | ASN1_OBJECT *registeredID; | ||
| 191 | |||
| 192 | /* Old names */ | ||
| 193 | ASN1_OCTET_STRING *ip; /* iPAddress */ | ||
| 194 | X509_NAME *dirn; /* dirn */ | ||
| 195 | ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ | ||
| 196 | ASN1_OBJECT *rid; /* registeredID */ | ||
| 197 | ASN1_TYPE *other; /* x400Address */ | ||
| 198 | } d; | ||
| 199 | } GENERAL_NAME; | ||
| 200 | |||
| 201 | typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; | ||
| 202 | |||
| 203 | typedef struct ACCESS_DESCRIPTION_st { | ||
| 204 | ASN1_OBJECT *method; | ||
| 205 | GENERAL_NAME *location; | ||
| 206 | } ACCESS_DESCRIPTION; | ||
| 207 | |||
| 208 | typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; | ||
| 209 | |||
| 210 | typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; | ||
| 211 | |||
| 212 | DECLARE_STACK_OF(GENERAL_NAME) | ||
| 213 | DECLARE_ASN1_SET_OF(GENERAL_NAME) | ||
| 214 | |||
| 215 | DECLARE_STACK_OF(ACCESS_DESCRIPTION) | ||
| 216 | DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) | ||
| 217 | |||
| 218 | typedef struct DIST_POINT_NAME_st { | ||
| 219 | int type; | ||
| 220 | union { | ||
| 221 | GENERAL_NAMES *fullname; | ||
| 222 | STACK_OF(X509_NAME_ENTRY) *relativename; | ||
| 223 | } name; | ||
| 224 | } DIST_POINT_NAME; | ||
| 225 | |||
| 226 | typedef struct DIST_POINT_st { | ||
| 227 | DIST_POINT_NAME *distpoint; | ||
| 228 | ASN1_BIT_STRING *reasons; | ||
| 229 | GENERAL_NAMES *CRLissuer; | ||
| 230 | } DIST_POINT; | ||
| 231 | |||
| 232 | typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; | ||
| 233 | |||
| 234 | DECLARE_STACK_OF(DIST_POINT) | ||
| 235 | DECLARE_ASN1_SET_OF(DIST_POINT) | ||
| 236 | |||
| 237 | typedef struct AUTHORITY_KEYID_st { | ||
| 238 | ASN1_OCTET_STRING *keyid; | ||
| 239 | GENERAL_NAMES *issuer; | ||
| 240 | ASN1_INTEGER *serial; | ||
| 241 | } AUTHORITY_KEYID; | ||
| 242 | |||
| 243 | /* Strong extranet structures */ | ||
| 244 | |||
| 245 | typedef struct SXNET_ID_st { | ||
| 246 | ASN1_INTEGER *zone; | ||
| 247 | ASN1_OCTET_STRING *user; | ||
| 248 | } SXNETID; | ||
| 249 | |||
| 250 | DECLARE_STACK_OF(SXNETID) | ||
| 251 | DECLARE_ASN1_SET_OF(SXNETID) | ||
| 252 | |||
| 253 | typedef struct SXNET_st { | ||
| 254 | ASN1_INTEGER *version; | ||
| 255 | STACK_OF(SXNETID) *ids; | ||
| 256 | } SXNET; | ||
| 257 | |||
| 258 | typedef struct NOTICEREF_st { | ||
| 259 | ASN1_STRING *organization; | ||
| 260 | STACK_OF(ASN1_INTEGER) *noticenos; | ||
| 261 | } NOTICEREF; | ||
| 262 | |||
| 263 | typedef struct USERNOTICE_st { | ||
| 264 | NOTICEREF *noticeref; | ||
| 265 | ASN1_STRING *exptext; | ||
| 266 | } USERNOTICE; | ||
| 267 | |||
| 268 | typedef struct POLICYQUALINFO_st { | ||
| 269 | ASN1_OBJECT *pqualid; | ||
| 270 | union { | ||
| 271 | ASN1_IA5STRING *cpsuri; | ||
| 272 | USERNOTICE *usernotice; | ||
| 273 | ASN1_TYPE *other; | ||
| 274 | } d; | ||
| 275 | } POLICYQUALINFO; | ||
| 276 | |||
| 277 | DECLARE_STACK_OF(POLICYQUALINFO) | ||
| 278 | DECLARE_ASN1_SET_OF(POLICYQUALINFO) | ||
| 279 | |||
| 280 | typedef struct POLICYINFO_st { | ||
| 281 | ASN1_OBJECT *policyid; | ||
| 282 | STACK_OF(POLICYQUALINFO) *qualifiers; | ||
| 283 | } POLICYINFO; | ||
| 284 | |||
| 285 | typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; | ||
| 286 | |||
| 287 | DECLARE_STACK_OF(POLICYINFO) | ||
| 288 | DECLARE_ASN1_SET_OF(POLICYINFO) | ||
| 289 | |||
| 290 | #define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ | ||
| 291 | ",name:", val->name, ",value:", val->value); | ||
| 292 | |||
| 293 | #define X509V3_set_ctx_test(ctx) \ | ||
| 294 | X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) | ||
| 295 | #define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; | ||
| 296 | |||
| 297 | #define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ | ||
| 298 | 0,0,0,0, \ | ||
| 299 | 0,0, \ | ||
| 300 | (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ | ||
| 301 | (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ | ||
| 302 | NULL, NULL, \ | ||
| 303 | table} | ||
| 304 | |||
| 305 | #define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ | ||
| 306 | 0,0,0,0, \ | ||
| 307 | (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ | ||
| 308 | (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ | ||
| 309 | 0,0,0,0, \ | ||
| 310 | NULL} | ||
| 311 | |||
| 312 | #define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||
| 313 | |||
| 314 | |||
| 315 | /* X509_PURPOSE stuff */ | ||
| 316 | |||
| 317 | #define EXFLAG_BCONS 0x1 | ||
| 318 | #define EXFLAG_KUSAGE 0x2 | ||
| 319 | #define EXFLAG_XKUSAGE 0x4 | ||
| 320 | #define EXFLAG_NSCERT 0x8 | ||
| 321 | |||
| 322 | #define EXFLAG_CA 0x10 | ||
| 323 | #define EXFLAG_SS 0x20 | ||
| 324 | #define EXFLAG_V1 0x40 | ||
| 325 | #define EXFLAG_INVALID 0x80 | ||
| 326 | #define EXFLAG_SET 0x100 | ||
| 327 | #define EXFLAG_CRITICAL 0x200 | ||
| 328 | |||
| 329 | #define KU_DIGITAL_SIGNATURE 0x0080 | ||
| 330 | #define KU_NON_REPUDIATION 0x0040 | ||
| 331 | #define KU_KEY_ENCIPHERMENT 0x0020 | ||
| 332 | #define KU_DATA_ENCIPHERMENT 0x0010 | ||
| 333 | #define KU_KEY_AGREEMENT 0x0008 | ||
| 334 | #define KU_KEY_CERT_SIGN 0x0004 | ||
| 335 | #define KU_CRL_SIGN 0x0002 | ||
| 336 | #define KU_ENCIPHER_ONLY 0x0001 | ||
| 337 | #define KU_DECIPHER_ONLY 0x8000 | ||
| 338 | |||
| 339 | #define NS_SSL_CLIENT 0x80 | ||
| 340 | #define NS_SSL_SERVER 0x40 | ||
| 341 | #define NS_SMIME 0x20 | ||
| 342 | #define NS_OBJSIGN 0x10 | ||
| 343 | #define NS_SSL_CA 0x04 | ||
| 344 | #define NS_SMIME_CA 0x02 | ||
| 345 | #define NS_OBJSIGN_CA 0x01 | ||
| 346 | #define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) | ||
| 347 | |||
| 348 | #define XKU_SSL_SERVER 0x1 | ||
| 349 | #define XKU_SSL_CLIENT 0x2 | ||
| 350 | #define XKU_SMIME 0x4 | ||
| 351 | #define XKU_CODE_SIGN 0x8 | ||
| 352 | #define XKU_SGC 0x10 | ||
| 353 | #define XKU_OCSP_SIGN 0x20 | ||
| 354 | #define XKU_TIMESTAMP 0x40 | ||
| 355 | |||
| 356 | #define X509_PURPOSE_DYNAMIC 0x1 | ||
| 357 | #define X509_PURPOSE_DYNAMIC_NAME 0x2 | ||
| 358 | |||
| 359 | typedef struct x509_purpose_st { | ||
| 360 | int purpose; | ||
| 361 | int trust; /* Default trust ID */ | ||
| 362 | int flags; | ||
| 363 | int (*check_purpose)(const struct x509_purpose_st *, | ||
| 364 | const X509 *, int); | ||
| 365 | char *name; | ||
| 366 | char *sname; | ||
| 367 | void *usr_data; | ||
| 368 | } X509_PURPOSE; | ||
| 369 | |||
| 370 | #define X509_PURPOSE_SSL_CLIENT 1 | ||
| 371 | #define X509_PURPOSE_SSL_SERVER 2 | ||
| 372 | #define X509_PURPOSE_NS_SSL_SERVER 3 | ||
| 373 | #define X509_PURPOSE_SMIME_SIGN 4 | ||
| 374 | #define X509_PURPOSE_SMIME_ENCRYPT 5 | ||
| 375 | #define X509_PURPOSE_CRL_SIGN 6 | ||
| 376 | #define X509_PURPOSE_ANY 7 | ||
| 377 | #define X509_PURPOSE_OCSP_HELPER 8 | ||
| 378 | |||
| 379 | #define X509_PURPOSE_MIN 1 | ||
| 380 | #define X509_PURPOSE_MAX 8 | ||
| 381 | |||
| 382 | /* Flags for X509V3_EXT_print() */ | ||
| 383 | |||
| 384 | #define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) | ||
| 385 | /* Return error for unknown extensions */ | ||
| 386 | #define X509V3_EXT_DEFAULT 0 | ||
| 387 | /* Print error for unknown extensions */ | ||
| 388 | #define X509V3_EXT_ERROR_UNKNOWN (1L << 16) | ||
| 389 | /* ASN1 parse unknown extensions */ | ||
| 390 | #define X509V3_EXT_PARSE_UNKNOWN (2L << 16) | ||
| 391 | /* BIO_dump unknown extensions */ | ||
| 392 | #define X509V3_EXT_DUMP_UNKNOWN (3L << 16) | ||
| 393 | |||
| 394 | /* Flags for X509V3_add1_i2d */ | ||
| 395 | |||
| 396 | #define X509V3_ADD_OP_MASK 0xfL | ||
| 397 | #define X509V3_ADD_DEFAULT 0L | ||
| 398 | #define X509V3_ADD_APPEND 1L | ||
| 399 | #define X509V3_ADD_REPLACE 2L | ||
| 400 | #define X509V3_ADD_REPLACE_EXISTING 3L | ||
| 401 | #define X509V3_ADD_KEEP_EXISTING 4L | ||
| 402 | #define X509V3_ADD_DELETE 5L | ||
| 403 | #define X509V3_ADD_SILENT 0x10 | ||
| 404 | |||
| 405 | DECLARE_STACK_OF(X509_PURPOSE) | ||
| 406 | |||
| 407 | DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) | ||
| 408 | |||
| 409 | DECLARE_ASN1_FUNCTIONS(SXNET) | ||
| 410 | DECLARE_ASN1_FUNCTIONS(SXNETID) | ||
| 411 | |||
| 412 | int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); | ||
| 413 | int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); | ||
| 414 | int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); | ||
| 415 | |||
| 416 | ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); | ||
| 417 | ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); | ||
| 418 | ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); | ||
| 419 | |||
| 420 | DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) | ||
| 421 | |||
| 422 | DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) | ||
| 423 | |||
| 424 | DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) | ||
| 425 | |||
| 426 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); | ||
| 427 | int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); | ||
| 428 | |||
| 429 | DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) | ||
| 430 | |||
| 431 | STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, | ||
| 432 | GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); | ||
| 433 | GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, | ||
| 434 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | ||
| 435 | |||
| 436 | DECLARE_ASN1_FUNCTIONS(OTHERNAME) | ||
| 437 | DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) | ||
| 438 | |||
| 439 | char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); | ||
| 440 | ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); | ||
| 441 | |||
| 442 | DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) | ||
| 443 | int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); | ||
| 444 | |||
| 445 | DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) | ||
| 446 | DECLARE_ASN1_FUNCTIONS(POLICYINFO) | ||
| 447 | DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) | ||
| 448 | DECLARE_ASN1_FUNCTIONS(USERNOTICE) | ||
| 449 | DECLARE_ASN1_FUNCTIONS(NOTICEREF) | ||
| 450 | |||
| 451 | DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) | ||
| 452 | DECLARE_ASN1_FUNCTIONS(DIST_POINT) | ||
| 453 | DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) | ||
| 454 | |||
| 455 | DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) | ||
| 456 | DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) | ||
| 457 | |||
| 458 | #ifdef HEADER_CONF_H | ||
| 459 | GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf); | ||
| 460 | void X509V3_conf_free(CONF_VALUE *val); | ||
| 461 | |||
| 462 | X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); | ||
| 463 | X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); | ||
| 464 | int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); | ||
| 465 | int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); | ||
| 466 | int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); | ||
| 467 | int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); | ||
| 468 | |||
| 469 | X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); | ||
| 470 | X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); | ||
| 471 | int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); | ||
| 472 | int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); | ||
| 473 | int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); | ||
| 474 | |||
| 475 | int X509V3_add_value_bool_nf(char *name, int asn1_bool, | ||
| 476 | STACK_OF(CONF_VALUE) **extlist); | ||
| 477 | int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); | ||
| 478 | int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); | ||
| 479 | void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); | ||
| 480 | void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); | ||
| 481 | #endif | ||
| 482 | |||
| 483 | char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); | ||
| 484 | STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); | ||
| 485 | void X509V3_string_free(X509V3_CTX *ctx, char *str); | ||
| 486 | void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); | ||
| 487 | void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, | ||
| 488 | X509_REQ *req, X509_CRL *crl, int flags); | ||
| 489 | |||
| 490 | int X509V3_add_value(const char *name, const char *value, | ||
| 491 | STACK_OF(CONF_VALUE) **extlist); | ||
| 492 | int X509V3_add_value_uchar(const char *name, const unsigned char *value, | ||
| 493 | STACK_OF(CONF_VALUE) **extlist); | ||
| 494 | int X509V3_add_value_bool(const char *name, int asn1_bool, | ||
| 495 | STACK_OF(CONF_VALUE) **extlist); | ||
| 496 | int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, | ||
| 497 | STACK_OF(CONF_VALUE) **extlist); | ||
| 498 | char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); | ||
| 499 | ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); | ||
| 500 | char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); | ||
| 501 | char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); | ||
| 502 | int X509V3_EXT_add(X509V3_EXT_METHOD *ext); | ||
| 503 | int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); | ||
| 504 | int X509V3_EXT_add_alias(int nid_to, int nid_from); | ||
| 505 | void X509V3_EXT_cleanup(void); | ||
| 506 | |||
| 507 | X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); | ||
| 508 | X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); | ||
| 509 | int X509V3_add_standard_extensions(void); | ||
| 510 | STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); | ||
| 511 | void *X509V3_EXT_d2i(X509_EXTENSION *ext); | ||
| 512 | void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); | ||
| 513 | |||
| 514 | |||
| 515 | X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); | ||
| 516 | int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); | ||
| 517 | |||
| 518 | char *hex_to_string(unsigned char *buffer, long len); | ||
| 519 | unsigned char *string_to_hex(char *str, long *len); | ||
| 520 | int name_cmp(const char *name, const char *cmp); | ||
| 521 | |||
| 522 | void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, | ||
| 523 | int ml); | ||
| 524 | int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); | ||
| 525 | int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); | ||
| 526 | |||
| 527 | int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); | ||
| 528 | |||
| 529 | int X509_check_purpose(X509 *x, int id, int ca); | ||
| 530 | int X509_supported_extension(X509_EXTENSION *ex); | ||
| 531 | int X509_PURPOSE_set(int *p, int purpose); | ||
| 532 | int X509_check_issued(X509 *issuer, X509 *subject); | ||
| 533 | int X509_PURPOSE_get_count(void); | ||
| 534 | X509_PURPOSE * X509_PURPOSE_get0(int idx); | ||
| 535 | int X509_PURPOSE_get_by_sname(char *sname); | ||
| 536 | int X509_PURPOSE_get_by_id(int id); | ||
| 537 | int X509_PURPOSE_add(int id, int trust, int flags, | ||
| 538 | int (*ck)(const X509_PURPOSE *, const X509 *, int), | ||
| 539 | char *name, char *sname, void *arg); | ||
| 540 | char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); | ||
| 541 | char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); | ||
| 542 | int X509_PURPOSE_get_trust(X509_PURPOSE *xp); | ||
| 543 | void X509_PURPOSE_cleanup(void); | ||
| 544 | int X509_PURPOSE_get_id(X509_PURPOSE *); | ||
| 545 | |||
| 546 | STACK *X509_get1_email(X509 *x); | ||
| 547 | STACK *X509_REQ_get1_email(X509_REQ *x); | ||
| 548 | void X509_email_free(STACK *sk); | ||
| 549 | |||
| 550 | |||
| 551 | /* BEGIN ERROR CODES */ | ||
| 552 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 553 | * made after this point may be overwritten when the script is next run. | ||
| 554 | */ | ||
| 555 | void ERR_load_X509V3_strings(void); | ||
| 556 | |||
| 557 | /* Error codes for the X509V3 functions. */ | ||
| 558 | |||
| 559 | /* Function codes. */ | ||
| 560 | #define X509V3_F_COPY_EMAIL 122 | ||
| 561 | #define X509V3_F_COPY_ISSUER 123 | ||
| 562 | #define X509V3_F_DO_EXT_CONF 124 | ||
| 563 | #define X509V3_F_DO_EXT_I2D 135 | ||
| 564 | #define X509V3_F_HEX_TO_STRING 111 | ||
| 565 | #define X509V3_F_I2S_ASN1_ENUMERATED 121 | ||
| 566 | #define X509V3_F_I2S_ASN1_INTEGER 120 | ||
| 567 | #define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 | ||
| 568 | #define X509V3_F_NOTICE_SECTION 132 | ||
| 569 | #define X509V3_F_NREF_NOS 133 | ||
| 570 | #define X509V3_F_POLICY_SECTION 131 | ||
| 571 | #define X509V3_F_R2I_CERTPOL 130 | ||
| 572 | #define X509V3_F_S2I_ASN1_IA5STRING 100 | ||
| 573 | #define X509V3_F_S2I_ASN1_INTEGER 108 | ||
| 574 | #define X509V3_F_S2I_ASN1_OCTET_STRING 112 | ||
| 575 | #define X509V3_F_S2I_ASN1_SKEY_ID 114 | ||
| 576 | #define X509V3_F_S2I_S2I_SKEY_ID 115 | ||
| 577 | #define X509V3_F_STRING_TO_HEX 113 | ||
| 578 | #define X509V3_F_SXNET_ADD_ASC 125 | ||
| 579 | #define X509V3_F_SXNET_ADD_ID_INTEGER 126 | ||
| 580 | #define X509V3_F_SXNET_ADD_ID_ULONG 127 | ||
| 581 | #define X509V3_F_SXNET_GET_ID_ASC 128 | ||
| 582 | #define X509V3_F_SXNET_GET_ID_ULONG 129 | ||
| 583 | #define X509V3_F_V2I_ACCESS_DESCRIPTION 139 | ||
| 584 | #define X509V3_F_V2I_ASN1_BIT_STRING 101 | ||
| 585 | #define X509V3_F_V2I_AUTHORITY_KEYID 119 | ||
| 586 | #define X509V3_F_V2I_BASIC_CONSTRAINTS 102 | ||
| 587 | #define X509V3_F_V2I_CRLD 134 | ||
| 588 | #define X509V3_F_V2I_EXT_KU 103 | ||
| 589 | #define X509V3_F_V2I_GENERAL_NAME 117 | ||
| 590 | #define X509V3_F_V2I_GENERAL_NAMES 118 | ||
| 591 | #define X509V3_F_V3_GENERIC_EXTENSION 116 | ||
| 592 | #define X509V3_F_X509V3_ADD_I2D 140 | ||
| 593 | #define X509V3_F_X509V3_ADD_VALUE 105 | ||
| 594 | #define X509V3_F_X509V3_EXT_ADD 104 | ||
| 595 | #define X509V3_F_X509V3_EXT_ADD_ALIAS 106 | ||
| 596 | #define X509V3_F_X509V3_EXT_CONF 107 | ||
| 597 | #define X509V3_F_X509V3_EXT_I2D 136 | ||
| 598 | #define X509V3_F_X509V3_GET_VALUE_BOOL 110 | ||
| 599 | #define X509V3_F_X509V3_PARSE_LIST 109 | ||
| 600 | #define X509V3_F_X509_PURPOSE_ADD 137 | ||
| 601 | #define X509V3_F_X509_PURPOSE_SET 141 | ||
| 602 | |||
| 603 | /* Reason codes. */ | ||
| 604 | #define X509V3_R_BAD_IP_ADDRESS 118 | ||
| 605 | #define X509V3_R_BAD_OBJECT 119 | ||
| 606 | #define X509V3_R_BN_DEC2BN_ERROR 100 | ||
| 607 | #define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 | ||
| 608 | #define X509V3_R_DUPLICATE_ZONE_ID 133 | ||
| 609 | #define X509V3_R_ERROR_CONVERTING_ZONE 131 | ||
| 610 | #define X509V3_R_ERROR_CREATING_EXTENSION 144 | ||
| 611 | #define X509V3_R_ERROR_IN_EXTENSION 128 | ||
| 612 | #define X509V3_R_EXPECTED_A_SECTION_NAME 137 | ||
| 613 | #define X509V3_R_EXTENSION_EXISTS 145 | ||
| 614 | #define X509V3_R_EXTENSION_NAME_ERROR 115 | ||
| 615 | #define X509V3_R_EXTENSION_NOT_FOUND 102 | ||
| 616 | #define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 | ||
| 617 | #define X509V3_R_EXTENSION_VALUE_ERROR 116 | ||
| 618 | #define X509V3_R_ILLEGAL_HEX_DIGIT 113 | ||
| 619 | #define X509V3_R_INVALID_BOOLEAN_STRING 104 | ||
| 620 | #define X509V3_R_INVALID_EXTENSION_STRING 105 | ||
| 621 | #define X509V3_R_INVALID_NAME 106 | ||
| 622 | #define X509V3_R_INVALID_NULL_ARGUMENT 107 | ||
| 623 | #define X509V3_R_INVALID_NULL_NAME 108 | ||
| 624 | #define X509V3_R_INVALID_NULL_VALUE 109 | ||
| 625 | #define X509V3_R_INVALID_NUMBER 140 | ||
| 626 | #define X509V3_R_INVALID_NUMBERS 141 | ||
| 627 | #define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 | ||
| 628 | #define X509V3_R_INVALID_OPTION 138 | ||
| 629 | #define X509V3_R_INVALID_POLICY_IDENTIFIER 134 | ||
| 630 | #define X509V3_R_INVALID_PURPOSE 146 | ||
| 631 | #define X509V3_R_INVALID_SECTION 135 | ||
| 632 | #define X509V3_R_INVALID_SYNTAX 143 | ||
| 633 | #define X509V3_R_ISSUER_DECODE_ERROR 126 | ||
| 634 | #define X509V3_R_MISSING_VALUE 124 | ||
| 635 | #define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 | ||
| 636 | #define X509V3_R_NO_CONFIG_DATABASE 136 | ||
| 637 | #define X509V3_R_NO_ISSUER_CERTIFICATE 121 | ||
| 638 | #define X509V3_R_NO_ISSUER_DETAILS 127 | ||
| 639 | #define X509V3_R_NO_POLICY_IDENTIFIER 139 | ||
| 640 | #define X509V3_R_NO_PUBLIC_KEY 114 | ||
| 641 | #define X509V3_R_NO_SUBJECT_DETAILS 125 | ||
| 642 | #define X509V3_R_ODD_NUMBER_OF_DIGITS 112 | ||
| 643 | #define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 | ||
| 644 | #define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 | ||
| 645 | #define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 | ||
| 646 | #define X509V3_R_UNKNOWN_EXTENSION 129 | ||
| 647 | #define X509V3_R_UNKNOWN_EXTENSION_NAME 130 | ||
| 648 | #define X509V3_R_UNKNOWN_OPTION 120 | ||
| 649 | #define X509V3_R_UNSUPPORTED_OPTION 117 | ||
| 650 | #define X509V3_R_USER_TOO_LONG 132 | ||
| 651 | |||
| 652 | #ifdef __cplusplus | ||
| 653 | } | ||
| 654 | #endif | ||
| 655 | #endif | ||
