diff options
| author | djm <> | 2010-10-01 22:59:01 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:59:01 +0000 |
| commit | 8922d4bc4a8b8893d72a48deb2cdf58215f98505 (patch) | |
| tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/dsa | |
| parent | 76262f7bf9262f965142b1b2b2105cb279c5c696 (diff) | |
| download | openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.gz openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.bz2 openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.zip | |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/dsa')
| -rw-r--r-- | src/lib/libcrypto/dsa/Makefile | 133 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/Makefile.ssl | 171 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 69 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_asn1.c | 96 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_err.c | 26 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 124 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 49 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 48 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_sign.c | 35 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_utl.c | 95 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_vrf.c | 37 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsatest.c | 3 |
13 files changed, 298 insertions, 592 deletions
diff --git a/src/lib/libcrypto/dsa/Makefile b/src/lib/libcrypto/dsa/Makefile index 2cc45cdc62..8073c4ecfe 100644 --- a/src/lib/libcrypto/dsa/Makefile +++ b/src/lib/libcrypto/dsa/Makefile | |||
| @@ -18,14 +18,14 @@ APPS= | |||
| 18 | 18 | ||
| 19 | LIB=$(TOP)/libcrypto.a | 19 | LIB=$(TOP)/libcrypto.a |
| 20 | LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ | 20 | LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ |
| 21 | dsa_err.c dsa_ossl.c dsa_depr.c dsa_utl.c | 21 | dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c |
| 22 | LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ | 22 | LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ |
| 23 | dsa_err.o dsa_ossl.o dsa_depr.o dsa_utl.o | 23 | dsa_err.o dsa_ossl.o dsa_depr.o dsa_ameth.o dsa_pmeth.o dsa_prn.o |
| 24 | 24 | ||
| 25 | SRC= $(LIBSRC) | 25 | SRC= $(LIBSRC) |
| 26 | 26 | ||
| 27 | EXHEADER= dsa.h | 27 | EXHEADER= dsa.h |
| 28 | HEADER= $(EXHEADER) | 28 | HEADER= dsa_locl.h $(EXHEADER) |
| 29 | 29 | ||
| 30 | ALL= $(GENERAL) $(SRC) $(HEADER) | 30 | ALL= $(GENERAL) $(SRC) $(HEADER) |
| 31 | 31 | ||
| @@ -35,7 +35,7 @@ top: | |||
| 35 | all: lib | 35 | all: lib |
| 36 | 36 | ||
| 37 | lib: $(LIBOBJ) | 37 | lib: $(LIBOBJ) |
| 38 | $(ARX) $(LIB) $(LIBOBJ) | 38 | $(AR) $(LIB) $(LIBOBJ) |
| 39 | $(RANLIB) $(LIB) || echo Never mind. | 39 | $(RANLIB) $(LIB) || echo Never mind. |
| 40 | @touch lib | 40 | @touch lib |
| 41 | 41 | ||
| @@ -76,12 +76,27 @@ clean: | |||
| 76 | 76 | ||
| 77 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 77 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 78 | 78 | ||
| 79 | dsa_ameth.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 80 | dsa_ameth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 81 | dsa_ameth.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h | ||
| 82 | dsa_ameth.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h | ||
| 83 | dsa_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | ||
| 84 | dsa_ameth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | ||
| 85 | dsa_ameth.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 86 | dsa_ameth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 87 | dsa_ameth.o: ../../include/openssl/objects.h | ||
| 88 | dsa_ameth.o: ../../include/openssl/opensslconf.h | ||
| 89 | dsa_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 90 | dsa_ameth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | ||
| 91 | dsa_ameth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 92 | dsa_ameth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 93 | dsa_ameth.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h | ||
| 94 | dsa_ameth.o: dsa_ameth.c | ||
| 79 | dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h | 95 | dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h |
| 80 | dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | 96 | dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h |
| 81 | dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | 97 | dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 82 | dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h | 98 | dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 83 | dsa_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 99 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 84 | dsa_asn1.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 85 | dsa_asn1.o: ../../include/openssl/opensslconf.h | 100 | dsa_asn1.o: ../../include/openssl/opensslconf.h |
| 86 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 101 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 87 | dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 102 | dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| @@ -91,9 +106,8 @@ dsa_depr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | |||
| 91 | dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 106 | dsa_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 92 | dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 107 | dsa_depr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 93 | dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 108 | dsa_depr.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 94 | dsa_depr.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 109 | dsa_depr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 95 | dsa_depr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 110 | dsa_depr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 96 | dsa_depr.o: ../../include/openssl/opensslconf.h | ||
| 97 | dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 111 | dsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 98 | dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 112 | dsa_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 99 | dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 113 | dsa_depr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| @@ -110,13 +124,12 @@ dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | |||
| 110 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 124 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 111 | dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 125 | dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 112 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 126 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 113 | dsa_gen.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 127 | dsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 114 | dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 128 | dsa_gen.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 115 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 129 | dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 116 | dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 130 | dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 117 | dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 131 | dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 118 | dsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 132 | dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_gen.c dsa_locl.h |
| 119 | dsa_gen.o: ../cryptlib.h dsa_gen.c | ||
| 120 | dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h | 133 | dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 121 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 134 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 122 | dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 135 | dsa_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| @@ -132,14 +145,14 @@ dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | |||
| 132 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | 145 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h |
| 133 | dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | 146 | dsa_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h |
| 134 | dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 147 | dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h |
| 135 | dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/fips.h | 148 | dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 136 | dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 149 | dsa_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 137 | dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 150 | dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 138 | dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 151 | dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h |
| 139 | dsa_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | 152 | dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 140 | dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 153 | dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 141 | dsa_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | 154 | dsa_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
| 142 | dsa_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_lib.c | 155 | dsa_lib.o: ../cryptlib.h dsa_lib.c |
| 143 | dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h | 156 | dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h |
| 144 | dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 157 | dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
| 145 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 158 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| @@ -148,40 +161,48 @@ dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | |||
| 148 | dsa_ossl.o: ../../include/openssl/opensslconf.h | 161 | dsa_ossl.o: ../../include/openssl/opensslconf.h |
| 149 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 162 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 150 | dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 163 | dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 151 | dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 164 | dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 152 | dsa_ossl.o: ../cryptlib.h dsa_ossl.c | 165 | dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_ossl.c |
| 153 | dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h | 166 | dsa_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h |
| 154 | dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 167 | dsa_pmeth.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h |
| 168 | dsa_pmeth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 169 | dsa_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h | ||
| 170 | dsa_pmeth.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | ||
| 171 | dsa_pmeth.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | ||
| 172 | dsa_pmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 173 | dsa_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 174 | dsa_pmeth.o: ../../include/openssl/objects.h | ||
| 175 | dsa_pmeth.o: ../../include/openssl/opensslconf.h | ||
| 176 | dsa_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 177 | dsa_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | ||
| 178 | dsa_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 179 | dsa_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 180 | dsa_pmeth.o: ../../include/openssl/x509_vfy.h ../cryptlib.h ../evp/evp_locl.h | ||
| 181 | dsa_pmeth.o: dsa_locl.h dsa_pmeth.c | ||
| 182 | dsa_prn.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 183 | dsa_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 184 | dsa_prn.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h | ||
| 185 | dsa_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 186 | dsa_prn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 187 | dsa_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 188 | dsa_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 189 | dsa_prn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 190 | dsa_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 191 | dsa_prn.o: ../cryptlib.h dsa_prn.c | ||
| 192 | dsa_sign.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 155 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 193 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 156 | dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 194 | dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 157 | dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/fips.h | 195 | dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 158 | dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 196 | dsa_sign.o: ../../include/openssl/opensslconf.h |
| 159 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 197 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 160 | dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 198 | dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 161 | dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 199 | dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 162 | dsa_sign.o: ../cryptlib.h dsa_sign.c | 200 | dsa_sign.o: ../cryptlib.h dsa_sign.c |
| 163 | dsa_utl.o: ../../e_os.h ../../include/openssl/asn1.h | 201 | dsa_vrf.o: ../../e_os.h ../../include/openssl/bio.h |
| 164 | dsa_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 202 | dsa_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 165 | dsa_utl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 203 | dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 166 | dsa_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 204 | dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
| 167 | dsa_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | ||
| 168 | dsa_utl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | ||
| 169 | dsa_utl.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 170 | dsa_utl.o: ../../include/openssl/evp.h ../../include/openssl/fips.h | ||
| 171 | dsa_utl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 172 | dsa_utl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 173 | dsa_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 174 | dsa_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h | ||
| 175 | dsa_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 176 | dsa_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h | ||
| 177 | dsa_utl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h dsa_utl.c | ||
| 178 | dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 179 | dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h | ||
| 180 | dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 181 | dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dsa.h | ||
| 182 | dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 183 | dsa_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
| 184 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 205 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 185 | dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 206 | dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h |
| 186 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 207 | dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 187 | dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c | 208 | dsa_vrf.o: ../cryptlib.h dsa_vrf.c |
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl deleted file mode 100644 index e5f8a8cf51..0000000000 --- a/src/lib/libcrypto/dsa/Makefile.ssl +++ /dev/null | |||
| @@ -1,171 +0,0 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/dsa/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= dsa | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST=dsatest.c | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ | ||
| 27 | dsa_err.c dsa_ossl.c | ||
| 28 | LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ | ||
| 29 | dsa_err.o dsa_ossl.o | ||
| 30 | |||
| 31 | SRC= $(LIBSRC) | ||
| 32 | |||
| 33 | EXHEADER= dsa.h | ||
| 34 | HEADER= $(EXHEADER) | ||
| 35 | |||
| 36 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 37 | |||
| 38 | top: | ||
| 39 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 40 | |||
| 41 | all: lib | ||
| 42 | |||
| 43 | lib: $(LIBOBJ) | ||
| 44 | $(AR) $(LIB) $(LIBOBJ) | ||
| 45 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 46 | @touch lib | ||
| 47 | |||
| 48 | files: | ||
| 49 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 50 | |||
| 51 | links: | ||
| 52 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 53 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 54 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 55 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 56 | |||
| 57 | install: | ||
| 58 | @for i in $(EXHEADER) ; \ | ||
| 59 | do \ | ||
| 60 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 61 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 62 | done; | ||
| 63 | |||
| 64 | tags: | ||
| 65 | ctags $(SRC) | ||
| 66 | |||
| 67 | tests: | ||
| 68 | |||
| 69 | lint: | ||
| 70 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 71 | |||
| 72 | depend: | ||
| 73 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 74 | |||
| 75 | dclean: | ||
| 76 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 77 | mv -f Makefile.new $(MAKEFILE) | ||
| 78 | |||
| 79 | clean: | ||
| 80 | rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 81 | |||
| 82 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 83 | |||
| 84 | dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 85 | dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
| 86 | dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 87 | dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 88 | dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 89 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 90 | dsa_asn1.o: ../../include/openssl/opensslconf.h | ||
| 91 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 92 | dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 93 | dsa_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_asn1.c | ||
| 94 | dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 95 | dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 96 | dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 97 | dsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 98 | dsa_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 99 | dsa_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 100 | dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 101 | dsa_err.o: dsa_err.c | ||
| 102 | dsa_gen.o: ../../e_os.h ../../include/openssl/aes.h | ||
| 103 | dsa_gen.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 104 | dsa_gen.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 105 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 106 | dsa_gen.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 107 | dsa_gen.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
| 108 | dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 109 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 110 | dsa_gen.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
| 111 | dsa_gen.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
| 112 | dsa_gen.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 113 | dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 114 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 115 | dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 116 | dsa_gen.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 117 | dsa_gen.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 118 | dsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 119 | dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 120 | dsa_gen.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 121 | dsa_gen.o: ../../include/openssl/ui_compat.h ../cryptlib.h dsa_gen.c | ||
| 122 | dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 123 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 124 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 125 | dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 126 | dsa_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 127 | dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 128 | dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
| 129 | dsa_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 130 | dsa_key.o: ../cryptlib.h dsa_key.c | ||
| 131 | dsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 132 | dsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 133 | dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 134 | dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 135 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 136 | dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 137 | dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 138 | dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 139 | dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 140 | dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 141 | dsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h dsa_lib.c | ||
| 142 | dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 143 | dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 144 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 145 | dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 146 | dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 147 | dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 148 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 149 | dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
| 150 | dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 151 | dsa_ossl.o: ../cryptlib.h dsa_ossl.c | ||
| 152 | dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 153 | dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 154 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 155 | dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 156 | dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 157 | dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 158 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 159 | dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
| 160 | dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 161 | dsa_sign.o: ../cryptlib.h dsa_sign.c | ||
| 162 | dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 163 | dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h | ||
| 164 | dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
| 165 | dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 166 | dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 167 | dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 168 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 169 | dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 170 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 171 | dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c | ||
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index 702c50d6dc..ac50a5c846 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
| @@ -88,8 +88,6 @@ | |||
| 88 | # define OPENSSL_DSA_MAX_MODULUS_BITS 10000 | 88 | # define OPENSSL_DSA_MAX_MODULUS_BITS 10000 |
| 89 | #endif | 89 | #endif |
| 90 | 90 | ||
| 91 | #define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 | ||
| 92 | |||
| 93 | #define DSA_FLAG_CACHE_MONT_P 0x01 | 91 | #define DSA_FLAG_CACHE_MONT_P 0x01 |
| 94 | #define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA | 92 | #define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA |
| 95 | * implementation now uses constant time | 93 | * implementation now uses constant time |
| @@ -99,25 +97,6 @@ | |||
| 99 | * be used for all exponents. | 97 | * be used for all exponents. |
| 100 | */ | 98 | */ |
| 101 | 99 | ||
| 102 | /* If this flag is set the DSA method is FIPS compliant and can be used | ||
| 103 | * in FIPS mode. This is set in the validated module method. If an | ||
| 104 | * application sets this flag in its own methods it is its reposibility | ||
| 105 | * to ensure the result is compliant. | ||
| 106 | */ | ||
| 107 | |||
| 108 | #define DSA_FLAG_FIPS_METHOD 0x0400 | ||
| 109 | |||
| 110 | /* If this flag is set the operations normally disabled in FIPS mode are | ||
| 111 | * permitted it is then the applications responsibility to ensure that the | ||
| 112 | * usage is compliant. | ||
| 113 | */ | ||
| 114 | |||
| 115 | #define DSA_FLAG_NON_FIPS_ALLOW 0x0400 | ||
| 116 | |||
| 117 | #ifdef OPENSSL_FIPS | ||
| 118 | #define FIPS_DSA_SIZE_T int | ||
| 119 | #endif | ||
| 120 | |||
| 121 | #ifdef __cplusplus | 100 | #ifdef __cplusplus |
| 122 | extern "C" { | 101 | extern "C" { |
| 123 | #endif | 102 | #endif |
| @@ -139,7 +118,7 @@ struct dsa_method | |||
| 139 | int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, | 118 | int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, |
| 140 | BIGNUM **rp); | 119 | BIGNUM **rp); |
| 141 | int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, | 120 | int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, |
| 142 | DSA_SIG *sig, DSA *dsa); | 121 | DSA_SIG *sig, DSA *dsa); |
| 143 | int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, | 122 | int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, |
| 144 | BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, | 123 | BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, |
| 145 | BN_MONT_CTX *in_mont); | 124 | BN_MONT_CTX *in_mont); |
| @@ -152,7 +131,7 @@ struct dsa_method | |||
| 152 | char *app_data; | 131 | char *app_data; |
| 153 | /* If this is non-NULL, it is used to generate DSA parameters */ | 132 | /* If this is non-NULL, it is used to generate DSA parameters */ |
| 154 | int (*dsa_paramgen)(DSA *dsa, int bits, | 133 | int (*dsa_paramgen)(DSA *dsa, int bits, |
| 155 | unsigned char *seed, int seed_len, | 134 | const unsigned char *seed, int seed_len, |
| 156 | int *counter_ret, unsigned long *h_ret, | 135 | int *counter_ret, unsigned long *h_ret, |
| 157 | BN_GENCB *cb); | 136 | BN_GENCB *cb); |
| 158 | /* If this is non-NULL, it is used to generate DSA keys */ | 137 | /* If this is non-NULL, it is used to generate DSA keys */ |
| @@ -186,7 +165,6 @@ struct dsa_st | |||
| 186 | ENGINE *engine; | 165 | ENGINE *engine; |
| 187 | }; | 166 | }; |
| 188 | 167 | ||
| 189 | #define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) | ||
| 190 | #define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ | 168 | #define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ |
| 191 | (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) | 169 | (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) |
| 192 | #define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ | 170 | #define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ |
| @@ -195,6 +173,7 @@ struct dsa_st | |||
| 195 | #define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) | 173 | #define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) |
| 196 | 174 | ||
| 197 | 175 | ||
| 176 | DSA *DSAparams_dup(DSA *x); | ||
| 198 | DSA_SIG * DSA_SIG_new(void); | 177 | DSA_SIG * DSA_SIG_new(void); |
| 199 | void DSA_SIG_free(DSA_SIG *a); | 178 | void DSA_SIG_free(DSA_SIG *a); |
| 200 | int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); | 179 | int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); |
| @@ -210,11 +189,6 @@ void DSA_set_default_method(const DSA_METHOD *); | |||
| 210 | const DSA_METHOD *DSA_get_default_method(void); | 189 | const DSA_METHOD *DSA_get_default_method(void); |
| 211 | int DSA_set_method(DSA *dsa, const DSA_METHOD *); | 190 | int DSA_set_method(DSA *dsa, const DSA_METHOD *); |
| 212 | 191 | ||
| 213 | #ifdef OPENSSL_FIPS | ||
| 214 | DSA * FIPS_dsa_new(void); | ||
| 215 | void FIPS_dsa_free (DSA *r); | ||
| 216 | #endif | ||
| 217 | |||
| 218 | DSA * DSA_new(void); | 192 | DSA * DSA_new(void); |
| 219 | DSA * DSA_new_method(ENGINE *engine); | 193 | DSA * DSA_new_method(ENGINE *engine); |
| 220 | void DSA_free (DSA *r); | 194 | void DSA_free (DSA *r); |
| @@ -246,7 +220,7 @@ DSA * DSA_generate_parameters(int bits, | |||
| 246 | 220 | ||
| 247 | /* New version */ | 221 | /* New version */ |
| 248 | int DSA_generate_parameters_ex(DSA *dsa, int bits, | 222 | int DSA_generate_parameters_ex(DSA *dsa, int bits, |
| 249 | unsigned char *seed,int seed_len, | 223 | const unsigned char *seed,int seed_len, |
| 250 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); | 224 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); |
| 251 | 225 | ||
| 252 | int DSA_generate_key(DSA *a); | 226 | int DSA_generate_key(DSA *a); |
| @@ -275,10 +249,13 @@ int DSA_print_fp(FILE *bp, const DSA *x, int off); | |||
| 275 | DH *DSA_dup_DH(const DSA *r); | 249 | DH *DSA_dup_DH(const DSA *r); |
| 276 | #endif | 250 | #endif |
| 277 | 251 | ||
| 278 | #ifdef OPENSSL_FIPS | 252 | #define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ |
| 279 | int FIPS_dsa_sig_encode(unsigned char *out, DSA_SIG *sig); | 253 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ |
| 280 | int FIPS_dsa_sig_decode(DSA_SIG *sig, const unsigned char *in, int inlen); | 254 | EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) |
| 281 | #endif | 255 | |
| 256 | #define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1) | ||
| 257 | #define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2) | ||
| 258 | #define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3) | ||
| 282 | 259 | ||
| 283 | /* BEGIN ERROR CODES */ | 260 | /* BEGIN ERROR CODES */ |
| 284 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 261 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| @@ -290,33 +267,39 @@ void ERR_load_DSA_strings(void); | |||
| 290 | 267 | ||
| 291 | /* Function codes. */ | 268 | /* Function codes. */ |
| 292 | #define DSA_F_D2I_DSA_SIG 110 | 269 | #define DSA_F_D2I_DSA_SIG 110 |
| 270 | #define DSA_F_DO_DSA_PRINT 104 | ||
| 293 | #define DSA_F_DSAPARAMS_PRINT 100 | 271 | #define DSA_F_DSAPARAMS_PRINT 100 |
| 294 | #define DSA_F_DSAPARAMS_PRINT_FP 101 | 272 | #define DSA_F_DSAPARAMS_PRINT_FP 101 |
| 295 | #define DSA_F_DSA_BUILTIN_KEYGEN 119 | ||
| 296 | #define DSA_F_DSA_BUILTIN_PARAMGEN 118 | ||
| 297 | #define DSA_F_DSA_DO_SIGN 112 | 273 | #define DSA_F_DSA_DO_SIGN 112 |
| 298 | #define DSA_F_DSA_DO_VERIFY 113 | 274 | #define DSA_F_DSA_DO_VERIFY 113 |
| 299 | #define DSA_F_DSA_GENERATE_PARAMETERS 117 | ||
| 300 | #define DSA_F_DSA_NEW_METHOD 103 | 275 | #define DSA_F_DSA_NEW_METHOD 103 |
| 301 | #define DSA_F_DSA_PRINT 104 | 276 | #define DSA_F_DSA_PARAM_DECODE 119 |
| 302 | #define DSA_F_DSA_PRINT_FP 105 | 277 | #define DSA_F_DSA_PRINT_FP 105 |
| 303 | #define DSA_F_DSA_SET_DEFAULT_METHOD 115 | 278 | #define DSA_F_DSA_PRIV_DECODE 115 |
| 304 | #define DSA_F_DSA_SET_METHOD 116 | 279 | #define DSA_F_DSA_PRIV_ENCODE 116 |
| 280 | #define DSA_F_DSA_PUB_DECODE 117 | ||
| 281 | #define DSA_F_DSA_PUB_ENCODE 118 | ||
| 305 | #define DSA_F_DSA_SIGN 106 | 282 | #define DSA_F_DSA_SIGN 106 |
| 306 | #define DSA_F_DSA_SIGN_SETUP 107 | 283 | #define DSA_F_DSA_SIGN_SETUP 107 |
| 307 | #define DSA_F_DSA_SIG_NEW 109 | 284 | #define DSA_F_DSA_SIG_NEW 109 |
| 308 | #define DSA_F_DSA_VERIFY 108 | 285 | #define DSA_F_DSA_VERIFY 108 |
| 309 | #define DSA_F_I2D_DSA_SIG 111 | 286 | #define DSA_F_I2D_DSA_SIG 111 |
| 287 | #define DSA_F_OLD_DSA_PRIV_DECODE 122 | ||
| 288 | #define DSA_F_PKEY_DSA_CTRL 120 | ||
| 289 | #define DSA_F_PKEY_DSA_KEYGEN 121 | ||
| 310 | #define DSA_F_SIG_CB 114 | 290 | #define DSA_F_SIG_CB 114 |
| 311 | 291 | ||
| 312 | /* Reason codes. */ | 292 | /* Reason codes. */ |
| 313 | #define DSA_R_BAD_Q_VALUE 102 | 293 | #define DSA_R_BAD_Q_VALUE 102 |
| 294 | #define DSA_R_BN_DECODE_ERROR 108 | ||
| 295 | #define DSA_R_BN_ERROR 109 | ||
| 314 | #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 | 296 | #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 |
| 315 | #define DSA_R_KEY_SIZE_TOO_SMALL 106 | 297 | #define DSA_R_DECODE_ERROR 104 |
| 298 | #define DSA_R_INVALID_DIGEST_TYPE 106 | ||
| 316 | #define DSA_R_MISSING_PARAMETERS 101 | 299 | #define DSA_R_MISSING_PARAMETERS 101 |
| 317 | #define DSA_R_MODULUS_TOO_LARGE 103 | 300 | #define DSA_R_MODULUS_TOO_LARGE 103 |
| 318 | #define DSA_R_NON_FIPS_METHOD 104 | 301 | #define DSA_R_NO_PARAMETERS_SET 107 |
| 319 | #define DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE 105 | 302 | #define DSA_R_PARAMETER_ENCODING_ERROR 105 |
| 320 | 303 | ||
| 321 | #ifdef __cplusplus | 304 | #ifdef __cplusplus |
| 322 | } | 305 | } |
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c index 0645facb4b..c37460b2d6 100644 --- a/src/lib/libcrypto/dsa/dsa_asn1.c +++ b/src/lib/libcrypto/dsa/dsa_asn1.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. |
| 7 | * | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
| @@ -61,24 +61,23 @@ | |||
| 61 | #include <openssl/dsa.h> | 61 | #include <openssl/dsa.h> |
| 62 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
| 63 | #include <openssl/asn1t.h> | 63 | #include <openssl/asn1t.h> |
| 64 | #include <openssl/bn.h> | ||
| 65 | #ifdef OPENSSL_FIPS | ||
| 66 | #include <openssl/fips.h> | ||
| 67 | #endif | ||
| 68 | |||
| 69 | 64 | ||
| 70 | /* Override the default new methods */ | 65 | /* Override the default new methods */ |
| 71 | static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 66 | static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 67 | void *exarg) | ||
| 72 | { | 68 | { |
| 73 | if(operation == ASN1_OP_NEW_PRE) { | 69 | if(operation == ASN1_OP_NEW_PRE) { |
| 74 | DSA_SIG *sig; | 70 | DSA_SIG *sig; |
| 75 | sig = OPENSSL_malloc(sizeof(DSA_SIG)); | 71 | sig = OPENSSL_malloc(sizeof(DSA_SIG)); |
| 72 | if (!sig) | ||
| 73 | { | ||
| 74 | DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); | ||
| 75 | return 0; | ||
| 76 | } | ||
| 76 | sig->r = NULL; | 77 | sig->r = NULL; |
| 77 | sig->s = NULL; | 78 | sig->s = NULL; |
| 78 | *pval = (ASN1_VALUE *)sig; | 79 | *pval = (ASN1_VALUE *)sig; |
| 79 | if(sig) return 2; | 80 | return 2; |
| 80 | DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); | ||
| 81 | return 0; | ||
| 82 | } | 81 | } |
| 83 | return 1; | 82 | return 1; |
| 84 | } | 83 | } |
| @@ -88,10 +87,11 @@ ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = { | |||
| 88 | ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) | 87 | ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) |
| 89 | } ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) | 88 | } ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) |
| 90 | 89 | ||
| 91 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG,DSA_SIG,DSA_SIG) | 90 | IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG) |
| 92 | 91 | ||
| 93 | /* Override the default free and new methods */ | 92 | /* Override the default free and new methods */ |
| 94 | static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 93 | static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 94 | void *exarg) | ||
| 95 | { | 95 | { |
| 96 | if(operation == ASN1_OP_NEW_PRE) { | 96 | if(operation == ASN1_OP_NEW_PRE) { |
| 97 | *pval = (ASN1_VALUE *)DSA_new(); | 97 | *pval = (ASN1_VALUE *)DSA_new(); |
| @@ -144,75 +144,7 @@ ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = { | |||
| 144 | 144 | ||
| 145 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) | 145 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) |
| 146 | 146 | ||
| 147 | int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | 147 | DSA *DSAparams_dup(DSA *dsa) |
| 148 | unsigned int *siglen, DSA *dsa) | ||
| 149 | { | ||
| 150 | DSA_SIG *s; | ||
| 151 | #ifdef OPENSSL_FIPS | ||
| 152 | if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | ||
| 153 | { | ||
| 154 | DSAerr(DSA_F_DSA_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | #endif | ||
| 158 | s=DSA_do_sign(dgst,dlen,dsa); | ||
| 159 | if (s == NULL) | ||
| 160 | { | ||
| 161 | *siglen=0; | ||
| 162 | return(0); | ||
| 163 | } | ||
| 164 | *siglen=i2d_DSA_SIG(s,&sig); | ||
| 165 | DSA_SIG_free(s); | ||
| 166 | return(1); | ||
| 167 | } | ||
| 168 | |||
| 169 | int DSA_size(const DSA *r) | ||
| 170 | { | ||
| 171 | int ret,i; | ||
| 172 | ASN1_INTEGER bs; | ||
| 173 | unsigned char buf[4]; /* 4 bytes looks really small. | ||
| 174 | However, i2d_ASN1_INTEGER() will not look | ||
| 175 | beyond the first byte, as long as the second | ||
| 176 | parameter is NULL. */ | ||
| 177 | |||
| 178 | i=BN_num_bits(r->q); | ||
| 179 | bs.length=(i+7)/8; | ||
| 180 | bs.data=buf; | ||
| 181 | bs.type=V_ASN1_INTEGER; | ||
| 182 | /* If the top bit is set the asn1 encoding is 1 larger. */ | ||
| 183 | buf[0]=0xff; | ||
| 184 | |||
| 185 | i=i2d_ASN1_INTEGER(&bs,NULL); | ||
| 186 | i+=i; /* r and s */ | ||
| 187 | ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | ||
| 188 | return(ret); | ||
| 189 | } | ||
| 190 | |||
| 191 | /* data has already been hashed (probably with SHA or SHA-1). */ | ||
| 192 | /* returns | ||
| 193 | * 1: correct signature | ||
| 194 | * 0: incorrect signature | ||
| 195 | * -1: error | ||
| 196 | */ | ||
| 197 | int DSA_verify(int type, const unsigned char *dgst, int dgst_len, | ||
| 198 | const unsigned char *sigbuf, int siglen, DSA *dsa) | ||
| 199 | { | 148 | { |
| 200 | DSA_SIG *s; | 149 | return ASN1_item_dup(ASN1_ITEM_rptr(DSAparams), dsa); |
| 201 | int ret=-1; | ||
| 202 | #ifdef OPENSSL_FIPS | ||
| 203 | if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | ||
| 204 | { | ||
| 205 | DSAerr(DSA_F_DSA_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
| 206 | return 0; | ||
| 207 | } | ||
| 208 | #endif | ||
| 209 | |||
| 210 | s = DSA_SIG_new(); | ||
| 211 | if (s == NULL) return(ret); | ||
| 212 | if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err; | ||
| 213 | ret=DSA_do_verify(dgst,dgst_len,s,dsa); | ||
| 214 | err: | ||
| 215 | DSA_SIG_free(s); | ||
| 216 | return(ret); | ||
| 217 | } | 150 | } |
| 218 | |||
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c index 872839af94..bba984e92e 100644 --- a/src/lib/libcrypto/dsa/dsa_err.c +++ b/src/lib/libcrypto/dsa/dsa_err.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* crypto/dsa/dsa_err.c */ | 1 | /* crypto/dsa/dsa_err.c */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
| @@ -71,23 +71,26 @@ | |||
| 71 | static ERR_STRING_DATA DSA_str_functs[]= | 71 | static ERR_STRING_DATA DSA_str_functs[]= |
| 72 | { | 72 | { |
| 73 | {ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, | 73 | {ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, |
| 74 | {ERR_FUNC(DSA_F_DO_DSA_PRINT), "DO_DSA_PRINT"}, | ||
| 74 | {ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"}, | 75 | {ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"}, |
| 75 | {ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"}, | 76 | {ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"}, |
| 76 | {ERR_FUNC(DSA_F_DSA_BUILTIN_KEYGEN), "DSA_BUILTIN_KEYGEN"}, | ||
| 77 | {ERR_FUNC(DSA_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"}, | ||
| 78 | {ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, | 77 | {ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, |
| 79 | {ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, | 78 | {ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, |
| 80 | {ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS), "DSA_generate_parameters"}, | ||
| 81 | {ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, | 79 | {ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, |
| 82 | {ERR_FUNC(DSA_F_DSA_PRINT), "DSA_print"}, | 80 | {ERR_FUNC(DSA_F_DSA_PARAM_DECODE), "DSA_PARAM_DECODE"}, |
| 83 | {ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, | 81 | {ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, |
| 84 | {ERR_FUNC(DSA_F_DSA_SET_DEFAULT_METHOD), "DSA_set_default_method"}, | 82 | {ERR_FUNC(DSA_F_DSA_PRIV_DECODE), "DSA_PRIV_DECODE"}, |
| 85 | {ERR_FUNC(DSA_F_DSA_SET_METHOD), "DSA_set_method"}, | 83 | {ERR_FUNC(DSA_F_DSA_PRIV_ENCODE), "DSA_PRIV_ENCODE"}, |
| 84 | {ERR_FUNC(DSA_F_DSA_PUB_DECODE), "DSA_PUB_DECODE"}, | ||
| 85 | {ERR_FUNC(DSA_F_DSA_PUB_ENCODE), "DSA_PUB_ENCODE"}, | ||
| 86 | {ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"}, | 86 | {ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"}, |
| 87 | {ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"}, | 87 | {ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"}, |
| 88 | {ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"}, | 88 | {ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"}, |
| 89 | {ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"}, | 89 | {ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"}, |
| 90 | {ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"}, | 90 | {ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"}, |
| 91 | {ERR_FUNC(DSA_F_OLD_DSA_PRIV_DECODE), "OLD_DSA_PRIV_DECODE"}, | ||
| 92 | {ERR_FUNC(DSA_F_PKEY_DSA_CTRL), "PKEY_DSA_CTRL"}, | ||
| 93 | {ERR_FUNC(DSA_F_PKEY_DSA_KEYGEN), "PKEY_DSA_KEYGEN"}, | ||
| 91 | {ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"}, | 94 | {ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"}, |
| 92 | {0,NULL} | 95 | {0,NULL} |
| 93 | }; | 96 | }; |
| @@ -95,12 +98,15 @@ static ERR_STRING_DATA DSA_str_functs[]= | |||
| 95 | static ERR_STRING_DATA DSA_str_reasons[]= | 98 | static ERR_STRING_DATA DSA_str_reasons[]= |
| 96 | { | 99 | { |
| 97 | {ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, | 100 | {ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, |
| 101 | {ERR_REASON(DSA_R_BN_DECODE_ERROR) ,"bn decode error"}, | ||
| 102 | {ERR_REASON(DSA_R_BN_ERROR) ,"bn error"}, | ||
| 98 | {ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, | 103 | {ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, |
| 99 | {ERR_REASON(DSA_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, | 104 | {ERR_REASON(DSA_R_DECODE_ERROR) ,"decode error"}, |
| 105 | {ERR_REASON(DSA_R_INVALID_DIGEST_TYPE) ,"invalid digest type"}, | ||
| 100 | {ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, | 106 | {ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, |
| 101 | {ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, | 107 | {ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, |
| 102 | {ERR_REASON(DSA_R_NON_FIPS_METHOD) ,"non fips method"}, | 108 | {ERR_REASON(DSA_R_NO_PARAMETERS_SET) ,"no parameters set"}, |
| 103 | {ERR_REASON(DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE),"operation not allowed in fips mode"}, | 109 | {ERR_REASON(DSA_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"}, |
| 104 | {0,NULL} | 110 | {0,NULL} |
| 105 | }; | 111 | }; |
| 106 | 112 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index 6f1728e3cf..0fcd25f8b0 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
| @@ -74,69 +74,88 @@ | |||
| 74 | #ifndef OPENSSL_NO_SHA | 74 | #ifndef OPENSSL_NO_SHA |
| 75 | 75 | ||
| 76 | #include <stdio.h> | 76 | #include <stdio.h> |
| 77 | #include <time.h> | ||
| 78 | #include "cryptlib.h" | 77 | #include "cryptlib.h" |
| 79 | #include <openssl/evp.h> | 78 | #include <openssl/evp.h> |
| 80 | #include <openssl/bn.h> | 79 | #include <openssl/bn.h> |
| 81 | #include <openssl/dsa.h> | ||
| 82 | #include <openssl/rand.h> | 80 | #include <openssl/rand.h> |
| 83 | #include <openssl/sha.h> | 81 | #include <openssl/sha.h> |
| 84 | 82 | #include "dsa_locl.h" | |
| 85 | #ifndef OPENSSL_FIPS | ||
| 86 | |||
| 87 | static int dsa_builtin_paramgen(DSA *ret, int bits, | ||
| 88 | unsigned char *seed_in, int seed_len, | ||
| 89 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); | ||
| 90 | 83 | ||
| 91 | int DSA_generate_parameters_ex(DSA *ret, int bits, | 84 | int DSA_generate_parameters_ex(DSA *ret, int bits, |
| 92 | unsigned char *seed_in, int seed_len, | 85 | const unsigned char *seed_in, int seed_len, |
| 93 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) | 86 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) |
| 94 | { | 87 | { |
| 95 | if(ret->meth->dsa_paramgen) | 88 | if(ret->meth->dsa_paramgen) |
| 96 | return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len, | 89 | return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len, |
| 97 | counter_ret, h_ret, cb); | 90 | counter_ret, h_ret, cb); |
| 98 | return dsa_builtin_paramgen(ret, bits, seed_in, seed_len, | 91 | else |
| 99 | counter_ret, h_ret, cb); | 92 | { |
| 93 | const EVP_MD *evpmd; | ||
| 94 | size_t qbits = bits >= 2048 ? 256 : 160; | ||
| 95 | |||
| 96 | if (bits >= 2048) | ||
| 97 | { | ||
| 98 | qbits = 256; | ||
| 99 | evpmd = EVP_sha256(); | ||
| 100 | } | ||
| 101 | else | ||
| 102 | { | ||
| 103 | qbits = 160; | ||
| 104 | evpmd = EVP_sha1(); | ||
| 105 | } | ||
| 106 | |||
| 107 | return dsa_builtin_paramgen(ret, bits, qbits, evpmd, | ||
| 108 | seed_in, seed_len, counter_ret, h_ret, cb); | ||
| 109 | } | ||
| 100 | } | 110 | } |
| 101 | 111 | ||
| 102 | static int dsa_builtin_paramgen(DSA *ret, int bits, | 112 | int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, |
| 103 | unsigned char *seed_in, int seed_len, | 113 | const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, |
| 104 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) | 114 | int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) |
| 105 | { | 115 | { |
| 106 | int ok=0; | 116 | int ok=0; |
| 107 | unsigned char seed[SHA_DIGEST_LENGTH]; | 117 | unsigned char seed[SHA256_DIGEST_LENGTH]; |
| 108 | unsigned char md[SHA_DIGEST_LENGTH]; | 118 | unsigned char md[SHA256_DIGEST_LENGTH]; |
| 109 | unsigned char buf[SHA_DIGEST_LENGTH],buf2[SHA_DIGEST_LENGTH]; | 119 | unsigned char buf[SHA256_DIGEST_LENGTH],buf2[SHA256_DIGEST_LENGTH]; |
| 110 | BIGNUM *r0,*W,*X,*c,*test; | 120 | BIGNUM *r0,*W,*X,*c,*test; |
| 111 | BIGNUM *g=NULL,*q=NULL,*p=NULL; | 121 | BIGNUM *g=NULL,*q=NULL,*p=NULL; |
| 112 | BN_MONT_CTX *mont=NULL; | 122 | BN_MONT_CTX *mont=NULL; |
| 113 | int k,n=0,i,b,m=0; | 123 | int i, k,n=0,b,m=0, qsize = qbits >> 3; |
| 114 | int counter=0; | 124 | int counter=0; |
| 115 | int r=0; | 125 | int r=0; |
| 116 | BN_CTX *ctx=NULL; | 126 | BN_CTX *ctx=NULL; |
| 117 | unsigned int h=2; | 127 | unsigned int h=2; |
| 118 | 128 | ||
| 119 | if (bits < 512) bits=512; | 129 | if (qsize != SHA_DIGEST_LENGTH && qsize != SHA224_DIGEST_LENGTH && |
| 120 | bits=(bits+63)/64*64; | 130 | qsize != SHA256_DIGEST_LENGTH) |
| 131 | /* invalid q size */ | ||
| 132 | return 0; | ||
| 133 | |||
| 134 | if (evpmd == NULL) | ||
| 135 | /* use SHA1 as default */ | ||
| 136 | evpmd = EVP_sha1(); | ||
| 137 | |||
| 138 | if (bits < 512) | ||
| 139 | bits = 512; | ||
| 140 | |||
| 141 | bits = (bits+63)/64*64; | ||
| 121 | 142 | ||
| 122 | /* NB: seed_len == 0 is special case: copy generated seed to | 143 | /* NB: seed_len == 0 is special case: copy generated seed to |
| 123 | * seed_in if it is not NULL. | 144 | * seed_in if it is not NULL. |
| 124 | */ | 145 | */ |
| 125 | if (seed_len && (seed_len < 20)) | 146 | if (seed_len && (seed_len < (size_t)qsize)) |
| 126 | seed_in = NULL; /* seed buffer too small -- ignore */ | 147 | seed_in = NULL; /* seed buffer too small -- ignore */ |
| 127 | if (seed_len > 20) | 148 | if (seed_len > (size_t)qsize) |
| 128 | seed_len = 20; /* App. 2.2 of FIPS PUB 186 allows larger SEED, | 149 | seed_len = qsize; /* App. 2.2 of FIPS PUB 186 allows larger SEED, |
| 129 | * but our internal buffers are restricted to 160 bits*/ | 150 | * but our internal buffers are restricted to 160 bits*/ |
| 130 | if ((seed_in != NULL) && (seed_len == 20)) | 151 | if (seed_in != NULL) |
| 131 | { | 152 | memcpy(seed, seed_in, seed_len); |
| 132 | memcpy(seed,seed_in,seed_len); | 153 | |
| 133 | /* set seed_in to NULL to avoid it being copied back */ | 154 | if ((ctx=BN_CTX_new()) == NULL) |
| 134 | seed_in = NULL; | 155 | goto err; |
| 135 | } | ||
| 136 | |||
| 137 | if ((ctx=BN_CTX_new()) == NULL) goto err; | ||
| 138 | 156 | ||
| 139 | if ((mont=BN_MONT_CTX_new()) == NULL) goto err; | 157 | if ((mont=BN_MONT_CTX_new()) == NULL) |
| 158 | goto err; | ||
| 140 | 159 | ||
| 141 | BN_CTX_start(ctx); | 160 | BN_CTX_start(ctx); |
| 142 | r0 = BN_CTX_get(ctx); | 161 | r0 = BN_CTX_get(ctx); |
| @@ -163,7 +182,7 @@ static int dsa_builtin_paramgen(DSA *ret, int bits, | |||
| 163 | 182 | ||
| 164 | if (!seed_len) | 183 | if (!seed_len) |
| 165 | { | 184 | { |
| 166 | RAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH); | 185 | RAND_pseudo_bytes(seed, qsize); |
| 167 | seed_is_random = 1; | 186 | seed_is_random = 1; |
| 168 | } | 187 | } |
| 169 | else | 188 | else |
| @@ -171,25 +190,27 @@ static int dsa_builtin_paramgen(DSA *ret, int bits, | |||
| 171 | seed_is_random = 0; | 190 | seed_is_random = 0; |
| 172 | seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/ | 191 | seed_len=0; /* use random seed if 'seed_in' turns out to be bad*/ |
| 173 | } | 192 | } |
| 174 | memcpy(buf,seed,SHA_DIGEST_LENGTH); | 193 | memcpy(buf , seed, qsize); |
| 175 | memcpy(buf2,seed,SHA_DIGEST_LENGTH); | 194 | memcpy(buf2, seed, qsize); |
| 176 | /* precompute "SEED + 1" for step 7: */ | 195 | /* precompute "SEED + 1" for step 7: */ |
| 177 | for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) | 196 | for (i = qsize-1; i >= 0; i--) |
| 178 | { | 197 | { |
| 179 | buf[i]++; | 198 | buf[i]++; |
| 180 | if (buf[i] != 0) break; | 199 | if (buf[i] != 0) |
| 200 | break; | ||
| 181 | } | 201 | } |
| 182 | 202 | ||
| 183 | /* step 2 */ | 203 | /* step 2 */ |
| 184 | EVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); | 204 | EVP_Digest(seed, qsize, md, NULL, evpmd, NULL); |
| 185 | EVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL); | 205 | EVP_Digest(buf, qsize, buf2, NULL, evpmd, NULL); |
| 186 | for (i=0; i<SHA_DIGEST_LENGTH; i++) | 206 | for (i = 0; i < qsize; i++) |
| 187 | md[i]^=buf2[i]; | 207 | md[i]^=buf2[i]; |
| 188 | 208 | ||
| 189 | /* step 3 */ | 209 | /* step 3 */ |
| 190 | md[0]|=0x80; | 210 | md[0] |= 0x80; |
| 191 | md[SHA_DIGEST_LENGTH-1]|=0x01; | 211 | md[qsize-1] |= 0x01; |
| 192 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) goto err; | 212 | if (!BN_bin2bn(md, qsize, q)) |
| 213 | goto err; | ||
| 193 | 214 | ||
| 194 | /* step 4 */ | 215 | /* step 4 */ |
| 195 | r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx, | 216 | r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx, |
| @@ -224,18 +245,19 @@ static int dsa_builtin_paramgen(DSA *ret, int bits, | |||
| 224 | for (k=0; k<=n; k++) | 245 | for (k=0; k<=n; k++) |
| 225 | { | 246 | { |
| 226 | /* obtain "SEED + offset + k" by incrementing: */ | 247 | /* obtain "SEED + offset + k" by incrementing: */ |
| 227 | for (i=SHA_DIGEST_LENGTH-1; i >= 0; i--) | 248 | for (i = qsize-1; i >= 0; i--) |
| 228 | { | 249 | { |
| 229 | buf[i]++; | 250 | buf[i]++; |
| 230 | if (buf[i] != 0) break; | 251 | if (buf[i] != 0) |
| 252 | break; | ||
| 231 | } | 253 | } |
| 232 | 254 | ||
| 233 | EVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); | 255 | EVP_Digest(buf, qsize, md ,NULL, evpmd, NULL); |
| 234 | 256 | ||
| 235 | /* step 8 */ | 257 | /* step 8 */ |
| 236 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) | 258 | if (!BN_bin2bn(md, qsize, r0)) |
| 237 | goto err; | 259 | goto err; |
| 238 | if (!BN_lshift(r0,r0,160*k)) goto err; | 260 | if (!BN_lshift(r0,r0,(qsize << 3)*k)) goto err; |
| 239 | if (!BN_add(W,W,r0)) goto err; | 261 | if (!BN_add(W,W,r0)) goto err; |
| 240 | } | 262 | } |
| 241 | 263 | ||
| @@ -309,7 +331,6 @@ err: | |||
| 309 | ok=0; | 331 | ok=0; |
| 310 | goto err; | 332 | goto err; |
| 311 | } | 333 | } |
| 312 | if (seed_in != NULL) memcpy(seed_in,seed,20); | ||
| 313 | if (counter_ret != NULL) *counter_ret=counter; | 334 | if (counter_ret != NULL) *counter_ret=counter; |
| 314 | if (h_ret != NULL) *h_ret=h; | 335 | if (h_ret != NULL) *h_ret=h; |
| 315 | } | 336 | } |
| @@ -322,4 +343,3 @@ err: | |||
| 322 | return ok; | 343 | return ok; |
| 323 | } | 344 | } |
| 324 | #endif | 345 | #endif |
| 325 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index 5e39124230..c4aa86bc6d 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
| @@ -64,8 +64,6 @@ | |||
| 64 | #include <openssl/dsa.h> | 64 | #include <openssl/dsa.h> |
| 65 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
| 66 | 66 | ||
| 67 | #ifndef OPENSSL_FIPS | ||
| 68 | |||
| 69 | static int dsa_builtin_keygen(DSA *dsa); | 67 | static int dsa_builtin_keygen(DSA *dsa); |
| 70 | 68 | ||
| 71 | int DSA_generate_key(DSA *dsa) | 69 | int DSA_generate_key(DSA *dsa) |
| @@ -128,5 +126,3 @@ err: | |||
| 128 | return(ok); | 126 | return(ok); |
| 129 | } | 127 | } |
| 130 | #endif | 128 | #endif |
| 131 | |||
| 132 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 7ac9dc8c89..e9b75902db 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
| @@ -76,14 +76,6 @@ static const DSA_METHOD *default_DSA_method = NULL; | |||
| 76 | 76 | ||
| 77 | void DSA_set_default_method(const DSA_METHOD *meth) | 77 | void DSA_set_default_method(const DSA_METHOD *meth) |
| 78 | { | 78 | { |
| 79 | #ifdef OPENSSL_FIPS | ||
| 80 | if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
| 81 | { | ||
| 82 | DSAerr(DSA_F_DSA_SET_DEFAULT_METHOD, DSA_R_NON_FIPS_METHOD); | ||
| 83 | return; | ||
| 84 | } | ||
| 85 | #endif | ||
| 86 | |||
| 87 | default_DSA_method = meth; | 79 | default_DSA_method = meth; |
| 88 | } | 80 | } |
| 89 | 81 | ||
| @@ -104,13 +96,6 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) | |||
| 104 | /* NB: The caller is specifically setting a method, so it's not up to us | 96 | /* NB: The caller is specifically setting a method, so it's not up to us |
| 105 | * to deal with which ENGINE it comes from. */ | 97 | * to deal with which ENGINE it comes from. */ |
| 106 | const DSA_METHOD *mtmp; | 98 | const DSA_METHOD *mtmp; |
| 107 | #ifdef OPENSSL_FIPS | ||
| 108 | if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
| 109 | { | ||
| 110 | DSAerr(DSA_F_DSA_SET_METHOD, DSA_R_NON_FIPS_METHOD); | ||
| 111 | return 0; | ||
| 112 | } | ||
| 113 | #endif | ||
| 114 | mtmp = dsa->meth; | 99 | mtmp = dsa->meth; |
| 115 | if (mtmp->finish) mtmp->finish(dsa); | 100 | if (mtmp->finish) mtmp->finish(dsa); |
| 116 | #ifndef OPENSSL_NO_ENGINE | 101 | #ifndef OPENSSL_NO_ENGINE |
| @@ -162,18 +147,6 @@ DSA *DSA_new_method(ENGINE *engine) | |||
| 162 | } | 147 | } |
| 163 | } | 148 | } |
| 164 | #endif | 149 | #endif |
| 165 | #ifdef OPENSSL_FIPS | ||
| 166 | if (FIPS_mode() && !(ret->meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
| 167 | { | ||
| 168 | DSAerr(DSA_F_DSA_NEW_METHOD, DSA_R_NON_FIPS_METHOD); | ||
| 169 | #ifndef OPENSSL_NO_ENGINE | ||
| 170 | if (ret->engine) | ||
| 171 | ENGINE_finish(ret->engine); | ||
| 172 | #endif | ||
| 173 | OPENSSL_free(ret); | ||
| 174 | return NULL; | ||
| 175 | } | ||
| 176 | #endif | ||
| 177 | 150 | ||
| 178 | ret->pad=0; | 151 | ret->pad=0; |
| 179 | ret->version=0; | 152 | ret->version=0; |
| @@ -260,6 +233,28 @@ int DSA_up_ref(DSA *r) | |||
| 260 | return ((i > 1) ? 1 : 0); | 233 | return ((i > 1) ? 1 : 0); |
| 261 | } | 234 | } |
| 262 | 235 | ||
| 236 | int DSA_size(const DSA *r) | ||
| 237 | { | ||
| 238 | int ret,i; | ||
| 239 | ASN1_INTEGER bs; | ||
| 240 | unsigned char buf[4]; /* 4 bytes looks really small. | ||
| 241 | However, i2d_ASN1_INTEGER() will not look | ||
| 242 | beyond the first byte, as long as the second | ||
| 243 | parameter is NULL. */ | ||
| 244 | |||
| 245 | i=BN_num_bits(r->q); | ||
| 246 | bs.length=(i+7)/8; | ||
| 247 | bs.data=buf; | ||
| 248 | bs.type=V_ASN1_INTEGER; | ||
| 249 | /* If the top bit is set the asn1 encoding is 1 larger. */ | ||
| 250 | buf[0]=0xff; | ||
| 251 | |||
| 252 | i=i2d_ASN1_INTEGER(&bs,NULL); | ||
| 253 | i+=i; /* r and s */ | ||
| 254 | ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | ||
| 255 | return(ret); | ||
| 256 | } | ||
| 257 | |||
| 263 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 258 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 264 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 259 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
| 265 | { | 260 | { |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index 412cf1d88b..4fead07e80 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
| @@ -61,16 +61,15 @@ | |||
| 61 | #include <stdio.h> | 61 | #include <stdio.h> |
| 62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
| 64 | #include <openssl/sha.h> | ||
| 64 | #include <openssl/dsa.h> | 65 | #include <openssl/dsa.h> |
| 65 | #include <openssl/rand.h> | 66 | #include <openssl/rand.h> |
| 66 | #include <openssl/asn1.h> | 67 | #include <openssl/asn1.h> |
| 67 | 68 | ||
| 68 | #ifndef OPENSSL_FIPS | ||
| 69 | |||
| 70 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); | 69 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); |
| 71 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); | 70 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); |
| 72 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 71 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
| 73 | DSA *dsa); | 72 | DSA *dsa); |
| 74 | static int dsa_init(DSA *dsa); | 73 | static int dsa_init(DSA *dsa); |
| 75 | static int dsa_finish(DSA *dsa); | 74 | static int dsa_finish(DSA *dsa); |
| 76 | 75 | ||
| @@ -135,7 +134,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
| 135 | BIGNUM m; | 134 | BIGNUM m; |
| 136 | BIGNUM xr; | 135 | BIGNUM xr; |
| 137 | BN_CTX *ctx=NULL; | 136 | BN_CTX *ctx=NULL; |
| 138 | int i,reason=ERR_R_BN_LIB; | 137 | int reason=ERR_R_BN_LIB; |
| 139 | DSA_SIG *ret=NULL; | 138 | DSA_SIG *ret=NULL; |
| 140 | 139 | ||
| 141 | BN_init(&m); | 140 | BN_init(&m); |
| @@ -150,8 +149,9 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
| 150 | s=BN_new(); | 149 | s=BN_new(); |
| 151 | if (s == NULL) goto err; | 150 | if (s == NULL) goto err; |
| 152 | 151 | ||
| 153 | i=BN_num_bytes(dsa->q); /* should be 20 */ | 152 | /* reject a excessive digest length (currently at most |
| 154 | if ((dlen > i) || (dlen > 50)) | 153 | * dsa-with-SHA256 is supported) */ |
| 154 | if (dlen > SHA256_DIGEST_LENGTH) | ||
| 155 | { | 155 | { |
| 156 | reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE; | 156 | reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE; |
| 157 | goto err; | 157 | goto err; |
| @@ -172,7 +172,14 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
| 172 | dsa->r=NULL; | 172 | dsa->r=NULL; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err; | 175 | |
| 176 | if (dlen > BN_num_bytes(dsa->q)) | ||
| 177 | /* if the digest length is greater than the size of q use the | ||
| 178 | * BN_num_bits(dsa->q) leftmost bits of the digest, see | ||
| 179 | * fips 186-3, 4.2 */ | ||
| 180 | dlen = BN_num_bytes(dsa->q); | ||
| 181 | if (BN_bin2bn(dgst,dlen,&m) == NULL) | ||
| 182 | goto err; | ||
| 176 | 183 | ||
| 177 | /* Compute s = inv(k) (m + xr) mod q */ | 184 | /* Compute s = inv(k) (m + xr) mod q */ |
| 178 | if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ | 185 | if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ |
| @@ -283,30 +290,31 @@ err: | |||
| 283 | if (!ret) | 290 | if (!ret) |
| 284 | { | 291 | { |
| 285 | DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB); | 292 | DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB); |
| 286 | if (kinv != NULL) BN_clear_free(kinv); | 293 | if (r != NULL) |
| 287 | if (r != NULL) BN_clear_free(r); | 294 | BN_clear_free(r); |
| 288 | } | 295 | } |
| 289 | if (ctx_in == NULL) BN_CTX_free(ctx); | 296 | if (ctx_in == NULL) BN_CTX_free(ctx); |
| 290 | if (kinv != NULL) BN_clear_free(kinv); | ||
| 291 | BN_clear_free(&k); | 297 | BN_clear_free(&k); |
| 292 | BN_clear_free(&kq); | 298 | BN_clear_free(&kq); |
| 293 | return(ret); | 299 | return(ret); |
| 294 | } | 300 | } |
| 295 | 301 | ||
| 296 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 302 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
| 297 | DSA *dsa) | 303 | DSA *dsa) |
| 298 | { | 304 | { |
| 299 | BN_CTX *ctx; | 305 | BN_CTX *ctx; |
| 300 | BIGNUM u1,u2,t1; | 306 | BIGNUM u1,u2,t1; |
| 301 | BN_MONT_CTX *mont=NULL; | 307 | BN_MONT_CTX *mont=NULL; |
| 302 | int ret = -1; | 308 | int ret = -1, i; |
| 303 | if (!dsa->p || !dsa->q || !dsa->g) | 309 | if (!dsa->p || !dsa->q || !dsa->g) |
| 304 | { | 310 | { |
| 305 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS); | 311 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS); |
| 306 | return -1; | 312 | return -1; |
| 307 | } | 313 | } |
| 308 | 314 | ||
| 309 | if (BN_num_bits(dsa->q) != 160) | 315 | i = BN_num_bits(dsa->q); |
| 316 | /* fips 186-3 allows only different sizes for q */ | ||
| 317 | if (i != 160 && i != 224 && i != 256) | ||
| 310 | { | 318 | { |
| 311 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE); | 319 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE); |
| 312 | return -1; | 320 | return -1; |
| @@ -318,6 +326,14 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
| 318 | return -1; | 326 | return -1; |
| 319 | } | 327 | } |
| 320 | 328 | ||
| 329 | /* reject a excessive digest length (currently at most | ||
| 330 | * dsa-with-SHA256 is supported) */ | ||
| 331 | if (dgst_len > SHA256_DIGEST_LENGTH) | ||
| 332 | { | ||
| 333 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); | ||
| 334 | return -1; | ||
| 335 | } | ||
| 336 | |||
| 321 | BN_init(&u1); | 337 | BN_init(&u1); |
| 322 | BN_init(&u2); | 338 | BN_init(&u2); |
| 323 | BN_init(&t1); | 339 | BN_init(&t1); |
| @@ -342,6 +358,11 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
| 342 | if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err; | 358 | if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err; |
| 343 | 359 | ||
| 344 | /* save M in u1 */ | 360 | /* save M in u1 */ |
| 361 | if (dgst_len > (i >> 3)) | ||
| 362 | /* if the digest length is greater than the size of q use the | ||
| 363 | * BN_num_bits(dsa->q) leftmost bits of the digest, see | ||
| 364 | * fips 186-3, 4.2 */ | ||
| 365 | dgst_len = (i >> 3); | ||
| 345 | if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err; | 366 | if (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err; |
| 346 | 367 | ||
| 347 | /* u1 = M * w mod q */ | 368 | /* u1 = M * w mod q */ |
| @@ -393,4 +414,3 @@ static int dsa_finish(DSA *dsa) | |||
| 393 | return(1); | 414 | return(1); |
| 394 | } | 415 | } |
| 395 | 416 | ||
| 396 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c index 4cfbbe57a8..17555e5892 100644 --- a/src/lib/libcrypto/dsa/dsa_sign.c +++ b/src/lib/libcrypto/dsa/dsa_sign.c | |||
| @@ -58,38 +58,33 @@ | |||
| 58 | 58 | ||
| 59 | /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ | 59 | /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ |
| 60 | 60 | ||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 63 | #include <openssl/bn.h> | ||
| 64 | #include <openssl/dsa.h> | 62 | #include <openssl/dsa.h> |
| 65 | #include <openssl/rand.h> | 63 | #include <openssl/rand.h> |
| 66 | #include <openssl/asn1.h> | ||
| 67 | #ifdef OPENSSL_FIPS | ||
| 68 | #include <openssl/fips.h> | ||
| 69 | #endif | ||
| 70 | |||
| 71 | 64 | ||
| 72 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | 65 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) |
| 73 | { | 66 | { |
| 74 | #ifdef OPENSSL_FIPS | ||
| 75 | if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | ||
| 76 | { | ||
| 77 | DSAerr(DSA_F_DSA_DO_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
| 78 | return NULL; | ||
| 79 | } | ||
| 80 | #endif | ||
| 81 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); | 67 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); |
| 82 | } | 68 | } |
| 83 | 69 | ||
| 84 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | 70 | int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, |
| 71 | unsigned int *siglen, DSA *dsa) | ||
| 85 | { | 72 | { |
| 86 | #ifdef OPENSSL_FIPS | 73 | DSA_SIG *s; |
| 87 | if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | 74 | RAND_seed(dgst, dlen); |
| 75 | s=DSA_do_sign(dgst,dlen,dsa); | ||
| 76 | if (s == NULL) | ||
| 88 | { | 77 | { |
| 89 | DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | 78 | *siglen=0; |
| 90 | return 0; | 79 | return(0); |
| 91 | } | 80 | } |
| 92 | #endif | 81 | *siglen=i2d_DSA_SIG(s,&sig); |
| 82 | DSA_SIG_free(s); | ||
| 83 | return(1); | ||
| 84 | } | ||
| 85 | |||
| 86 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | ||
| 87 | { | ||
| 93 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); | 88 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); |
| 94 | } | 89 | } |
| 95 | 90 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_utl.c b/src/lib/libcrypto/dsa/dsa_utl.c deleted file mode 100644 index 24c021d120..0000000000 --- a/src/lib/libcrypto/dsa/dsa_utl.c +++ /dev/null | |||
| @@ -1,95 +0,0 @@ | |||
| 1 | /* crypto/dsa/dsa_lib.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include <openssl/bn.h> | ||
| 64 | #include <openssl/dsa.h> | ||
| 65 | #include <openssl/asn1.h> | ||
| 66 | #ifndef OPENSSL_NO_ENGINE | ||
| 67 | #include <openssl/engine.h> | ||
| 68 | #endif | ||
| 69 | #ifndef OPENSSL_NO_DH | ||
| 70 | #include <openssl/dh.h> | ||
| 71 | #endif | ||
| 72 | |||
| 73 | DSA_SIG *DSA_SIG_new(void) | ||
| 74 | { | ||
| 75 | DSA_SIG *sig; | ||
| 76 | sig = OPENSSL_malloc(sizeof(DSA_SIG)); | ||
| 77 | if (!sig) | ||
| 78 | return NULL; | ||
| 79 | sig->r = NULL; | ||
| 80 | sig->s = NULL; | ||
| 81 | return sig; | ||
| 82 | } | ||
| 83 | |||
| 84 | void DSA_SIG_free(DSA_SIG *sig) | ||
| 85 | { | ||
| 86 | if (sig) | ||
| 87 | { | ||
| 88 | if (sig->r) | ||
| 89 | BN_free(sig->r); | ||
| 90 | if (sig->s) | ||
| 91 | BN_free(sig->s); | ||
| 92 | OPENSSL_free(sig); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c index c75e423048..226a75ff3f 100644 --- a/src/lib/libcrypto/dsa/dsa_vrf.c +++ b/src/lib/libcrypto/dsa/dsa_vrf.c | |||
| @@ -58,27 +58,32 @@ | |||
| 58 | 58 | ||
| 59 | /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ | 59 | /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ |
| 60 | 60 | ||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 63 | #include <openssl/bn.h> | ||
| 64 | #include <openssl/dsa.h> | 62 | #include <openssl/dsa.h> |
| 65 | #include <openssl/rand.h> | ||
| 66 | #include <openssl/asn1.h> | ||
| 67 | #ifdef OPENSSL_FIPS | ||
| 68 | #include <openssl/fips.h> | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #include <openssl/asn1_mac.h> | ||
| 72 | 63 | ||
| 73 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 64 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
| 74 | DSA *dsa) | 65 | DSA *dsa) |
| 75 | { | 66 | { |
| 76 | #ifdef OPENSSL_FIPS | ||
| 77 | if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | ||
| 78 | { | ||
| 79 | DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
| 80 | return 0; | ||
| 81 | } | ||
| 82 | #endif | ||
| 83 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); | 67 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); |
| 84 | } | 68 | } |
| 69 | |||
| 70 | /* data has already been hashed (probably with SHA or SHA-1). */ | ||
| 71 | /* returns | ||
| 72 | * 1: correct signature | ||
| 73 | * 0: incorrect signature | ||
| 74 | * -1: error | ||
| 75 | */ | ||
| 76 | int DSA_verify(int type, const unsigned char *dgst, int dgst_len, | ||
| 77 | const unsigned char *sigbuf, int siglen, DSA *dsa) | ||
| 78 | { | ||
| 79 | DSA_SIG *s; | ||
| 80 | int ret=-1; | ||
| 81 | |||
| 82 | s = DSA_SIG_new(); | ||
| 83 | if (s == NULL) return(ret); | ||
| 84 | if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err; | ||
| 85 | ret=DSA_do_verify(dgst,dgst_len,s,dsa); | ||
| 86 | err: | ||
| 87 | DSA_SIG_free(s); | ||
| 88 | return(ret); | ||
| 89 | } | ||
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c index 912317bb44..edffd24e6b 100644 --- a/src/lib/libcrypto/dsa/dsatest.c +++ b/src/lib/libcrypto/dsa/dsatest.c | |||
| @@ -169,7 +169,6 @@ int main(int argc, char **argv) | |||
| 169 | } | 169 | } |
| 170 | BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h); | 170 | BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h); |
| 171 | 171 | ||
| 172 | if (dsa == NULL) goto end; | ||
| 173 | DSA_print(bio_err,dsa,0); | 172 | DSA_print(bio_err,dsa,0); |
| 174 | if (counter != 105) | 173 | if (counter != 105) |
| 175 | { | 174 | { |
| @@ -223,7 +222,7 @@ end: | |||
| 223 | ERR_print_errors(bio_err); | 222 | ERR_print_errors(bio_err); |
| 224 | if (dsa != NULL) DSA_free(dsa); | 223 | if (dsa != NULL) DSA_free(dsa); |
| 225 | CRYPTO_cleanup_all_ex_data(); | 224 | CRYPTO_cleanup_all_ex_data(); |
| 226 | ERR_remove_state(0); | 225 | ERR_remove_thread_state(NULL); |
| 227 | ERR_free_strings(); | 226 | ERR_free_strings(); |
| 228 | CRYPTO_mem_leaks(bio_err); | 227 | CRYPTO_mem_leaks(bio_err); |
| 229 | if (bio_err != NULL) | 228 | if (bio_err != NULL) |
