diff options
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r-- | src/lib/libcrypto/dsa/Makefile | 173 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/Makefile.ssl | 171 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/README | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 45 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_sign.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_vrf.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsagen.c | 111 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsatest.c | 242 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/fips186a.txt | 122 |
12 files changed, 841 insertions, 55 deletions
diff --git a/src/lib/libcrypto/dsa/Makefile b/src/lib/libcrypto/dsa/Makefile new file mode 100644 index 0000000000..3a55058973 --- /dev/null +++ b/src/lib/libcrypto/dsa/Makefile | |||
@@ -0,0 +1,173 @@ | |||
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 | MAKEDEPPROG= makedepend | ||
14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
15 | MAKEFILE= Makefile | ||
16 | AR= ar r | ||
17 | |||
18 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
19 | |||
20 | GENERAL=Makefile | ||
21 | TEST=dsatest.c | ||
22 | APPS= | ||
23 | |||
24 | LIB=$(TOP)/libcrypto.a | ||
25 | LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c \ | ||
26 | dsa_err.c dsa_ossl.c | ||
27 | LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o \ | ||
28 | dsa_err.o dsa_ossl.o | ||
29 | |||
30 | SRC= $(LIBSRC) | ||
31 | |||
32 | EXHEADER= dsa.h | ||
33 | HEADER= $(EXHEADER) | ||
34 | |||
35 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
36 | |||
37 | top: | ||
38 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
39 | |||
40 | all: lib | ||
41 | |||
42 | lib: $(LIBOBJ) | ||
43 | $(AR) $(LIB) $(LIBOBJ) | ||
44 | $(RANLIB) $(LIB) || echo Never mind. | ||
45 | @touch lib | ||
46 | |||
47 | files: | ||
48 | $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO | ||
49 | |||
50 | links: | ||
51 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
52 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
53 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
54 | |||
55 | install: | ||
56 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | ||
57 | do \ | ||
58 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
59 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
60 | done; | ||
61 | |||
62 | tags: | ||
63 | ctags $(SRC) | ||
64 | |||
65 | tests: | ||
66 | |||
67 | lint: | ||
68 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
69 | |||
70 | depend: | ||
71 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
72 | |||
73 | dclean: | ||
74 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
75 | mv -f Makefile.new $(MAKEFILE) | ||
76 | |||
77 | clean: | ||
78 | rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
79 | |||
80 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
81 | |||
82 | dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h | ||
83 | dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h | ||
84 | dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
85 | dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
86 | dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
87 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
88 | dsa_asn1.o: ../../include/openssl/opensslconf.h | ||
89 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
90 | dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
91 | dsa_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_asn1.c | ||
92 | dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
93 | dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
94 | dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
95 | dsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
96 | dsa_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
97 | dsa_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
98 | dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
99 | dsa_err.o: dsa_err.c | ||
100 | dsa_gen.o: ../../e_os.h ../../include/openssl/aes.h | ||
101 | dsa_gen.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
102 | dsa_gen.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
103 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
104 | dsa_gen.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
105 | dsa_gen.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
106 | dsa_gen.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
107 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
108 | dsa_gen.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
109 | dsa_gen.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
110 | dsa_gen.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
111 | dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
112 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
113 | dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
114 | dsa_gen.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
115 | dsa_gen.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
116 | dsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
117 | dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
118 | dsa_gen.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
119 | dsa_gen.o: ../../include/openssl/ui_compat.h ../cryptlib.h dsa_gen.c | ||
120 | 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 | ||
122 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
123 | dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
124 | dsa_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
125 | dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
126 | dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
127 | dsa_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
128 | dsa_key.o: ../cryptlib.h dsa_key.c | ||
129 | dsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h | ||
130 | dsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
131 | dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
132 | dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
133 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
134 | dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
135 | dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
136 | dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
137 | dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
138 | dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
139 | dsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h dsa_lib.c | ||
140 | dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h | ||
141 | dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
142 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
143 | dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
144 | dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
145 | dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
146 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
147 | dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | ||
148 | dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
149 | dsa_ossl.o: ../cryptlib.h dsa_ossl.c | ||
150 | dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h | ||
151 | dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
152 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
153 | dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
154 | dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
155 | dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/fips.h | ||
156 | dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
157 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
158 | dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
159 | dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
160 | dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.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/engine.h ../../include/openssl/err.h | ||
168 | dsa_vrf.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
169 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
170 | dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
171 | dsa_vrf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
172 | dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
173 | dsa_vrf.o: ../../include/openssl/ui.h ../cryptlib.h dsa_vrf.c | ||
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl new file mode 100644 index 0000000000..e5f8a8cf51 --- /dev/null +++ b/src/lib/libcrypto/dsa/Makefile.ssl | |||
@@ -0,0 +1,171 @@ | |||
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/README b/src/lib/libcrypto/dsa/README new file mode 100644 index 0000000000..6a7e9c170a --- /dev/null +++ b/src/lib/libcrypto/dsa/README | |||
@@ -0,0 +1,4 @@ | |||
1 | The stuff in here is based on patches supplied to me by | ||
2 | Steven Schoch <schoch@sheba.arc.nasa.gov> to do DSS. | ||
3 | I have since modified a them a little but a debt of gratitude | ||
4 | is due for doing the initial work. | ||
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index 225ff391f9..9b3baadf2c 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
@@ -81,10 +81,6 @@ | |||
81 | 81 | ||
82 | #define DSA_FLAG_CACHE_MONT_P 0x01 | 82 | #define DSA_FLAG_CACHE_MONT_P 0x01 |
83 | 83 | ||
84 | #if defined(OPENSSL_FIPS) | ||
85 | #define FIPS_DSA_SIZE_T int | ||
86 | #endif | ||
87 | |||
88 | #ifdef __cplusplus | 84 | #ifdef __cplusplus |
89 | extern "C" { | 85 | extern "C" { |
90 | #endif | 86 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index e40afeea51..dc9c249310 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
@@ -80,7 +80,6 @@ | |||
80 | #include <openssl/rand.h> | 80 | #include <openssl/rand.h> |
81 | #include <openssl/sha.h> | 81 | #include <openssl/sha.h> |
82 | 82 | ||
83 | #ifndef OPENSSL_FIPS | ||
84 | DSA *DSA_generate_parameters(int bits, | 83 | DSA *DSA_generate_parameters(int bits, |
85 | unsigned char *seed_in, int seed_len, | 84 | unsigned char *seed_in, int seed_len, |
86 | int *counter_ret, unsigned long *h_ret, | 85 | int *counter_ret, unsigned long *h_ret, |
@@ -128,9 +127,8 @@ DSA *DSA_generate_parameters(int bits, | |||
128 | c = BN_CTX_get(ctx2); | 127 | c = BN_CTX_get(ctx2); |
129 | p = BN_CTX_get(ctx2); | 128 | p = BN_CTX_get(ctx2); |
130 | test = BN_CTX_get(ctx2); | 129 | test = BN_CTX_get(ctx2); |
131 | if (test == NULL) goto err; | ||
132 | 130 | ||
133 | if (!BN_lshift(test,BN_value_one(),bits-1)) goto err; | 131 | BN_lshift(test,BN_value_one(),bits-1); |
134 | 132 | ||
135 | for (;;) | 133 | for (;;) |
136 | { | 134 | { |
@@ -198,7 +196,7 @@ DSA *DSA_generate_parameters(int bits, | |||
198 | callback(0,counter,cb_arg); | 196 | callback(0,counter,cb_arg); |
199 | 197 | ||
200 | /* step 7 */ | 198 | /* step 7 */ |
201 | if (!BN_zero(W)) goto err; | 199 | BN_zero(W); |
202 | /* now 'buf' contains "SEED + offset - 1" */ | 200 | /* now 'buf' contains "SEED + offset - 1" */ |
203 | for (k=0; k<=n; k++) | 201 | for (k=0; k<=n; k++) |
204 | { | 202 | { |
@@ -214,20 +212,20 @@ DSA *DSA_generate_parameters(int bits, | |||
214 | /* step 8 */ | 212 | /* step 8 */ |
215 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) | 213 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) |
216 | goto err; | 214 | goto err; |
217 | if (!BN_lshift(r0,r0,160*k)) goto err; | 215 | BN_lshift(r0,r0,160*k); |
218 | if (!BN_add(W,W,r0)) goto err; | 216 | BN_add(W,W,r0); |
219 | } | 217 | } |
220 | 218 | ||
221 | /* more of step 8 */ | 219 | /* more of step 8 */ |
222 | if (!BN_mask_bits(W,bits-1)) goto err; | 220 | BN_mask_bits(W,bits-1); |
223 | if (!BN_copy(X,W)) goto err; | 221 | BN_copy(X,W); /* this should be ok */ |
224 | if (!BN_add(X,X,test)) goto err; | 222 | BN_add(X,X,test); /* this should be ok */ |
225 | 223 | ||
226 | /* step 9 */ | 224 | /* step 9 */ |
227 | if (!BN_lshift1(r0,q)) goto err; | 225 | BN_lshift1(r0,q); |
228 | if (!BN_mod(c,X,r0,ctx)) goto err; | 226 | BN_mod(c,X,r0,ctx); |
229 | if (!BN_sub(r0,c,BN_value_one())) goto err; | 227 | BN_sub(r0,c,BN_value_one()); |
230 | if (!BN_sub(p,X,r0)) goto err; | 228 | BN_sub(p,X,r0); |
231 | 229 | ||
232 | /* step 10 */ | 230 | /* step 10 */ |
233 | if (BN_cmp(p,test) >= 0) | 231 | if (BN_cmp(p,test) >= 0) |
@@ -253,18 +251,18 @@ end: | |||
253 | 251 | ||
254 | /* We now need to generate g */ | 252 | /* We now need to generate g */ |
255 | /* Set r0=(p-1)/q */ | 253 | /* Set r0=(p-1)/q */ |
256 | if (!BN_sub(test,p,BN_value_one())) goto err; | 254 | BN_sub(test,p,BN_value_one()); |
257 | if (!BN_div(r0,NULL,test,q,ctx)) goto err; | 255 | BN_div(r0,NULL,test,q,ctx); |
258 | 256 | ||
259 | if (!BN_set_word(test,h)) goto err; | 257 | BN_set_word(test,h); |
260 | if (!BN_MONT_CTX_set(mont,p,ctx)) goto err; | 258 | BN_MONT_CTX_set(mont,p,ctx); |
261 | 259 | ||
262 | for (;;) | 260 | for (;;) |
263 | { | 261 | { |
264 | /* g=test^r0%p */ | 262 | /* g=test^r0%p */ |
265 | if (!BN_mod_exp_mont(g,test,r0,p,ctx,mont)) goto err; | 263 | BN_mod_exp_mont(g,test,r0,p,ctx,mont); |
266 | if (!BN_is_one(g)) break; | 264 | if (!BN_is_one(g)) break; |
267 | if (!BN_add(test,test,BN_value_one())) goto err; | 265 | BN_add(test,test,BN_value_one()); |
268 | h++; | 266 | h++; |
269 | } | 267 | } |
270 | 268 | ||
@@ -281,11 +279,6 @@ err: | |||
281 | ret->p=BN_dup(p); | 279 | ret->p=BN_dup(p); |
282 | ret->q=BN_dup(q); | 280 | ret->q=BN_dup(q); |
283 | ret->g=BN_dup(g); | 281 | ret->g=BN_dup(g); |
284 | if (ret->p == NULL || ret->q == NULL || ret->g == NULL) | ||
285 | { | ||
286 | ok=0; | ||
287 | goto err; | ||
288 | } | ||
289 | if ((m > 1) && (seed_in != NULL)) memcpy(seed_in,seed,20); | 282 | if ((m > 1) && (seed_in != NULL)) memcpy(seed_in,seed,20); |
290 | if (counter_ret != NULL) *counter_ret=counter; | 283 | if (counter_ret != NULL) *counter_ret=counter; |
291 | if (h_ret != NULL) *h_ret=h; | 284 | if (h_ret != NULL) *h_ret=h; |
@@ -300,6 +293,4 @@ err: | |||
300 | if (mont != NULL) BN_MONT_CTX_free(mont); | 293 | if (mont != NULL) BN_MONT_CTX_free(mont); |
301 | return(ok?ret:NULL); | 294 | return(ok?ret:NULL); |
302 | } | 295 | } |
303 | #endif /* ndef OPENSSL_FIPS */ | 296 | #endif |
304 | #endif /* ndef OPENSSL_NO_SHA */ | ||
305 | |||
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index 30607ca579..ef87c3e637 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
@@ -64,7 +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 | int DSA_generate_key(DSA *dsa) | 67 | int DSA_generate_key(DSA *dsa) |
69 | { | 68 | { |
70 | int ok=0; | 69 | int ok=0; |
@@ -104,4 +103,3 @@ err: | |||
104 | return(ok); | 103 | return(ok); |
105 | } | 104 | } |
106 | #endif | 105 | #endif |
107 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index f1a85afcde..b9e7f3ea5c 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
@@ -65,7 +65,6 @@ | |||
65 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
66 | #include <openssl/asn1.h> | 66 | #include <openssl/asn1.h> |
67 | 67 | ||
68 | #ifndef OPENSSL_FIPS | ||
69 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); | 68 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); |
70 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); | 69 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); |
71 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 70 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
@@ -347,4 +346,3 @@ static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, | |||
347 | { | 346 | { |
348 | return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); | 347 | return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); |
349 | } | 348 | } |
350 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c index 3c9753bac3..89205026f0 100644 --- a/src/lib/libcrypto/dsa/dsa_sign.c +++ b/src/lib/libcrypto/dsa/dsa_sign.c | |||
@@ -64,17 +64,9 @@ | |||
64 | #include <openssl/dsa.h> | 64 | #include <openssl/dsa.h> |
65 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
66 | #include <openssl/asn1.h> | 66 | #include <openssl/asn1.h> |
67 | #ifndef OPENSSL_NO_ENGINE | ||
68 | #include <openssl/engine.h> | ||
69 | #endif | ||
70 | #include <openssl/fips.h> | ||
71 | 67 | ||
72 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | 68 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) |
73 | { | 69 | { |
74 | #ifdef OPENSSL_FIPS | ||
75 | if(FIPS_mode() && !FIPS_dsa_check(dsa)) | ||
76 | return NULL; | ||
77 | #endif | ||
78 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); | 70 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); |
79 | } | 71 | } |
80 | 72 | ||
@@ -95,10 +87,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | |||
95 | 87 | ||
96 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | 88 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) |
97 | { | 89 | { |
98 | #ifdef OPENSSL_FIPS | ||
99 | if(FIPS_mode() && !FIPS_dsa_check(dsa)) | ||
100 | return 0; | ||
101 | #endif | ||
102 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); | 90 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); |
103 | } | 91 | } |
104 | 92 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c index 8ef0c45025..c4aeddd056 100644 --- a/src/lib/libcrypto/dsa/dsa_vrf.c +++ b/src/lib/libcrypto/dsa/dsa_vrf.c | |||
@@ -65,18 +65,10 @@ | |||
65 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
66 | #include <openssl/asn1.h> | 66 | #include <openssl/asn1.h> |
67 | #include <openssl/asn1_mac.h> | 67 | #include <openssl/asn1_mac.h> |
68 | #ifndef OPENSSL_NO_ENGINE | ||
69 | #include <openssl/engine.h> | ||
70 | #endif | ||
71 | #include <openssl/fips.h> | ||
72 | 68 | ||
73 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 69 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
74 | DSA *dsa) | 70 | DSA *dsa) |
75 | { | 71 | { |
76 | #ifdef OPENSSL_FIPS | ||
77 | if(FIPS_mode() && !FIPS_dsa_check(dsa)) | ||
78 | return -1; | ||
79 | #endif | ||
80 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); | 72 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); |
81 | } | 73 | } |
82 | 74 | ||
diff --git a/src/lib/libcrypto/dsa/dsagen.c b/src/lib/libcrypto/dsa/dsagen.c new file mode 100644 index 0000000000..1b6a1cca0f --- /dev/null +++ b/src/lib/libcrypto/dsa/dsagen.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* crypto/dsa/dsagen.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <openssl/dsa.h> | ||
61 | |||
62 | #define TEST | ||
63 | #define GENUINE_DSA | ||
64 | |||
65 | #ifdef GENUINE_DSA | ||
66 | #define LAST_VALUE 0xbd | ||
67 | #else | ||
68 | #define LAST_VALUE 0xd3 | ||
69 | #endif | ||
70 | |||
71 | #ifdef TEST | ||
72 | unsigned char seed[20]={ | ||
73 | 0xd5,0x01,0x4e,0x4b, | ||
74 | 0x60,0xef,0x2b,0xa8, | ||
75 | 0xb6,0x21,0x1b,0x40, | ||
76 | 0x62,0xba,0x32,0x24, | ||
77 | 0xe0,0x42,0x7d,LAST_VALUE}; | ||
78 | #endif | ||
79 | |||
80 | int cb(int p, int n) | ||
81 | { | ||
82 | char c='*'; | ||
83 | |||
84 | if (p == 0) c='.'; | ||
85 | if (p == 1) c='+'; | ||
86 | if (p == 2) c='*'; | ||
87 | if (p == 3) c='\n'; | ||
88 | printf("%c",c); | ||
89 | fflush(stdout); | ||
90 | } | ||
91 | |||
92 | main() | ||
93 | { | ||
94 | int i; | ||
95 | BIGNUM *n; | ||
96 | BN_CTX *ctx; | ||
97 | unsigned char seed_buf[20]; | ||
98 | DSA *dsa; | ||
99 | int counter,h; | ||
100 | BIO *bio_err=NULL; | ||
101 | |||
102 | if (bio_err == NULL) | ||
103 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
104 | |||
105 | memcpy(seed_buf,seed,20); | ||
106 | dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb,bio_err); | ||
107 | |||
108 | if (dsa == NULL) | ||
109 | DSA_print(bio_err,dsa,0); | ||
110 | } | ||
111 | |||
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c new file mode 100644 index 0000000000..4734ce4af8 --- /dev/null +++ b/src/lib/libcrypto/dsa/dsatest.c | |||
@@ -0,0 +1,242 @@ | |||
1 | /* crypto/dsa/dsatest.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <stdlib.h> | ||
61 | #include <string.h> | ||
62 | #include <sys/types.h> | ||
63 | #include <sys/stat.h> | ||
64 | |||
65 | #include "../e_os.h" | ||
66 | |||
67 | #include <openssl/crypto.h> | ||
68 | #include <openssl/rand.h> | ||
69 | #include <openssl/bio.h> | ||
70 | #include <openssl/err.h> | ||
71 | |||
72 | #ifdef OPENSSL_NO_DSA | ||
73 | int main(int argc, char *argv[]) | ||
74 | { | ||
75 | printf("No DSA support\n"); | ||
76 | return(0); | ||
77 | } | ||
78 | #else | ||
79 | #include <openssl/dsa.h> | ||
80 | |||
81 | #ifdef OPENSSL_SYS_WIN16 | ||
82 | #define MS_CALLBACK _far _loadds | ||
83 | #else | ||
84 | #define MS_CALLBACK | ||
85 | #endif | ||
86 | |||
87 | static void MS_CALLBACK dsa_cb(int p, int n, void *arg); | ||
88 | |||
89 | /* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to | ||
90 | * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */ | ||
91 | static unsigned char seed[20]={ | ||
92 | 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, | ||
93 | 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, | ||
94 | }; | ||
95 | |||
96 | static unsigned char out_p[]={ | ||
97 | 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa, | ||
98 | 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb, | ||
99 | 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7, | ||
100 | 0xcb,0xb8,0x32,0x4f,0x0d,0x78,0x82,0xe5, | ||
101 | 0xd0,0x76,0x2f,0xc5,0xb7,0x21,0x0e,0xaf, | ||
102 | 0xc2,0xe9,0xad,0xac,0x32,0xab,0x7a,0xac, | ||
103 | 0x49,0x69,0x3d,0xfb,0xf8,0x37,0x24,0xc2, | ||
104 | 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91, | ||
105 | }; | ||
106 | |||
107 | static unsigned char out_q[]={ | ||
108 | 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee, | ||
109 | 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e, | ||
110 | 0xda,0xce,0x91,0x5f, | ||
111 | }; | ||
112 | |||
113 | static unsigned char out_g[]={ | ||
114 | 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13, | ||
115 | 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00, | ||
116 | 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb, | ||
117 | 0x3b,0xff,0x10,0xf3,0x99,0xce,0x2c,0x2e, | ||
118 | 0x71,0xcb,0x9d,0xe5,0xfa,0x24,0xba,0xbf, | ||
119 | 0x58,0xe5,0xb7,0x95,0x21,0x92,0x5c,0x9c, | ||
120 | 0xc4,0x2e,0x9f,0x6f,0x46,0x4b,0x08,0x8c, | ||
121 | 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, | ||
122 | }; | ||
123 | |||
124 | static const unsigned char str1[]="12345678901234567890"; | ||
125 | |||
126 | static const char rnd_seed[] = "string to make the random number generator think it has entropy"; | ||
127 | |||
128 | static BIO *bio_err=NULL; | ||
129 | |||
130 | int main(int argc, char **argv) | ||
131 | { | ||
132 | DSA *dsa=NULL; | ||
133 | int counter,ret=0,i,j; | ||
134 | unsigned char buf[256]; | ||
135 | unsigned long h; | ||
136 | unsigned char sig[256]; | ||
137 | unsigned int siglen; | ||
138 | |||
139 | if (bio_err == NULL) | ||
140 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
141 | |||
142 | CRYPTO_malloc_debug_init(); | ||
143 | CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); | ||
144 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
145 | |||
146 | ERR_load_crypto_strings(); | ||
147 | RAND_seed(rnd_seed, sizeof rnd_seed); | ||
148 | |||
149 | BIO_printf(bio_err,"test generation of DSA parameters\n"); | ||
150 | |||
151 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); | ||
152 | |||
153 | BIO_printf(bio_err,"seed\n"); | ||
154 | for (i=0; i<20; i+=4) | ||
155 | { | ||
156 | BIO_printf(bio_err,"%02X%02X%02X%02X ", | ||
157 | seed[i],seed[i+1],seed[i+2],seed[i+3]); | ||
158 | } | ||
159 | BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h); | ||
160 | |||
161 | if (dsa == NULL) goto end; | ||
162 | DSA_print(bio_err,dsa,0); | ||
163 | if (counter != 105) | ||
164 | { | ||
165 | BIO_printf(bio_err,"counter should be 105\n"); | ||
166 | goto end; | ||
167 | } | ||
168 | if (h != 2) | ||
169 | { | ||
170 | BIO_printf(bio_err,"h should be 2\n"); | ||
171 | goto end; | ||
172 | } | ||
173 | |||
174 | i=BN_bn2bin(dsa->q,buf); | ||
175 | j=sizeof(out_q); | ||
176 | if ((i != j) || (memcmp(buf,out_q,i) != 0)) | ||
177 | { | ||
178 | BIO_printf(bio_err,"q value is wrong\n"); | ||
179 | goto end; | ||
180 | } | ||
181 | |||
182 | i=BN_bn2bin(dsa->p,buf); | ||
183 | j=sizeof(out_p); | ||
184 | if ((i != j) || (memcmp(buf,out_p,i) != 0)) | ||
185 | { | ||
186 | BIO_printf(bio_err,"p value is wrong\n"); | ||
187 | goto end; | ||
188 | } | ||
189 | |||
190 | i=BN_bn2bin(dsa->g,buf); | ||
191 | j=sizeof(out_g); | ||
192 | if ((i != j) || (memcmp(buf,out_g,i) != 0)) | ||
193 | { | ||
194 | BIO_printf(bio_err,"g value is wrong\n"); | ||
195 | goto end; | ||
196 | } | ||
197 | DSA_generate_key(dsa); | ||
198 | DSA_sign(0, str1, 20, sig, &siglen, dsa); | ||
199 | if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1) | ||
200 | ret=1; | ||
201 | end: | ||
202 | if (!ret) | ||
203 | ERR_print_errors(bio_err); | ||
204 | if (dsa != NULL) DSA_free(dsa); | ||
205 | CRYPTO_cleanup_all_ex_data(); | ||
206 | ERR_remove_state(0); | ||
207 | ERR_free_strings(); | ||
208 | CRYPTO_mem_leaks(bio_err); | ||
209 | if (bio_err != NULL) | ||
210 | { | ||
211 | BIO_free(bio_err); | ||
212 | bio_err = NULL; | ||
213 | } | ||
214 | EXIT(!ret); | ||
215 | return(0); | ||
216 | } | ||
217 | |||
218 | static int cb_exit(int ec) | ||
219 | { | ||
220 | EXIT(ec); | ||
221 | return(0); /* To keep some compilers quiet */ | ||
222 | } | ||
223 | |||
224 | static void MS_CALLBACK dsa_cb(int p, int n, void *arg) | ||
225 | { | ||
226 | char c='*'; | ||
227 | static int ok=0,num=0; | ||
228 | |||
229 | if (p == 0) { c='.'; num++; }; | ||
230 | if (p == 1) c='+'; | ||
231 | if (p == 2) { c='*'; ok++; } | ||
232 | if (p == 3) c='\n'; | ||
233 | BIO_write(arg,&c,1); | ||
234 | (void)BIO_flush(arg); | ||
235 | |||
236 | if (!ok && (p == 0) && (num > 1)) | ||
237 | { | ||
238 | BIO_printf((BIO *)arg,"error in dsatest\n"); | ||
239 | cb_exit(1); | ||
240 | } | ||
241 | } | ||
242 | #endif | ||
diff --git a/src/lib/libcrypto/dsa/fips186a.txt b/src/lib/libcrypto/dsa/fips186a.txt new file mode 100644 index 0000000000..3a2e0a0d51 --- /dev/null +++ b/src/lib/libcrypto/dsa/fips186a.txt | |||
@@ -0,0 +1,122 @@ | |||
1 | The origional FIPE 180 used SHA-0 (FIPS 180) for its appendix 5 | ||
2 | examples. This is an updated version that uses SHA-1 (FIPS 180-1) | ||
3 | supplied to me by Wei Dai | ||
4 | -- | ||
5 | APPENDIX 5. EXAMPLE OF THE DSA | ||
6 | |||
7 | |||
8 | This appendix is for informational purposes only and is not required to meet | ||
9 | the standard. | ||
10 | |||
11 | Let L = 512 (size of p). The values in this example are expressed in | ||
12 | hexadecimal notation. The p and q given here were generated by the prime | ||
13 | generation standard described in appendix 2 using the 160-bit SEED: | ||
14 | |||
15 | d5014e4b 60ef2ba8 b6211b40 62ba3224 e0427dd3 | ||
16 | |||
17 | With this SEED, the algorithm found p and q when the counter was at 105. | ||
18 | |||
19 | x was generated by the algorithm described in appendix 3, section 3.1, using | ||
20 | the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit XSEED: | ||
21 | |||
22 | XSEED = | ||
23 | |||
24 | bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6 | ||
25 | |||
26 | t = | ||
27 | 67452301 EFCDAB89 98BADCFE 10325476 C3D2E1F0 | ||
28 | |||
29 | x = G(t,XSEED) mod q | ||
30 | |||
31 | k was generated by the algorithm described in appendix 3, section 3.2, using | ||
32 | the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit KSEED: | ||
33 | |||
34 | KSEED = | ||
35 | |||
36 | 687a66d9 0648f993 867e121f 4ddf9ddb 01205584 | ||
37 | |||
38 | t = | ||
39 | EFCDAB89 98BADCFE 10325476 C3D2E1F0 67452301 | ||
40 | |||
41 | k = G(t,KSEED) mod q | ||
42 | |||
43 | Finally: | ||
44 | |||
45 | h = 2 | ||
46 | |||
47 | p = | ||
48 | 8df2a494 492276aa 3d25759b b06869cb eac0d83a fb8d0cf7 | ||
49 | cbb8324f 0d7882e5 d0762fc5 b7210eaf c2e9adac 32ab7aac | ||
50 | 49693dfb f83724c2 ec0736ee 31c80291 | ||
51 | |||
52 | |||
53 | q = | ||
54 | c773218c 737ec8ee 993b4f2d ed30f48e dace915f | ||
55 | |||
56 | |||
57 | g = | ||
58 | 626d0278 39ea0a13 413163a5 5b4cb500 299d5522 956cefcb | ||
59 | 3bff10f3 99ce2c2e 71cb9de5 fa24babf 58e5b795 21925c9c | ||
60 | c42e9f6f 464b088c c572af53 e6d78802 | ||
61 | |||
62 | |||
63 | x = | ||
64 | 2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614 | ||
65 | |||
66 | |||
67 | k = | ||
68 | 358dad57 1462710f 50e254cf 1a376b2b deaadfbf | ||
69 | |||
70 | |||
71 | kinv = | ||
72 | |||
73 | 0d516729 8202e49b 4116ac10 4fc3f415 ae52f917 | ||
74 | |||
75 | M = ASCII form of "abc" (See FIPS PUB 180-1, Appendix A) | ||
76 | |||
77 | SHA(M) = | ||
78 | |||
79 | a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d | ||
80 | |||
81 | |||
82 | y = | ||
83 | |||
84 | 19131871 d75b1612 a819f29d 78d1b0d7 346f7aa7 7bb62a85 | ||
85 | 9bfd6c56 75da9d21 2d3a36ef 1672ef66 0b8c7c25 5cc0ec74 | ||
86 | 858fba33 f44c0669 9630a76b 030ee333 | ||
87 | |||
88 | |||
89 | r = | ||
90 | 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0 | ||
91 | |||
92 | s = | ||
93 | 41e2345f 1f56df24 58f426d1 55b4ba2d b6dcd8c8 | ||
94 | |||
95 | |||
96 | w = | ||
97 | 9df4ece5 826be95f ed406d41 b43edc0b 1c18841b | ||
98 | |||
99 | |||
100 | u1 = | ||
101 | bf655bd0 46f0b35e c791b004 804afcbb 8ef7d69d | ||
102 | |||
103 | |||
104 | u2 = | ||
105 | 821a9263 12e97ade abcc8d08 2b527897 8a2df4b0 | ||
106 | |||
107 | |||
108 | gu1 mod p = | ||
109 | |||
110 | 51b1bf86 7888e5f3 af6fb476 9dd016bc fe667a65 aafc2753 | ||
111 | 9063bd3d 2b138b4c e02cc0c0 2ec62bb6 7306c63e 4db95bbf | ||
112 | 6f96662a 1987a21b e4ec1071 010b6069 | ||
113 | |||
114 | |||
115 | yu2 mod p = | ||
116 | |||
117 | 8b510071 2957e950 50d6b8fd 376a668e 4b0d633c 1e46e665 | ||
118 | 5c611a72 e2b28483 be52c74d 4b30de61 a668966e dc307a67 | ||
119 | c19441f4 22bf3c34 08aeba1f 0a4dbec7 | ||
120 | |||
121 | v = | ||
122 | 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0 | ||