Compare commits
755 Commits
OpenSSL_1_
...
OpenSSL_1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94f4166017 | ||
|
|
a74c9c9e10 | ||
|
|
d2a3c4497f | ||
|
|
a129850922 | ||
|
|
c3f5d3d93a | ||
|
|
c5ea65b157 | ||
|
|
58b86e4235 | ||
|
|
a466be6243 | ||
|
|
60327ce41a | ||
|
|
2d4d9623da | ||
|
|
6b3b6beaa1 | ||
|
|
7743be3aac | ||
|
|
b709f8ef54 | ||
|
|
c74ce24cd2 | ||
|
|
612566e752 | ||
|
|
3ecce3dbeb | ||
|
|
71eca86c30 | ||
|
|
dd1e3bd8d4 | ||
|
|
c55fef76f7 | ||
|
|
eb70d4407f | ||
|
|
b335b5440a | ||
|
|
a8eeedb603 | ||
|
|
b3d8de7903 | ||
|
|
0413ea5801 | ||
|
|
2f6fba6772 | ||
|
|
d69acceca9 | ||
|
|
aff78bb39a | ||
|
|
104c032b7b | ||
|
|
b347341c75 | ||
|
|
c00f8d697a | ||
|
|
b07e4f2f46 | ||
|
|
ced6dc5cef | ||
|
|
bf2d129194 | ||
|
|
d59d0b7c21 | ||
|
|
dbd512e1b7 | ||
|
|
fcc6f699e3 | ||
|
|
7078d93307 | ||
|
|
a2317c3ffd | ||
|
|
75917fac8e | ||
|
|
295fd057ce | ||
|
|
8c4e09f74f | ||
|
|
e32cbae224 | ||
|
|
f6fd8db2a4 | ||
|
|
d65db21976 | ||
|
|
8acf1ff4b4 | ||
|
|
8b41df41c2 | ||
|
|
c32ebefaa8 | ||
|
|
ed0dc93d89 | ||
|
|
5a32dd8930 | ||
|
|
130ebe34c8 | ||
|
|
7612511b3b | ||
|
|
19a28a8aa3 | ||
|
|
fc213217e8 | ||
|
|
7198c5af1f | ||
|
|
40632f6b77 | ||
|
|
038bec784e | ||
|
|
f407eec799 | ||
|
|
bd618bebbe | ||
|
|
e2884b3e9a | ||
|
|
c41e242e5c | ||
|
|
9578319394 | ||
|
|
16eaca2c79 | ||
|
|
3bff195dca | ||
|
|
41cf2d2518 | ||
|
|
e0d4272a58 | ||
|
|
41c373fa3e | ||
|
|
7f6e09b531 | ||
|
|
e2f06800bc | ||
|
|
1180833643 | ||
|
|
130eed01cc | ||
|
|
2ded87355f | ||
|
|
b1ae02e2ff | ||
|
|
381417089a | ||
|
|
984a30423d | ||
|
|
2ad673c611 | ||
|
|
0693dd954e | ||
|
|
9071b36d9a | ||
|
|
eb6af20d2e | ||
|
|
8087969c5b | ||
|
|
cb437c66d1 | ||
|
|
40b0d0765e | ||
|
|
41235f30fb | ||
|
|
130c15ef5a | ||
|
|
2cc5142fb1 | ||
|
|
d451ece4e7 | ||
|
|
1121ba1b74 | ||
|
|
1fb039fde2 | ||
|
|
3073927e42 | ||
|
|
b6c2029931 | ||
|
|
45d010255f | ||
|
|
7e569022c5 | ||
|
|
50f1b47c7f | ||
|
|
5572bc4e2f | ||
|
|
729d334106 | ||
|
|
cacdfcb247 | ||
|
|
519ad9b384 | ||
|
|
7b2d785d20 | ||
|
|
f2d678e6e8 | ||
|
|
448e9b7cf1 | ||
|
|
2c4c9867e7 | ||
|
|
a99540a6de | ||
|
|
9614ed695d | ||
|
|
aabfee601e | ||
|
|
cee1d9e02f | ||
|
|
285f7fb0f9 | ||
|
|
ede90b1121 | ||
|
|
5e7329d156 | ||
|
|
9f1979b94a | ||
|
|
3fcf327e26 | ||
|
|
3f4742b48c | ||
|
|
c4f01c533b | ||
|
|
b7a8550988 | ||
|
|
e775891708 | ||
|
|
ae6fbb5df0 | ||
|
|
f9c1f03754 | ||
|
|
50701af9d5 | ||
|
|
1d6af3d430 | ||
|
|
392fd8f89c | ||
|
|
802db0fab2 | ||
|
|
2f972419a3 | ||
|
|
a05a2c67ef | ||
|
|
e34140620e | ||
|
|
acd9121085 | ||
|
|
b17d6b8d1d | ||
|
|
b9fa413a08 | ||
|
|
4abe148444 | ||
|
|
04d6940436 | ||
|
|
8511b5f594 | ||
|
|
546d6760b9 | ||
|
|
ccbb8d5e95 | ||
|
|
d7d7e7b038 | ||
|
|
80b6d97585 | ||
|
|
ff64ab32ae | ||
|
|
fc9c9e47f7 | ||
|
|
68e6ac4379 | ||
|
|
e34b7e99fd | ||
|
|
a32ba49352 | ||
|
|
3a0c71541b | ||
|
|
adc6bd73e3 | ||
|
|
8c6d8c2a49 | ||
|
|
53a8f8c26d | ||
|
|
bf4863b3f5 | ||
|
|
8f68678989 | ||
|
|
57c4e42d75 | ||
|
|
ff672cf8dd | ||
|
|
d43b040773 | ||
|
|
422c8c36e5 | ||
|
|
b76310ba74 | ||
|
|
c012f6e576 | ||
|
|
cf6d55961c | ||
|
|
3aa1b1ccbb | ||
|
|
3dcae82fa9 | ||
|
|
86b81ecb73 | ||
|
|
c43dc3dd77 | ||
|
|
e5eab8a199 | ||
|
|
7bab6eb6f0 | ||
|
|
87d9526d0c | ||
|
|
36982f056a | ||
|
|
c97ec5631b | ||
|
|
fdb0d5dd8f | ||
|
|
81b6dfe40d | ||
|
|
bc35b8e435 | ||
|
|
6859f3fc12 | ||
|
|
8b2d5cc4a7 | ||
|
|
74184b6f21 | ||
|
|
6416aed586 | ||
|
|
2a1b7bd380 | ||
|
|
4bba0bda61 | ||
|
|
27baa8317a | ||
|
|
1abfa78a8b | ||
|
|
edc687ba0f | ||
|
|
ff0bdbed85 | ||
|
|
dc4bdf592f | ||
|
|
b03d0513d0 | ||
|
|
0de70011ad | ||
|
|
220d1e5353 | ||
|
|
ca44f72938 | ||
|
|
18f49508a5 | ||
|
|
5c50462e1e | ||
|
|
a257865303 | ||
|
|
60adefa610 | ||
|
|
b5dde6bcc6 | ||
|
|
024dbfd44c | ||
|
|
233069f8db | ||
|
|
c76d6922b1 | ||
|
|
3241496144 | ||
|
|
63fe69c12e | ||
|
|
a4947e4e06 | ||
|
|
262f1c524e | ||
|
|
bd80d0229c | ||
|
|
163d794845 | ||
|
|
0b33466b3f | ||
|
|
bed27f4db3 | ||
|
|
738a224bd0 | ||
|
|
044f8ca87d | ||
|
|
45ee08d99b | ||
|
|
5ff68e8f6d | ||
|
|
f14a4a861d | ||
|
|
f596e3c491 | ||
|
|
9fb523adce | ||
|
|
cecf4d98d0 | ||
|
|
070e40e2f5 | ||
|
|
d757097bbc | ||
|
|
7b112c2766 | ||
|
|
03ee8c2ed7 | ||
|
|
3495842bb0 | ||
|
|
face65dab8 | ||
|
|
e41a49c625 | ||
|
|
3a55a42bff | ||
|
|
72550c52ed | ||
|
|
a9d0c56de1 | ||
|
|
469bcb0c24 | ||
|
|
43ce9cdde9 | ||
|
|
011f89893c | ||
|
|
958608ca1c | ||
|
|
1aecb23f5b | ||
|
|
9ed6fba2b4 | ||
|
|
df5c435c0b | ||
|
|
1ebaf97c44 | ||
|
|
c8c6914aac | ||
|
|
c99028f252 | ||
|
|
90d8c5862b | ||
|
|
2d5dd00f9e | ||
|
|
cb52183836 | ||
|
|
ab3b624b0c | ||
|
|
7c81de9a91 | ||
|
|
4dfac659ff | ||
|
|
66e0f9db08 | ||
|
|
a2eef41993 | ||
|
|
9a8646510b | ||
|
|
fa03d0117a | ||
|
|
03614034e9 | ||
|
|
444b1d416b | ||
|
|
4055ca1f9e | ||
|
|
7a216dfee5 | ||
|
|
a78b21fc67 | ||
|
|
a808002bc3 | ||
|
|
2fc368c111 | ||
|
|
6ed3af7d50 | ||
|
|
d037e0d30c | ||
|
|
51cb950904 | ||
|
|
4bfa88bb4c | ||
|
|
9d1e475db6 | ||
|
|
3e792793f6 | ||
|
|
ac5cb33356 | ||
|
|
aaf74259ec | ||
|
|
ecf9ceb90d | ||
|
|
5c4ff8ad37 | ||
|
|
dc427fc8e2 | ||
|
|
e1e6c4dae7 | ||
|
|
1747fd1cc6 | ||
|
|
a119822b90 | ||
|
|
8c798690ce | ||
|
|
ea6bf26657 | ||
|
|
4a26fd6e3b | ||
|
|
dddb38834e | ||
|
|
af7d6b936b | ||
|
|
a64b8786b5 | ||
|
|
25f93585a7 | ||
|
|
0d5a49e150 | ||
|
|
5c49a98c5e | ||
|
|
869772ff08 | ||
|
|
f2edf3181e | ||
|
|
d6dc5c506a | ||
|
|
eebd5e5dd7 | ||
|
|
868b266451 | ||
|
|
3fa23ff0f1 | ||
|
|
c275fb091e | ||
|
|
90c341c601 | ||
|
|
52d0e1ca4e | ||
|
|
c6f3386577 | ||
|
|
cf65a07256 | ||
|
|
051dc9db2b | ||
|
|
93a886b45a | ||
|
|
ec19082ecc | ||
|
|
0eff7c7c88 | ||
|
|
6c4b3514d7 | ||
|
|
d84cca7447 | ||
|
|
3a8b23bfd9 | ||
|
|
63fe322160 | ||
|
|
c808798013 | ||
|
|
379f21ce5c | ||
|
|
4f3b1b3eb9 | ||
|
|
b49df9502e | ||
|
|
4f8a706dc7 | ||
|
|
7560f63909 | ||
|
|
1dfb1b103c | ||
|
|
6e1987ca1d | ||
|
|
d307176931 | ||
|
|
c391a74266 | ||
|
|
65a87d3cc3 | ||
|
|
b60b9e7afe | ||
|
|
919834dc84 | ||
|
|
efc17286f8 | ||
|
|
acec5a6244 | ||
|
|
68039af3e7 | ||
|
|
da1247d653 | ||
|
|
052d0358f2 | ||
|
|
1b6ab411d3 | ||
|
|
d88d98edd3 | ||
|
|
741c9959f6 | ||
|
|
7c23127fde | ||
|
|
8b9722a3c0 | ||
|
|
8c149cfd83 | ||
|
|
6da498991c | ||
|
|
86a66deb7e | ||
|
|
9409e18179 | ||
|
|
6a0b803fc0 | ||
|
|
5fa3b54788 | ||
|
|
07df5018be | ||
|
|
1b9a59c36a | ||
|
|
8f89c33451 | ||
|
|
485d7d5904 | ||
|
|
e3720888c7 | ||
|
|
d75e384ff8 | ||
|
|
c340c7a88c | ||
|
|
9ecf6e93af | ||
|
|
a41735288c | ||
|
|
8ae78c6bd9 | ||
|
|
cb3cec4adf | ||
|
|
b0d6f3c58f | ||
|
|
0338648426 | ||
|
|
c7dc404188 | ||
|
|
08853158b6 | ||
|
|
74e0187663 | ||
|
|
bb4aa95c81 | ||
|
|
5117d50b7e | ||
|
|
593605d3ec | ||
|
|
c9ea4df8f9 | ||
|
|
89ff56faf1 | ||
|
|
9855026c43 | ||
|
|
904348a492 | ||
|
|
aaaa18392d | ||
|
|
8c33e40d2e | ||
|
|
0d04af1e72 | ||
|
|
8f17495800 | ||
|
|
95c1a24853 | ||
|
|
08374de10f | ||
|
|
506e70a216 | ||
|
|
0cca92cdd3 | ||
|
|
5b430cfc44 | ||
|
|
171c4da568 | ||
|
|
04611fb0f1 | ||
|
|
df430489cf | ||
|
|
5085e57fb5 | ||
|
|
75b81247a0 | ||
|
|
2c1a5c1039 | ||
|
|
71c34b7f2d | ||
|
|
b0cfaf58ad | ||
|
|
9dc07f04c3 | ||
|
|
f15c16200b | ||
|
|
4e09add6f8 | ||
|
|
355a6236be | ||
|
|
6d7fa9c25c | ||
|
|
82ae22ef4d | ||
|
|
b56bae5126 | ||
|
|
2d3f31e0a1 | ||
|
|
ae74191e38 | ||
|
|
ab8233ab81 | ||
|
|
d5572bdc64 | ||
|
|
e3990db59c | ||
|
|
87d90528ac | ||
|
|
e27711cfdd | ||
|
|
28c08222c0 | ||
|
|
8508a80998 | ||
|
|
7850a8bc04 | ||
|
|
fccec89084 | ||
|
|
6c7fa27404 | ||
|
|
e7f9c08ab8 | ||
|
|
03c8441b14 | ||
|
|
e887c4187e | ||
|
|
933aee6199 | ||
|
|
90e7f983b5 | ||
|
|
f00962aaf3 | ||
|
|
3eccd2e53a | ||
|
|
fcd0e61c24 | ||
|
|
e7a02b24c1 | ||
|
|
cbe6bb54e6 | ||
|
|
23966faca4 | ||
|
|
514f1a7835 | ||
|
|
af908bc48b | ||
|
|
233ebcb543 | ||
|
|
da0c007254 | ||
|
|
01bc7dcafc | ||
|
|
83e2ff8c51 | ||
|
|
e3120586fb | ||
|
|
3941aa12f1 | ||
|
|
0c10cf0ad6 | ||
|
|
62874a5a69 | ||
|
|
8c1f9c56fd | ||
|
|
75063c1527 | ||
|
|
5de583aa91 | ||
|
|
a0675d8149 | ||
|
|
a7e9ed95ec | ||
|
|
615d0edf1f | ||
|
|
e775755dec | ||
|
|
a1bf7de5a7 | ||
|
|
047c02e8db | ||
|
|
c92989d2b7 | ||
|
|
039e7875ff | ||
|
|
48b7b96bd0 | ||
|
|
747b7a636a | ||
|
|
635f56fabd | ||
|
|
c617bc0054 | ||
|
|
d215724753 | ||
|
|
9c1ee1bed5 | ||
|
|
14ef63c15e | ||
|
|
5a456140c1 | ||
|
|
1ff546737b | ||
|
|
56f0b25754 | ||
|
|
b0f78dc018 | ||
|
|
1f2d194acf | ||
|
|
aacfb2a2c6 | ||
|
|
0ba304dd31 | ||
|
|
8eb2da5fbb | ||
|
|
d1896e8ccd | ||
|
|
0edcb7a556 | ||
|
|
ecc2c5d81a | ||
|
|
441dec8e9f | ||
|
|
4f566c360b | ||
|
|
e10cd58090 | ||
|
|
5c8ae6d93e | ||
|
|
e72f7677bf | ||
|
|
e815d72b1f | ||
|
|
ddf918673d | ||
|
|
8517d0c00d | ||
|
|
8659dc73f4 | ||
|
|
07464787a8 | ||
|
|
e9a3aa9721 | ||
|
|
a8cc9f1873 | ||
|
|
f25c3c0542 | ||
|
|
4e5b9645e8 | ||
|
|
04347839ea | ||
|
|
e14b8410ca | ||
|
|
2a1ab7b438 | ||
|
|
dd1e4fbcc0 | ||
|
|
3f84d34c37 | ||
|
|
d7e429b91d | ||
|
|
155ef13c67 | ||
|
|
c3466040ec | ||
|
|
2d9be79407 | ||
|
|
2e4b7eede3 | ||
|
|
e1dee801b9 | ||
|
|
3c53fd892c | ||
|
|
c46990b13b | ||
|
|
1510b1f4c2 | ||
|
|
f8a69166ed | ||
|
|
b9eef98883 | ||
|
|
ae5c1ca377 | ||
|
|
188ab7df98 | ||
|
|
2e3d02fe1a | ||
|
|
3a3a1af1da | ||
|
|
0ced72c608 | ||
|
|
5584a95490 | ||
|
|
a3e66779d3 | ||
|
|
919eab8a8b | ||
|
|
e9baceab5a | ||
|
|
b05561c4b7 | ||
|
|
b7355af421 | ||
|
|
0462eedf5e | ||
|
|
82425f2c28 | ||
|
|
af010edd55 | ||
|
|
5966f4d973 | ||
|
|
eeb486a5f4 | ||
|
|
d7f55e76f2 | ||
|
|
7d9e781a1d | ||
|
|
e0c21a0b6b | ||
|
|
1dfb4b9400 | ||
|
|
e5cb774323 | ||
|
|
73390e6ba5 | ||
|
|
d91d9acc58 | ||
|
|
820988a0c0 | ||
|
|
1326a64a33 | ||
|
|
e0da2c2ed2 | ||
|
|
fb0a59cc58 | ||
|
|
f5cd3561ba | ||
|
|
115f7fa562 | ||
|
|
c867d87180 | ||
|
|
2a713eadc3 | ||
|
|
2e7900b624 | ||
|
|
f8435919a1 | ||
|
|
1db4354b53 | ||
|
|
3f233a1e77 | ||
|
|
25917e972d | ||
|
|
8812a81bdd | ||
|
|
b17ffba915 | ||
|
|
3619e34f50 | ||
|
|
6924686b78 | ||
|
|
92745f8116 | ||
|
|
17cf9864e0 | ||
|
|
5cfefd3ce3 | ||
|
|
9ccc6f4382 | ||
|
|
3c92471723 | ||
|
|
1a932ae094 | ||
|
|
57912ed329 | ||
|
|
e998f8aeb8 | ||
|
|
e318431e54 | ||
|
|
6a10f38daa | ||
|
|
c095078890 | ||
|
|
c644b83227 | ||
|
|
75f535315a | ||
|
|
7c283d9e97 | ||
|
|
2aa3ef78b6 | ||
|
|
1c0964e87f | ||
|
|
5c8d41be85 | ||
|
|
b286640360 | ||
|
|
75a8ff9263 | ||
|
|
50b5966e57 | ||
|
|
8eb4456f93 | ||
|
|
24c45faba0 | ||
|
|
010ac38a98 | ||
|
|
1c25ed5dbb | ||
|
|
bf1d32e52a | ||
|
|
6c86b69729 | ||
|
|
72dfff2d5e | ||
|
|
3341b820cc | ||
|
|
ede5f6cf74 | ||
|
|
321a9fea75 | ||
|
|
2e00f46b51 | ||
|
|
8c3f868983 | ||
|
|
d03cc94f47 | ||
|
|
5477ff9ba2 | ||
|
|
46b11600b0 | ||
|
|
15387e4ce0 | ||
|
|
49ef33fa34 | ||
|
|
1166323530 | ||
|
|
29113688a1 | ||
|
|
44c970746f | ||
|
|
bc200e691c | ||
|
|
a08f8d73cc | ||
|
|
b52f12b3ba | ||
|
|
78b5d89ddf | ||
|
|
b79df62eff | ||
|
|
e3c76874ad | ||
|
|
4347394a27 | ||
|
|
53bb723834 | ||
|
|
684a2264c5 | ||
|
|
fde8dc1798 | ||
|
|
3c87a2bdfa | ||
|
|
1520e6c084 | ||
|
|
2001129f09 | ||
|
|
a50ecaee56 | ||
|
|
67d9dcf003 | ||
|
|
79dcae32ef | ||
|
|
ccf6a19e2d | ||
|
|
28fbbe3b1b | ||
|
|
8d2dbe6ac0 | ||
|
|
ba8bdea771 | ||
|
|
3d9916298a | ||
|
|
87054c4f0e | ||
|
|
6660baee66 | ||
|
|
25d4c9254c | ||
|
|
44adfeb6c0 | ||
|
|
5ff2ef79e6 | ||
|
|
b762acadeb | ||
|
|
7d779eefb4 | ||
|
|
35b7757f9b | ||
|
|
23195e4dcc | ||
|
|
b28fbdfa7d | ||
|
|
a897502cd9 | ||
|
|
8546add692 | ||
|
|
aa5c5eb4c1 | ||
|
|
731abd3bd7 | ||
|
|
7531dd18dc | ||
|
|
04c32cddaa | ||
|
|
623a5e24cb | ||
|
|
bd9fc1d667 | ||
|
|
c550f2e37b | ||
|
|
484f876235 | ||
|
|
c70a1fee71 | ||
|
|
0b362de5f5 | ||
|
|
d312f7be37 | ||
|
|
2b5e5c3d08 | ||
|
|
708454f010 | ||
|
|
f1aec4dec3 | ||
|
|
1c53a72f17 | ||
|
|
9b157602e0 | ||
|
|
67e217c84c | ||
|
|
e6b650df0a | ||
|
|
7b7b667ddc | ||
|
|
70cd3c6b95 | ||
|
|
db05bc512d | ||
|
|
45da1efcdb | ||
|
|
54a0076e94 | ||
|
|
f8cab37bc1 | ||
|
|
2e65277695 | ||
|
|
9a1f59cd31 | ||
|
|
4e72220fd6 | ||
|
|
d65b8b2162 | ||
|
|
5dca1e338c | ||
|
|
5f4cf08864 | ||
|
|
2a2e537983 | ||
|
|
d79fc8da02 | ||
|
|
e04ccbc5cc | ||
|
|
bc946bfb97 | ||
|
|
38680fa466 | ||
|
|
a902b6bd98 | ||
|
|
c5e91a9ae9 | ||
|
|
b5f57f455a | ||
|
|
ad00a52f2d | ||
|
|
e08c7f15b4 | ||
|
|
7469af4484 | ||
|
|
ec76d850af | ||
|
|
cedf19f356 | ||
|
|
1d5f3f4640 | ||
|
|
a060fc3b8e | ||
|
|
bda5153703 | ||
|
|
6f539399ef | ||
|
|
d90bf2ab21 | ||
|
|
02620cfcd5 | ||
|
|
74daafaa94 | ||
|
|
aa963813ed | ||
|
|
9a6aff50ff | ||
|
|
c7d16ac8da | ||
|
|
b626f0396c | ||
|
|
9d2006d8ed | ||
|
|
abf1e32f2f | ||
|
|
fc1e09bf81 | ||
|
|
451cec33df | ||
|
|
16c92916c7 | ||
|
|
988037fe18 | ||
|
|
9a7f80c869 | ||
|
|
507e5c3a61 | ||
|
|
f8b90b5a5d | ||
|
|
dc14441757 | ||
|
|
da8512aaff | ||
|
|
d46a1a6178 | ||
|
|
957c7c0e88 | ||
|
|
3ebe87473c | ||
|
|
0e05b51fe5 | ||
|
|
c759e453bc | ||
|
|
40ce8fca73 | ||
|
|
8e1c33e160 | ||
|
|
13b0cae256 | ||
|
|
6d78a93b5b | ||
|
|
ae92994645 | ||
|
|
c4aa6b041b | ||
|
|
80158304f0 | ||
|
|
f0a069c1a2 | ||
|
|
5b4b9ce976 | ||
|
|
7fbcc2f24a | ||
|
|
e4be79a383 | ||
|
|
658604473f | ||
|
|
86bea6455c | ||
|
|
1e4a6e7b7f | ||
|
|
fd6a72fa1c | ||
|
|
ccffdb3fdc | ||
|
|
74d89b0d93 | ||
|
|
f142a71c3d | ||
|
|
5b7af6de43 | ||
|
|
ae414a0e42 | ||
|
|
a240ea8ab8 | ||
|
|
8b654459be | ||
|
|
93cf058334 | ||
|
|
3e8b4b5055 | ||
|
|
3c56d65a41 | ||
|
|
e51ec51af9 | ||
|
|
ff1c55e983 | ||
|
|
835d104f46 | ||
|
|
aeba1ef352 | ||
|
|
49e9f751a4 | ||
|
|
ff46820da6 | ||
|
|
6fba65e20d | ||
|
|
68d2cf51bc | ||
|
|
19eedffcaf | ||
|
|
4e14996e8a | ||
|
|
8a02a46a5c | ||
|
|
0de5a0feee | ||
|
|
4d321e0767 | ||
|
|
67fda0c12e | ||
|
|
1dded7f7e8 | ||
|
|
482f238069 | ||
|
|
5e145e54cc | ||
|
|
df73e68a43 | ||
|
|
e7c8483891 | ||
|
|
712d523484 | ||
|
|
24547c23ca | ||
|
|
8baf604a39 | ||
|
|
95416ce5b3 | ||
|
|
a56f9a612b | ||
|
|
0ae89cf32e | ||
|
|
7e0c9630a3 | ||
|
|
a6df6702c6 | ||
|
|
f69abd5321 | ||
|
|
fe9ce2b7d6 | ||
|
|
8e7ccf6ff7 | ||
|
|
51b77c0337 | ||
|
|
85d179d4eb | ||
|
|
890f5ada82 | ||
|
|
1cc8410e36 | ||
|
|
6ca7af9ec0 | ||
|
|
bc2c8efc80 | ||
|
|
00bb875240 | ||
|
|
c3cb563d87 | ||
|
|
d6ef8165bb | ||
|
|
564a503b1b | ||
|
|
56eeb1b28c | ||
|
|
068fc255ac | ||
|
|
cc8f2fb917 | ||
|
|
b583ebb7dd | ||
|
|
f897fe4146 | ||
|
|
bb3add20f3 | ||
|
|
48e0f6667b | ||
|
|
32213fb25a | ||
|
|
f6a1939f0f | ||
|
|
94c666479d | ||
|
|
09f17419a6 | ||
|
|
eb8a65db16 | ||
|
|
e6255a7d1e | ||
|
|
65a0f68484 | ||
|
|
e1a7db8fdd | ||
|
|
65331f225a | ||
|
|
64e8dc7981 | ||
|
|
737fe7ea29 | ||
|
|
b344a826ad | ||
|
|
bc0f56d6d7 | ||
|
|
3a89e9f106 | ||
|
|
79e75e04ea | ||
|
|
c3cb069108 | ||
|
|
cdb41713a4 | ||
|
|
491734eb21 | ||
|
|
4e891a191d | ||
|
|
b73a69a9c2 | ||
|
|
e811eff5a9 | ||
|
|
1d0c47fd55 | ||
|
|
e46c807e4f | ||
|
|
c132ca95c0 | ||
|
|
6b870763ac | ||
|
|
5505818199 | ||
|
|
7493bcc659 | ||
|
|
a068a1d0e3 | ||
|
|
37b16c84bb | ||
|
|
0ac89e8f54 | ||
|
|
7e65b21a24 | ||
|
|
736d69750d | ||
|
|
0cb9dbed4e | ||
|
|
6cfccfec33 | ||
|
|
c523eb98d1 | ||
|
|
0ffa49970b | ||
|
|
8cd2ea552e | ||
|
|
3f0becbf75 | ||
|
|
1b0ae81f4a | ||
|
|
54543b954c | ||
|
|
5e2187f7ee | ||
|
|
7b087bf4a9 | ||
|
|
9df9c9d102 | ||
|
|
7e8b5493a4 | ||
|
|
265863c6a4 | ||
|
|
2fee1e0666 | ||
|
|
b4ff166cbc | ||
|
|
861a0722c2 | ||
|
|
b1cef8d984 | ||
|
|
b911523977 | ||
|
|
247c3f6049 | ||
|
|
bd5770c6b1 |
82
.gitignore
vendored
Normal file
82
.gitignore
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
# Object files
|
||||
*.o
|
||||
|
||||
# editor artefacts
|
||||
*.swp
|
||||
.#*
|
||||
#*#
|
||||
*~
|
||||
|
||||
# Top level excludes
|
||||
/Makefile.bak
|
||||
/Makefile
|
||||
/MINFO
|
||||
/*.a
|
||||
/include
|
||||
/*.pc
|
||||
/rehash.time
|
||||
/inc.*
|
||||
/makefile.*
|
||||
/out.*
|
||||
/tmp.*
|
||||
|
||||
# Most *.c files under test/ are symlinks
|
||||
/test/*.c
|
||||
# Apart from these
|
||||
!/test/asn1test.c
|
||||
!/test/methtest.c
|
||||
!/test/dummytest.c
|
||||
!/test/igetest.c
|
||||
!/test/r160test.c
|
||||
!/test/fips_algvs.c
|
||||
|
||||
/test/*.ss
|
||||
/test/*.srl
|
||||
/test/.rnd
|
||||
/test/test*.pem
|
||||
/test/newkey.pem
|
||||
|
||||
# Certificate symbolic links
|
||||
*.0
|
||||
|
||||
# Links under apps
|
||||
/apps/CA.pl
|
||||
/apps/md4.c
|
||||
|
||||
|
||||
# Auto generated headers
|
||||
/crypto/buildinf.h
|
||||
/crypto/opensslconf.h
|
||||
|
||||
# Auto generated assembly language source files
|
||||
*.s
|
||||
!/crypto/bn/asm/pa-risc2.s
|
||||
!/crypto/bn/asm/pa-risc2W.s
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
/test/sha256t
|
||||
/test/sha512t
|
||||
/test/*test
|
||||
/test/fips_aesavs
|
||||
/test/fips_desmovs
|
||||
/test/fips_dhvs
|
||||
/test/fips_drbgvs
|
||||
/test/fips_dssvs
|
||||
/test/fips_ecdhvs
|
||||
/test/fips_ecdsavs
|
||||
/test/fips_rngvs
|
||||
/test/fips_test_suite
|
||||
*.so*
|
||||
*.dylib*
|
||||
*.dll*
|
||||
# Exceptions
|
||||
!/test/bctest
|
||||
!/crypto/des/times/486-50.sol
|
||||
|
||||
# Misc auto generated files
|
||||
/tools/c_rehash
|
||||
/test/evptests.txt
|
||||
lib
|
||||
Makefile.save
|
||||
*.bak
|
||||
590
CHANGES
590
CHANGES
@@ -2,6 +2,444 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.1f and 1.0.2 [xx XXX xxxx]
|
||||
|
||||
*) Use algorithm specific chains in SSL_CTX_use_certificate_chain_file():
|
||||
this fixes a limiation in previous versions of OpenSSL.
|
||||
[Steve Henson]
|
||||
|
||||
*) TLS pad extension: draft-agl-tls-padding-02
|
||||
|
||||
Workaround for the "TLS hang bug" (see FAQ and PR#2771): if the
|
||||
TLS client Hello record length value would otherwise be > 255 and
|
||||
less that 512 pad with a dummy extension containing zeroes so it
|
||||
is at least 512 bytes long.
|
||||
|
||||
To enable it use an unused extension number (for example chrome uses
|
||||
35655) using:
|
||||
|
||||
e.g. -DTLSEXT_TYPE_padding=35655
|
||||
|
||||
Since the extension is ignored the actual number doesn't matter as long
|
||||
as it doesn't clash with any existing extension.
|
||||
|
||||
This will be updated when the extension gets an official number.
|
||||
|
||||
[Adam Langley, Steve Henson]
|
||||
|
||||
*) Extended RSA OAEP support via EVP_PKEY API. Options to specify digest,
|
||||
MGF1 digest and OAEP label.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add callbacks supporting generation and retrieval of supplemental
|
||||
data entries.
|
||||
[Scott Deboy <sdeboy@apache.org>, Trevor Perrin and Ben Laurie]
|
||||
|
||||
*) Add EVP support for key wrapping algorithms, to avoid problems with
|
||||
existing code the flag EVP_CIPHER_CTX_WRAP_ALLOW has to be set in
|
||||
the EVP_CIPHER_CTX or an error is returned. Add AES and DES3 wrap
|
||||
algorithms and include tests cases.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add functions to allocate and set the fields of an ECDSA_METHOD
|
||||
structure.
|
||||
[Douglas E. Engert, Steve Henson]
|
||||
|
||||
*) Add option SSL_OP_SAFARI_ECDHE_ECDSA_BUG (part of SSL_OP_ALL) which
|
||||
avoids preferring ECDHE-ECDSA ciphers when the client appears to be
|
||||
Safari on OS X. Safari on OS X 10.8..10.8.3 advertises support for
|
||||
several ECDHE-ECDSA ciphers, but fails to negotiate them. The bug
|
||||
is fixed in OS X 10.8.4, but Apple have ruled out both hot fixing
|
||||
10.8..10.8.3 and forcing users to upgrade to 10.8.4 or newer.
|
||||
[Rob Stradling, Adam Langley]
|
||||
|
||||
*) New functions OPENSSL_gmtime_diff and ASN1_TIME_diff to find the
|
||||
difference in days and seconds between two tm or ASN1_TIME structures.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add -rev test option to s_server to just reverse order of characters
|
||||
received by client and send back to server. Also prints an abbreviated
|
||||
summary of the connection parameters.
|
||||
[Steve Henson]
|
||||
|
||||
*) New option -brief for s_client and s_server to print out a brief summary
|
||||
of connection parameters.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add callbacks for arbitrary TLS extensions.
|
||||
[Trevor Perrin <trevp@trevp.net> and Ben Laurie]
|
||||
|
||||
*) New option -crl_download in several openssl utilities to download CRLs
|
||||
from CRLDP extension in certificates.
|
||||
[Steve Henson]
|
||||
|
||||
*) New options -CRL and -CRLform for s_client and s_server for CRLs.
|
||||
[Steve Henson]
|
||||
|
||||
*) New function X509_CRL_diff to generate a delta CRL from the difference
|
||||
of two full CRLs. Add support to "crl" utility.
|
||||
[Steve Henson]
|
||||
|
||||
*) New functions to set lookup_crls function and to retrieve
|
||||
X509_STORE from X509_STORE_CTX.
|
||||
[Steve Henson]
|
||||
|
||||
*) Print out deprecated issuer and subject unique ID fields in
|
||||
certificates.
|
||||
[Steve Henson]
|
||||
|
||||
*) Extend OCSP I/O functions so they can be used for simple general purpose
|
||||
HTTP as well as OCSP. New wrapper function which can be used to download
|
||||
CRLs using the OCSP API.
|
||||
[Steve Henson]
|
||||
|
||||
*) Delegate command line handling in s_client/s_server to SSL_CONF APIs.
|
||||
[Steve Henson]
|
||||
|
||||
*) SSL_CONF* functions. These provide a common framework for application
|
||||
configuration using configuration files or command lines.
|
||||
[Steve Henson]
|
||||
|
||||
*) SSL/TLS tracing code. This parses out SSL/TLS records using the
|
||||
message callback and prints the results. Needs compile time option
|
||||
"enable-ssl-trace". New options to s_client and s_server to enable
|
||||
tracing.
|
||||
[Steve Henson]
|
||||
|
||||
*) New ctrl and macro to retrieve supported points extensions.
|
||||
Print out extension in s_server and s_client.
|
||||
[Steve Henson]
|
||||
|
||||
*) New functions to retrieve certificate signature and signature
|
||||
OID NID.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add functions to retrieve and manipulate the raw cipherlist sent by a
|
||||
client to OpenSSL.
|
||||
[Steve Henson]
|
||||
|
||||
*) New Suite B modes for TLS code. These use and enforce the requirements
|
||||
of RFC6460: restrict ciphersuites, only permit Suite B algorithms and
|
||||
only use Suite B curves. The Suite B modes can be set by using the
|
||||
strings "SUITEB128", "SUITEB192" or "SUITEB128ONLY" for the cipherstring.
|
||||
[Steve Henson]
|
||||
|
||||
*) New chain verification flags for Suite B levels of security. Check
|
||||
algorithms are acceptable when flags are set in X509_verify_cert.
|
||||
[Steve Henson]
|
||||
|
||||
*) Make tls1_check_chain return a set of flags indicating checks passed
|
||||
by a certificate chain. Add additional tests to handle client
|
||||
certificates: checks for matching certificate type and issuer name
|
||||
comparison.
|
||||
[Steve Henson]
|
||||
|
||||
*) If an attempt is made to use a signature algorithm not in the peer
|
||||
preference list abort the handshake. If client has no suitable
|
||||
signature algorithms in response to a certificate request do not
|
||||
use the certificate.
|
||||
[Steve Henson]
|
||||
|
||||
*) If server EC tmp key is not in client preference list abort handshake.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add support for certificate stores in CERT structure. This makes it
|
||||
possible to have different stores per SSL structure or one store in
|
||||
the parent SSL_CTX. Include distint stores for certificate chain
|
||||
verification and chain building. New ctrl SSL_CTRL_BUILD_CERT_CHAIN
|
||||
to build and store a certificate chain in CERT structure: returing
|
||||
an error if the chain cannot be built: this will allow applications
|
||||
to test if a chain is correctly configured.
|
||||
|
||||
Note: if the CERT based stores are not set then the parent SSL_CTX
|
||||
store is used to retain compatibility with existing behaviour.
|
||||
|
||||
[Steve Henson]
|
||||
|
||||
*) New function ssl_set_client_disabled to set a ciphersuite disabled
|
||||
mask based on the current session, check mask when sending client
|
||||
hello and checking the requested ciphersuite.
|
||||
[Steve Henson]
|
||||
|
||||
*) New ctrls to retrieve and set certificate types in a certificate
|
||||
request message. Print out received values in s_client. If certificate
|
||||
types is not set with custom values set sensible values based on
|
||||
supported signature algorithms.
|
||||
[Steve Henson]
|
||||
|
||||
*) Support for distinct client and server supported signature algorithms.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add certificate callback. If set this is called whenever a certificate
|
||||
is required by client or server. An application can decide which
|
||||
certificate chain to present based on arbitrary criteria: for example
|
||||
supported signature algorithms. Add very simple example to s_server.
|
||||
This fixes many of the problems and restrictions of the existing client
|
||||
certificate callback: for example you can now clear an existing
|
||||
certificate and specify the whole chain.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add new "valid_flags" field to CERT_PKEY structure which determines what
|
||||
the certificate can be used for (if anything). Set valid_flags field
|
||||
in new tls1_check_chain function. Simplify ssl_set_cert_masks which used
|
||||
to have similar checks in it.
|
||||
|
||||
Add new "cert_flags" field to CERT structure and include a "strict mode".
|
||||
This enforces some TLS certificate requirements (such as only permitting
|
||||
certificate signature algorithms contained in the supported algorithms
|
||||
extension) which some implementations ignore: this option should be used
|
||||
with caution as it could cause interoperability issues.
|
||||
[Steve Henson]
|
||||
|
||||
*) Update and tidy signature algorithm extension processing. Work out
|
||||
shared signature algorithms based on preferences and peer algorithms
|
||||
and print them out in s_client and s_server. Abort handshake if no
|
||||
shared signature algorithms.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add new functions to allow customised supported signature algorithms
|
||||
for SSL and SSL_CTX structures. Add options to s_client and s_server
|
||||
to support them.
|
||||
[Steve Henson]
|
||||
|
||||
*) New function SSL_certs_clear() to delete all references to certificates
|
||||
from an SSL structure. Before this once a certificate had been added
|
||||
it couldn't be removed.
|
||||
[Steve Henson]
|
||||
|
||||
*) Integrate hostname, email address and IP address checking with certificate
|
||||
verification. New verify options supporting checking in opensl utility.
|
||||
[Steve Henson]
|
||||
|
||||
*) Fixes and wildcard matching support to hostname and email checking
|
||||
functions. Add manual page.
|
||||
[Florian Weimer (Red Hat Product Security Team)]
|
||||
|
||||
*) New functions to check a hostname email or IP address against a
|
||||
certificate. Add options x509 utility to print results of checks against
|
||||
a certificate.
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix OCSP checking.
|
||||
[Rob Stradling <rob.stradling@comodo.com> and Ben Laurie]
|
||||
|
||||
*) Initial experimental support for explicitly trusted non-root CAs.
|
||||
OpenSSL still tries to build a complete chain to a root but if an
|
||||
intermediate CA has a trust setting included that is used. The first
|
||||
setting is used: whether to trust (e.g., -addtrust option to the x509
|
||||
utility) or reject.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add -trusted_first option which attempts to find certificates in the
|
||||
trusted store even if an untrusted chain is also supplied.
|
||||
[Steve Henson]
|
||||
|
||||
*) MIPS assembly pack updates: support for MIPS32r2 and SmartMIPS ASE,
|
||||
platform support for Linux and Android.
|
||||
[Andy Polyakov]
|
||||
|
||||
*) Support for linux-x32, ILP32 environment in x86_64 framework.
|
||||
[Andy Polyakov]
|
||||
|
||||
*) RFC 5878 (TLS Authorization Extensions) support.
|
||||
[Emilia Kasper, Adam Langley, Ben Laurie (Google)]
|
||||
|
||||
*) Experimental multi-implementation support for FIPS capable OpenSSL.
|
||||
When in FIPS mode the approved implementations are used as normal,
|
||||
when not in FIPS mode the internal unapproved versions are used instead.
|
||||
This means that the FIPS capable OpenSSL isn't forced to use the
|
||||
(often lower perfomance) FIPS implementations outside FIPS mode.
|
||||
[Steve Henson]
|
||||
|
||||
*) Transparently support X9.42 DH parameters when calling
|
||||
PEM_read_bio_DHparameters. This means existing applications can handle
|
||||
the new parameter format automatically.
|
||||
[Steve Henson]
|
||||
|
||||
*) Initial experimental support for X9.42 DH parameter format: mainly
|
||||
to support use of 'q' parameter for RFC5114 parameters.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add DH parameters from RFC5114 including test data to dhtest.
|
||||
[Steve Henson]
|
||||
|
||||
*) Support for automatic EC temporary key parameter selection. If enabled
|
||||
the most preferred EC parameters are automatically used instead of
|
||||
hardcoded fixed parameters. Now a server just has to call:
|
||||
SSL_CTX_set_ecdh_auto(ctx, 1) and the server will automatically
|
||||
support ECDH and use the most appropriate parameters.
|
||||
[Steve Henson]
|
||||
|
||||
*) Enhance and tidy EC curve and point format TLS extension code. Use
|
||||
static structures instead of allocation if default values are used.
|
||||
New ctrls to set curves we wish to support and to retrieve shared curves.
|
||||
Print out shared curves in s_server. New options to s_server and s_client
|
||||
to set list of supported curves.
|
||||
[Steve Henson]
|
||||
|
||||
*) New ctrls to retrieve supported signature algorithms and
|
||||
supported curve values as an array of NIDs. Extend openssl utility
|
||||
to print out received values.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add new APIs EC_curve_nist2nid and EC_curve_nid2nist which convert
|
||||
between NIDs and the more common NIST names such as "P-256". Enhance
|
||||
ecparam utility and ECC method to recognise the NIST names for curves.
|
||||
[Steve Henson]
|
||||
|
||||
*) Enhance SSL/TLS certificate chain handling to support different
|
||||
chains for each certificate instead of one chain in the parent SSL_CTX.
|
||||
[Steve Henson]
|
||||
|
||||
*) Support for fixed DH ciphersuite client authentication: where both
|
||||
server and client use DH certificates with common parameters.
|
||||
[Steve Henson]
|
||||
|
||||
*) Support for fixed DH ciphersuites: those requiring DH server
|
||||
certificates.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1e and 1.0.1f [6 Jan 2014]
|
||||
|
||||
*) Fix for TLS record tampering bug. A carefully crafted invalid
|
||||
handshake could crash OpenSSL with a NULL pointer exception.
|
||||
Thanks to Anton Johansson for reporting this issues.
|
||||
(CVE-2013-4353)
|
||||
|
||||
*) Keep original DTLS digest and encryption contexts in retransmission
|
||||
structures so we can use the previous session parameters if they need
|
||||
to be resent. (CVE-2013-6450)
|
||||
[Steve Henson]
|
||||
|
||||
*) Add option SSL_OP_SAFARI_ECDHE_ECDSA_BUG (part of SSL_OP_ALL) which
|
||||
avoids preferring ECDHE-ECDSA ciphers when the client appears to be
|
||||
Safari on OS X. Safari on OS X 10.8..10.8.3 advertises support for
|
||||
several ECDHE-ECDSA ciphers, but fails to negotiate them. The bug
|
||||
is fixed in OS X 10.8.4, but Apple have ruled out both hot fixing
|
||||
10.8..10.8.3 and forcing users to upgrade to 10.8.4 or newer.
|
||||
[Rob Stradling, Adam Langley]
|
||||
|
||||
Changes between 1.0.1d and 1.0.1e [11 Feb 2013]
|
||||
|
||||
*) Correct fix for CVE-2013-0169. The original didn't work on AES-NI
|
||||
supporting platforms or when small records were transferred.
|
||||
[Andy Polyakov, Steve Henson]
|
||||
|
||||
Changes between 1.0.1c and 1.0.1d [5 Feb 2013]
|
||||
|
||||
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
|
||||
|
||||
This addresses the flaw in CBC record processing discovered by
|
||||
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
|
||||
at: http://www.isg.rhul.ac.uk/tls/
|
||||
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
|
||||
Emilia K<>sper for the initial patch.
|
||||
(CVE-2013-0169)
|
||||
[Emilia K<>sper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
|
||||
|
||||
*) Fix flaw in AESNI handling of TLS 1.2 and 1.1 records for CBC mode
|
||||
ciphersuites which can be exploited in a denial of service attack.
|
||||
Thanks go to and to Adam Langley <agl@chromium.org> for discovering
|
||||
and detecting this bug and to Wolfgang Ettlinger
|
||||
<wolfgang.ettlinger@gmail.com> for independently discovering this issue.
|
||||
(CVE-2012-2686)
|
||||
[Adam Langley]
|
||||
|
||||
*) Return an error when checking OCSP signatures when key is NULL.
|
||||
This fixes a DoS attack. (CVE-2013-0166)
|
||||
[Steve Henson]
|
||||
|
||||
*) Make openssl verify return errors.
|
||||
[Chris Palmer <palmer@google.com> and Ben Laurie]
|
||||
|
||||
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
|
||||
the right response is stapled. Also change SSL_get_certificate()
|
||||
so it returns the certificate actually sent.
|
||||
See http://rt.openssl.org/Ticket/Display.html?id=2836.
|
||||
[Rob Stradling <rob.stradling@comodo.com>]
|
||||
|
||||
*) Fix possible deadlock when decoding public keys.
|
||||
[Steve Henson]
|
||||
|
||||
*) Don't use TLS 1.0 record version number in initial client hello
|
||||
if renegotiating.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1b and 1.0.1c [10 May 2012]
|
||||
|
||||
*) Sanity check record length before skipping explicit IV in TLS
|
||||
1.2, 1.1 and DTLS to fix DoS attack.
|
||||
|
||||
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
|
||||
fuzzing as a service testing platform.
|
||||
(CVE-2012-2333)
|
||||
[Steve Henson]
|
||||
|
||||
*) Initialise tkeylen properly when encrypting CMS messages.
|
||||
Thanks to Solar Designer of Openwall for reporting this issue.
|
||||
[Steve Henson]
|
||||
|
||||
*) In FIPS mode don't try to use composite ciphers as they are not
|
||||
approved.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1a and 1.0.1b [26 Apr 2012]
|
||||
|
||||
*) OpenSSL 1.0.0 sets SSL_OP_ALL to 0x80000FFFL and OpenSSL 1.0.1 and
|
||||
1.0.1a set SSL_OP_NO_TLSv1_1 to 0x00000400L which would unfortunately
|
||||
mean any application compiled against OpenSSL 1.0.0 headers setting
|
||||
SSL_OP_ALL would also set SSL_OP_NO_TLSv1_1, unintentionally disablng
|
||||
TLS 1.1 also. Fix this by changing the value of SSL_OP_NO_TLSv1_1 to
|
||||
0x10000000L Any application which was previously compiled against
|
||||
OpenSSL 1.0.1 or 1.0.1a headers and which cares about SSL_OP_NO_TLSv1_1
|
||||
will need to be recompiled as a result. Letting be results in
|
||||
inability to disable specifically TLS 1.1 and in client context,
|
||||
in unlike event, limit maximum offered version to TLS 1.0 [see below].
|
||||
[Steve Henson]
|
||||
|
||||
*) In order to ensure interoperabilty SSL_OP_NO_protocolX does not
|
||||
disable just protocol X, but all protocols above X *if* there are
|
||||
protocols *below* X still enabled. In more practical terms it means
|
||||
that if application wants to disable TLS1.0 in favor of TLS1.1 and
|
||||
above, it's not sufficient to pass SSL_OP_NO_TLSv1, one has to pass
|
||||
SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2. This applies to
|
||||
client side.
|
||||
[Andy Polyakov]
|
||||
|
||||
Changes between 1.0.1 and 1.0.1a [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
*) Don't allow TLS 1.2 SHA-256 ciphersuites in TLS 1.0, 1.1 connections.
|
||||
[Adam Langley]
|
||||
|
||||
*) Workarounds for some broken servers that "hang" if a client hello
|
||||
record length exceeds 255 bytes.
|
||||
|
||||
1. Do not use record version number > TLS 1.0 in initial client
|
||||
hello: some (but not all) hanging servers will now work.
|
||||
2. If we set OPENSSL_MAX_TLS1_2_CIPHER_LENGTH this will truncate
|
||||
the number of ciphers sent in the client hello. This should be
|
||||
set to an even number, such as 50, for example by passing:
|
||||
-DOPENSSL_MAX_TLS1_2_CIPHER_LENGTH=50 to config or Configure.
|
||||
Most broken servers should now work.
|
||||
3. If all else fails setting OPENSSL_NO_TLS1_2_CLIENT will disable
|
||||
TLS 1.2 client support entirely.
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix SEGV in Vector Permutation AES module observed in OpenSSH.
|
||||
[Andy Polyakov]
|
||||
|
||||
Changes between 1.0.0h and 1.0.1 [14 Mar 2012]
|
||||
|
||||
*) Add compatibility with old MDC2 signatures which use an ASN1 OCTET
|
||||
@@ -285,7 +723,75 @@
|
||||
Add command line options to s_client/s_server.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0g and 1.0.0h [xx XXX xxxx]
|
||||
Changes between 1.0.0j and 1.0.0k [5 Feb 2013]
|
||||
|
||||
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
|
||||
|
||||
This addresses the flaw in CBC record processing discovered by
|
||||
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
|
||||
at: http://www.isg.rhul.ac.uk/tls/
|
||||
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
|
||||
Emilia K<>sper for the initial patch.
|
||||
(CVE-2013-0169)
|
||||
[Emilia K<>sper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
|
||||
|
||||
*) Return an error when checking OCSP signatures when key is NULL.
|
||||
This fixes a DoS attack. (CVE-2013-0166)
|
||||
[Steve Henson]
|
||||
|
||||
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
|
||||
the right response is stapled. Also change SSL_get_certificate()
|
||||
so it returns the certificate actually sent.
|
||||
See http://rt.openssl.org/Ticket/Display.html?id=2836.
|
||||
(This is a backport)
|
||||
[Rob Stradling <rob.stradling@comodo.com>]
|
||||
|
||||
*) Fix possible deadlock when decoding public keys.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0i and 1.0.0j [10 May 2012]
|
||||
|
||||
[NB: OpenSSL 1.0.0i and later 1.0.0 patch levels were released after
|
||||
OpenSSL 1.0.1.]
|
||||
|
||||
*) Sanity check record length before skipping explicit IV in DTLS
|
||||
to fix DoS attack.
|
||||
|
||||
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
|
||||
fuzzing as a service testing platform.
|
||||
(CVE-2012-2333)
|
||||
[Steve Henson]
|
||||
|
||||
*) Initialise tkeylen properly when encrypting CMS messages.
|
||||
Thanks to Solar Designer of Openwall for reporting this issue.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0h and 1.0.0i [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
Changes between 1.0.0g and 1.0.0h [12 Mar 2012]
|
||||
|
||||
*) Fix MMA (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) weakness
|
||||
in CMS and PKCS7 code. When RSA decryption fails use a random key for
|
||||
content decryption and always return the same error. Note: this attack
|
||||
needs on average 2^20 messages so it only affects automated senders. The
|
||||
old behaviour can be reenabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag: this is useful for debugging and testing where
|
||||
an MMA defence is not necessary.
|
||||
Thanks to Ivan Nestlerode <inestlerode@us.ibm.com> for discovering
|
||||
this issue. (CVE-2012-0884)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix CVE-2011-4619: make sure we really are receiving a
|
||||
client hello before rejecting multiple SGC restarts. Thanks to
|
||||
@@ -1264,6 +1770,86 @@
|
||||
*) Change 'Configure' script to enable Camellia by default.
|
||||
[NTT]
|
||||
|
||||
Changes between 0.9.8x and 0.9.8y [5 Feb 2013]
|
||||
|
||||
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
|
||||
|
||||
This addresses the flaw in CBC record processing discovered by
|
||||
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
|
||||
at: http://www.isg.rhul.ac.uk/tls/
|
||||
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
|
||||
Emilia K<>sper for the initial patch.
|
||||
(CVE-2013-0169)
|
||||
[Emilia K<>sper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
|
||||
|
||||
*) Return an error when checking OCSP signatures when key is NULL.
|
||||
This fixes a DoS attack. (CVE-2013-0166)
|
||||
[Steve Henson]
|
||||
|
||||
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
|
||||
the right response is stapled. Also change SSL_get_certificate()
|
||||
so it returns the certificate actually sent.
|
||||
See http://rt.openssl.org/Ticket/Display.html?id=2836.
|
||||
(This is a backport)
|
||||
[Rob Stradling <rob.stradling@comodo.com>]
|
||||
|
||||
*) Fix possible deadlock when decoding public keys.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.8w and 0.9.8x [10 May 2012]
|
||||
|
||||
*) Sanity check record length before skipping explicit IV in DTLS
|
||||
to fix DoS attack.
|
||||
|
||||
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
|
||||
fuzzing as a service testing platform.
|
||||
(CVE-2012-2333)
|
||||
[Steve Henson]
|
||||
|
||||
*) Initialise tkeylen properly when encrypting CMS messages.
|
||||
Thanks to Solar Designer of Openwall for reporting this issue.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.8v and 0.9.8w [23 Apr 2012]
|
||||
|
||||
*) The fix for CVE-2012-2110 did not take into account that the
|
||||
'len' argument to BUF_MEM_grow and BUF_MEM_grow_clean is an
|
||||
int in OpenSSL 0.9.8, making it still vulnerable. Fix by
|
||||
rejecting negative len parameter. (CVE-2012-2131)
|
||||
[Tomas Hoger <thoger@redhat.com>]
|
||||
|
||||
Changes between 0.9.8u and 0.9.8v [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
Changes between 0.9.8t and 0.9.8u [12 Mar 2012]
|
||||
|
||||
*) Fix MMA (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) weakness
|
||||
in CMS and PKCS7 code. When RSA decryption fails use a random key for
|
||||
content decryption and always return the same error. Note: this attack
|
||||
needs on average 2^20 messages so it only affects automated senders. The
|
||||
old behaviour can be reenabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag: this is useful for debugging and testing where
|
||||
an MMA defence is not necessary.
|
||||
Thanks to Ivan Nestlerode <inestlerode@us.ibm.com> for discovering
|
||||
this issue. (CVE-2012-0884)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix CVE-2011-4619: make sure we really are receiving a
|
||||
client hello before rejecting multiple SGC restarts. Thanks to
|
||||
Ivan Nestlerode <inestlerode@us.ibm.com> for discovering this bug.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.8s and 0.9.8t [18 Jan 2012]
|
||||
|
||||
*) Fix for DTLS DoS issue introduced by fix for CVE-2011-4109.
|
||||
@@ -1271,7 +1857,7 @@
|
||||
Development, Cisco Systems, Inc. for discovering this bug and
|
||||
preparing a fix. (CVE-2012-0050)
|
||||
[Antonio Martin]
|
||||
|
||||
|
||||
Changes between 0.9.8r and 0.9.8s [4 Jan 2012]
|
||||
|
||||
*) Nadhem Alfardan and Kenny Paterson have discovered an extension
|
||||
|
||||
102
Configure
102
Configure
@@ -128,19 +128,19 @@ my $x86_asm="x86cpuid.o:bn-586.o co-586.o x86-mont.o x86-gf2m.o:des-586.o crypt5
|
||||
|
||||
my $x86_elf_asm="$x86_asm:elf";
|
||||
|
||||
my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o modexp512-x86_64.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o:";
|
||||
my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o aesni-gcm-x86_64.o:";
|
||||
my $ia64_asm="ia64cpuid.o:bn-ia64.o ia64-mont.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o:::::ghash-ia64.o::void";
|
||||
my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o:aes_core.o aes_cbc.o aes-sparcv9.o:::sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o:::::::ghash-sparcv9.o::void";
|
||||
my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o vis3-mont.o sparct4-mont.o sparcv9-gf2m.o:des_enc-sparc.o fcrypt_b.o dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-sparcv9.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o::::::camellia.o cmll_misc.o cmll_cbc.o cmllt4-sparcv9.o:ghash-sparcv9.o::void";
|
||||
my $sparcv8_asm=":sparcv8.o:des_enc-sparc.o fcrypt_b.o:::::::::::::void";
|
||||
my $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o:::::sha1-alpha.o:::::::ghash-alpha.o::void";
|
||||
my $mips32_asm=":bn-mips.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o::::::::";
|
||||
my $mips64_asm=":bn-mips.o mips-mont.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o sha512-mips.o::::::::";
|
||||
my $mips32_asm=$mips64_asm; $mips32_asm =~ s/\s*sha512\-mips\.o//;
|
||||
my $s390x_asm="s390xcap.o s390xcpuid.o:bn-s390x.o s390x-mont.o s390x-gf2m.o::aes-s390x.o aes-ctr.o aes-xts.o:::sha1-s390x.o sha256-s390x.o sha512-s390x.o::rc4-s390x.o:::::ghash-s390x.o:";
|
||||
my $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o::aes_cbc.o aes-armv4.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o::void";
|
||||
my $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o::aes_cbc.o aes-armv4.o bsaes-armv7.o:::sha1-armv4-large.o sha256-armv4.o sha512-armv4.o:::::::ghash-armv4.o::void";
|
||||
my $parisc11_asm="pariscid.o:bn_asm.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::32";
|
||||
my $parisc20_asm="pariscid.o:pa-risc2W.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::64";
|
||||
my $ppc32_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o:::sha1-ppc.o sha256-ppc.o::::::::";
|
||||
my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o::::::::";
|
||||
my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o::::::::";
|
||||
my $ppc32_asm=$ppc64_asm;
|
||||
my $no_asm=":::::::::::::::void";
|
||||
|
||||
# As for $BSDthreads. Idea is to maintain "collective" set of flags,
|
||||
@@ -171,20 +171,23 @@ my %table=(
|
||||
"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
|
||||
"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
|
||||
"debug-ben-debug", "gcc44:$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O2 -pipe::(unknown)::::::",
|
||||
"debug-ben-debug-64", "gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-ben-macos", "cc:$gcc_devteam_warn -arch i386 -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::-Wl,-search_paths_first::::",
|
||||
"debug-ben-macos-gcc46", "gcc-mp-4.6:$gcc_devteam_warn -Wconversion -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DL_ENDIAN -g3 -pipe::(unknown)::::::",
|
||||
"debug-ben-darwin64","cc:$gcc_devteam_warn -g -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-ben-debug-64-clang", "clang:$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-ben-no-opt", "gcc: -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -DTERMIOS -Wall -g3::(unknown)::::::",
|
||||
"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
|
||||
"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
|
||||
"debug-bodo", "gcc:$gcc_devteam_warn -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -DBIO_PAIR_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"debug-bodo", "gcc:$gcc_devteam_warn -Wno-error=overlength-strings -DBN_DEBUG -DBN_DEBUG_RAND -DCONF_DEBUG -DBIO_PAIR_DEBUG -m64 -DL_ENDIAN -DTERMIO -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"debug-ulf", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DBN_DEBUG_RAND -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations:::CYGWIN32:::${no_asm}:win32:cygwin-shared:::.dll",
|
||||
"debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -Wno-overlength-strings -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve-opt", "gcc:$gcc_devteam_warn -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-noasm-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-geoff32","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:BN_LLONG:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-geoff64","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
|
||||
@@ -243,7 +246,7 @@ my %table=(
|
||||
"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64",
|
||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
|
||||
####
|
||||
"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -348,17 +351,26 @@ my %table=(
|
||||
# It's believed that majority of ARM toolchains predefine appropriate -march.
|
||||
# If you compiler does not, do complement config command line with one!
|
||||
"linux-armv4", "gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
# Configure script adds minimally required -march for assembly support,
|
||||
# if no -march was specified at command line. mips32 and mips64 below
|
||||
# refer to contemporary MIPS Architecture specifications, MIPS32 and
|
||||
# MIPS64, rather than to kernel bitness.
|
||||
"linux-mips32", "gcc:-mabi=32 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-mips64", "gcc:-mabi=n32 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:n32:dlfcn:linux-shared:-fPIC:-mabi=n32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::32",
|
||||
"linux64-mips64", "gcc:-mabi=64 -DTERMIO -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips64_asm}:64:dlfcn:linux-shared:-fPIC:-mabi=64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
#### IA-32 targets...
|
||||
"linux-ia32-icc", "icc:-DL_ENDIAN -DTERMIO -O2 -no_cpprt::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia32-icc", "icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl -no_cpprt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out",
|
||||
####
|
||||
"linux-generic64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ppc64", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc64_asm}:linux64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-ppc64le","gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:$ppc64_asm:linux64le:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::",
|
||||
"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia64-ecc","ecc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x86_64-icc", "icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x32", "gcc:-mx32 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32",
|
||||
"linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
#### So called "highgprs" target for z/Architecture CPUs
|
||||
# "Highgprs" is kernel feature first implemented in Linux 2.6.32, see
|
||||
@@ -405,6 +417,7 @@ my %table=(
|
||||
"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
#### *BSD [do see comment about ${BSDthreads} above!]
|
||||
"BSD-generic32","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -464,8 +477,8 @@ my %table=(
|
||||
"aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64",
|
||||
# Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE
|
||||
# at build time. $OBJECT_MODE is respected at ./config stage!
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
|
||||
#
|
||||
# Cray T90 and similar (SDSC)
|
||||
@@ -547,6 +560,7 @@ my %table=(
|
||||
# Cygwin
|
||||
"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32",
|
||||
"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:coff:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
|
||||
"Cygwin-x86_64", "gcc:-DTERMIOS -DL_ENDIAN -O3 -Wall:::CYGWIN32::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:mingw64:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
|
||||
"debug-Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:::CYGWIN32:::${no_asm}:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",
|
||||
|
||||
# NetWare from David Ward (dsward@novell.com)
|
||||
@@ -579,7 +593,8 @@ my %table=(
|
||||
"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
# iPhoneOS/iOS
|
||||
"iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
@@ -709,14 +724,18 @@ if (exists $ENV{FIPSDIR})
|
||||
# All of the following is disabled by default (RC5 was enabled before 0.9.8):
|
||||
|
||||
my %disabled = ( # "what" => "comment" [or special keyword "experimental"]
|
||||
"dane" => "experimental",
|
||||
"ec_nistp_64_gcc_128" => "default",
|
||||
"gmp" => "default",
|
||||
"jpake" => "experimental",
|
||||
"libunbound" => "experimental",
|
||||
"md2" => "default",
|
||||
"multiblock" => "experimental",
|
||||
"rc5" => "default",
|
||||
"rfc3779" => "default",
|
||||
"sctp" => "default",
|
||||
"shared" => "default",
|
||||
"ssl-trace" => "default",
|
||||
"store" => "experimental",
|
||||
"zlib" => "default",
|
||||
"zlib-dynamic" => "default"
|
||||
@@ -725,7 +744,7 @@ my @experimental = ();
|
||||
|
||||
# This is what $depflags will look like with the above defaults
|
||||
# (we need this to see if we should advise the user to run "make depend"):
|
||||
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_STORE";
|
||||
my $default_depflags = " -DOPENSSL_NO_DANE -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MULTIBLOCK -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE";
|
||||
|
||||
# Explicit "no-..." options will be collected in %disabled along with the defaults.
|
||||
# To remove something from %disabled, use "enable-foo" (unless it's experimental).
|
||||
@@ -865,16 +884,7 @@ PROCESS_ARGS:
|
||||
}
|
||||
elsif (/^[-+]/)
|
||||
{
|
||||
if (/^-[lL](.*)$/ or /^-Wl,/)
|
||||
{
|
||||
$libs.=$_." ";
|
||||
}
|
||||
elsif (/^-[^-]/ or /^\+/)
|
||||
{
|
||||
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
|
||||
$flags.=$_." ";
|
||||
}
|
||||
elsif (/^--prefix=(.*)$/)
|
||||
if (/^--prefix=(.*)$/)
|
||||
{
|
||||
$prefix=$1;
|
||||
}
|
||||
@@ -918,10 +928,14 @@ PROCESS_ARGS:
|
||||
{
|
||||
$cross_compile_prefix=$1;
|
||||
}
|
||||
else
|
||||
elsif (/^-[lL](.*)$/ or /^-Wl,/)
|
||||
{
|
||||
print STDERR $usage;
|
||||
exit(1);
|
||||
$libs.=$_." ";
|
||||
}
|
||||
else # common if (/^[-+]/), just pass down...
|
||||
{
|
||||
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
|
||||
$flags.=$_." ";
|
||||
}
|
||||
}
|
||||
elsif ($_ =~ /^([^:]+):(.+)$/)
|
||||
@@ -1201,6 +1215,12 @@ if ($target =~ /^mingw/ && `$cc --target-help 2>&1` !~ m/\-mno\-cygwin/m)
|
||||
$shared_ldflag =~ s/\-mno\-cygwin\s*//;
|
||||
}
|
||||
|
||||
if ($target =~ /linux.*\-mips/ && !$no_asm && $flags !~ /\-m(ips|arch=)/) {
|
||||
# minimally required architecture flags for assembly modules
|
||||
$cflags="-mips2 $cflags" if ($target =~ /mips32/);
|
||||
$cflags="-mips3 $cflags" if ($target =~ /mips64/);
|
||||
}
|
||||
|
||||
my $no_shared_warn=0;
|
||||
my $no_user_cflags=0;
|
||||
|
||||
@@ -1408,6 +1428,7 @@ if ($target =~ /\-icc$/) # Intel C compiler
|
||||
}
|
||||
if ($iccver>=8)
|
||||
{
|
||||
$cflags=~s/\-KPIC/-fPIC/;
|
||||
# Eliminate unnecessary dependency from libirc.a. This is
|
||||
# essential for shared library support, as otherwise
|
||||
# apps/openssl can end up in endless loop upon startup...
|
||||
@@ -1415,12 +1436,17 @@ if ($target =~ /\-icc$/) # Intel C compiler
|
||||
}
|
||||
if ($iccver>=9)
|
||||
{
|
||||
$cflags.=" -i-static";
|
||||
$cflags=~s/\-no_cpprt/-no-cpprt/;
|
||||
$lflags.=" -i-static";
|
||||
$lflags=~s/\-no_cpprt/-no-cpprt/;
|
||||
}
|
||||
if ($iccver>=10)
|
||||
{
|
||||
$cflags=~s/\-i\-static/-static-intel/;
|
||||
$lflags=~s/\-i\-static/-static-intel/;
|
||||
}
|
||||
if ($iccver>=11)
|
||||
{
|
||||
$cflags.=" -no-intel-extensions"; # disable Cilk
|
||||
$lflags=~s/\-no\-cpprt/-no-cxxlib/;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1983,7 +2009,7 @@ BEGIN
|
||||
VALUE "ProductVersion", "$version\\0"
|
||||
// Optional:
|
||||
//VALUE "Comments", "\\0"
|
||||
VALUE "LegalCopyright", "Copyright <20> 1998-2005 The OpenSSL Project. Copyright <20> 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
|
||||
VALUE "LegalCopyright", "Copyright <EFBFBD> 1998-2005 The OpenSSL Project. Copyright <20> 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
|
||||
//VALUE "LegalTrademarks", "\\0"
|
||||
//VALUE "PrivateBuild", "\\0"
|
||||
//VALUE "SpecialBuild", "\\0"
|
||||
|
||||
62
FAQ
62
FAQ
@@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Why aren't tools like 'autoconf' and 'libtool' used?
|
||||
* What is an 'engine' version?
|
||||
* How do I check the authenticity of the OpenSSL distribution?
|
||||
* How does the versioning scheme work?
|
||||
|
||||
[LEGAL] Legal questions
|
||||
|
||||
@@ -82,11 +83,11 @@ OpenSSL - Frequently Asked Questions
|
||||
* Which is the current version of OpenSSL?
|
||||
|
||||
The current version is available from <URL: http://www.openssl.org>.
|
||||
OpenSSL 1.0.1 was released on Mar 14th, 2012.
|
||||
OpenSSL 1.0.1a was released on Apr 19th, 2012.
|
||||
|
||||
In addition to the current stable release, you can also access daily
|
||||
snapshots of the OpenSSL development version at <URL:
|
||||
ftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access.
|
||||
ftp://ftp.openssl.org/snapshot/>, or get it by anonymous Git access.
|
||||
|
||||
|
||||
* Where is the documentation?
|
||||
@@ -108,7 +109,9 @@ In addition, you can read the most current versions at
|
||||
<URL: http://www.openssl.org/docs/>. Note that the online documents refer
|
||||
to the very latest development versions of OpenSSL and may include features
|
||||
not present in released versions. If in doubt refer to the documentation
|
||||
that came with the version of OpenSSL you are using.
|
||||
that came with the version of OpenSSL you are using. The pod format
|
||||
documentation is included in each OpenSSL distribution under the docs
|
||||
directory.
|
||||
|
||||
For information on parts of libcrypto that are not yet documented, you
|
||||
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
|
||||
@@ -173,14 +176,31 @@ just do:
|
||||
|
||||
pgp TARBALL.asc
|
||||
|
||||
* How does the versioning scheme work?
|
||||
|
||||
After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter
|
||||
releases (e.g. 1.0.1a) can only contain bug and security fixes and no
|
||||
new features. Minor releases change the last number (e.g. 1.0.2) and
|
||||
can contain new features that retain binary compatibility. Changes to
|
||||
the middle number are considered major releases and neither source nor
|
||||
binary compatibility is guaranteed.
|
||||
|
||||
Therefore the answer to the common question "when will feature X be
|
||||
backported to OpenSSL 1.0.0/0.9.8?" is "never" but it could appear
|
||||
in the next minor release.
|
||||
|
||||
* What happens when the letter release reaches z?
|
||||
|
||||
It was decided after the release of OpenSSL 0.9.8y the next version should
|
||||
be 0.9.8za then 0.9.8zb and so on.
|
||||
|
||||
|
||||
[LEGAL] =======================================================================
|
||||
|
||||
* Do I need patent licenses to use OpenSSL?
|
||||
|
||||
The patents section of the README file lists patents that may apply to
|
||||
you if you want to use OpenSSL. For information on intellectual
|
||||
property rights, please consult a lawyer. The OpenSSL team does not
|
||||
offer legal advice.
|
||||
For information on intellectual property rights, please consult a lawyer.
|
||||
The OpenSSL team does not offer legal advice.
|
||||
|
||||
You can configure OpenSSL so as not to use IDEA, MDC2 and RC5 by using
|
||||
./config no-idea no-mdc2 no-rc5
|
||||
@@ -284,7 +304,7 @@ current directory in this case, but this has changed with 0.9.6a.)
|
||||
Check out the CA.pl(1) manual page. This provides a simple wrapper round
|
||||
the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
|
||||
out the manual pages for the individual utilities and the certificate
|
||||
extensions documentation (currently in doc/openssl.txt).
|
||||
extensions documentation (in ca(1), req(1), x509v3_config(5) )
|
||||
|
||||
|
||||
* Why can't I create certificate requests?
|
||||
@@ -597,8 +617,8 @@ valid for the current DOS session.
|
||||
* What is special about OpenSSL on Redhat?
|
||||
|
||||
Red Hat Linux (release 7.0 and later) include a preinstalled limited
|
||||
version of OpenSSL. For patent reasons, support for IDEA, RC5 and MDC2
|
||||
is disabled in this version. The same may apply to other Linux distributions.
|
||||
version of OpenSSL. Red Hat has chosen to disable support for IDEA, RC5 and
|
||||
MDC2 in this version. The same may apply to other Linux distributions.
|
||||
Users may therefore wish to install more or all of the features left out.
|
||||
|
||||
To do this you MUST ensure that you do not overwrite the openssl that is in
|
||||
@@ -621,11 +641,6 @@ relevant updates in packages up to and including 0.9.6b.
|
||||
A possible way around this is to persuade Red Hat to produce a non-US
|
||||
version of Red Hat Linux.
|
||||
|
||||
FYI: Patent numbers and expiry dates of US patents:
|
||||
MDC-2: 4,908,861 13/03/2007
|
||||
IDEA: 5,214,703 25/05/2010
|
||||
RC5: 5,724,428 03/03/2015
|
||||
|
||||
|
||||
* Why does the OpenSSL compilation fail on MacOS X?
|
||||
|
||||
@@ -848,7 +863,7 @@ The opposite assumes we already have len bytes in buf:
|
||||
p = buf;
|
||||
p7 = d2i_PKCS7(NULL, &p, len);
|
||||
|
||||
At this point p7 contains a valid PKCS7 structure of NULL if an error
|
||||
At this point p7 contains a valid PKCS7 structure or NULL if an error
|
||||
occurred. If an error occurred ERR_print_errors(bio) should give more
|
||||
information.
|
||||
|
||||
@@ -860,6 +875,21 @@ that has been read or written. This may well be uninitialized data
|
||||
and attempts to free the buffer will have unpredictable results
|
||||
because it no longer points to the same address.
|
||||
|
||||
Memory allocation and encoding can also be combined in a single
|
||||
operation by the ASN1 routines:
|
||||
|
||||
unsigned char *buf = NULL; /* mandatory */
|
||||
int len;
|
||||
len = i2d_PKCS7(p7, &buf);
|
||||
if (len < 0)
|
||||
/* Error */
|
||||
/* Do some things with 'buf' */
|
||||
/* Finished with buf: free it */
|
||||
OPENSSL_free(buf);
|
||||
|
||||
In this special case the "buf" parameter is *not* incremented, it points
|
||||
to the start of the encoding.
|
||||
|
||||
|
||||
* OpenSSL uses DER but I need BER format: does OpenSSL support BER?
|
||||
|
||||
|
||||
8
GitConfigure
Executable file
8
GitConfigure
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
./Configure $@ no-symlinks
|
||||
make files
|
||||
util/mk1mf.pl OUT=out.$BRANCH TMP=tmp.$BRANCH INC=inc.$BRANCH copy > makefile.$BRANCH
|
||||
make -f makefile.$BRANCH init
|
||||
5
GitMake
Executable file
5
GitMake
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
make -f makefile.$BRANCH $@
|
||||
@@ -29,7 +29,7 @@
|
||||
is required if you intend to utilize assembler modules. Note that NASM
|
||||
is now the only supported assembler.
|
||||
|
||||
If you are compiling from a tarball or a CVS snapshot then the Win32 files
|
||||
If you are compiling from a tarball or a Git snapshot then the Win32 files
|
||||
may well be not up to date. This may mean that some "tweaking" is required to
|
||||
get it all to work. See the trouble shooting section later on for if (when?)
|
||||
it goes wrong.
|
||||
@@ -257,7 +257,7 @@
|
||||
|
||||
then ms\do_XXX should not give a warning any more. However the numbers that
|
||||
get assigned by this technique may not match those that eventually get
|
||||
assigned in the CVS tree: so anything linked against this version of the
|
||||
assigned in the Git tree: so anything linked against this version of the
|
||||
library may need to be recompiled.
|
||||
|
||||
If you get errors about unresolved symbols there are several possible
|
||||
|
||||
17
Makefile.org
17
Makefile.org
@@ -198,7 +198,7 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
|
||||
|
||||
@@ -302,7 +302,8 @@ libcrypto$(SHLIB_EXT): libcrypto.a fips_premain_dso$(EXE_EXT)
|
||||
FIPSLD_CC="$(CC)"; CC=$(FIPSDIR)/bin/fipsld; \
|
||||
export CC FIPSLD_CC FIPSLD_LIBCRYPTO; \
|
||||
fi; \
|
||||
$(MAKE) -e SHLIBDIRS=crypto build-shared; \
|
||||
$(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
|
||||
touch -c fips_premain_dso$(EXE_EXT); \
|
||||
else \
|
||||
echo "There's no support for shared libraries on this platform" >&2; \
|
||||
exit 1; \
|
||||
@@ -325,7 +326,7 @@ clean-shared:
|
||||
done; \
|
||||
fi; \
|
||||
( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
|
||||
if [ "$(PLATFORM)" = "Cygwin" ]; then \
|
||||
if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
|
||||
fi; \
|
||||
done
|
||||
@@ -444,7 +445,7 @@ rehash.time: certs apps
|
||||
[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
|
||||
OPENSSL_DEBUG_MEMORY=on; \
|
||||
export OPENSSL OPENSSL_DEBUG_MEMORY; \
|
||||
$(PERL) tools/c_rehash certs) && \
|
||||
$(PERL) tools/c_rehash certs/demo) && \
|
||||
touch rehash.time; \
|
||||
else :; fi
|
||||
|
||||
@@ -469,9 +470,9 @@ tags:
|
||||
find . -name '[^.]*.[ch]' | xargs etags -a
|
||||
|
||||
errors:
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
$(PERL) util/mkerr.pl -recurse -write
|
||||
(cd engines; $(MAKE) PERL=$(PERL) errors)
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
|
||||
stacks:
|
||||
$(PERL) util/mkstack.pl -write
|
||||
@@ -570,7 +571,7 @@ install_sw:
|
||||
do \
|
||||
if [ -f "$$i" -o -f "$$i.a" ]; then \
|
||||
( echo installing $$i; \
|
||||
if [ "$(PLATFORM)" != "Cygwin" ]; then \
|
||||
if ! expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
|
||||
@@ -642,9 +643,9 @@ install_docs:
|
||||
@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
|
||||
here="`pwd`"; \
|
||||
filecase=; \
|
||||
if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \
|
||||
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
|
||||
filecase=-i; \
|
||||
fi; \
|
||||
esac; \
|
||||
set -e; for i in doc/apps/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
|
||||
|
||||
215
NEWS
215
NEWS
@@ -5,7 +5,54 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.1:
|
||||
Major changes between OpenSSL 1.0.1f and OpenSSL 1.0.2 [under development]:
|
||||
|
||||
o Suite B support for TLS 1.2 and DTLS 1.2
|
||||
o Support for DTLS 1.2
|
||||
o TLS automatic EC curve selection.
|
||||
o API to set TLS supported signature algorithms and curves
|
||||
o SSL_CONF configuration API.
|
||||
o TLS Brainpool support.
|
||||
o ALPN support.
|
||||
o CMS support for RSA-PSS, RSA-OAEP, ECDH and X9.42 DH.
|
||||
|
||||
Major changes between OpenSSL 1.0.1e and OpenSSL 1.0.1f [6 Jan 2014]
|
||||
|
||||
o Don't include gmt_unix_time in TLS server and client random values
|
||||
o Fix for TLS record tampering bug CVE-2013-4353
|
||||
o Fix for TLS version checking bug CVE-2013-6449
|
||||
o Fix for DTLS retransmission bug CVE-2013-6450
|
||||
|
||||
Major changes between OpenSSL 1.0.1d and OpenSSL 1.0.1e [11 Feb 2013]:
|
||||
|
||||
o Corrected fix for CVE-2013-0169
|
||||
|
||||
Major changes between OpenSSL 1.0.1c and OpenSSL 1.0.1d [4 Feb 2013]:
|
||||
|
||||
o Fix renegotiation in TLS 1.1, 1.2 by using the correct TLS version.
|
||||
o Include the fips configuration module.
|
||||
o Fix OCSP bad key DoS attack CVE-2013-0166
|
||||
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
|
||||
o Fix for TLS AESNI record handling flaw CVE-2012-2686
|
||||
|
||||
Major changes between OpenSSL 1.0.1b and OpenSSL 1.0.1c [10 May 2012]:
|
||||
|
||||
o Fix TLS/DTLS record length checking bug CVE-2012-2333
|
||||
o Don't attempt to use non-FIPS composite ciphers in FIPS mode.
|
||||
|
||||
Major changes between OpenSSL 1.0.1a and OpenSSL 1.0.1b [26 Apr 2012]:
|
||||
|
||||
o Fix compilation error on non-x86 platforms.
|
||||
o Make FIPS capable OpenSSL ciphers work in non-FIPS mode.
|
||||
o Fix SSL_OP_NO_TLSv1_1 clash with SSL_OP_ALL in OpenSSL 1.0.0
|
||||
|
||||
Major changes between OpenSSL 1.0.1 and OpenSSL 1.0.1a [19 Apr 2012]:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
o Workarounds for some servers that hang on long client hellos.
|
||||
o Fix SEGV in AES code.
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.1 [14 Mar 2012]:
|
||||
|
||||
o TLS/DTLS heartbeat support.
|
||||
o SCTP support.
|
||||
@@ -18,17 +65,30 @@
|
||||
o Preliminary FIPS capability for unvalidated 2.0 FIPS module.
|
||||
o SRP support.
|
||||
|
||||
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h:
|
||||
Major changes between OpenSSL 1.0.0j and OpenSSL 1.0.0k [5 Feb 2013]:
|
||||
|
||||
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
|
||||
o Fix OCSP bad key DoS attack CVE-2013-0166
|
||||
|
||||
Major changes between OpenSSL 1.0.0i and OpenSSL 1.0.0j [10 May 2012]:
|
||||
|
||||
o Fix DTLS record length checking bug CVE-2012-2333
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.0i [19 Apr 2012]:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
|
||||
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h [12 Mar 2012]:
|
||||
|
||||
o Fix for CMS/PKCS#7 MMA CVE-2012-0884
|
||||
o Corrected fix for CVE-2011-4619
|
||||
o Various DTLS fixes.
|
||||
|
||||
Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g:
|
||||
Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g [18 Jan 2012]:
|
||||
|
||||
o Fix for DTLS DoS issue CVE-2012-0050
|
||||
|
||||
Major changes between OpenSSL 1.0.0e and OpenSSL 1.0.0f:
|
||||
Major changes between OpenSSL 1.0.0e and OpenSSL 1.0.0f [4 Jan 2012]:
|
||||
|
||||
o Fix for DTLS plaintext recovery attack CVE-2011-4108
|
||||
o Clear block padding bytes of SSL 3.0 records CVE-2011-4576
|
||||
@@ -36,7 +96,7 @@
|
||||
o Check parameters are not NULL in GOST ENGINE CVE-2012-0027
|
||||
o Check for malformed RFC3779 data CVE-2011-4577
|
||||
|
||||
Major changes between OpenSSL 1.0.0d and OpenSSL 1.0.0e:
|
||||
Major changes between OpenSSL 1.0.0d and OpenSSL 1.0.0e [6 Sep 2011]:
|
||||
|
||||
o Fix for CRL vulnerability issue CVE-2011-3207
|
||||
o Fix for ECDH crashes CVE-2011-3210
|
||||
@@ -44,11 +104,11 @@
|
||||
o Support ECDH ciphersuites for certificates using SHA2 algorithms.
|
||||
o Various DTLS fixes.
|
||||
|
||||
Major changes between OpenSSL 1.0.0c and OpenSSL 1.0.0d:
|
||||
Major changes between OpenSSL 1.0.0c and OpenSSL 1.0.0d [8 Feb 2011]:
|
||||
|
||||
o Fix for security issue CVE-2011-0014
|
||||
|
||||
Major changes between OpenSSL 1.0.0b and OpenSSL 1.0.0c:
|
||||
Major changes between OpenSSL 1.0.0b and OpenSSL 1.0.0c [2 Dec 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-4180
|
||||
o Fix for CVE-2010-4252
|
||||
@@ -56,18 +116,18 @@
|
||||
o Fix various platform compilation issues.
|
||||
o Corrected fix for security issue CVE-2010-3864.
|
||||
|
||||
Major changes between OpenSSL 1.0.0a and OpenSSL 1.0.0b:
|
||||
Major changes between OpenSSL 1.0.0a and OpenSSL 1.0.0b [16 Nov 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-3864.
|
||||
o Fix for CVE-2010-2939
|
||||
o Fix WIN32 build system for GOST ENGINE.
|
||||
|
||||
Major changes between OpenSSL 1.0.0 and OpenSSL 1.0.0a:
|
||||
Major changes between OpenSSL 1.0.0 and OpenSSL 1.0.0a [1 Jun 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-1633.
|
||||
o GOST MAC and CFB fixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.8n and OpenSSL 1.0.0:
|
||||
Major changes between OpenSSL 0.9.8n and OpenSSL 1.0.0 [29 Mar 2010]:
|
||||
|
||||
o RFC3280 path validation: sufficient to process PKITS tests.
|
||||
o Integrated support for PVK files and keyblobs.
|
||||
@@ -90,20 +150,55 @@
|
||||
o Opaque PRF Input TLS extension support.
|
||||
o Updated time routines to avoid OS limitations.
|
||||
|
||||
Major changes between OpenSSL 0.9.8q and OpenSSL 0.9.8r:
|
||||
Major changes between OpenSSL 0.9.8x and OpenSSL 0.9.8y [5 Feb 2013]:
|
||||
|
||||
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
|
||||
o Fix OCSP bad key DoS attack CVE-2013-0166
|
||||
|
||||
Major changes between OpenSSL 0.9.8w and OpenSSL 0.9.8x [10 May 2012]:
|
||||
|
||||
o Fix DTLS record length checking bug CVE-2012-2333
|
||||
|
||||
Major changes between OpenSSL 0.9.8v and OpenSSL 0.9.8w [23 Apr 2012]:
|
||||
|
||||
o Fix for CVE-2012-2131 (corrected fix for 0.9.8 and CVE-2012-2110)
|
||||
|
||||
Major changes between OpenSSL 0.9.8u and OpenSSL 0.9.8v [19 Apr 2012]:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
|
||||
Major changes between OpenSSL 0.9.8t and OpenSSL 0.9.8u [12 Mar 2012]:
|
||||
|
||||
o Fix for CMS/PKCS#7 MMA CVE-2012-0884
|
||||
o Corrected fix for CVE-2011-4619
|
||||
o Various DTLS fixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.8s and OpenSSL 0.9.8t [18 Jan 2012]:
|
||||
|
||||
o Fix for DTLS DoS issue CVE-2012-0050
|
||||
|
||||
Major changes between OpenSSL 0.9.8r and OpenSSL 0.9.8s [4 Jan 2012]:
|
||||
|
||||
o Fix for DTLS plaintext recovery attack CVE-2011-4108
|
||||
o Fix policy check double free error CVE-2011-4109
|
||||
o Clear block padding bytes of SSL 3.0 records CVE-2011-4576
|
||||
o Only allow one SGC handshake restart for SSL/TLS CVE-2011-4619
|
||||
o Check for malformed RFC3779 data CVE-2011-4577
|
||||
|
||||
Major changes between OpenSSL 0.9.8q and OpenSSL 0.9.8r [8 Feb 2011]:
|
||||
|
||||
o Fix for security issue CVE-2011-0014
|
||||
|
||||
Major changes between OpenSSL 0.9.8p and OpenSSL 0.9.8q:
|
||||
Major changes between OpenSSL 0.9.8p and OpenSSL 0.9.8q [2 Dec 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-4180
|
||||
o Fix for CVE-2010-4252
|
||||
|
||||
Major changes between OpenSSL 0.9.8o and OpenSSL 0.9.8p:
|
||||
Major changes between OpenSSL 0.9.8o and OpenSSL 0.9.8p [16 Nov 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-3864.
|
||||
|
||||
Major changes between OpenSSL 0.9.8n and OpenSSL 0.9.8o:
|
||||
Major changes between OpenSSL 0.9.8n and OpenSSL 0.9.8o [1 Jun 2010]:
|
||||
|
||||
o Fix for security issue CVE-2010-0742.
|
||||
o Various DTLS fixes.
|
||||
@@ -111,12 +206,12 @@
|
||||
o Fix for no-rc4 compilation.
|
||||
o Chil ENGINE unload workaround.
|
||||
|
||||
Major changes between OpenSSL 0.9.8m and OpenSSL 0.9.8n:
|
||||
Major changes between OpenSSL 0.9.8m and OpenSSL 0.9.8n [24 Mar 2010]:
|
||||
|
||||
o CFB cipher definition fixes.
|
||||
o Fix security issues CVE-2010-0740 and CVE-2010-0433.
|
||||
|
||||
Major changes between OpenSSL 0.9.8l and OpenSSL 0.9.8m:
|
||||
Major changes between OpenSSL 0.9.8l and OpenSSL 0.9.8m [25 Feb 2010]:
|
||||
|
||||
o Cipher definition fixes.
|
||||
o Workaround for slow RAND_poll() on some WIN32 versions.
|
||||
@@ -128,33 +223,33 @@
|
||||
o Ticket and SNI coexistence fixes.
|
||||
o Many fixes to DTLS handling.
|
||||
|
||||
Major changes between OpenSSL 0.9.8k and OpenSSL 0.9.8l:
|
||||
Major changes between OpenSSL 0.9.8k and OpenSSL 0.9.8l [5 Nov 2009]:
|
||||
|
||||
o Temporary work around for CVE-2009-3555: disable renegotiation.
|
||||
|
||||
Major changes between OpenSSL 0.9.8j and OpenSSL 0.9.8k:
|
||||
Major changes between OpenSSL 0.9.8j and OpenSSL 0.9.8k [25 Mar 2009]:
|
||||
|
||||
o Fix various build issues.
|
||||
o Fix security issues (CVE-2009-0590, CVE-2009-0591, CVE-2009-0789)
|
||||
|
||||
Major changes between OpenSSL 0.9.8i and OpenSSL 0.9.8j:
|
||||
Major changes between OpenSSL 0.9.8i and OpenSSL 0.9.8j [7 Jan 2009]:
|
||||
|
||||
o Fix security issue (CVE-2008-5077)
|
||||
o Merge FIPS 140-2 branch code.
|
||||
|
||||
Major changes between OpenSSL 0.9.8g and OpenSSL 0.9.8h:
|
||||
Major changes between OpenSSL 0.9.8g and OpenSSL 0.9.8h [28 May 2008]:
|
||||
|
||||
o CryptoAPI ENGINE support.
|
||||
o Various precautionary measures.
|
||||
o Fix for bugs affecting certificate request creation.
|
||||
o Support for local machine keyset attribute in PKCS#12 files.
|
||||
|
||||
Major changes between OpenSSL 0.9.8f and OpenSSL 0.9.8g:
|
||||
Major changes between OpenSSL 0.9.8f and OpenSSL 0.9.8g [19 Oct 2007]:
|
||||
|
||||
o Backport of CMS functionality to 0.9.8.
|
||||
o Fixes for bugs introduced with 0.9.8f.
|
||||
|
||||
Major changes between OpenSSL 0.9.8e and OpenSSL 0.9.8f:
|
||||
Major changes between OpenSSL 0.9.8e and OpenSSL 0.9.8f [11 Oct 2007]:
|
||||
|
||||
o Add gcc 4.2 support.
|
||||
o Add support for AES and SSE2 assembly lanugauge optimization
|
||||
@@ -165,23 +260,23 @@
|
||||
o RFC4507bis support.
|
||||
o TLS Extensions support.
|
||||
|
||||
Major changes between OpenSSL 0.9.8d and OpenSSL 0.9.8e:
|
||||
Major changes between OpenSSL 0.9.8d and OpenSSL 0.9.8e [23 Feb 2007]:
|
||||
|
||||
o Various ciphersuite selection fixes.
|
||||
o RFC3779 support.
|
||||
|
||||
Major changes between OpenSSL 0.9.8c and OpenSSL 0.9.8d:
|
||||
Major changes between OpenSSL 0.9.8c and OpenSSL 0.9.8d [28 Sep 2006]:
|
||||
|
||||
o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
|
||||
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
|
||||
o Changes to ciphersuite selection algorithm
|
||||
|
||||
Major changes between OpenSSL 0.9.8b and OpenSSL 0.9.8c:
|
||||
Major changes between OpenSSL 0.9.8b and OpenSSL 0.9.8c [5 Sep 2006]:
|
||||
|
||||
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
|
||||
o New cipher Camellia
|
||||
|
||||
Major changes between OpenSSL 0.9.8a and OpenSSL 0.9.8b:
|
||||
Major changes between OpenSSL 0.9.8a and OpenSSL 0.9.8b [4 May 2006]:
|
||||
|
||||
o Cipher string fixes.
|
||||
o Fixes for VC++ 2005.
|
||||
@@ -191,12 +286,12 @@
|
||||
o Built in dynamic engine compilation support on Win32.
|
||||
o Fixes auto dynamic engine loading in Win32.
|
||||
|
||||
Major changes between OpenSSL 0.9.8 and OpenSSL 0.9.8a:
|
||||
Major changes between OpenSSL 0.9.8 and OpenSSL 0.9.8a [11 Oct 2005]:
|
||||
|
||||
o Fix potential SSL 2.0 rollback, CVE-2005-2969
|
||||
o Extended Windows CE support
|
||||
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.8:
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.8 [5 Jul 2005]:
|
||||
|
||||
o Major work on the BIGNUM library for higher efficiency and to
|
||||
make operations more streamlined and less contradictory. This
|
||||
@@ -270,36 +365,36 @@
|
||||
o Added initial support for Win64.
|
||||
o Added alternate pkg-config files.
|
||||
|
||||
Major changes between OpenSSL 0.9.7l and OpenSSL 0.9.7m:
|
||||
Major changes between OpenSSL 0.9.7l and OpenSSL 0.9.7m [23 Feb 2007]:
|
||||
|
||||
o FIPS 1.1.1 module linking.
|
||||
o Various ciphersuite selection fixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.7k and OpenSSL 0.9.7l:
|
||||
Major changes between OpenSSL 0.9.7k and OpenSSL 0.9.7l [28 Sep 2006]:
|
||||
|
||||
o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
|
||||
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
|
||||
|
||||
Major changes between OpenSSL 0.9.7j and OpenSSL 0.9.7k:
|
||||
Major changes between OpenSSL 0.9.7j and OpenSSL 0.9.7k [5 Sep 2006]:
|
||||
|
||||
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
|
||||
|
||||
Major changes between OpenSSL 0.9.7i and OpenSSL 0.9.7j:
|
||||
Major changes between OpenSSL 0.9.7i and OpenSSL 0.9.7j [4 May 2006]:
|
||||
|
||||
o Visual C++ 2005 fixes.
|
||||
o Update Windows build system for FIPS.
|
||||
|
||||
Major changes between OpenSSL 0.9.7h and OpenSSL 0.9.7i:
|
||||
Major changes between OpenSSL 0.9.7h and OpenSSL 0.9.7i [14 Oct 2005]:
|
||||
|
||||
o Give EVP_MAX_MD_SIZE it's old value, except for a FIPS build.
|
||||
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h:
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h [11 Oct 2005]:
|
||||
|
||||
o Fix SSL 2.0 Rollback, CVE-2005-2969
|
||||
o Allow use of fixed-length exponent on DSA signing
|
||||
o Default fixed-window RSA, DSA, DH private-key operations
|
||||
|
||||
Major changes between OpenSSL 0.9.7f and OpenSSL 0.9.7g:
|
||||
Major changes between OpenSSL 0.9.7f and OpenSSL 0.9.7g [11 Apr 2005]:
|
||||
|
||||
o More compilation issues fixed.
|
||||
o Adaptation to more modern Kerberos API.
|
||||
@@ -308,7 +403,7 @@
|
||||
o More constification.
|
||||
o Added processing of proxy certificates (RFC 3820).
|
||||
|
||||
Major changes between OpenSSL 0.9.7e and OpenSSL 0.9.7f:
|
||||
Major changes between OpenSSL 0.9.7e and OpenSSL 0.9.7f [22 Mar 2005]:
|
||||
|
||||
o Several compilation issues fixed.
|
||||
o Many memory allocation failure checks added.
|
||||
@@ -316,12 +411,12 @@
|
||||
o Mandatory basic checks on certificates.
|
||||
o Performance improvements.
|
||||
|
||||
Major changes between OpenSSL 0.9.7d and OpenSSL 0.9.7e:
|
||||
Major changes between OpenSSL 0.9.7d and OpenSSL 0.9.7e [25 Oct 2004]:
|
||||
|
||||
o Fix race condition in CRL checking code.
|
||||
o Fixes to PKCS#7 (S/MIME) code.
|
||||
|
||||
Major changes between OpenSSL 0.9.7c and OpenSSL 0.9.7d:
|
||||
Major changes between OpenSSL 0.9.7c and OpenSSL 0.9.7d [17 Mar 2004]:
|
||||
|
||||
o Security: Fix Kerberos ciphersuite SSL/TLS handshaking bug
|
||||
o Security: Fix null-pointer assignment in do_change_cipher_spec()
|
||||
@@ -329,14 +424,14 @@
|
||||
o Multiple X509 verification fixes
|
||||
o Speed up HMAC and other operations
|
||||
|
||||
Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c:
|
||||
Major changes between OpenSSL 0.9.7b and OpenSSL 0.9.7c [30 Sep 2003]:
|
||||
|
||||
o Security: fix various ASN1 parsing bugs.
|
||||
o New -ignore_err option to OCSP utility.
|
||||
o Various interop and bug fixes in S/MIME code.
|
||||
o SSL/TLS protocol fix for unrequested client certificates.
|
||||
|
||||
Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b:
|
||||
Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b [10 Apr 2003]:
|
||||
|
||||
o Security: counter the Klima-Pokorny-Rosa extension of
|
||||
Bleichbacher's attack
|
||||
@@ -347,7 +442,7 @@
|
||||
o ASN.1: treat domainComponent correctly.
|
||||
o Documentation: fixes and additions.
|
||||
|
||||
Major changes between OpenSSL 0.9.7 and OpenSSL 0.9.7a:
|
||||
Major changes between OpenSSL 0.9.7 and OpenSSL 0.9.7a [19 Feb 2003]:
|
||||
|
||||
o Security: Important security related bugfixes.
|
||||
o Enhanced compatibility with MIT Kerberos.
|
||||
@@ -358,7 +453,7 @@
|
||||
o SSL/TLS: now handles manual certificate chain building.
|
||||
o SSL/TLS: certain session ID malfunctions corrected.
|
||||
|
||||
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7:
|
||||
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7 [30 Dec 2002]:
|
||||
|
||||
o New library section OCSP.
|
||||
o Complete rewrite of ASN1 code.
|
||||
@@ -404,23 +499,23 @@
|
||||
o SSL/TLS: add callback to retrieve SSL/TLS messages.
|
||||
o SSL/TLS: support AES cipher suites (RFC3268).
|
||||
|
||||
Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k:
|
||||
Major changes between OpenSSL 0.9.6j and OpenSSL 0.9.6k [30 Sep 2003]:
|
||||
|
||||
o Security: fix various ASN1 parsing bugs.
|
||||
o SSL/TLS protocol fix for unrequested client certificates.
|
||||
|
||||
Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j:
|
||||
Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j [10 Apr 2003]:
|
||||
|
||||
o Security: counter the Klima-Pokorny-Rosa extension of
|
||||
Bleichbacher's attack
|
||||
o Security: make RSA blinding default.
|
||||
o Build: shared library support fixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.6h and OpenSSL 0.9.6i:
|
||||
Major changes between OpenSSL 0.9.6h and OpenSSL 0.9.6i [19 Feb 2003]:
|
||||
|
||||
o Important security related bugfixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.6g and OpenSSL 0.9.6h:
|
||||
Major changes between OpenSSL 0.9.6g and OpenSSL 0.9.6h [5 Dec 2002]:
|
||||
|
||||
o New configuration targets for Tandem OSS and A/UX.
|
||||
o New OIDs for Microsoft attributes.
|
||||
@@ -434,25 +529,25 @@
|
||||
o Fixes for smaller building problems.
|
||||
o Updates of manuals, FAQ and other instructive documents.
|
||||
|
||||
Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g:
|
||||
Major changes between OpenSSL 0.9.6f and OpenSSL 0.9.6g [9 Aug 2002]:
|
||||
|
||||
o Important building fixes on Unix.
|
||||
|
||||
Major changes between OpenSSL 0.9.6e and OpenSSL 0.9.6f:
|
||||
Major changes between OpenSSL 0.9.6e and OpenSSL 0.9.6f [8 Aug 2002]:
|
||||
|
||||
o Various important bugfixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.6d and OpenSSL 0.9.6e:
|
||||
Major changes between OpenSSL 0.9.6d and OpenSSL 0.9.6e [30 Jul 2002]:
|
||||
|
||||
o Important security related bugfixes.
|
||||
o Various SSL/TLS library bugfixes.
|
||||
|
||||
Major changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d:
|
||||
Major changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d [9 May 2002]:
|
||||
|
||||
o Various SSL/TLS library bugfixes.
|
||||
o Fix DH parameter generation for 'non-standard' generators.
|
||||
|
||||
Major changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c:
|
||||
Major changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c [21 Dec 2001]:
|
||||
|
||||
o Various SSL/TLS library bugfixes.
|
||||
o BIGNUM library fixes.
|
||||
@@ -465,7 +560,7 @@
|
||||
Broadcom and Cryptographic Appliance's keyserver
|
||||
[in 0.9.6c-engine release].
|
||||
|
||||
Major changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b:
|
||||
Major changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b [9 Jul 2001]:
|
||||
|
||||
o Security fix: PRNG improvements.
|
||||
o Security fix: RSA OAEP check.
|
||||
@@ -482,7 +577,7 @@
|
||||
o Increase default size for BIO buffering filter.
|
||||
o Compatibility fixes in some scripts.
|
||||
|
||||
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a:
|
||||
Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a [5 Apr 2001]:
|
||||
|
||||
o Security fix: change behavior of OpenSSL to avoid using
|
||||
environment variables when running as root.
|
||||
@@ -507,7 +602,7 @@
|
||||
o New function BN_rand_range().
|
||||
o Add "-rand" option to openssl s_client and s_server.
|
||||
|
||||
Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6:
|
||||
Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6 [10 Oct 2000]:
|
||||
|
||||
o Some documentation for BIO and SSL libraries.
|
||||
o Enhanced chain verification using key identifiers.
|
||||
@@ -522,7 +617,7 @@
|
||||
[1] The support for external crypto devices is currently a separate
|
||||
distribution. See the file README.ENGINE.
|
||||
|
||||
Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a:
|
||||
Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a [1 Apr 2000]:
|
||||
|
||||
o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8
|
||||
o Shared library support for HPUX and Solaris-gcc
|
||||
@@ -531,7 +626,7 @@
|
||||
o New 'rand' application
|
||||
o New way to check for existence of algorithms from scripts
|
||||
|
||||
Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5:
|
||||
Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5 [25 May 2000]:
|
||||
|
||||
o S/MIME support in new 'smime' command
|
||||
o Documentation for the OpenSSL command line application
|
||||
@@ -567,7 +662,7 @@
|
||||
o Enhanced support for Alpha Linux
|
||||
o Experimental MacOS support
|
||||
|
||||
Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4:
|
||||
Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4 [9 Aug 1999]:
|
||||
|
||||
o Transparent support for PKCS#8 format private keys: these are used
|
||||
by several software packages and are more secure than the standard
|
||||
@@ -578,7 +673,7 @@
|
||||
o New pipe-like BIO that allows using the SSL library when actual I/O
|
||||
must be handled by the application (BIO pair)
|
||||
|
||||
Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3:
|
||||
Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3 [24 May 1999]:
|
||||
o Lots of enhancements and cleanups to the Configuration mechanism
|
||||
o RSA OEAP related fixes
|
||||
o Added `openssl ca -revoke' option for revoking a certificate
|
||||
@@ -592,7 +687,7 @@
|
||||
o Sparc assembler bignum implementation, optimized hash functions
|
||||
o Option to disable selected ciphers
|
||||
|
||||
Major changes between OpenSSL 0.9.1c and OpenSSL 0.9.2b:
|
||||
Major changes between OpenSSL 0.9.1c and OpenSSL 0.9.2b [22 Mar 1999]:
|
||||
o Fixed a security hole related to session resumption
|
||||
o Fixed RSA encryption routines for the p < q case
|
||||
o "ALL" in cipher lists now means "everything except NULL ciphers"
|
||||
@@ -614,7 +709,7 @@
|
||||
o Lots of memory leak fixes.
|
||||
o Lots of bug fixes.
|
||||
|
||||
Major changes between SSLeay 0.9.0b and OpenSSL 0.9.1c:
|
||||
Major changes between SSLeay 0.9.0b and OpenSSL 0.9.1c [23 Dec 1998]:
|
||||
o Integration of the popular NO_RSA/NO_DSA patches
|
||||
o Initial support for compression inside the SSL record layer
|
||||
o Added BIO proxy and filtering functionality
|
||||
|
||||
14
PROBLEMS
14
PROBLEMS
@@ -197,3 +197,17 @@ reconfigure with additional no-sse2 [or 386] option passed to ./config.
|
||||
We don't have framework to associate -ldl with no-dso, therefore the only
|
||||
way is to edit Makefile right after ./config no-dso and remove -ldl from
|
||||
EX_LIBS line.
|
||||
|
||||
* hpux-parisc2-cc no-asm build fails with SEGV in ECDSA/DH.
|
||||
|
||||
Compiler bug, presumably at particular patch level. Remaining
|
||||
hpux*-parisc*-cc configurations can be affected too. Drop optimization
|
||||
level to +O2 when compiling bn_nist.o.
|
||||
|
||||
* solaris64-sparcv9-cc link failure
|
||||
|
||||
Solaris 8 ar can fail to maintain symbol table in .a, which results in
|
||||
link failures. Apply 109147-09 or later or modify Makefile generated
|
||||
by ./Configure solaris64-sparcv9-cc and replace RANLIB assignment with
|
||||
|
||||
RANLIB= /usr/ccs/bin/ar rs
|
||||
|
||||
30
README
30
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.1 14 Mar 2012
|
||||
OpenSSL 1.0.2-beta1 24 Feb 2014
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
@@ -90,32 +90,6 @@
|
||||
SSL/TLS Client and Server Tests
|
||||
Handling of S/MIME signed or encrypted mail
|
||||
|
||||
|
||||
PATENTS
|
||||
-------
|
||||
|
||||
Various companies hold various patents for various algorithms in various
|
||||
locations around the world. _YOU_ are responsible for ensuring that your use
|
||||
of any algorithms is legal by checking if there are any patents in your
|
||||
country. The file contains some of the patents that we know about or are
|
||||
rumored to exist. This is not a definitive list.
|
||||
|
||||
RSA Security holds software patents on the RC5 algorithm. If you
|
||||
intend to use this cipher, you must contact RSA Security for
|
||||
licensing conditions. Their web page is http://www.rsasecurity.com/.
|
||||
|
||||
RC4 is a trademark of RSA Security, so use of this label should perhaps
|
||||
only be used with RSA Security's permission.
|
||||
|
||||
The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy,
|
||||
Japan, the Netherlands, Spain, Sweden, Switzerland, UK and the USA. They
|
||||
should be contacted if that algorithm is to be used; their web page is
|
||||
http://www.ascom.ch/.
|
||||
|
||||
NTT and Mitsubishi have patents and pending patents on the Camellia
|
||||
algorithm, but allow use at no charge without requiring an explicit
|
||||
licensing agreement: http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
@@ -190,7 +164,7 @@
|
||||
reason as to why that feature isn't implemented.
|
||||
|
||||
Patches should be as up to date as possible, preferably relative to the
|
||||
current CVS or the last snapshot. They should follow the coding style of
|
||||
current Git or the last snapshot. They should follow the coding style of
|
||||
OpenSSL and compile without warnings. Some of the core team developer targets
|
||||
can be used for testing purposes, (debug-steve64, debug-geoff etc). OpenSSL
|
||||
compiles on many varied platforms: try to ensure you only use portable
|
||||
|
||||
155
STATUS
155
STATUS
@@ -1,155 +0,0 @@
|
||||
|
||||
OpenSSL STATUS Last modified at
|
||||
______________ $Date: 2012/03/14 12:14:06 $
|
||||
|
||||
DEVELOPMENT STATE
|
||||
|
||||
o OpenSSL 1.1.0: Under development...
|
||||
o OpenSSL 1.0.1: Released on March 14th, 2012
|
||||
o OpenSSL 1.0.0h: Released on March 12th, 2012
|
||||
o OpenSSL 1.0.0g: Released on January 18th, 2012
|
||||
o OpenSSL 1.0.0f: Released on January 4th, 2012
|
||||
o OpenSSL 1.0.0e: Released on September 6th, 2011
|
||||
o OpenSSL 1.0.0d: Released on February 8nd, 2011
|
||||
o OpenSSL 1.0.0c: Released on December 2nd, 2010
|
||||
o OpenSSL 1.0.0b: Released on November 16th, 2010
|
||||
o OpenSSL 1.0.0a: Released on June 1st, 2010
|
||||
o OpenSSL 1.0.0: Released on March 29th, 2010
|
||||
o OpenSSL 0.9.8u: Released on March 12th, 2012
|
||||
o OpenSSL 0.9.8t: Released on January 18th, 2012
|
||||
o OpenSSL 0.9.8s: Released on January 4th, 2012
|
||||
o OpenSSL 0.9.8r: Released on February 8nd, 2011
|
||||
o OpenSSL 0.9.8q: Released on December 2nd, 2010
|
||||
o OpenSSL 0.9.8p: Released on November 16th, 2010
|
||||
o OpenSSL 0.9.8o: Released on June 1st, 2010
|
||||
o OpenSSL 0.9.8n: Released on March 24th, 2010
|
||||
o OpenSSL 0.9.8m: Released on February 25th, 2010
|
||||
o OpenSSL 0.9.8l: Released on November 5th, 2009
|
||||
o OpenSSL 0.9.8k: Released on March 25th, 2009
|
||||
o OpenSSL 0.9.8j: Released on January 7th, 2009
|
||||
o OpenSSL 0.9.8i: Released on September 15th, 2008
|
||||
o OpenSSL 0.9.8h: Released on May 28th, 2008
|
||||
o OpenSSL 0.9.8g: Released on October 19th, 2007
|
||||
o OpenSSL 0.9.8f: Released on October 11th, 2007
|
||||
o OpenSSL 0.9.8e: Released on February 23rd, 2007
|
||||
o OpenSSL 0.9.8d: Released on September 28th, 2006
|
||||
o OpenSSL 0.9.8c: Released on September 5th, 2006
|
||||
o OpenSSL 0.9.8b: Released on May 4th, 2006
|
||||
o OpenSSL 0.9.8a: Released on October 11th, 2005
|
||||
o OpenSSL 0.9.8: Released on July 5th, 2005
|
||||
o OpenSSL 0.9.7m: Released on February 23rd, 2007
|
||||
o OpenSSL 0.9.7l: Released on September 28th, 2006
|
||||
o OpenSSL 0.9.7k: Released on September 5th, 2006
|
||||
o OpenSSL 0.9.7j: Released on May 4th, 2006
|
||||
o OpenSSL 0.9.7i: Released on October 14th, 2005
|
||||
o OpenSSL 0.9.7h: Released on October 11th, 2005
|
||||
o OpenSSL 0.9.7g: Released on April 11th, 2005
|
||||
o OpenSSL 0.9.7f: Released on March 22nd, 2005
|
||||
o OpenSSL 0.9.7e: Released on October 25th, 2004
|
||||
o OpenSSL 0.9.7d: Released on March 17th, 2004
|
||||
o OpenSSL 0.9.7c: Released on September 30th, 2003
|
||||
o OpenSSL 0.9.7b: Released on April 10th, 2003
|
||||
o OpenSSL 0.9.7a: Released on February 19th, 2003
|
||||
o OpenSSL 0.9.7: Released on December 31st, 2002
|
||||
o OpenSSL 0.9.6m: Released on March 17th, 2004
|
||||
o OpenSSL 0.9.6l: Released on November 4th, 2003
|
||||
o OpenSSL 0.9.6k: Released on September 30th, 2003
|
||||
o OpenSSL 0.9.6j: Released on April 10th, 2003
|
||||
o OpenSSL 0.9.6i: Released on February 19th, 2003
|
||||
o OpenSSL 0.9.6h: Released on December 5th, 2002
|
||||
o OpenSSL 0.9.6g: Released on August 9th, 2002
|
||||
o OpenSSL 0.9.6f: Released on August 8th, 2002
|
||||
o OpenSSL 0.9.6e: Released on July 30th, 2002
|
||||
o OpenSSL 0.9.6d: Released on May 9th, 2002
|
||||
o OpenSSL 0.9.6c: Released on December 21st, 2001
|
||||
o OpenSSL 0.9.6b: Released on July 9th, 2001
|
||||
o OpenSSL 0.9.6a: Released on April 5th, 2001
|
||||
o OpenSSL 0.9.6: Released on September 24th, 2000
|
||||
o OpenSSL 0.9.5a: Released on April 1st, 2000
|
||||
o OpenSSL 0.9.5: Released on February 28th, 2000
|
||||
o OpenSSL 0.9.4: Released on August 09th, 1999
|
||||
o OpenSSL 0.9.3a: Released on May 29th, 1999
|
||||
o OpenSSL 0.9.3: Released on May 25th, 1999
|
||||
o OpenSSL 0.9.2b: Released on March 22th, 1999
|
||||
o OpenSSL 0.9.1c: Released on December 23th, 1998
|
||||
|
||||
[See also http://www.openssl.org/support/rt.html]
|
||||
|
||||
RELEASE SHOWSTOPPERS
|
||||
|
||||
o The Makefiles fail with some SysV makes.
|
||||
o
|
||||
|
||||
AVAILABLE PATCHES
|
||||
|
||||
o
|
||||
|
||||
IN PROGRESS
|
||||
|
||||
o Steve is currently working on (in no particular order):
|
||||
ASN1 code redesign, butchery, replacement.
|
||||
OCSP
|
||||
EVP cipher enhancement.
|
||||
Enhanced certificate chain verification.
|
||||
Private key, certificate and CRL API and implementation.
|
||||
Developing and bugfixing PKCS#7 (S/MIME code).
|
||||
Various X509 issues: character sets, certificate request extensions.
|
||||
o Richard is currently working on:
|
||||
Constification
|
||||
Attribute Certificate support
|
||||
Certificate Pair support
|
||||
Storage Engines (primarly an LDAP storage engine)
|
||||
Certificate chain validation with full RFC 3280 compatibility
|
||||
|
||||
NEEDS PATCH
|
||||
|
||||
o 0.9.8-dev: COMPLEMENTOFALL and COMPLEMENTOFDEFAULT do not
|
||||
handle ECCdraft cipher suites correctly.
|
||||
|
||||
o apps/ca.c: "Sign the certificate?" - "n" creates empty certificate file
|
||||
|
||||
o "OpenSSL STATUS" is never up-to-date.
|
||||
|
||||
OPEN ISSUES
|
||||
|
||||
o The Makefile hierarchy and build mechanism is still not a round thing:
|
||||
|
||||
1. The config vs. Configure scripts
|
||||
It's the same nasty situation as for Apache with APACI vs.
|
||||
src/Configure. It confuses.
|
||||
Suggestion: Merge Configure and config into a single configure
|
||||
script with a Autoconf style interface ;-) and remove
|
||||
Configure and config. Or even let us use GNU Autoconf
|
||||
itself. Then we can avoid a lot of those platform checks
|
||||
which are currently in Configure.
|
||||
|
||||
o Support for Shared Libraries has to be added at least
|
||||
for the major Unix platforms. The details we can rip from the stuff
|
||||
Ralf has done for the Apache src/Configure script. Ben wants the
|
||||
solution to be really simple.
|
||||
|
||||
Status: Ralf will look how we can easily incorporate the
|
||||
compiler PIC and linker DSO flags from Apache
|
||||
into the OpenSSL Configure script.
|
||||
|
||||
Ulf: +1 for using GNU autoconf and libtool (but not automake,
|
||||
which apparently is not flexible enough to generate
|
||||
libcrypto)
|
||||
|
||||
WISHES
|
||||
|
||||
o Add variants of DH_generate_parameters() and BN_generate_prime() [etc?]
|
||||
where the callback function can request that the function be aborted.
|
||||
[Gregory Stark <ghstark@pobox.com>, <rayyang2000@yahoo.com>]
|
||||
|
||||
o SRP in TLS.
|
||||
[wished by:
|
||||
Dj <derek@yo.net>, Tom Wu <tom@arcot.com>,
|
||||
Tom Holroyd <tomh@po.crl.go.jp>]
|
||||
|
||||
See http://search.ietf.org/internet-drafts/draft-ietf-tls-srp-00.txt
|
||||
as well as http://www-cs-students.stanford.edu/~tjw/srp/.
|
||||
|
||||
Tom Holroyd tells us there is a SRP patch for OpenSSH at
|
||||
http://members.tripod.com/professor_tom/archives/, that could
|
||||
be useful.
|
||||
@@ -577,14 +577,15 @@ openssl.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
|
||||
openssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
openssl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
|
||||
openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
|
||||
openssl.o: ../include/openssl/pqueue.h ../include/openssl/safestack.h
|
||||
openssl.o: ../include/openssl/sha.h ../include/openssl/srtp.h
|
||||
openssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
|
||||
openssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
|
||||
openssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
openssl.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
|
||||
openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
|
||||
openssl.o: ../include/openssl/x509v3.h apps.h openssl.c progs.h s_apps.h
|
||||
openssl.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
|
||||
openssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
|
||||
openssl.o: ../include/openssl/srtp.h ../include/openssl/ssl.h
|
||||
openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
|
||||
openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
|
||||
openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
|
||||
openssl.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
|
||||
openssl.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
|
||||
openssl.o: openssl.c progs.h s_apps.h
|
||||
passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
||||
passwd.o: ../include/openssl/buffer.h ../include/openssl/conf.h
|
||||
passwd.o: ../include/openssl/crypto.h ../include/openssl/des.h
|
||||
|
||||
284
apps/apps.c
284
apps/apps.c
@@ -118,7 +118,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(NETWARE_CLIB)
|
||||
#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYSNAME_WINCE) && !defined(NETWARE_CLIB)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
@@ -275,6 +275,8 @@ int str2fmt(char *s)
|
||||
return(FORMAT_PKCS12);
|
||||
else if ((*s == 'E') || (*s == 'e'))
|
||||
return(FORMAT_ENGINE);
|
||||
else if ((*s == 'H') || (*s == 'h'))
|
||||
return FORMAT_HTTP;
|
||||
else if ((*s == 'P') || (*s == 'p'))
|
||||
{
|
||||
if (s[1] == 'V' || s[1] == 'v')
|
||||
@@ -783,12 +785,80 @@ static int load_pkcs12(BIO *err, BIO *in, const char *desc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int load_cert_crl_http(const char *url, BIO *err,
|
||||
X509 **pcert, X509_CRL **pcrl)
|
||||
{
|
||||
char *host = NULL, *port = NULL, *path = NULL;
|
||||
BIO *bio = NULL;
|
||||
OCSP_REQ_CTX *rctx = NULL;
|
||||
int use_ssl, rv = 0;
|
||||
if (!OCSP_parse_url(url, &host, &port, &path, &use_ssl))
|
||||
goto err;
|
||||
if (use_ssl)
|
||||
{
|
||||
if (err)
|
||||
BIO_puts(err, "https not supported\n");
|
||||
goto err;
|
||||
}
|
||||
bio = BIO_new_connect(host);
|
||||
if (!bio || !BIO_set_conn_port(bio, port))
|
||||
goto err;
|
||||
rctx = OCSP_REQ_CTX_new(bio, 1024);
|
||||
if (!rctx)
|
||||
goto err;
|
||||
if (!OCSP_REQ_CTX_http(rctx, "GET", path))
|
||||
goto err;
|
||||
if (!OCSP_REQ_CTX_add1_header(rctx, "Host", host))
|
||||
goto err;
|
||||
if (pcert)
|
||||
{
|
||||
do
|
||||
{
|
||||
rv = X509_http_nbio(rctx, pcert);
|
||||
}
|
||||
while (rv == -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
rv = X509_CRL_http_nbio(rctx, pcrl);
|
||||
} while (rv == -1);
|
||||
}
|
||||
|
||||
err:
|
||||
if (host)
|
||||
OPENSSL_free(host);
|
||||
if (path)
|
||||
OPENSSL_free(path);
|
||||
if (port)
|
||||
OPENSSL_free(port);
|
||||
if (bio)
|
||||
BIO_free_all(bio);
|
||||
if (rctx)
|
||||
OCSP_REQ_CTX_free(rctx);
|
||||
if (rv != 1)
|
||||
{
|
||||
if (bio && err)
|
||||
BIO_printf(bio_err, "Error loading %s from %s\n",
|
||||
pcert ? "certificate" : "CRL", url);
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
X509 *load_cert(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e, const char *cert_descrip)
|
||||
{
|
||||
X509 *x=NULL;
|
||||
BIO *cert;
|
||||
|
||||
if (format == FORMAT_HTTP)
|
||||
{
|
||||
load_cert_crl_http(file, err, &x, NULL);
|
||||
return x;
|
||||
}
|
||||
|
||||
if ((cert=BIO_new(BIO_s_file())) == NULL)
|
||||
{
|
||||
ERR_print_errors(err);
|
||||
@@ -859,6 +929,55 @@ end:
|
||||
return(x);
|
||||
}
|
||||
|
||||
X509_CRL *load_crl(const char *infile, int format)
|
||||
{
|
||||
X509_CRL *x=NULL;
|
||||
BIO *in=NULL;
|
||||
|
||||
if (format == FORMAT_HTTP)
|
||||
{
|
||||
load_cert_crl_http(infile, bio_err, NULL, &x);
|
||||
return x;
|
||||
}
|
||||
|
||||
in=BIO_new(BIO_s_file());
|
||||
if (in == NULL)
|
||||
{
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
else
|
||||
{
|
||||
if (BIO_read_filename(in,infile) <= 0)
|
||||
{
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (format == FORMAT_ASN1)
|
||||
x=d2i_X509_CRL_bio(in,NULL);
|
||||
else if (format == FORMAT_PEM)
|
||||
x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
|
||||
else {
|
||||
BIO_printf(bio_err,"bad input format specified for input crl\n");
|
||||
goto end;
|
||||
}
|
||||
if (x == NULL)
|
||||
{
|
||||
BIO_printf(bio_err,"unable to load CRL\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
BIO_free(in);
|
||||
return(x);
|
||||
}
|
||||
|
||||
|
||||
EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
|
||||
const char *pass, ENGINE *e, const char *key_descrip)
|
||||
{
|
||||
@@ -2132,7 +2251,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
|
||||
X509_NAME *n = NULL;
|
||||
int nid;
|
||||
|
||||
if (!buf || !ne_types || !ne_values)
|
||||
if (!buf || !ne_types || !ne_values || !mval)
|
||||
{
|
||||
BIO_printf(bio_err, "malloc error\n");
|
||||
goto error;
|
||||
@@ -2236,6 +2355,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
|
||||
OPENSSL_free(ne_values);
|
||||
OPENSSL_free(ne_types);
|
||||
OPENSSL_free(buf);
|
||||
OPENSSL_free(mval);
|
||||
return n;
|
||||
|
||||
error:
|
||||
@@ -2244,6 +2364,8 @@ error:
|
||||
OPENSSL_free(ne_values);
|
||||
if (ne_types)
|
||||
OPENSSL_free(ne_types);
|
||||
if (mval)
|
||||
OPENSSL_free(mval);
|
||||
if (buf)
|
||||
OPENSSL_free(buf);
|
||||
return NULL;
|
||||
@@ -2259,6 +2381,8 @@ int args_verify(char ***pargs, int *pargc,
|
||||
char **oldargs = *pargs;
|
||||
char *arg = **pargs, *argn = (*pargs)[1];
|
||||
time_t at_time = 0;
|
||||
const unsigned char *hostname = NULL, *email = NULL;
|
||||
char *ipasc = NULL;
|
||||
if (!strcmp(arg, "-policy"))
|
||||
{
|
||||
if (!argn)
|
||||
@@ -2332,6 +2456,27 @@ int args_verify(char ***pargs, int *pargc,
|
||||
}
|
||||
(*pargs)++;
|
||||
}
|
||||
else if (strcmp(arg,"-verify_hostname") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
*badarg = 1;
|
||||
hostname = (unsigned char *)argn;
|
||||
(*pargs)++;
|
||||
}
|
||||
else if (strcmp(arg,"-verify_email") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
*badarg = 1;
|
||||
email = (unsigned char *)argn;
|
||||
(*pargs)++;
|
||||
}
|
||||
else if (strcmp(arg,"-verify_ip") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
*badarg = 1;
|
||||
ipasc = argn;
|
||||
(*pargs)++;
|
||||
}
|
||||
else if (!strcmp(arg, "-ignore_critical"))
|
||||
flags |= X509_V_FLAG_IGNORE_CRITICAL;
|
||||
else if (!strcmp(arg, "-issuer_checks"))
|
||||
@@ -2358,6 +2503,16 @@ int args_verify(char ***pargs, int *pargc,
|
||||
flags |= X509_V_FLAG_NOTIFY_POLICY;
|
||||
else if (!strcmp(arg, "-check_ss_sig"))
|
||||
flags |= X509_V_FLAG_CHECK_SS_SIGNATURE;
|
||||
else if (!strcmp(arg, "-trusted_first"))
|
||||
flags |= X509_V_FLAG_TRUSTED_FIRST;
|
||||
else if (!strcmp(arg, "-suiteB_128_only"))
|
||||
flags |= X509_V_FLAG_SUITEB_128_LOS_ONLY;
|
||||
else if (!strcmp(arg, "-suiteB_128"))
|
||||
flags |= X509_V_FLAG_SUITEB_128_LOS;
|
||||
else if (!strcmp(arg, "-suiteB_192"))
|
||||
flags |= X509_V_FLAG_SUITEB_192_LOS;
|
||||
else if (!strcmp(arg, "-partial_chain"))
|
||||
flags |= X509_V_FLAG_PARTIAL_CHAIN;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -2389,6 +2544,15 @@ int args_verify(char ***pargs, int *pargc,
|
||||
if (at_time)
|
||||
X509_VERIFY_PARAM_set_time(*pm, at_time);
|
||||
|
||||
if (hostname && !X509_VERIFY_PARAM_set1_host(*pm, hostname, 0))
|
||||
*badarg = 1;
|
||||
|
||||
if (email && !X509_VERIFY_PARAM_set1_email(*pm, email, 0))
|
||||
*badarg = 1;
|
||||
|
||||
if (ipasc && !X509_VERIFY_PARAM_set1_ip_asc(*pm, ipasc))
|
||||
*badarg = 1;
|
||||
|
||||
end:
|
||||
|
||||
(*pargs)++;
|
||||
@@ -2681,6 +2845,9 @@ void jpake_client_auth(BIO *out, BIO *conn, const char *secret)
|
||||
|
||||
BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
|
||||
|
||||
if (psk_key)
|
||||
OPENSSL_free(psk_key);
|
||||
|
||||
psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
|
||||
|
||||
BIO_pop(bconn);
|
||||
@@ -2710,6 +2877,9 @@ void jpake_server_auth(BIO *out, BIO *conn, const char *secret)
|
||||
|
||||
BIO_puts(out, "JPAKE authentication succeeded, setting PSK\n");
|
||||
|
||||
if (psk_key)
|
||||
OPENSSL_free(psk_key);
|
||||
|
||||
psk_key = BN_bn2hex(JPAKE_get_shared_key(ctx));
|
||||
|
||||
BIO_pop(bconn);
|
||||
@@ -2720,7 +2890,7 @@ void jpake_server_auth(BIO *out, BIO *conn, const char *secret)
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
/* next_protos_parse parses a comma separated list of strings into a string
|
||||
* in a format suitable for passing to SSL_CTX_set_next_protos_advertised.
|
||||
* outlen: (output) set to the length of the resulting buffer on success.
|
||||
@@ -2762,7 +2932,113 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in)
|
||||
*outlen = len + 1;
|
||||
return out;
|
||||
}
|
||||
#endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */
|
||||
#endif /* ndef OPENSSL_NO_TLSEXT */
|
||||
|
||||
void print_cert_checks(BIO *bio, X509 *x,
|
||||
const unsigned char *checkhost,
|
||||
const unsigned char *checkemail,
|
||||
const char *checkip)
|
||||
{
|
||||
if (x == NULL)
|
||||
return;
|
||||
if (checkhost)
|
||||
{
|
||||
BIO_printf(bio, "Hostname %s does%s match certificate\n",
|
||||
checkhost, X509_check_host(x, checkhost, 0, 0)
|
||||
? "" : " NOT");
|
||||
}
|
||||
|
||||
if (checkemail)
|
||||
{
|
||||
BIO_printf(bio, "Email %s does%s match certificate\n",
|
||||
checkemail, X509_check_email(x, checkemail, 0,
|
||||
0) ? "" : " NOT");
|
||||
}
|
||||
|
||||
if (checkip)
|
||||
{
|
||||
BIO_printf(bio, "IP %s does%s match certificate\n",
|
||||
checkip, X509_check_ip_asc(x, checkip,
|
||||
0) ? "" : " NOT");
|
||||
}
|
||||
}
|
||||
|
||||
/* Get first http URL from a DIST_POINT structure */
|
||||
|
||||
static const char *get_dp_url(DIST_POINT *dp)
|
||||
{
|
||||
GENERAL_NAMES *gens;
|
||||
GENERAL_NAME *gen;
|
||||
int i, gtype;
|
||||
ASN1_STRING *uri;
|
||||
if (!dp->distpoint || dp->distpoint->type != 0)
|
||||
return NULL;
|
||||
gens = dp->distpoint->name.fullname;
|
||||
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
|
||||
{
|
||||
gen = sk_GENERAL_NAME_value(gens, i);
|
||||
uri = GENERAL_NAME_get0_value(gen, >ype);
|
||||
if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6)
|
||||
{
|
||||
char *uptr = (char *)ASN1_STRING_data(uri);
|
||||
if (!strncmp(uptr, "http://", 7))
|
||||
return uptr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Look through a CRLDP structure and attempt to find an http URL to downloads
|
||||
* a CRL from.
|
||||
*/
|
||||
|
||||
static X509_CRL *load_crl_crldp(STACK_OF(DIST_POINT) *crldp)
|
||||
{
|
||||
int i;
|
||||
const char *urlptr = NULL;
|
||||
for (i = 0; i < sk_DIST_POINT_num(crldp); i++)
|
||||
{
|
||||
DIST_POINT *dp = sk_DIST_POINT_value(crldp, i);
|
||||
urlptr = get_dp_url(dp);
|
||||
if (urlptr)
|
||||
return load_crl(urlptr, FORMAT_HTTP);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Example of downloading CRLs from CRLDP: not usable for real world
|
||||
* as it always downloads, doesn't support non-blocking I/O and doesn't
|
||||
* cache anything.
|
||||
*/
|
||||
|
||||
static STACK_OF(X509_CRL) *crls_http_cb(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
{
|
||||
X509 *x;
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
X509_CRL *crl;
|
||||
STACK_OF(DIST_POINT) *crldp;
|
||||
x = X509_STORE_CTX_get_current_cert(ctx);
|
||||
crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
|
||||
crl = load_crl_crldp(crldp);
|
||||
sk_DIST_POINT_pop_free(crldp, DIST_POINT_free);
|
||||
if (!crl)
|
||||
return NULL;
|
||||
crls = sk_X509_CRL_new_null();
|
||||
sk_X509_CRL_push(crls, crl);
|
||||
/* Try to download delta CRL */
|
||||
crldp = X509_get_ext_d2i(x, NID_freshest_crl, NULL, NULL);
|
||||
crl = load_crl_crldp(crldp);
|
||||
sk_DIST_POINT_pop_free(crldp, DIST_POINT_free);
|
||||
if (crl)
|
||||
sk_X509_CRL_push(crls, crl);
|
||||
return crls;
|
||||
}
|
||||
|
||||
void store_setup_crl_download(X509_STORE *st)
|
||||
{
|
||||
X509_STORE_set_lookup_crls_cb(st, crls_http_cb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Platform-specific sections
|
||||
|
||||
26
apps/apps.h
26
apps/apps.h
@@ -188,6 +188,7 @@ extern BIO *bio_err;
|
||||
do { CONF_modules_unload(1); destroy_ui_method(); \
|
||||
OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \
|
||||
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
|
||||
RAND_cleanup(); \
|
||||
ERR_free_strings(); zlib_cleanup();} while(0)
|
||||
# else
|
||||
# define apps_startup() \
|
||||
@@ -198,11 +199,12 @@ extern BIO *bio_err;
|
||||
do { CONF_modules_unload(1); destroy_ui_method(); \
|
||||
OBJ_cleanup(); EVP_cleanup(); \
|
||||
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
|
||||
RAND_cleanup(); \
|
||||
ERR_free_strings(); zlib_cleanup(); } while(0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_SYSNAME_WIN32
|
||||
#if defined(OPENSSL_SYSNAME_WIN32) || defined(OPENSSL_SYSNAME_WINCE)
|
||||
# define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
|
||||
#else
|
||||
# define openssl_fdset(a,b) FD_SET(a, b)
|
||||
@@ -245,6 +247,9 @@ int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
|
||||
int add_oid_section(BIO *err, CONF *conf);
|
||||
X509 *load_cert(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e, const char *cert_descrip);
|
||||
X509_CRL *load_crl(const char *infile, int format);
|
||||
int load_cert_crl_http(const char *url, BIO *err,
|
||||
X509 **pcert, X509_CRL **pcrl);
|
||||
EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
|
||||
const char *pass, ENGINE *e, const char *key_descrip);
|
||||
EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
|
||||
@@ -260,9 +265,10 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug);
|
||||
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
|
||||
char *host, char *path, char *port, int use_ssl,
|
||||
STACK_OF(CONF_VALUE) *headers,
|
||||
int req_timeout);
|
||||
const char *host, const char *path,
|
||||
const char *port, int use_ssl,
|
||||
const STACK_OF(CONF_VALUE) *headers,
|
||||
int req_timeout);
|
||||
#endif
|
||||
|
||||
int load_config(BIO *err, CONF *cnf);
|
||||
@@ -331,9 +337,16 @@ void jpake_client_auth(BIO *out, BIO *conn, const char *secret);
|
||||
void jpake_server_auth(BIO *out, BIO *conn, const char *secret);
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
|
||||
#endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */
|
||||
#endif /* ndef OPENSSL_NO_TLSEXT */
|
||||
|
||||
void print_cert_checks(BIO *bio, X509 *x,
|
||||
const unsigned char *checkhost,
|
||||
const unsigned char *checkemail,
|
||||
const char *checkip);
|
||||
|
||||
void store_setup_crl_download(X509_STORE *st);
|
||||
|
||||
#define FORMAT_UNDEF 0
|
||||
#define FORMAT_ASN1 1
|
||||
@@ -349,6 +362,7 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
|
||||
#define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
|
||||
#define FORMAT_MSBLOB 11 /* MS Key blob format */
|
||||
#define FORMAT_PVK 12 /* MS PVK file format */
|
||||
#define FORMAT_HTTP 13 /* Download using HTTP */
|
||||
|
||||
#define EXT_COPY_NONE 0
|
||||
#define EXT_COPY_ADD 1
|
||||
|
||||
28
apps/ca.c
28
apps/ca.c
@@ -501,6 +501,12 @@ EF_ALIGNMENT=0;
|
||||
infile= *(++argv);
|
||||
dorevoke=1;
|
||||
}
|
||||
else if (strcmp(*argv,"-valid") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
infile= *(++argv);
|
||||
dorevoke=2;
|
||||
}
|
||||
else if (strcmp(*argv,"-extensions") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -1408,6 +1414,7 @@ bad:
|
||||
if (!NCONF_get_number(conf,section,
|
||||
ENV_DEFAULT_CRL_HOURS, &crlhours))
|
||||
crlhours = 0;
|
||||
ERR_clear_error();
|
||||
}
|
||||
if ((crldays == 0) && (crlhours == 0) && (crlsec == 0))
|
||||
{
|
||||
@@ -1522,6 +1529,8 @@ bad:
|
||||
NULL, e, infile);
|
||||
if (revcert == NULL)
|
||||
goto err;
|
||||
if (dorevoke == 2)
|
||||
rev_type = -1;
|
||||
j=do_revoke(revcert,db, rev_type, rev_arg);
|
||||
if (j <= 0) goto err;
|
||||
X509_free(revcert);
|
||||
@@ -2043,7 +2052,13 @@ again2:
|
||||
|
||||
if (enddate == NULL)
|
||||
X509_time_adj_ex(X509_get_notAfter(ret),days, 0, NULL);
|
||||
else ASN1_TIME_set_string(X509_get_notAfter(ret),enddate);
|
||||
else
|
||||
{
|
||||
int tdays;
|
||||
ASN1_TIME_set_string(X509_get_notAfter(ret),enddate);
|
||||
ASN1_TIME_diff(&tdays, NULL, NULL, X509_get_notAfter(ret));
|
||||
days = tdays;
|
||||
}
|
||||
|
||||
if (!X509_set_subject_name(ret,subject)) goto err;
|
||||
|
||||
@@ -2485,7 +2500,10 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
|
||||
}
|
||||
|
||||
/* Revoke Certificate */
|
||||
ok = do_revoke(x509,db, type, value);
|
||||
if (type == -1)
|
||||
ok = 1;
|
||||
else
|
||||
ok = do_revoke(x509,db, type, value);
|
||||
|
||||
goto err;
|
||||
|
||||
@@ -2496,6 +2514,12 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
|
||||
row[DB_name]);
|
||||
goto err;
|
||||
}
|
||||
else if (type == -1)
|
||||
{
|
||||
BIO_printf(bio_err,"ERROR:Already present, serial number %s\n",
|
||||
row[DB_serial]);
|
||||
goto err;
|
||||
}
|
||||
else if (rrow[DB_type][0]=='R')
|
||||
{
|
||||
BIO_printf(bio_err,"ERROR:Already revoked, serial number %s\n",
|
||||
|
||||
@@ -85,6 +85,9 @@ int MAIN(int argc, char **argv)
|
||||
{
|
||||
int ret=1,i;
|
||||
int verbose=0,Verbose=0;
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
int stdname = 0;
|
||||
#endif
|
||||
const char **pp;
|
||||
const char *p;
|
||||
int badops=0;
|
||||
@@ -126,6 +129,10 @@ int MAIN(int argc, char **argv)
|
||||
verbose=1;
|
||||
else if (strcmp(*argv,"-V") == 0)
|
||||
verbose=Verbose=1;
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
else if (strcmp(*argv,"-stdname") == 0)
|
||||
stdname=verbose=1;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
else if (strcmp(*argv,"-ssl2") == 0)
|
||||
meth=SSLv2_client_method();
|
||||
@@ -209,7 +216,15 @@ int MAIN(int argc, char **argv)
|
||||
else
|
||||
BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3); /* whatever */
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
if (stdname)
|
||||
{
|
||||
const char *nm = SSL_CIPHER_standard_name(c);
|
||||
if (nm == NULL)
|
||||
nm = "UNKNOWN";
|
||||
BIO_printf(STDout, "%s - ", nm);
|
||||
}
|
||||
#endif
|
||||
BIO_puts(STDout,SSL_CIPHER_description(c,buf,sizeof buf));
|
||||
}
|
||||
}
|
||||
|
||||
170
apps/cms.c
170
apps/cms.c
@@ -74,6 +74,8 @@ static void receipt_request_print(BIO *out, CMS_ContentInfo *cms);
|
||||
static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
|
||||
int rr_allorfirst,
|
||||
STACK_OF(OPENSSL_STRING) *rr_from);
|
||||
static int cms_set_pkey_param(EVP_PKEY_CTX *pctx,
|
||||
STACK_OF(OPENSSL_STRING) *param);
|
||||
|
||||
#define SMIME_OP 0x10
|
||||
#define SMIME_IP 0x20
|
||||
@@ -97,6 +99,15 @@ static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
|
||||
|
||||
int verify_err = 0;
|
||||
|
||||
typedef struct cms_key_param_st cms_key_param;
|
||||
|
||||
struct cms_key_param_st
|
||||
{
|
||||
int idx;
|
||||
STACK_OF(OPENSSL_STRING)*param;
|
||||
cms_key_param *next;
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
@@ -111,7 +122,7 @@ int MAIN(int argc, char **argv)
|
||||
STACK_OF(OPENSSL_STRING) *sksigners = NULL, *skkeys = NULL;
|
||||
char *certfile = NULL, *keyfile = NULL, *contfile=NULL;
|
||||
char *certsoutfile = NULL;
|
||||
const EVP_CIPHER *cipher = NULL;
|
||||
const EVP_CIPHER *cipher = NULL, *wrap_cipher = NULL;
|
||||
CMS_ContentInfo *cms = NULL, *rcms = NULL;
|
||||
X509_STORE *store = NULL;
|
||||
X509 *cert = NULL, *recip = NULL, *signer = NULL;
|
||||
@@ -139,6 +150,8 @@ int MAIN(int argc, char **argv)
|
||||
unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;
|
||||
size_t secret_keylen = 0, secret_keyidlen = 0;
|
||||
|
||||
cms_key_param *key_first = NULL, *key_param = NULL;
|
||||
|
||||
ASN1_OBJECT *econtent_type = NULL;
|
||||
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
@@ -204,6 +217,8 @@ int MAIN(int argc, char **argv)
|
||||
cipher = EVP_des_ede3_cbc();
|
||||
else if (!strcmp (*args, "-des"))
|
||||
cipher = EVP_des_cbc();
|
||||
else if (!strcmp (*args, "-des3-wrap"))
|
||||
wrap_cipher = EVP_des_ede3_wrap();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
else if (!strcmp (*args, "-seed"))
|
||||
@@ -224,6 +239,12 @@ int MAIN(int argc, char **argv)
|
||||
cipher = EVP_aes_192_cbc();
|
||||
else if (!strcmp(*args,"-aes256"))
|
||||
cipher = EVP_aes_256_cbc();
|
||||
else if (!strcmp(*args,"-aes128-wrap"))
|
||||
wrap_cipher = EVP_aes_128_wrap();
|
||||
else if (!strcmp(*args,"-aes192-wrap"))
|
||||
wrap_cipher = EVP_aes_192_wrap();
|
||||
else if (!strcmp(*args,"-aes256-wrap"))
|
||||
wrap_cipher = EVP_aes_256_wrap();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (!strcmp(*args,"-camellia128"))
|
||||
@@ -233,6 +254,8 @@ int MAIN(int argc, char **argv)
|
||||
else if (!strcmp(*args,"-camellia256"))
|
||||
cipher = EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (!strcmp (*args, "-debug_decrypt"))
|
||||
flags |= CMS_DEBUG_DECRYPT;
|
||||
else if (!strcmp (*args, "-text"))
|
||||
flags |= CMS_TEXT;
|
||||
else if (!strcmp (*args, "-nointern"))
|
||||
@@ -410,7 +433,20 @@ int MAIN(int argc, char **argv)
|
||||
{
|
||||
if (!args[1])
|
||||
goto argerr;
|
||||
recipfile = *++args;
|
||||
if (operation == SMIME_ENCRYPT)
|
||||
{
|
||||
if (!encerts)
|
||||
encerts = sk_X509_new_null();
|
||||
cert = load_cert(bio_err,*++args,FORMAT_PEM,
|
||||
NULL, e,
|
||||
"recipient certificate file");
|
||||
if (!cert)
|
||||
goto end;
|
||||
sk_X509_push(encerts, cert);
|
||||
cert = NULL;
|
||||
}
|
||||
else
|
||||
recipfile = *++args;
|
||||
}
|
||||
else if (!strcmp (*args, "-certsout"))
|
||||
{
|
||||
@@ -458,6 +494,43 @@ int MAIN(int argc, char **argv)
|
||||
goto argerr;
|
||||
keyform = str2fmt(*++args);
|
||||
}
|
||||
else if (!strcmp (*args, "-keyopt"))
|
||||
{
|
||||
int keyidx = -1;
|
||||
if (!args[1])
|
||||
goto argerr;
|
||||
if (operation == SMIME_ENCRYPT)
|
||||
{
|
||||
if (encerts)
|
||||
keyidx += sk_X509_num(encerts);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyfile || signerfile)
|
||||
keyidx++;
|
||||
if (skkeys)
|
||||
keyidx += sk_OPENSSL_STRING_num(skkeys);
|
||||
}
|
||||
if (keyidx < 0)
|
||||
{
|
||||
BIO_printf(bio_err, "No key specified\n");
|
||||
goto argerr;
|
||||
}
|
||||
if (key_param == NULL || key_param->idx != keyidx)
|
||||
{
|
||||
cms_key_param *nparam;
|
||||
nparam = OPENSSL_malloc(sizeof(cms_key_param));
|
||||
nparam->idx = keyidx;
|
||||
nparam->param = sk_OPENSSL_STRING_new_null();
|
||||
nparam->next = NULL;
|
||||
if (key_first == NULL)
|
||||
key_first = nparam;
|
||||
else
|
||||
key_param->next = nparam;
|
||||
key_param = nparam;
|
||||
}
|
||||
sk_OPENSSL_STRING_push(key_param->param, *++args);
|
||||
}
|
||||
else if (!strcmp (*args, "-rctform"))
|
||||
{
|
||||
if (!args[1])
|
||||
@@ -575,7 +648,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else if (operation == SMIME_ENCRYPT)
|
||||
{
|
||||
if (!*args && !secret_key && !pwri_pass)
|
||||
if (!*args && !secret_key && !pwri_pass && !encerts)
|
||||
{
|
||||
BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
|
||||
badarg = 1;
|
||||
@@ -631,6 +704,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n");
|
||||
BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n");
|
||||
BIO_printf (bio_err, "-keyform arg input private key format (PEM or ENGINE)\n");
|
||||
BIO_printf (bio_err, "-keyopt nm:v set public key parameters\n");
|
||||
BIO_printf (bio_err, "-out file output file\n");
|
||||
BIO_printf (bio_err, "-outform arg output format SMIME (default), PEM or DER\n");
|
||||
BIO_printf (bio_err, "-content file supply or override content for detached signature\n");
|
||||
@@ -716,7 +790,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (*args)
|
||||
if (*args && !encerts)
|
||||
encerts = sk_X509_new_null();
|
||||
while (*args)
|
||||
{
|
||||
@@ -910,10 +984,45 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else if (operation == SMIME_ENCRYPT)
|
||||
{
|
||||
int i;
|
||||
flags |= CMS_PARTIAL;
|
||||
cms = CMS_encrypt(encerts, in, cipher, flags);
|
||||
cms = CMS_encrypt(NULL, in, cipher, flags);
|
||||
if (!cms)
|
||||
goto end;
|
||||
for (i = 0; i < sk_X509_num(encerts); i++)
|
||||
{
|
||||
CMS_RecipientInfo *ri;
|
||||
cms_key_param *kparam;
|
||||
int tflags = flags;
|
||||
X509 *x = sk_X509_value(encerts, i);
|
||||
for(kparam = key_first; kparam; kparam = kparam->next)
|
||||
{
|
||||
if(kparam->idx == i)
|
||||
{
|
||||
tflags |= CMS_KEY_PARAM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ri = CMS_add1_recipient_cert(cms, x, tflags);
|
||||
if (!ri)
|
||||
goto end;
|
||||
if (kparam)
|
||||
{
|
||||
EVP_PKEY_CTX *pctx;
|
||||
pctx = CMS_RecipientInfo_get0_pkey_ctx(ri);
|
||||
if (!cms_set_pkey_param(pctx, kparam->param))
|
||||
goto end;
|
||||
}
|
||||
if (CMS_RecipientInfo_type(ri) == CMS_RECIPINFO_AGREE
|
||||
&& wrap_cipher)
|
||||
{
|
||||
EVP_CIPHER_CTX *wctx;
|
||||
wctx = CMS_RecipientInfo_kari_get0_ctx(ri);
|
||||
EVP_EncryptInit_ex(wctx, wrap_cipher,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (secret_key)
|
||||
{
|
||||
if (!CMS_add0_recipient_key(cms, NID_undef,
|
||||
@@ -1002,8 +1111,11 @@ int MAIN(int argc, char **argv)
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++)
|
||||
{
|
||||
CMS_SignerInfo *si;
|
||||
cms_key_param *kparam;
|
||||
int tflags = flags;
|
||||
signerfile = sk_OPENSSL_STRING_value(sksigners, i);
|
||||
keyfile = sk_OPENSSL_STRING_value(skkeys, i);
|
||||
|
||||
signer = load_cert(bio_err, signerfile,FORMAT_PEM, NULL,
|
||||
e, "signer certificate");
|
||||
if (!signer)
|
||||
@@ -1012,9 +1124,24 @@ int MAIN(int argc, char **argv)
|
||||
"signing key file");
|
||||
if (!key)
|
||||
goto end;
|
||||
si = CMS_add1_signer(cms, signer, key, sign_md, flags);
|
||||
for(kparam = key_first; kparam; kparam = kparam->next)
|
||||
{
|
||||
if(kparam->idx == i)
|
||||
{
|
||||
tflags |= CMS_KEY_PARAM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
si = CMS_add1_signer(cms, signer, key, sign_md, tflags);
|
||||
if (!si)
|
||||
goto end;
|
||||
if (kparam)
|
||||
{
|
||||
EVP_PKEY_CTX *pctx;
|
||||
pctx = CMS_SignerInfo_get0_pkey_ctx(si);
|
||||
if (!cms_set_pkey_param(pctx, kparam->param))
|
||||
goto end;
|
||||
}
|
||||
if (rr && !CMS_add1_ReceiptRequest(si, rr))
|
||||
goto end;
|
||||
X509_free(signer);
|
||||
@@ -1039,6 +1166,8 @@ int MAIN(int argc, char **argv)
|
||||
ret = 4;
|
||||
if (operation == SMIME_DECRYPT)
|
||||
{
|
||||
if (flags & CMS_DEBUG_DECRYPT)
|
||||
CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);
|
||||
|
||||
if (secret_key)
|
||||
{
|
||||
@@ -1206,6 +1335,14 @@ end:
|
||||
sk_OPENSSL_STRING_free(rr_to);
|
||||
if (rr_from)
|
||||
sk_OPENSSL_STRING_free(rr_from);
|
||||
for(key_param = key_first; key_param;)
|
||||
{
|
||||
cms_key_param *tparam;
|
||||
sk_OPENSSL_STRING_free(key_param->param);
|
||||
tparam = key_param->next;
|
||||
OPENSSL_free(key_param);
|
||||
key_param = tparam;
|
||||
}
|
||||
X509_STORE_free(store);
|
||||
X509_free(cert);
|
||||
X509_free(recip);
|
||||
@@ -1390,4 +1527,25 @@ static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) *rr_to,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int cms_set_pkey_param(EVP_PKEY_CTX *pctx,
|
||||
STACK_OF(OPENSSL_STRING) *param)
|
||||
{
|
||||
char *keyopt;
|
||||
int i;
|
||||
if (sk_OPENSSL_STRING_num(param) <= 0)
|
||||
return 1;
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(param); i++)
|
||||
{
|
||||
keyopt = sk_OPENSSL_STRING_value(param, i);
|
||||
if (pkey_ctrl_string(pctx, keyopt) <= 0)
|
||||
{
|
||||
BIO_printf(bio_err, "parameter error \"%s\"\n",
|
||||
keyopt);
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
106
apps/crl.c
106
apps/crl.c
@@ -93,7 +93,6 @@ static const char *crl_usage[]={
|
||||
NULL
|
||||
};
|
||||
|
||||
static X509_CRL *load_crl(char *file, int format);
|
||||
static BIO *bio_out=NULL;
|
||||
|
||||
int MAIN(int, char **);
|
||||
@@ -103,10 +102,10 @@ int MAIN(int argc, char **argv)
|
||||
unsigned long nmflag = 0;
|
||||
X509_CRL *x=NULL;
|
||||
char *CAfile = NULL, *CApath = NULL;
|
||||
int ret=1,i,num,badops=0;
|
||||
int ret=1,i,num,badops=0,badsig=0;
|
||||
BIO *out=NULL;
|
||||
int informat,outformat;
|
||||
char *infile=NULL,*outfile=NULL;
|
||||
int informat,outformat, keyformat;
|
||||
char *infile=NULL,*outfile=NULL, *crldiff = NULL, *keyfile = NULL;
|
||||
int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
|
||||
int fingerprint = 0, crlnumber = 0;
|
||||
const char **pp;
|
||||
@@ -141,6 +140,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
informat=FORMAT_PEM;
|
||||
outformat=FORMAT_PEM;
|
||||
keyformat=FORMAT_PEM;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -169,6 +169,21 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1) goto bad;
|
||||
infile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-gendelta") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
crldiff= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-key") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
keyfile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-keyform") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
keyformat=str2fmt(*(++argv));
|
||||
}
|
||||
else if (strcmp(*argv,"-out") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -209,6 +224,8 @@ int MAIN(int argc, char **argv)
|
||||
fingerprint= ++num;
|
||||
else if (strcmp(*argv,"-crlnumber") == 0)
|
||||
crlnumber= ++num;
|
||||
else if (strcmp(*argv,"-badsig") == 0)
|
||||
badsig = 1;
|
||||
else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
|
||||
{
|
||||
/* ok */
|
||||
@@ -276,6 +293,39 @@ bad:
|
||||
else BIO_printf(bio_err, "verify OK\n");
|
||||
}
|
||||
|
||||
if (crldiff)
|
||||
{
|
||||
X509_CRL *newcrl, *delta;
|
||||
if (!keyfile)
|
||||
{
|
||||
BIO_puts(bio_err, "Missing CRL signing key\n");
|
||||
goto end;
|
||||
}
|
||||
newcrl = load_crl(crldiff,informat);
|
||||
if (!newcrl)
|
||||
goto end;
|
||||
pkey = load_key(bio_err, keyfile, keyformat, 0, NULL, NULL,
|
||||
"CRL signing key");
|
||||
if (!pkey)
|
||||
{
|
||||
X509_CRL_free(newcrl);
|
||||
goto end;
|
||||
}
|
||||
delta = X509_CRL_diff(x, newcrl, pkey, digest, 0);
|
||||
X509_CRL_free(newcrl);
|
||||
EVP_PKEY_free(pkey);
|
||||
if (delta)
|
||||
{
|
||||
X509_CRL_free(x);
|
||||
x = delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_puts(bio_err, "Error creating delta CRL\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (num)
|
||||
{
|
||||
for (i=1; i<=num; i++)
|
||||
@@ -378,6 +428,9 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (badsig)
|
||||
x->signature->data[x->signature->length - 1] ^= 0x1;
|
||||
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i=(int)i2d_X509_CRL_bio(out,x);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
@@ -390,6 +443,8 @@ bad:
|
||||
if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
|
||||
ret=0;
|
||||
end:
|
||||
if (ret != 0)
|
||||
ERR_print_errors(bio_err);
|
||||
BIO_free_all(out);
|
||||
BIO_free_all(bio_out);
|
||||
bio_out=NULL;
|
||||
@@ -401,46 +456,3 @@ end:
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
|
||||
static X509_CRL *load_crl(char *infile, int format)
|
||||
{
|
||||
X509_CRL *x=NULL;
|
||||
BIO *in=NULL;
|
||||
|
||||
in=BIO_new(BIO_s_file());
|
||||
if (in == NULL)
|
||||
{
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
else
|
||||
{
|
||||
if (BIO_read_filename(in,infile) <= 0)
|
||||
{
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (format == FORMAT_ASN1)
|
||||
x=d2i_X509_CRL_bio(in,NULL);
|
||||
else if (format == FORMAT_PEM)
|
||||
x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
|
||||
else {
|
||||
BIO_printf(bio_err,"bad input format specified for input crl\n");
|
||||
goto end;
|
||||
}
|
||||
if (x == NULL)
|
||||
{
|
||||
BIO_printf(bio_err,"unable to load CRL\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
BIO_free(in);
|
||||
return(x);
|
||||
}
|
||||
|
||||
|
||||
31
apps/dgst.c
31
apps/dgst.c
@@ -103,7 +103,7 @@ int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
ENGINE *e = NULL, *impl = NULL;
|
||||
unsigned char *buf=NULL;
|
||||
int i,err=1;
|
||||
const EVP_MD *md=NULL,*m;
|
||||
@@ -124,6 +124,7 @@ int MAIN(int argc, char **argv)
|
||||
char *passargin = NULL, *passin = NULL;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine=NULL;
|
||||
int engine_impl = 0;
|
||||
#endif
|
||||
char *hmac_key=NULL;
|
||||
char *mac_name=NULL;
|
||||
@@ -209,6 +210,8 @@ int MAIN(int argc, char **argv)
|
||||
engine= *(++argv);
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
}
|
||||
else if (strcmp(*argv,"-engine_impl") == 0)
|
||||
engine_impl = 1;
|
||||
#endif
|
||||
else if (strcmp(*argv,"-hex") == 0)
|
||||
out_bin = 0;
|
||||
@@ -216,10 +219,10 @@ int MAIN(int argc, char **argv)
|
||||
out_bin = 1;
|
||||
else if (strcmp(*argv,"-d") == 0)
|
||||
debug=1;
|
||||
else if (strcmp(*argv,"-non-fips-allow") == 0)
|
||||
non_fips_allow=1;
|
||||
else if (!strcmp(*argv,"-fips-fingerprint"))
|
||||
hmac_key = "etaonrishdlcupfm";
|
||||
else if (strcmp(*argv,"-non-fips-allow") == 0)
|
||||
non_fips_allow=1;
|
||||
else if (!strcmp(*argv,"-hmac"))
|
||||
{
|
||||
if (--argc < 1)
|
||||
@@ -291,6 +294,11 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine_impl)
|
||||
impl = e;
|
||||
#endif
|
||||
|
||||
in=BIO_new(BIO_s_file());
|
||||
bmd=BIO_new(BIO_f_md());
|
||||
if (debug)
|
||||
@@ -368,7 +376,7 @@ int MAIN(int argc, char **argv)
|
||||
{
|
||||
EVP_PKEY_CTX *mac_ctx = NULL;
|
||||
int r = 0;
|
||||
if (!init_gen_str(bio_err, &mac_ctx, mac_name,e, 0))
|
||||
if (!init_gen_str(bio_err, &mac_ctx, mac_name, impl, 0))
|
||||
goto mac_end;
|
||||
if (macopts)
|
||||
{
|
||||
@@ -409,7 +417,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (hmac_key)
|
||||
{
|
||||
sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, e,
|
||||
sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, impl,
|
||||
(unsigned char *)hmac_key, -1);
|
||||
if (!sigkey)
|
||||
goto end;
|
||||
@@ -427,9 +435,9 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
if (do_verify)
|
||||
r = EVP_DigestVerifyInit(mctx, &pctx, md, e, sigkey);
|
||||
r = EVP_DigestVerifyInit(mctx, &pctx, md, impl, sigkey);
|
||||
else
|
||||
r = EVP_DigestSignInit(mctx, &pctx, md, e, sigkey);
|
||||
r = EVP_DigestSignInit(mctx, &pctx, md, impl, sigkey);
|
||||
if (!r)
|
||||
{
|
||||
BIO_printf(bio_err, "Error setting context\n");
|
||||
@@ -456,9 +464,16 @@ int MAIN(int argc, char **argv)
|
||||
/* we use md as a filter, reading from 'in' */
|
||||
else
|
||||
{
|
||||
EVP_MD_CTX *mctx = NULL;
|
||||
if (!BIO_get_md_ctx(bmd, &mctx))
|
||||
{
|
||||
BIO_printf(bio_err, "Error getting context\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (md == NULL)
|
||||
md = EVP_md5();
|
||||
if (!BIO_set_md(bmd,md))
|
||||
if (!EVP_DigestInit_ex(mctx, md, impl))
|
||||
{
|
||||
BIO_printf(bio_err, "Error setting digest %s\n", pname);
|
||||
ERR_print_errors(bio_err);
|
||||
|
||||
@@ -332,7 +332,6 @@ bad:
|
||||
BIO_printf(bio_err,"This is going to take a long time\n");
|
||||
if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
|
||||
{
|
||||
if(dh) DH_free(dh);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@@ -513,7 +512,12 @@ bad:
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i=i2d_DHparams_bio(out,dh);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
i=PEM_write_bio_DHparams(out,dh);
|
||||
{
|
||||
if (dh->q)
|
||||
i=PEM_write_bio_DHxparams(out,dh);
|
||||
else
|
||||
i=PEM_write_bio_DHparams(out,dh);
|
||||
}
|
||||
else {
|
||||
BIO_printf(bio_err,"bad output format specified for outfile\n");
|
||||
goto end;
|
||||
|
||||
@@ -326,6 +326,7 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
ERR_print_errors(bio_err);
|
||||
BIO_printf(bio_err,"Error, DSA key generation failed\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -429,13 +430,19 @@ bad:
|
||||
|
||||
assert(need_rand);
|
||||
if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end;
|
||||
if (!DSA_generate_key(dsakey)) goto end;
|
||||
if (!DSA_generate_key(dsakey))
|
||||
{
|
||||
ERR_print_errors(bio_err);
|
||||
DSA_free(dsakey);
|
||||
goto end;
|
||||
}
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i=i2d_DSAPrivateKey_bio(out,dsakey);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL,NULL);
|
||||
else {
|
||||
BIO_printf(bio_err,"bad output format specified for outfile\n");
|
||||
DSA_free(dsakey);
|
||||
goto end;
|
||||
}
|
||||
DSA_free(dsakey);
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
* in the asn1 der encoding
|
||||
* possible values: named_curve (default)
|
||||
* explicit
|
||||
* -no_seed - if 'explicit' parameters are choosen do not use the seed
|
||||
* -no_seed - if 'explicit' parameters are chosen do not use the seed
|
||||
* -genkey - generate ec key
|
||||
* -rand file - files to use for random number input
|
||||
* -engine e - use engine e, possibly a hardware device
|
||||
@@ -286,7 +286,7 @@ bad:
|
||||
BIO_printf(bio_err, " "
|
||||
" explicit\n");
|
||||
BIO_printf(bio_err, " -no_seed if 'explicit'"
|
||||
" parameters are choosen do not"
|
||||
" parameters are chosen do not"
|
||||
" use the seed\n");
|
||||
BIO_printf(bio_err, " -genkey generate ec"
|
||||
" key\n");
|
||||
@@ -402,6 +402,9 @@ bad:
|
||||
}
|
||||
else
|
||||
nid = OBJ_sn2nid(curve_name);
|
||||
|
||||
if (nid == 0)
|
||||
nid = EC_curve_nist2nid(curve_name);
|
||||
|
||||
if (nid == 0)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#define DEFBITS 512
|
||||
#define DEFBITS 1024
|
||||
#undef PROG
|
||||
#define PROG genrsa_main
|
||||
|
||||
|
||||
109
apps/ocsp.c
109
apps/ocsp.c
@@ -105,17 +105,17 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
|
||||
long maxage);
|
||||
|
||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
|
||||
X509 *ca, X509 *rcert, EVP_PKEY *rkey,
|
||||
X509 *ca, X509 *rcert, EVP_PKEY *rkey, const EVP_MD *md,
|
||||
STACK_OF(X509) *rother, unsigned long flags,
|
||||
int nmin, int ndays);
|
||||
int nmin, int ndays, int badsig);
|
||||
|
||||
static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser);
|
||||
static BIO *init_responder(char *port);
|
||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port);
|
||||
static BIO *init_responder(const char *port);
|
||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, const char *port);
|
||||
static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp);
|
||||
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path,
|
||||
STACK_OF(CONF_VALUE) *headers,
|
||||
OCSP_REQUEST *req, int req_timeout);
|
||||
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, const char *path,
|
||||
const STACK_OF(CONF_VALUE) *headers,
|
||||
OCSP_REQUEST *req, int req_timeout);
|
||||
|
||||
#undef PROG
|
||||
#define PROG ocsp_main
|
||||
@@ -148,12 +148,14 @@ int MAIN(int argc, char **argv)
|
||||
long nsec = MAX_VALIDITY_PERIOD, maxage = -1;
|
||||
char *CAfile = NULL, *CApath = NULL;
|
||||
X509_STORE *store = NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
STACK_OF(X509) *sign_other = NULL, *verify_other = NULL, *rother = NULL;
|
||||
char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL;
|
||||
unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
|
||||
int ret = 1;
|
||||
int accept_count = -1;
|
||||
int badarg = 0;
|
||||
int badsig = 0;
|
||||
int i;
|
||||
int ignore_err = 0;
|
||||
STACK_OF(OPENSSL_STRING) *reqnames = NULL;
|
||||
@@ -164,7 +166,7 @@ int MAIN(int argc, char **argv)
|
||||
char *rca_filename = NULL;
|
||||
CA_DB *rdb = NULL;
|
||||
int nmin = 0, ndays = -1;
|
||||
const EVP_MD *cert_id_md = NULL;
|
||||
const EVP_MD *cert_id_md = NULL, *rsign_md = NULL;
|
||||
|
||||
if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
|
||||
|
||||
@@ -271,6 +273,8 @@ int MAIN(int argc, char **argv)
|
||||
verify_flags |= OCSP_TRUSTOTHER;
|
||||
else if (!strcmp(*args, "-no_intern"))
|
||||
verify_flags |= OCSP_NOINTERN;
|
||||
else if (!strcmp(*args, "-badsig"))
|
||||
badsig = 1;
|
||||
else if (!strcmp(*args, "-text"))
|
||||
{
|
||||
req_text = 1;
|
||||
@@ -353,6 +357,12 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else badarg = 1;
|
||||
}
|
||||
else if (args_verify(&args, NULL, &badarg, bio_err, &vpm))
|
||||
{
|
||||
if (badarg)
|
||||
goto end;
|
||||
continue;
|
||||
}
|
||||
else if (!strcmp (*args, "-validity_period"))
|
||||
{
|
||||
if (args[1])
|
||||
@@ -558,6 +568,17 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else badarg = 1;
|
||||
}
|
||||
else if (!strcmp(*args, "-rmd"))
|
||||
{
|
||||
if (args[1])
|
||||
{
|
||||
args++;
|
||||
rsign_md = EVP_get_digestbyname(*args);
|
||||
if (!rsign_md)
|
||||
badarg = 1;
|
||||
}
|
||||
else badarg = 1;
|
||||
}
|
||||
else if ((cert_id_md = EVP_get_digestbyname((*args)+1))==NULL)
|
||||
{
|
||||
badarg = 1;
|
||||
@@ -617,7 +638,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -634,7 +655,10 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (!req && reqin)
|
||||
{
|
||||
derbio = BIO_new_file(reqin, "rb");
|
||||
if (!strcmp(reqin, "-"))
|
||||
derbio = BIO_new_fp(stdin, BIO_NOCLOSE);
|
||||
else
|
||||
derbio = BIO_new_file(reqin, "rb");
|
||||
if (!derbio)
|
||||
{
|
||||
BIO_printf(bio_err, "Error Opening OCSP request file\n");
|
||||
@@ -736,7 +760,10 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (reqout)
|
||||
{
|
||||
derbio = BIO_new_file(reqout, "wb");
|
||||
if (!strcmp(reqout, "-"))
|
||||
derbio = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
else
|
||||
derbio = BIO_new_file(reqout, "wb");
|
||||
if(!derbio)
|
||||
{
|
||||
BIO_printf(bio_err, "Error opening file %s\n", reqout);
|
||||
@@ -761,7 +788,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (rdb)
|
||||
{
|
||||
i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey, rother, rflags, nmin, ndays);
|
||||
i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey,rsign_md, rother, rflags, nmin, ndays, badsig);
|
||||
if (cbio)
|
||||
send_ocsp_response(cbio, resp);
|
||||
}
|
||||
@@ -779,7 +806,10 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else if (respin)
|
||||
{
|
||||
derbio = BIO_new_file(respin, "rb");
|
||||
if (!strcmp(respin, "-"))
|
||||
derbio = BIO_new_fp(stdin, BIO_NOCLOSE);
|
||||
else
|
||||
derbio = BIO_new_file(respin, "rb");
|
||||
if (!derbio)
|
||||
{
|
||||
BIO_printf(bio_err, "Error Opening OCSP response file\n");
|
||||
@@ -804,7 +834,10 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (respout)
|
||||
{
|
||||
derbio = BIO_new_file(respout, "wb");
|
||||
if (!strcmp(respout, "-"))
|
||||
derbio = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
else
|
||||
derbio = BIO_new_file(respout, "wb");
|
||||
if(!derbio)
|
||||
{
|
||||
BIO_printf(bio_err, "Error opening file %s\n", respout);
|
||||
@@ -844,6 +877,12 @@ int MAIN(int argc, char **argv)
|
||||
resp = NULL;
|
||||
goto redo_accept;
|
||||
}
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
else if (ridx_filename)
|
||||
{
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -851,6 +890,8 @@ int MAIN(int argc, char **argv)
|
||||
store = setup_verify(bio_err, CAfile, CApath);
|
||||
if (!store)
|
||||
goto end;
|
||||
if (vpm)
|
||||
X509_STORE_set1_param(store, vpm);
|
||||
if (verify_certfile)
|
||||
{
|
||||
verify_other = load_certs(bio_err, verify_certfile, FORMAT_PEM,
|
||||
@@ -866,6 +907,8 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
if (!noverify)
|
||||
{
|
||||
if (req && ((i = OCSP_check_nonce(req, bs)) <= 0))
|
||||
@@ -875,17 +918,17 @@ int MAIN(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
BIO_printf(bio_err, "Nonce Verify error\n");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
i = OCSP_basic_verify(bs, verify_other, store, verify_flags);
|
||||
if (i < 0) i = OCSP_basic_verify(bs, NULL, store, 0);
|
||||
|
||||
if(i <= 0)
|
||||
{
|
||||
BIO_printf(bio_err, "Response Verify Failure\n");
|
||||
ERR_print_errors(bio_err);
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
BIO_printf(bio_err, "Response verify OK\n");
|
||||
@@ -893,14 +936,14 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!print_ocsp_summary(out, bs, req, reqnames, ids, nsec, maxage))
|
||||
goto end;
|
||||
|
||||
ret = 0;
|
||||
ret = 1;
|
||||
|
||||
end:
|
||||
ERR_print_errors(bio_err);
|
||||
X509_free(signer);
|
||||
X509_STORE_free(store);
|
||||
if (vpm)
|
||||
X509_VERIFY_PARAM_free(vpm);
|
||||
EVP_PKEY_free(key);
|
||||
EVP_PKEY_free(rkey);
|
||||
X509_free(issuer);
|
||||
@@ -1051,9 +1094,10 @@ static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
|
||||
|
||||
|
||||
static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db,
|
||||
X509 *ca, X509 *rcert, EVP_PKEY *rkey,
|
||||
X509 *ca, X509 *rcert,
|
||||
EVP_PKEY *rkey, const EVP_MD *rmd,
|
||||
STACK_OF(X509) *rother, unsigned long flags,
|
||||
int nmin, int ndays)
|
||||
int nmin, int ndays, int badsig)
|
||||
{
|
||||
ASN1_TIME *thisupd = NULL, *nextupd = NULL;
|
||||
OCSP_CERTID *cid, *ca_id = NULL;
|
||||
@@ -1142,7 +1186,10 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db
|
||||
|
||||
OCSP_copy_nonce(bs, req);
|
||||
|
||||
OCSP_basic_sign(bs, rcert, rkey, NULL, rother, flags);
|
||||
OCSP_basic_sign(bs, rcert, rkey, rmd, rother, flags);
|
||||
|
||||
if (badsig)
|
||||
bs->signature->data[bs->signature->length -1] ^= 0x1;
|
||||
|
||||
*resp = OCSP_response_create(OCSP_RESPONSE_STATUS_SUCCESSFUL, bs);
|
||||
|
||||
@@ -1176,7 +1223,7 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
|
||||
|
||||
/* Quick and dirty OCSP server: read in and parse input request */
|
||||
|
||||
static BIO *init_responder(char *port)
|
||||
static BIO *init_responder(const char *port)
|
||||
{
|
||||
BIO *acbio = NULL, *bufbio = NULL;
|
||||
bufbio = BIO_new(BIO_f_buffer());
|
||||
@@ -1207,7 +1254,8 @@ static BIO *init_responder(char *port)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port)
|
||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
|
||||
const char *port)
|
||||
{
|
||||
int have_post = 0, len;
|
||||
OCSP_REQUEST *req = NULL;
|
||||
@@ -1273,9 +1321,9 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path,
|
||||
STACK_OF(CONF_VALUE) *headers,
|
||||
OCSP_REQUEST *req, int req_timeout)
|
||||
static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, const char *path,
|
||||
const STACK_OF(CONF_VALUE) *headers,
|
||||
OCSP_REQUEST *req, int req_timeout)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
@@ -1371,9 +1419,10 @@ static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path,
|
||||
}
|
||||
|
||||
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
|
||||
char *host, char *path, char *port, int use_ssl,
|
||||
STACK_OF(CONF_VALUE) *headers,
|
||||
int req_timeout)
|
||||
const char *host, const char *path,
|
||||
const char *port, int use_ssl,
|
||||
const STACK_OF(CONF_VALUE) *headers,
|
||||
int req_timeout)
|
||||
{
|
||||
BIO *cbio = NULL;
|
||||
SSL_CTX *ctx = NULL;
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
#include "apps.h"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
@@ -112,7 +112,7 @@ int MAIN(int argc, char **argv)
|
||||
int maciter = PKCS12_DEFAULT_ITER;
|
||||
int twopass = 0;
|
||||
int keytype = 0;
|
||||
int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
|
||||
int cert_pbe;
|
||||
int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||
int ret = 1;
|
||||
int macver = 1;
|
||||
@@ -130,6 +130,13 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
apps_startup();
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
if (FIPS_mode())
|
||||
cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||
else
|
||||
#endif
|
||||
cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
|
||||
|
||||
enc = EVP_des_ede3_cbc();
|
||||
if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
|
||||
|
||||
|
||||
13
apps/req.c
13
apps/req.c
@@ -644,6 +644,11 @@ bad:
|
||||
if (inrand)
|
||||
app_RAND_load_files(inrand);
|
||||
|
||||
if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
|
||||
{
|
||||
newkey=DEFAULT_KEY_LENGTH;
|
||||
}
|
||||
|
||||
if (keyalg)
|
||||
{
|
||||
genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey,
|
||||
@@ -652,12 +657,6 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (newkey <= 0)
|
||||
{
|
||||
if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
|
||||
newkey=DEFAULT_KEY_LENGTH;
|
||||
}
|
||||
|
||||
if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA))
|
||||
{
|
||||
BIO_printf(bio_err,"private key length is too short,\n");
|
||||
@@ -1649,6 +1648,8 @@ static EVP_PKEY_CTX *set_keygen_ctx(BIO *err, const char *gstr, int *pkey_type,
|
||||
keylen = atol(p + 1);
|
||||
*pkeylen = keylen;
|
||||
}
|
||||
else
|
||||
keylen = *pkeylen;
|
||||
}
|
||||
else if (p)
|
||||
paramfile = p + 1;
|
||||
|
||||
@@ -148,14 +148,19 @@ typedef fd_mask fd_set;
|
||||
#define PORT_STR "4433"
|
||||
#define PROTOCOL "tcp"
|
||||
|
||||
int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, unsigned char *context), unsigned char *context);
|
||||
int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, int stype, unsigned char *context), unsigned char *context, int naccept);
|
||||
#ifdef HEADER_X509_H
|
||||
int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
|
||||
#endif
|
||||
#ifdef HEADER_SSL_H
|
||||
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
|
||||
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key);
|
||||
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
||||
STACK_OF(X509) *chain, int build_chain);
|
||||
int ssl_print_sigalgs(BIO *out, SSL *s);
|
||||
int ssl_print_point_formats(BIO *out, SSL *s);
|
||||
int ssl_print_curves(BIO *out, SSL *s, int noshared);
|
||||
#endif
|
||||
int ssl_print_tmp_key(BIO *out, SSL *s);
|
||||
int init_client(int *sock, char *server, int port, int type);
|
||||
int should_retry(int i);
|
||||
int extract_port(char *str, short *port_ptr);
|
||||
@@ -174,3 +179,23 @@ void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
|
||||
|
||||
int MS_CALLBACK generate_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len);
|
||||
int MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int cookie_len);
|
||||
|
||||
typedef struct ssl_excert_st SSL_EXCERT;
|
||||
|
||||
void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc);
|
||||
void ssl_excert_free(SSL_EXCERT *exc);
|
||||
int args_excert(char ***pargs, int *pargc,
|
||||
int *badarg, BIO *err, SSL_EXCERT **pexc);
|
||||
int load_excert(SSL_EXCERT **pexc, BIO *err);
|
||||
void print_ssl_summary(BIO *bio, SSL *s);
|
||||
#ifdef HEADER_SSL_H
|
||||
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr);
|
||||
int args_ssl_call(SSL_CTX *ctx, BIO *err, SSL_CONF_CTX *cctx,
|
||||
STACK_OF(OPENSSL_STRING) *str, int no_ecdhe, int no_jpake);
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download);
|
||||
int ssl_load_stores(SSL_CTX *ctx,
|
||||
const char *vfyCApath, const char *vfyCAfile,
|
||||
const char *chCApath, const char *chCAfile,
|
||||
STACK_OF(X509_CRL) *crls, int crl_download);
|
||||
#endif
|
||||
|
||||
874
apps/s_cb.c
874
apps/s_cb.c
@@ -125,6 +125,7 @@
|
||||
#define COOKIE_SECRET_LENGTH 16
|
||||
|
||||
int verify_depth=0;
|
||||
int verify_quiet=0;
|
||||
int verify_error=X509_V_OK;
|
||||
int verify_return_error=0;
|
||||
unsigned char cookie_secret[COOKIE_SECRET_LENGTH];
|
||||
@@ -139,15 +140,19 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
|
||||
err= X509_STORE_CTX_get_error(ctx);
|
||||
depth= X509_STORE_CTX_get_error_depth(ctx);
|
||||
|
||||
BIO_printf(bio_err,"depth=%d ",depth);
|
||||
if (err_cert)
|
||||
if (!verify_quiet || !ok)
|
||||
{
|
||||
X509_NAME_print_ex(bio_err, X509_get_subject_name(err_cert),
|
||||
BIO_printf(bio_err,"depth=%d ",depth);
|
||||
if (err_cert)
|
||||
{
|
||||
X509_NAME_print_ex(bio_err,
|
||||
X509_get_subject_name(err_cert),
|
||||
0, XN_FLAG_ONELINE);
|
||||
BIO_puts(bio_err, "\n");
|
||||
BIO_puts(bio_err, "\n");
|
||||
}
|
||||
else
|
||||
BIO_puts(bio_err, "<no cert>\n");
|
||||
}
|
||||
else
|
||||
BIO_puts(bio_err, "<no cert>\n");
|
||||
if (!ok)
|
||||
{
|
||||
BIO_printf(bio_err,"verify error:num=%d:%s\n",err,
|
||||
@@ -185,13 +190,14 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
|
||||
BIO_printf(bio_err,"\n");
|
||||
break;
|
||||
case X509_V_ERR_NO_EXPLICIT_POLICY:
|
||||
policies_print(bio_err, ctx);
|
||||
if (!verify_quiet)
|
||||
policies_print(bio_err, ctx);
|
||||
break;
|
||||
}
|
||||
if (err == X509_V_OK && ok == 2)
|
||||
if (err == X509_V_OK && ok == 2 && !verify_quiet)
|
||||
policies_print(bio_err, ctx);
|
||||
|
||||
BIO_printf(bio_err,"verify return:%d\n",ok);
|
||||
if (ok && !verify_quiet)
|
||||
BIO_printf(bio_err,"verify return:%d\n",ok);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
@@ -237,8 +243,8 @@ int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file)
|
||||
|
||||
/* If we are using DSA, we can copy the parameters from
|
||||
* the private key */
|
||||
|
||||
|
||||
|
||||
|
||||
/* Now we know that a key and cert have been set against
|
||||
* the SSL context */
|
||||
if (!SSL_CTX_check_private_key(ctx))
|
||||
@@ -250,9 +256,11 @@ int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file)
|
||||
return(1);
|
||||
}
|
||||
|
||||
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
|
||||
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
||||
STACK_OF(X509) *chain, int build_chain)
|
||||
{
|
||||
if (cert == NULL)
|
||||
int chflags = chain ? SSL_BUILD_CHAIN_FLAG_CHECK : 0;
|
||||
if (cert == NULL)
|
||||
return 1;
|
||||
if (SSL_CTX_use_certificate(ctx,cert) <= 0)
|
||||
{
|
||||
@@ -260,24 +268,291 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
if (SSL_CTX_use_PrivateKey(ctx,key) <= 0)
|
||||
{
|
||||
BIO_printf(bio_err,"error setting private key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Now we know that a key and cert have been set against
|
||||
* the SSL context */
|
||||
if (SSL_CTX_use_PrivateKey(ctx,key) <= 0)
|
||||
{
|
||||
BIO_printf(bio_err,"error setting private key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now we know that a key and cert have been set against
|
||||
* the SSL context */
|
||||
if (!SSL_CTX_check_private_key(ctx))
|
||||
{
|
||||
BIO_printf(bio_err,"Private key does not match the certificate public key\n");
|
||||
return 0;
|
||||
}
|
||||
if (chain && !SSL_CTX_set1_chain(ctx, chain))
|
||||
{
|
||||
BIO_printf(bio_err,"error setting certificate chain\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
if (build_chain && !SSL_CTX_build_cert_chain(ctx, chflags))
|
||||
{
|
||||
BIO_printf(bio_err,"error building certificate chain\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ssl_print_client_cert_types(BIO *bio, SSL *s)
|
||||
{
|
||||
const unsigned char *p;
|
||||
int i;
|
||||
int cert_type_num = SSL_get0_certificate_types(s, &p);
|
||||
if (!cert_type_num)
|
||||
return;
|
||||
BIO_puts(bio, "Client Certificate Types: ");
|
||||
for (i = 0; i < cert_type_num; i++)
|
||||
{
|
||||
unsigned char cert_type = p[i];
|
||||
char *cname;
|
||||
switch(cert_type)
|
||||
{
|
||||
case TLS_CT_RSA_SIGN:
|
||||
cname = "RSA sign";
|
||||
break;
|
||||
|
||||
case TLS_CT_DSS_SIGN:
|
||||
cname = "DSA sign";
|
||||
break;
|
||||
|
||||
case TLS_CT_RSA_FIXED_DH:
|
||||
cname = "RSA fixed DH";
|
||||
break;
|
||||
|
||||
case TLS_CT_DSS_FIXED_DH:
|
||||
cname = "DSS fixed DH";
|
||||
break;
|
||||
|
||||
case TLS_CT_ECDSA_SIGN:
|
||||
cname = "ECDSA sign";
|
||||
break;
|
||||
|
||||
case TLS_CT_RSA_FIXED_ECDH:
|
||||
cname = "RSA fixed ECDH";
|
||||
break;
|
||||
|
||||
case TLS_CT_ECDSA_FIXED_ECDH:
|
||||
cname = "ECDSA fixed ECDH";
|
||||
break;
|
||||
|
||||
case TLS_CT_GOST94_SIGN:
|
||||
cname = "GOST94 Sign";
|
||||
break;
|
||||
|
||||
case TLS_CT_GOST01_SIGN:
|
||||
cname = "GOST01 Sign";
|
||||
break;
|
||||
|
||||
default:
|
||||
cname = NULL;
|
||||
}
|
||||
|
||||
if (i)
|
||||
BIO_puts(bio, ", ");
|
||||
|
||||
if (cname)
|
||||
BIO_puts(bio, cname);
|
||||
else
|
||||
BIO_printf(bio, "UNKNOWN (%d),", cert_type);
|
||||
}
|
||||
BIO_puts(bio, "\n");
|
||||
}
|
||||
|
||||
static int do_print_sigalgs(BIO *out, SSL *s, int shared)
|
||||
{
|
||||
int i, nsig, client;
|
||||
client = SSL_is_server(s) ? 0 : 1;
|
||||
if (shared)
|
||||
nsig = SSL_get_shared_sigalgs(s, -1, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
else
|
||||
nsig = SSL_get_sigalgs(s, -1, NULL, NULL, NULL, NULL, NULL);
|
||||
if (nsig == 0)
|
||||
return 1;
|
||||
|
||||
if (shared)
|
||||
BIO_puts(out, "Shared ");
|
||||
|
||||
if (client)
|
||||
BIO_puts(out, "Requested ");
|
||||
BIO_puts(out, "Signature Algorithms: ");
|
||||
for (i = 0; i < nsig; i++)
|
||||
{
|
||||
int hash_nid, sign_nid;
|
||||
unsigned char rhash, rsign;
|
||||
const char *sstr = NULL;
|
||||
if (shared)
|
||||
SSL_get_shared_sigalgs(s, i, &sign_nid, &hash_nid, NULL,
|
||||
&rsign, &rhash);
|
||||
else
|
||||
SSL_get_sigalgs(s, i, &sign_nid, &hash_nid, NULL,
|
||||
&rsign, &rhash);
|
||||
if (i)
|
||||
BIO_puts(out, ":");
|
||||
if (sign_nid == EVP_PKEY_RSA)
|
||||
sstr = "RSA";
|
||||
else if(sign_nid == EVP_PKEY_DSA)
|
||||
sstr = "DSA";
|
||||
else if(sign_nid == EVP_PKEY_EC)
|
||||
sstr = "ECDSA";
|
||||
if (sstr)
|
||||
BIO_printf(out,"%s+", sstr);
|
||||
else
|
||||
BIO_printf(out,"0x%02X+", (int)rsign);
|
||||
if (hash_nid != NID_undef)
|
||||
BIO_printf(out, "%s", OBJ_nid2sn(hash_nid));
|
||||
else
|
||||
BIO_printf(out,"0x%02X", (int)rhash);
|
||||
}
|
||||
BIO_puts(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl_print_sigalgs(BIO *out, SSL *s)
|
||||
{
|
||||
int mdnid;
|
||||
if (!SSL_is_server(s))
|
||||
ssl_print_client_cert_types(out, s);
|
||||
do_print_sigalgs(out, s, 0);
|
||||
do_print_sigalgs(out, s, 1);
|
||||
if (SSL_get_peer_signature_nid(s, &mdnid))
|
||||
BIO_printf(out, "Peer signing digest: %s\n", OBJ_nid2sn(mdnid));
|
||||
return 1;
|
||||
}
|
||||
#ifndef OPENSSL_NO_EC
|
||||
int ssl_print_point_formats(BIO *out, SSL *s)
|
||||
{
|
||||
int i, nformats;
|
||||
const char *pformats;
|
||||
nformats = SSL_get0_ec_point_formats(s, &pformats);
|
||||
if (nformats <= 0)
|
||||
return 1;
|
||||
BIO_puts(out, "Supported Elliptic Curve Point Formats: ");
|
||||
for (i = 0; i < nformats; i++, pformats++)
|
||||
{
|
||||
if (i)
|
||||
BIO_puts(out, ":");
|
||||
switch(*pformats)
|
||||
{
|
||||
case TLSEXT_ECPOINTFORMAT_uncompressed:
|
||||
BIO_puts(out, "uncompressed");
|
||||
break;
|
||||
|
||||
case TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime:
|
||||
BIO_puts(out, "ansiX962_compressed_prime");
|
||||
break;
|
||||
|
||||
case TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2:
|
||||
BIO_puts(out, "ansiX962_compressed_char2");
|
||||
break;
|
||||
|
||||
default:
|
||||
BIO_printf(out, "unknown(%d)", (int)*pformats);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (nformats <= 0)
|
||||
BIO_puts(out, "NONE");
|
||||
BIO_puts(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl_print_curves(BIO *out, SSL *s, int noshared)
|
||||
{
|
||||
int i, ncurves, *curves, nid;
|
||||
const char *cname;
|
||||
ncurves = SSL_get1_curves(s, NULL);
|
||||
if (ncurves <= 0)
|
||||
return 1;
|
||||
curves = OPENSSL_malloc(ncurves * sizeof(int));
|
||||
SSL_get1_curves(s, curves);
|
||||
|
||||
BIO_puts(out, "Supported Elliptic Curves: ");
|
||||
for (i = 0; i < ncurves; i++)
|
||||
{
|
||||
if (i)
|
||||
BIO_puts(out, ":");
|
||||
nid = curves[i];
|
||||
/* If unrecognised print out hex version */
|
||||
if (nid & TLSEXT_nid_unknown)
|
||||
BIO_printf(out, "0x%04X", nid & 0xFFFF);
|
||||
else
|
||||
{
|
||||
/* Use NIST name for curve if it exists */
|
||||
cname = EC_curve_nid2nist(nid);
|
||||
if (!cname)
|
||||
cname = OBJ_nid2sn(nid);
|
||||
BIO_printf(out, "%s", cname);
|
||||
}
|
||||
}
|
||||
if (ncurves == 0)
|
||||
BIO_puts(out, "NONE");
|
||||
OPENSSL_free(curves);
|
||||
if (noshared)
|
||||
{
|
||||
BIO_puts(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
BIO_puts(out, "\nShared Elliptic curves: ");
|
||||
ncurves = SSL_get_shared_curve(s, -1);
|
||||
for (i = 0; i < ncurves; i++)
|
||||
{
|
||||
if (i)
|
||||
BIO_puts(out, ":");
|
||||
nid = SSL_get_shared_curve(s, i);
|
||||
cname = EC_curve_nid2nist(nid);
|
||||
if (!cname)
|
||||
cname = OBJ_nid2sn(nid);
|
||||
BIO_printf(out, "%s", cname);
|
||||
}
|
||||
if (ncurves == 0)
|
||||
BIO_puts(out, "NONE");
|
||||
BIO_puts(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int ssl_print_tmp_key(BIO *out, SSL *s)
|
||||
{
|
||||
EVP_PKEY *key;
|
||||
if (!SSL_get_server_tmp_key(s, &key))
|
||||
return 1;
|
||||
BIO_puts(out, "Server Temp Key: ");
|
||||
switch (EVP_PKEY_id(key))
|
||||
{
|
||||
case EVP_PKEY_RSA:
|
||||
BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
|
||||
break;
|
||||
|
||||
case EVP_PKEY_DH:
|
||||
BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
|
||||
break;
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
case EVP_PKEY_EC:
|
||||
{
|
||||
EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
|
||||
int nid;
|
||||
const char *cname;
|
||||
nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
|
||||
EC_KEY_free(ec);
|
||||
cname = EC_curve_nid2nist(nid);
|
||||
if (!cname)
|
||||
cname = OBJ_nid2sn(nid);
|
||||
BIO_printf(out, "ECDH, %s, %d bits\n",
|
||||
cname, EVP_PKEY_bits(key));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
EVP_PKEY_free(key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
|
||||
int argi, long argl, long ret)
|
||||
{
|
||||
@@ -436,6 +711,8 @@ void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *
|
||||
|
||||
if (version == SSL3_VERSION ||
|
||||
version == TLS1_VERSION ||
|
||||
version == TLS1_1_VERSION ||
|
||||
version == TLS1_2_VERSION ||
|
||||
version == DTLS1_VERSION ||
|
||||
version == DTLS1_BAD_VER)
|
||||
{
|
||||
@@ -603,6 +880,9 @@ void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *
|
||||
case 20:
|
||||
str_details1 = ", Finished";
|
||||
break;
|
||||
case 23:
|
||||
str_details1 = ", SupplementalData";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -926,3 +1206,551 @@ int MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Example of extended certificate handling. Where the standard support
|
||||
* of one certificate per algorithm is not sufficient an application
|
||||
* can decide which certificate(s) to use at runtime based on whatever
|
||||
* criteria it deems appropriate.
|
||||
*/
|
||||
|
||||
/* Linked list of certificates, keys and chains */
|
||||
struct ssl_excert_st
|
||||
{
|
||||
int certform;
|
||||
const char *certfile;
|
||||
int keyform;
|
||||
const char *keyfile;
|
||||
const char *chainfile;
|
||||
X509 *cert;
|
||||
EVP_PKEY *key;
|
||||
STACK_OF(X509) *chain;
|
||||
int build_chain;
|
||||
struct ssl_excert_st *next, *prev;
|
||||
};
|
||||
|
||||
struct chain_flags
|
||||
{
|
||||
int flag;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct chain_flags chain_flags_list[] =
|
||||
{
|
||||
{CERT_PKEY_VALID, "Overall Validity"},
|
||||
{CERT_PKEY_SIGN, "Sign with EE key"},
|
||||
{CERT_PKEY_EE_SIGNATURE, "EE signature"},
|
||||
{CERT_PKEY_CA_SIGNATURE, "CA signature"},
|
||||
{CERT_PKEY_EE_PARAM, "EE key parameters"},
|
||||
{CERT_PKEY_CA_PARAM, "CA key parameters"},
|
||||
{CERT_PKEY_EXPLICIT_SIGN, "Explicity sign with EE key"},
|
||||
{CERT_PKEY_ISSUER_NAME, "Issuer Name"},
|
||||
{CERT_PKEY_CERT_TYPE, "Certificate Type"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
static void print_chain_flags(BIO *out, int flags)
|
||||
{
|
||||
struct chain_flags *ctmp = chain_flags_list;
|
||||
while(ctmp->name)
|
||||
{
|
||||
BIO_printf(out, "\t%s: %s\n", ctmp->name,
|
||||
flags & ctmp->flag ? "OK" : "NOT OK");
|
||||
ctmp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Very basic selection callback: just use any certificate chain
|
||||
* reported as valid. More sophisticated could prioritise according
|
||||
* to local policy.
|
||||
*/
|
||||
static int set_cert_cb(SSL *ssl, void *arg)
|
||||
{
|
||||
int i, rv;
|
||||
SSL_EXCERT *exc = arg;
|
||||
#ifdef CERT_CB_TEST_RETRY
|
||||
static int retry_cnt;
|
||||
if (retry_cnt < 5)
|
||||
{
|
||||
retry_cnt++;
|
||||
fprintf(stderr, "Certificate callback retry test: count %d\n",
|
||||
retry_cnt);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
SSL_certs_clear(ssl);
|
||||
|
||||
if (!exc)
|
||||
return 1;
|
||||
|
||||
/* Go to end of list and traverse backwards since we prepend
|
||||
* newer entries this retains the original order.
|
||||
*/
|
||||
while (exc->next)
|
||||
exc = exc->next;
|
||||
|
||||
i = 0;
|
||||
|
||||
while(exc)
|
||||
{
|
||||
i++;
|
||||
rv = SSL_check_chain(ssl, exc->cert, exc->key, exc->chain);
|
||||
BIO_printf(bio_err, "Checking cert chain %d:\nSubject: ", i);
|
||||
X509_NAME_print_ex(bio_err, X509_get_subject_name(exc->cert), 0,
|
||||
XN_FLAG_ONELINE);
|
||||
BIO_puts(bio_err, "\n");
|
||||
|
||||
print_chain_flags(bio_err, rv);
|
||||
if (rv & CERT_PKEY_VALID)
|
||||
{
|
||||
SSL_use_certificate(ssl, exc->cert);
|
||||
SSL_use_PrivateKey(ssl, exc->key);
|
||||
/* NB: we wouldn't normally do this as it is
|
||||
* not efficient building chains on each connection
|
||||
* better to cache the chain in advance.
|
||||
*/
|
||||
if (exc->build_chain)
|
||||
{
|
||||
if (!SSL_build_cert_chain(ssl, 0))
|
||||
return 0;
|
||||
}
|
||||
else if (exc->chain)
|
||||
SSL_set1_chain(ssl, exc->chain);
|
||||
}
|
||||
exc = exc->prev;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc)
|
||||
{
|
||||
SSL_CTX_set_cert_cb(ctx, set_cert_cb, exc);
|
||||
}
|
||||
|
||||
static int ssl_excert_prepend(SSL_EXCERT **pexc)
|
||||
{
|
||||
SSL_EXCERT *exc;
|
||||
exc = OPENSSL_malloc(sizeof(SSL_EXCERT));
|
||||
if (!exc)
|
||||
return 0;
|
||||
exc->certfile = NULL;
|
||||
exc->keyfile = NULL;
|
||||
exc->chainfile = NULL;
|
||||
exc->cert = NULL;
|
||||
exc->key = NULL;
|
||||
exc->chain = NULL;
|
||||
exc->prev = NULL;
|
||||
exc->build_chain = 0;
|
||||
|
||||
exc->next = *pexc;
|
||||
*pexc = exc;
|
||||
|
||||
if (exc->next)
|
||||
{
|
||||
exc->certform = exc->next->certform;
|
||||
exc->keyform = exc->next->keyform;
|
||||
exc->next->prev = exc;
|
||||
}
|
||||
else
|
||||
{
|
||||
exc->certform = FORMAT_PEM;
|
||||
exc->keyform = FORMAT_PEM;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
void ssl_excert_free(SSL_EXCERT *exc)
|
||||
{
|
||||
SSL_EXCERT *curr;
|
||||
while (exc)
|
||||
{
|
||||
if (exc->cert)
|
||||
X509_free(exc->cert);
|
||||
if (exc->key)
|
||||
EVP_PKEY_free(exc->key);
|
||||
if (exc->chain)
|
||||
sk_X509_pop_free(exc->chain, X509_free);
|
||||
curr = exc;
|
||||
exc = exc->next;
|
||||
OPENSSL_free(curr);
|
||||
}
|
||||
}
|
||||
|
||||
int load_excert(SSL_EXCERT **pexc, BIO *err)
|
||||
{
|
||||
SSL_EXCERT *exc = *pexc;
|
||||
if (!exc)
|
||||
return 1;
|
||||
/* If nothing in list, free and set to NULL */
|
||||
if (!exc->certfile && !exc->next)
|
||||
{
|
||||
ssl_excert_free(exc);
|
||||
*pexc = NULL;
|
||||
return 1;
|
||||
}
|
||||
for(; exc; exc=exc->next)
|
||||
{
|
||||
if (!exc->certfile)
|
||||
{
|
||||
BIO_printf(err, "Missing filename\n");
|
||||
return 0;
|
||||
}
|
||||
exc->cert = load_cert(err, exc->certfile, exc->certform,
|
||||
NULL, NULL, "Server Certificate");
|
||||
if (!exc->cert)
|
||||
return 0;
|
||||
if (exc->keyfile)
|
||||
exc->keyfile = exc->certfile;
|
||||
exc->key = load_key(err, exc->certfile, exc->certform, 0,
|
||||
NULL, NULL, "Server Certificate");
|
||||
if (!exc->key)
|
||||
return 0;
|
||||
if (exc->chainfile)
|
||||
{
|
||||
exc->chain = load_certs(err,
|
||||
exc->chainfile, FORMAT_PEM,
|
||||
NULL, NULL,
|
||||
"Server Chain");
|
||||
if (!exc->chainfile)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int args_excert(char ***pargs, int *pargc,
|
||||
int *badarg, BIO *err, SSL_EXCERT **pexc)
|
||||
{
|
||||
char *arg = **pargs, *argn = (*pargs)[1];
|
||||
SSL_EXCERT *exc = *pexc;
|
||||
int narg = 2;
|
||||
if (!exc)
|
||||
{
|
||||
if (ssl_excert_prepend(&exc))
|
||||
*pexc = exc;
|
||||
else
|
||||
{
|
||||
BIO_printf(err, "Error initialising xcert\n");
|
||||
*badarg = 1;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (strcmp(arg, "-xcert") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
{
|
||||
*badarg = 1;
|
||||
return 1;
|
||||
}
|
||||
if (exc->certfile && !ssl_excert_prepend(&exc))
|
||||
{
|
||||
BIO_printf(err, "Error adding xcert\n");
|
||||
*badarg = 1;
|
||||
goto err;
|
||||
}
|
||||
exc->certfile = argn;
|
||||
}
|
||||
else if (strcmp(arg,"-xkey") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
{
|
||||
*badarg = 1;
|
||||
return 1;
|
||||
}
|
||||
if (exc->keyfile)
|
||||
{
|
||||
BIO_printf(err, "Key already specified\n");
|
||||
*badarg = 1;
|
||||
return 1;
|
||||
}
|
||||
exc->keyfile = argn;
|
||||
}
|
||||
else if (strcmp(arg,"-xchain") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
{
|
||||
*badarg = 1;
|
||||
return 1;
|
||||
}
|
||||
if (exc->chainfile)
|
||||
{
|
||||
BIO_printf(err, "Chain already specified\n");
|
||||
*badarg = 1;
|
||||
return 1;
|
||||
}
|
||||
exc->chainfile = argn;
|
||||
}
|
||||
else if (strcmp(arg,"-xchain_build") == 0)
|
||||
{
|
||||
narg = 1;
|
||||
exc->build_chain = 1;
|
||||
}
|
||||
else if (strcmp(arg,"-xcertform") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
{
|
||||
*badarg = 1;
|
||||
goto err;
|
||||
}
|
||||
exc->certform = str2fmt(argn);
|
||||
}
|
||||
else if (strcmp(arg,"-xkeyform") == 0)
|
||||
{
|
||||
if (!argn)
|
||||
{
|
||||
*badarg = 1;
|
||||
goto err;
|
||||
}
|
||||
exc->keyform = str2fmt(argn);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
(*pargs) += narg;
|
||||
|
||||
if (pargc)
|
||||
*pargc -= narg;
|
||||
|
||||
*pexc = exc;
|
||||
|
||||
return 1;
|
||||
|
||||
err:
|
||||
ERR_print_errors(err);
|
||||
ssl_excert_free(exc);
|
||||
*pexc = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void print_raw_cipherlist(BIO *bio, SSL *s)
|
||||
{
|
||||
const unsigned char *rlist;
|
||||
static const unsigned char scsv_id[] = {0, 0, 0xFF};
|
||||
size_t i, rlistlen, num;
|
||||
if (!SSL_is_server(s))
|
||||
return;
|
||||
num = SSL_get0_raw_cipherlist(s, NULL);
|
||||
rlistlen = SSL_get0_raw_cipherlist(s, &rlist);
|
||||
BIO_puts(bio, "Client cipher list: ");
|
||||
for (i = 0; i < rlistlen; i += num, rlist += num)
|
||||
{
|
||||
const SSL_CIPHER *c = SSL_CIPHER_find(s, rlist);
|
||||
if (i)
|
||||
BIO_puts(bio, ":");
|
||||
if (c)
|
||||
BIO_puts(bio, SSL_CIPHER_get_name(c));
|
||||
else if (!memcmp(rlist, scsv_id - num + 3, num))
|
||||
BIO_puts(bio, "SCSV");
|
||||
else
|
||||
{
|
||||
size_t j;
|
||||
BIO_puts(bio, "0x");
|
||||
for (j = 0; j < num; j++)
|
||||
BIO_printf(bio, "%02X", rlist[j]);
|
||||
}
|
||||
}
|
||||
BIO_puts(bio, "\n");
|
||||
}
|
||||
|
||||
|
||||
void print_ssl_summary(BIO *bio, SSL *s)
|
||||
{
|
||||
const SSL_CIPHER *c;
|
||||
X509 *peer;
|
||||
/*const char *pnam = SSL_is_server(s) ? "client" : "server";*/
|
||||
BIO_printf(bio, "Protocol version: %s\n", SSL_get_version(s));
|
||||
print_raw_cipherlist(bio, s);
|
||||
c = SSL_get_current_cipher(s);
|
||||
BIO_printf(bio,"Ciphersuite: %s\n", SSL_CIPHER_get_name(c));
|
||||
do_print_sigalgs(bio, s, 0);
|
||||
peer = SSL_get_peer_certificate(s);
|
||||
if (peer)
|
||||
{
|
||||
int nid;
|
||||
BIO_puts(bio, "Peer certificate: ");
|
||||
X509_NAME_print_ex(bio, X509_get_subject_name(peer),
|
||||
0, XN_FLAG_ONELINE);
|
||||
BIO_puts(bio, "\n");
|
||||
if (SSL_get_peer_signature_nid(s, &nid))
|
||||
BIO_printf(bio, "Hash used: %s\n", OBJ_nid2sn(nid));
|
||||
}
|
||||
else
|
||||
BIO_puts(bio, "No peer certificate\n");
|
||||
if (peer)
|
||||
X509_free(peer);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ssl_print_point_formats(bio, s);
|
||||
if (SSL_is_server(s))
|
||||
ssl_print_curves(bio, s, 1);
|
||||
else
|
||||
ssl_print_tmp_key(bio, s);
|
||||
#else
|
||||
if (!SSL_is_server(s))
|
||||
ssl_print_tmp_key(bio, s);
|
||||
#endif
|
||||
}
|
||||
|
||||
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr)
|
||||
{
|
||||
char *arg = **pargs, *argn = (*pargs)[1];
|
||||
int rv;
|
||||
|
||||
/* Attempt to run SSL configuration command */
|
||||
rv = SSL_CONF_cmd_argv(cctx, pargc, pargs);
|
||||
/* If parameter not recognised just return */
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
/* see if missing argument error */
|
||||
if (rv == -3)
|
||||
{
|
||||
BIO_printf(err, "%s needs an argument\n", arg);
|
||||
*badarg = 1;
|
||||
goto end;
|
||||
}
|
||||
/* Check for some other error */
|
||||
if (rv < 0)
|
||||
{
|
||||
BIO_printf(err, "Error with command: \"%s %s\"\n",
|
||||
arg, argn ? argn : "");
|
||||
*badarg = 1;
|
||||
goto end;
|
||||
}
|
||||
/* Store command and argument */
|
||||
/* If only one argument processed store value as NULL */
|
||||
if (rv == 1)
|
||||
argn = NULL;
|
||||
if (!*pstr)
|
||||
*pstr = sk_OPENSSL_STRING_new_null();
|
||||
if (!*pstr || !sk_OPENSSL_STRING_push(*pstr, arg) ||
|
||||
!sk_OPENSSL_STRING_push(*pstr, argn))
|
||||
{
|
||||
BIO_puts(err, "Memory allocation failure\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
if (*badarg)
|
||||
ERR_print_errors(err);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int args_ssl_call(SSL_CTX *ctx, BIO *err, SSL_CONF_CTX *cctx,
|
||||
STACK_OF(OPENSSL_STRING) *str, int no_ecdhe, int no_jpake)
|
||||
{
|
||||
int i;
|
||||
SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(str); i+= 2)
|
||||
{
|
||||
const char *param = sk_OPENSSL_STRING_value(str, i);
|
||||
const char *value = sk_OPENSSL_STRING_value(str, i + 1);
|
||||
/* If no_ecdhe or named curve already specified don't need
|
||||
* a default.
|
||||
*/
|
||||
if (!no_ecdhe && !strcmp(param, "-named_curve"))
|
||||
no_ecdhe = 1;
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
if (!no_jpake && !strcmp(param, "-cipher"))
|
||||
{
|
||||
BIO_puts(err, "JPAKE sets cipher to PSK\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (SSL_CONF_cmd(cctx, param, value) <= 0)
|
||||
{
|
||||
BIO_printf(err, "Error with command: \"%s %s\"\n",
|
||||
param, value ? value : "");
|
||||
ERR_print_errors(err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* This is a special case to keep existing s_server functionality:
|
||||
* if we don't have any curve specified *and* we haven't disabled
|
||||
* ECDHE then use P-256.
|
||||
*/
|
||||
if (!no_ecdhe)
|
||||
{
|
||||
if (SSL_CONF_cmd(cctx, "-named_curve", "P-256") <= 0)
|
||||
{
|
||||
BIO_puts(err, "Error setting EC curve\n");
|
||||
ERR_print_errors(err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
if (!no_jpake)
|
||||
{
|
||||
if (SSL_CONF_cmd(cctx, "-cipher", "PSK") <= 0)
|
||||
{
|
||||
BIO_puts(err, "Error setting cipher to PSK\n");
|
||||
ERR_print_errors(err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!SSL_CONF_CTX_finish(cctx))
|
||||
{
|
||||
BIO_puts(err, "Error finishing context\n");
|
||||
ERR_print_errors(err);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int add_crls_store(X509_STORE *st, STACK_OF(X509_CRL) *crls)
|
||||
{
|
||||
X509_CRL *crl;
|
||||
int i;
|
||||
for (i = 0; i < sk_X509_CRL_num(crls); i++)
|
||||
{
|
||||
crl = sk_X509_CRL_value(crls, i);
|
||||
X509_STORE_add_crl(st, crl);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download)
|
||||
{
|
||||
X509_STORE *st;
|
||||
st = SSL_CTX_get_cert_store(ctx);
|
||||
add_crls_store(st, crls);
|
||||
if (crl_download)
|
||||
store_setup_crl_download(st);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ssl_load_stores(SSL_CTX *ctx,
|
||||
const char *vfyCApath, const char *vfyCAfile,
|
||||
const char *chCApath, const char *chCAfile,
|
||||
STACK_OF(X509_CRL) *crls, int crl_download)
|
||||
{
|
||||
X509_STORE *vfy = NULL, *ch = NULL;
|
||||
int rv = 0;
|
||||
if (vfyCApath || vfyCAfile)
|
||||
{
|
||||
vfy = X509_STORE_new();
|
||||
if (!X509_STORE_load_locations(vfy, vfyCAfile, vfyCApath))
|
||||
goto err;
|
||||
add_crls_store(vfy, crls);
|
||||
SSL_CTX_set1_verify_cert_store(ctx, vfy);
|
||||
if (crl_download)
|
||||
store_setup_crl_download(vfy);
|
||||
}
|
||||
if (chCApath || chCAfile)
|
||||
{
|
||||
ch = X509_STORE_new();
|
||||
if (!X509_STORE_load_locations(ch, chCAfile, chCApath))
|
||||
goto err;
|
||||
SSL_CTX_set1_chain_cert_store(ctx, ch);
|
||||
}
|
||||
rv = 1;
|
||||
err:
|
||||
if (vfy)
|
||||
X509_STORE_free(vfy);
|
||||
if (ch)
|
||||
X509_STORE_free(ch);
|
||||
return rv;
|
||||
}
|
||||
|
||||
500
apps/s_client.c
500
apps/s_client.c
@@ -193,6 +193,7 @@ typedef unsigned int u_int;
|
||||
extern int verify_depth;
|
||||
extern int verify_error;
|
||||
extern int verify_return_error;
|
||||
extern int verify_quiet;
|
||||
|
||||
#ifdef FIONBIO
|
||||
static int c_nbio=0;
|
||||
@@ -213,10 +214,45 @@ static void sc_usage(void);
|
||||
static void print_stuff(BIO *berr,SSL *con,int full);
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
static int ocsp_resp_cb(SSL *s, void *arg);
|
||||
static int c_auth = 0;
|
||||
static int c_auth_require_reneg = 0;
|
||||
#endif
|
||||
static BIO *bio_c_out=NULL;
|
||||
static BIO *bio_c_msg=NULL;
|
||||
static int c_quiet=0;
|
||||
static int c_ign_eof=0;
|
||||
static int c_brief=0;
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
|
||||
static unsigned char *generated_supp_data = NULL;
|
||||
|
||||
static const unsigned char *most_recent_supplemental_data = NULL;
|
||||
static size_t most_recent_supplemental_data_length = 0;
|
||||
|
||||
static int server_provided_server_authz = 0;
|
||||
static int server_provided_client_authz = 0;
|
||||
|
||||
static const unsigned char auth_ext_data[]={TLSEXT_AUTHZDATAFORMAT_dtcp};
|
||||
|
||||
static int suppdata_cb(SSL *s, unsigned short supp_data_type,
|
||||
const unsigned char *in,
|
||||
unsigned short inlen, int *al,
|
||||
void *arg);
|
||||
|
||||
static int auth_suppdata_generate_cb(SSL *s, unsigned short supp_data_type,
|
||||
const unsigned char **out,
|
||||
unsigned short *outlen, int *al, void *arg);
|
||||
|
||||
static int authz_tlsext_generate_cb(SSL *s, unsigned short ext_type,
|
||||
const unsigned char **out, unsigned short *outlen,
|
||||
int *al, void *arg);
|
||||
|
||||
static int authz_tlsext_cb(SSL *s, unsigned short ext_type,
|
||||
const unsigned char *in,
|
||||
unsigned short inlen, int *al,
|
||||
void *arg);
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
/* Default PSK identity and key */
|
||||
@@ -288,6 +324,9 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -host host - use -connect instead\n");
|
||||
BIO_printf(bio_err," -port port - use -connect instead\n");
|
||||
BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR);
|
||||
BIO_printf(bio_err," -checkhost host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err," -checkemail email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err," -checkip ipaddr - check peer certificate matches \"ipaddr\"\n");
|
||||
|
||||
BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n");
|
||||
BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n");
|
||||
@@ -357,10 +396,14 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n");
|
||||
BIO_printf(bio_err," -status - request certificate status from server\n");
|
||||
BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n");
|
||||
# if !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
BIO_printf(bio_err," -serverinfo types - send empty ClientHello extensions (comma-separated numbers)\n");
|
||||
BIO_printf(bio_err," -auth - send and receive RFC 5878 TLS auth extensions and supplemental data\n");
|
||||
BIO_printf(bio_err," -auth_require_reneg - Do not send TLS auth extensions until renegotiation\n");
|
||||
#endif
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
BIO_printf(bio_err," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n");
|
||||
# endif
|
||||
#endif
|
||||
BIO_printf(bio_err," -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n");
|
||||
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
|
||||
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
|
||||
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
|
||||
@@ -536,7 +579,28 @@ static int next_proto_cb(SSL *s, unsigned char **out, unsigned char *outlen, con
|
||||
ctx->status = SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
# endif
|
||||
# endif /* ndef OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
static int serverinfo_cli_cb(SSL* s, unsigned short ext_type,
|
||||
const unsigned char* in, unsigned short inlen,
|
||||
int* al, void* arg)
|
||||
{
|
||||
char pem_name[100];
|
||||
unsigned char ext_buf[4 + 65536];
|
||||
|
||||
/* Reconstruct the type/len fields prior to extension data */
|
||||
ext_buf[0] = ext_type >> 8;
|
||||
ext_buf[1] = ext_type & 0xFF;
|
||||
ext_buf[2] = inlen >> 8;
|
||||
ext_buf[3] = inlen & 0xFF;
|
||||
memcpy(ext_buf+4, in, inlen);
|
||||
|
||||
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
|
||||
ext_type);
|
||||
PEM_write_bio(bio_c_out, pem_name, "", ext_buf, 4 + inlen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
enum
|
||||
@@ -553,7 +617,7 @@ int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
unsigned int off=0, clr=0;
|
||||
int build_chain = 0;
|
||||
SSL *con=NULL;
|
||||
#ifndef OPENSSL_NO_KRB5
|
||||
KSSL_CTX *kctx;
|
||||
@@ -566,13 +630,16 @@ int MAIN(int argc, char **argv)
|
||||
short port=PORT;
|
||||
int full_log=1;
|
||||
char *host=SSL_HOST_NAME;
|
||||
char *cert_file=NULL,*key_file=NULL;
|
||||
char *cert_file=NULL,*key_file=NULL,*chain_file=NULL;
|
||||
int cert_format = FORMAT_PEM, key_format = FORMAT_PEM;
|
||||
char *passarg = NULL, *pass = NULL;
|
||||
X509 *cert = NULL;
|
||||
EVP_PKEY *key = NULL;
|
||||
char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
|
||||
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
|
||||
STACK_OF(X509) *chain = NULL;
|
||||
char *CApath=NULL,*CAfile=NULL;
|
||||
char *chCApath=NULL,*chCAfile=NULL;
|
||||
char *vfyCApath=NULL,*vfyCAfile=NULL;
|
||||
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE;
|
||||
int crlf=0;
|
||||
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
|
||||
SSL_CTX *ctx=NULL;
|
||||
@@ -606,6 +673,10 @@ int MAIN(int argc, char **argv)
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
const char *next_proto_neg_in = NULL;
|
||||
# endif
|
||||
const char *alpn_in = NULL;
|
||||
# define MAX_SI_TYPES 100
|
||||
unsigned short serverinfo_types[MAX_SI_TYPES];
|
||||
int serverinfo_types_count = 0;
|
||||
#endif
|
||||
char *sess_in = NULL;
|
||||
char *sess_out = NULL;
|
||||
@@ -614,13 +685,25 @@ int MAIN(int argc, char **argv)
|
||||
int enable_timeouts = 0 ;
|
||||
long socket_mtu = 0;
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
char *jpake_secret = NULL;
|
||||
static char *jpake_secret = NULL;
|
||||
#define no_jpake !jpake_secret
|
||||
#else
|
||||
#define no_jpake 1
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
char * srppass = NULL;
|
||||
int srp_lateuser = 0;
|
||||
SRP_ARG srp_arg = {NULL,NULL,0,0,0,1024};
|
||||
#endif
|
||||
SSL_EXCERT *exc = NULL;
|
||||
|
||||
SSL_CONF_CTX *cctx = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *ssl_args = NULL;
|
||||
|
||||
char *crl_file = NULL;
|
||||
int crl_format = FORMAT_PEM;
|
||||
int crl_download = 0;
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
|
||||
meth=SSLv23_client_method();
|
||||
|
||||
@@ -638,6 +721,12 @@ int MAIN(int argc, char **argv)
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
cctx = SSL_CONF_CTX_new();
|
||||
if (!cctx)
|
||||
goto end;
|
||||
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CLIENT);
|
||||
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CMDLINE);
|
||||
|
||||
if ( ((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
|
||||
((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
|
||||
((mbuf=OPENSSL_malloc(BUFSIZZ)) == NULL))
|
||||
@@ -678,13 +767,21 @@ int MAIN(int argc, char **argv)
|
||||
verify=SSL_VERIFY_PEER;
|
||||
if (--argc < 1) goto bad;
|
||||
verify_depth=atoi(*(++argv));
|
||||
BIO_printf(bio_err,"verify depth is %d\n",verify_depth);
|
||||
if (!c_quiet)
|
||||
BIO_printf(bio_err,"verify depth is %d\n",verify_depth);
|
||||
}
|
||||
else if (strcmp(*argv,"-cert") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
cert_file= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-CRL") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
crl_file= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-crl_download") == 0)
|
||||
crl_download = 1;
|
||||
else if (strcmp(*argv,"-sess_out") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -700,6 +797,11 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1) goto bad;
|
||||
cert_format = str2fmt(*(++argv));
|
||||
}
|
||||
else if (strcmp(*argv,"-CRLform") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
crl_format = str2fmt(*(++argv));
|
||||
}
|
||||
else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm))
|
||||
{
|
||||
if (badarg)
|
||||
@@ -708,6 +810,26 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else if (strcmp(*argv,"-verify_return_error") == 0)
|
||||
verify_return_error = 1;
|
||||
else if (strcmp(*argv,"-verify_quiet") == 0)
|
||||
verify_quiet = 1;
|
||||
else if (strcmp(*argv,"-brief") == 0)
|
||||
{
|
||||
c_brief = 1;
|
||||
verify_quiet = 1;
|
||||
c_quiet = 1;
|
||||
}
|
||||
else if (args_excert(&argv, &argc, &badarg, bio_err, &exc))
|
||||
{
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
}
|
||||
else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args))
|
||||
{
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
}
|
||||
else if (strcmp(*argv,"-prexit") == 0)
|
||||
prexit=1;
|
||||
else if (strcmp(*argv,"-crlf") == 0)
|
||||
@@ -730,6 +852,10 @@ int MAIN(int argc, char **argv)
|
||||
c_tlsextdebug=1;
|
||||
else if (strcmp(*argv,"-status") == 0)
|
||||
c_status_req=1;
|
||||
else if (strcmp(*argv,"-auth") == 0)
|
||||
c_auth = 1;
|
||||
else if (strcmp(*argv,"-auth_require_reneg") == 0)
|
||||
c_auth_require_reneg = 1;
|
||||
#endif
|
||||
#ifdef WATT32
|
||||
else if (strcmp(*argv,"-wdebug") == 0)
|
||||
@@ -737,6 +863,15 @@ int MAIN(int argc, char **argv)
|
||||
#endif
|
||||
else if (strcmp(*argv,"-msg") == 0)
|
||||
c_msg=1;
|
||||
else if (strcmp(*argv,"-msgfile") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
bio_c_msg = BIO_new_file(*(++argv), "w");
|
||||
}
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
else if (strcmp(*argv,"-trace") == 0)
|
||||
c_msg=2;
|
||||
#endif
|
||||
else if (strcmp(*argv,"-showcerts") == 0)
|
||||
c_showcerts=1;
|
||||
else if (strcmp(*argv,"-nbio_test") == 0)
|
||||
@@ -812,11 +947,21 @@ int MAIN(int argc, char **argv)
|
||||
meth=TLSv1_client_method();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DTLS1
|
||||
else if (strcmp(*argv,"-dtls") == 0)
|
||||
{
|
||||
meth=DTLS_client_method();
|
||||
socket_type=SOCK_DGRAM;
|
||||
}
|
||||
else if (strcmp(*argv,"-dtls1") == 0)
|
||||
{
|
||||
meth=DTLSv1_client_method();
|
||||
socket_type=SOCK_DGRAM;
|
||||
}
|
||||
else if (strcmp(*argv,"-dtls1_2") == 0)
|
||||
{
|
||||
meth=DTLSv1_2_client_method();
|
||||
socket_type=SOCK_DGRAM;
|
||||
}
|
||||
else if (strcmp(*argv,"-timeout") == 0)
|
||||
enable_timeouts=1;
|
||||
else if (strcmp(*argv,"-mtu") == 0)
|
||||
@@ -825,8 +970,6 @@ int MAIN(int argc, char **argv)
|
||||
socket_mtu = atol(*(++argv));
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv,"-bugs") == 0)
|
||||
bugs=1;
|
||||
else if (strcmp(*argv,"-keyform") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -837,6 +980,11 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1) goto bad;
|
||||
passarg = *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-cert_chain") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
chain_file= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-key") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -851,26 +999,34 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1) goto bad;
|
||||
CApath= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-chainCApath") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
chCApath= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-verifyCApath") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
vfyCApath= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-build_chain") == 0)
|
||||
build_chain = 1;
|
||||
else if (strcmp(*argv,"-CAfile") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
CAfile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-no_tls1_2") == 0)
|
||||
off|=SSL_OP_NO_TLSv1_2;
|
||||
else if (strcmp(*argv,"-no_tls1_1") == 0)
|
||||
off|=SSL_OP_NO_TLSv1_1;
|
||||
else if (strcmp(*argv,"-no_tls1") == 0)
|
||||
off|=SSL_OP_NO_TLSv1;
|
||||
else if (strcmp(*argv,"-no_ssl3") == 0)
|
||||
off|=SSL_OP_NO_SSLv3;
|
||||
else if (strcmp(*argv,"-no_ssl2") == 0)
|
||||
off|=SSL_OP_NO_SSLv2;
|
||||
else if (strcmp(*argv,"-no_comp") == 0)
|
||||
{ off|=SSL_OP_NO_COMPRESSION; }
|
||||
else if (strcmp(*argv,"-chainCAfile") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
chCAfile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-verifyCAfile") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
vfyCAfile= *(++argv);
|
||||
}
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
else if (strcmp(*argv,"-no_ticket") == 0)
|
||||
{ off|=SSL_OP_NO_TICKET; }
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
else if (strcmp(*argv,"-nextprotoneg") == 0)
|
||||
{
|
||||
@@ -878,20 +1034,35 @@ int MAIN(int argc, char **argv)
|
||||
next_proto_neg_in = *(++argv);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
else if (strcmp(*argv,"-serverpref") == 0)
|
||||
off|=SSL_OP_CIPHER_SERVER_PREFERENCE;
|
||||
else if (strcmp(*argv,"-legacy_renegotiation") == 0)
|
||||
off|=SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
|
||||
else if (strcmp(*argv,"-legacy_server_connect") == 0)
|
||||
{ off|=SSL_OP_LEGACY_SERVER_CONNECT; }
|
||||
else if (strcmp(*argv,"-no_legacy_server_connect") == 0)
|
||||
{ clr|=SSL_OP_LEGACY_SERVER_CONNECT; }
|
||||
else if (strcmp(*argv,"-cipher") == 0)
|
||||
else if (strcmp(*argv,"-alpn") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
cipher= *(++argv);
|
||||
alpn_in = *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-serverinfo") == 0)
|
||||
{
|
||||
char *c;
|
||||
int start = 0;
|
||||
int len;
|
||||
|
||||
if (--argc < 1) goto bad;
|
||||
c = *(++argv);
|
||||
serverinfo_types_count = 0;
|
||||
len = strlen(c);
|
||||
for (i = 0; i <= len; ++i)
|
||||
{
|
||||
if (i == len || c[i] == ',')
|
||||
{
|
||||
serverinfo_types[serverinfo_types_count]
|
||||
= atoi(c+start);
|
||||
serverinfo_types_count++;
|
||||
start = i+1;
|
||||
}
|
||||
if (serverinfo_types_count == MAX_SI_TYPES)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef FIONBIO
|
||||
else if (strcmp(*argv,"-nbio") == 0)
|
||||
{ c_nbio=1; }
|
||||
@@ -987,12 +1158,6 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
psk_identity = "JPAKE";
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1065,6 +1230,37 @@ bad:
|
||||
}
|
||||
}
|
||||
|
||||
if (chain_file)
|
||||
{
|
||||
chain = load_certs(bio_err, chain_file,FORMAT_PEM,
|
||||
NULL, e, "client certificate chain");
|
||||
if (!chain)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (crl_file)
|
||||
{
|
||||
X509_CRL *crl;
|
||||
crl = load_crl(crl_file, crl_format);
|
||||
if (!crl)
|
||||
{
|
||||
BIO_puts(bio_err, "Error loading CRL\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
crls = sk_X509_CRL_new_null();
|
||||
if (!crls || !sk_X509_CRL_push(crls, crl))
|
||||
{
|
||||
BIO_puts(bio_err, "Error adding CRL\n");
|
||||
ERR_print_errors(bio_err);
|
||||
X509_CRL_free(crl);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!load_excert(&exc, bio_err))
|
||||
goto end;
|
||||
|
||||
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
|
||||
&& !RAND_status())
|
||||
{
|
||||
@@ -1076,9 +1272,11 @@ bad:
|
||||
|
||||
if (bio_c_out == NULL)
|
||||
{
|
||||
if (c_quiet && !c_debug && !c_msg)
|
||||
if (c_quiet && !c_debug)
|
||||
{
|
||||
bio_c_out=BIO_new(BIO_s_null());
|
||||
if (c_msg && !bio_c_msg)
|
||||
bio_c_msg=BIO_new_fp(stdout,BIO_NOCLOSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1105,6 +1303,20 @@ bad:
|
||||
if (vpm)
|
||||
SSL_CTX_set1_param(ctx, vpm);
|
||||
|
||||
if (!args_ssl_call(ctx, bio_err, cctx, ssl_args, 1, no_jpake))
|
||||
{
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!ssl_load_stores(ctx, vfyCApath, vfyCAfile, chCApath, chCAfile,
|
||||
crls, crl_download))
|
||||
{
|
||||
BIO_printf(bio_err, "Error loading store locations\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (ssl_client_engine)
|
||||
{
|
||||
@@ -1133,38 +1345,52 @@ bad:
|
||||
if (srtp_profiles != NULL)
|
||||
SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles);
|
||||
#endif
|
||||
if (bugs)
|
||||
SSL_CTX_set_options(ctx,SSL_OP_ALL|off);
|
||||
else
|
||||
SSL_CTX_set_options(ctx,off);
|
||||
|
||||
if (clr)
|
||||
SSL_CTX_clear_options(ctx, clr);
|
||||
if (exc) ssl_ctx_set_excert(ctx, exc);
|
||||
/* DTLS: partial reads end up discarding unread UDP bytes :-(
|
||||
* Setting read ahead solves this problem.
|
||||
*/
|
||||
if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1);
|
||||
|
||||
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
#if !defined(OPENSSL_NO_TLSEXT)
|
||||
# if !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
if (next_proto.data)
|
||||
SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &next_proto);
|
||||
# endif
|
||||
if (alpn_in)
|
||||
{
|
||||
unsigned short alpn_len;
|
||||
unsigned char *alpn = next_protos_parse(&alpn_len, alpn_in);
|
||||
|
||||
if (alpn == NULL)
|
||||
{
|
||||
BIO_printf(bio_err, "Error parsing -alpn argument\n");
|
||||
goto end;
|
||||
}
|
||||
SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len);
|
||||
OPENSSL_free(alpn);
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (serverinfo_types_count)
|
||||
{
|
||||
for (i = 0; i < serverinfo_types_count; i++)
|
||||
{
|
||||
SSL_CTX_set_custom_cli_ext(ctx,
|
||||
serverinfo_types[i],
|
||||
NULL,
|
||||
serverinfo_cli_cb,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
|
||||
if (cipher != NULL)
|
||||
if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
|
||||
BIO_printf(bio_err,"error setting cipher list\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
|
||||
#endif
|
||||
|
||||
SSL_CTX_set_verify(ctx,verify,verify_callback);
|
||||
if (!set_cert_key_stuff(ctx,cert,key))
|
||||
goto end;
|
||||
|
||||
if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
|
||||
(!SSL_CTX_set_default_verify_paths(ctx)))
|
||||
@@ -1174,6 +1400,10 @@ bad:
|
||||
/* goto end; */
|
||||
}
|
||||
|
||||
ssl_ctx_add_crls(ctx, crls, crl_download);
|
||||
if (!set_cert_key_stuff(ctx,cert,key,chain,build_chain))
|
||||
goto end;
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (servername != NULL)
|
||||
{
|
||||
@@ -1199,6 +1429,12 @@ bad:
|
||||
}
|
||||
|
||||
#endif
|
||||
if (c_auth)
|
||||
{
|
||||
SSL_CTX_set_custom_cli_ext(ctx, TLSEXT_TYPE_client_authz, authz_tlsext_generate_cb, authz_tlsext_cb, bio_err);
|
||||
SSL_CTX_set_custom_cli_ext(ctx, TLSEXT_TYPE_server_authz, authz_tlsext_generate_cb, authz_tlsext_cb, bio_err);
|
||||
SSL_CTX_set_cli_supp_data(ctx, TLSEXT_SUPPLEMENTALDATATYPE_authz_data, suppdata_cb, auth_suppdata_generate_cb, bio_err);
|
||||
}
|
||||
#endif
|
||||
|
||||
con=SSL_new(ctx);
|
||||
@@ -1225,6 +1461,9 @@ bad:
|
||||
SSL_set_session(con, sess);
|
||||
SSL_SESSION_free(sess);
|
||||
}
|
||||
#ifndef OPENSSL_NO_DANE
|
||||
SSL_pull_tlsa_record(con,host,port);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (servername != NULL)
|
||||
{
|
||||
@@ -1274,7 +1513,7 @@ re_start:
|
||||
#endif
|
||||
if (c_Pause & 0x01) SSL_set_debug(con, 1);
|
||||
|
||||
if ( SSL_version(con) == DTLS1_VERSION)
|
||||
if (socket_type == SOCK_DGRAM)
|
||||
{
|
||||
|
||||
sbio=BIO_new_dgram(s,BIO_NOCLOSE);
|
||||
@@ -1327,8 +1566,13 @@ re_start:
|
||||
}
|
||||
if (c_msg)
|
||||
{
|
||||
SSL_set_msg_callback(con, msg_cb);
|
||||
SSL_set_msg_callback_arg(con, bio_c_out);
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
if (c_msg == 2)
|
||||
SSL_set_msg_callback(con, SSL_trace);
|
||||
else
|
||||
#endif
|
||||
SSL_set_msg_callback(con, msg_cb);
|
||||
SSL_set_msg_callback_arg(con, bio_c_msg ? bio_c_msg : bio_c_out);
|
||||
}
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (c_tlsextdebug)
|
||||
@@ -1528,6 +1772,19 @@ SSL_set_tlsext_status_ids(con, ids);
|
||||
else
|
||||
BIO_printf(bio_err, "Error writing session file %s\n", sess_out);
|
||||
}
|
||||
if (c_brief)
|
||||
{
|
||||
BIO_puts(bio_err,
|
||||
"CONNECTION ESTABLISHED\n");
|
||||
print_ssl_summary(bio_err, con);
|
||||
}
|
||||
/*handshake is complete - free the generated supp data allocated in the callback */
|
||||
if (generated_supp_data)
|
||||
{
|
||||
OPENSSL_free(generated_supp_data);
|
||||
generated_supp_data = NULL;
|
||||
}
|
||||
|
||||
print_stuff(bio_c_out,con,full_log);
|
||||
if (full_log > 0) full_log--;
|
||||
|
||||
@@ -1790,7 +2047,10 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
ret=get_last_socket_error();
|
||||
BIO_printf(bio_err,"read:errno=%d\n",ret);
|
||||
if (c_brief)
|
||||
BIO_puts(bio_err, "CONNECTION CLOSED BY SERVER\n");
|
||||
else
|
||||
BIO_printf(bio_err,"read:errno=%d\n",ret);
|
||||
goto shut;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
BIO_printf(bio_c_out,"closed\n");
|
||||
@@ -1890,13 +2150,32 @@ end:
|
||||
print_stuff(bio_c_out,con,1);
|
||||
SSL_free(con);
|
||||
}
|
||||
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
if (next_proto.data)
|
||||
OPENSSL_free(next_proto.data);
|
||||
#endif
|
||||
if (ctx != NULL) SSL_CTX_free(ctx);
|
||||
if (cert)
|
||||
X509_free(cert);
|
||||
if (crls)
|
||||
sk_X509_CRL_pop_free(crls, X509_CRL_free);
|
||||
if (key)
|
||||
EVP_PKEY_free(key);
|
||||
if (chain)
|
||||
sk_X509_pop_free(chain, X509_free);
|
||||
if (pass)
|
||||
OPENSSL_free(pass);
|
||||
if (vpm)
|
||||
X509_VERIFY_PARAM_free(vpm);
|
||||
ssl_excert_free(exc);
|
||||
if (ssl_args)
|
||||
sk_OPENSSL_STRING_free(ssl_args);
|
||||
if (cctx)
|
||||
SSL_CONF_CTX_free(cctx);
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
if (jpake_secret && psk_key)
|
||||
OPENSSL_free(psk_key);
|
||||
#endif
|
||||
if (cbuf != NULL) { OPENSSL_cleanse(cbuf,BUFSIZZ); OPENSSL_free(cbuf); }
|
||||
if (sbuf != NULL) { OPENSSL_cleanse(sbuf,BUFSIZZ); OPENSSL_free(sbuf); }
|
||||
if (mbuf != NULL) { OPENSSL_cleanse(mbuf,BUFSIZZ); OPENSSL_free(mbuf); }
|
||||
@@ -1905,6 +2184,11 @@ end:
|
||||
BIO_free(bio_c_out);
|
||||
bio_c_out=NULL;
|
||||
}
|
||||
if (bio_c_msg != NULL)
|
||||
{
|
||||
BIO_free(bio_c_msg);
|
||||
bio_c_msg=NULL;
|
||||
}
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
@@ -2011,6 +2295,9 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_write(bio,"\n",1);
|
||||
}
|
||||
|
||||
ssl_print_sigalgs(bio, s);
|
||||
ssl_print_tmp_key(bio, s);
|
||||
|
||||
BIO_printf(bio,"---\nSSL handshake has read %ld bytes and written %ld bytes\n",
|
||||
BIO_number_read(SSL_get_rbio(s)),
|
||||
BIO_number_written(SSL_get_wbio(s)));
|
||||
@@ -2050,7 +2337,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
#if !defined(OPENSSL_NO_TLSEXT)
|
||||
# if !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
if (next_proto.status != -1) {
|
||||
const unsigned char *proto;
|
||||
unsigned int proto_len;
|
||||
@@ -2059,6 +2347,20 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_write(bio, proto, proto_len);
|
||||
BIO_write(bio, "\n", 1);
|
||||
}
|
||||
# endif
|
||||
{
|
||||
const unsigned char *proto;
|
||||
unsigned int proto_len;
|
||||
SSL_get0_alpn_selected(s, &proto, &proto_len);
|
||||
if (proto_len > 0)
|
||||
{
|
||||
BIO_printf(bio, "ALPN protocol: ");
|
||||
BIO_write(bio, proto, proto_len);
|
||||
BIO_write(bio, "\n", 1);
|
||||
}
|
||||
else
|
||||
BIO_printf(bio, "No ALPN negotiated\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
@@ -2132,4 +2434,74 @@ static int ocsp_resp_cb(SSL *s, void *arg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int authz_tlsext_cb(SSL *s, unsigned short ext_type,
|
||||
const unsigned char *in,
|
||||
unsigned short inlen, int *al,
|
||||
void *arg)
|
||||
{
|
||||
if (TLSEXT_TYPE_server_authz == ext_type)
|
||||
server_provided_server_authz
|
||||
= (memchr(in, TLSEXT_AUTHZDATAFORMAT_dtcp, inlen) != NULL);
|
||||
|
||||
if (TLSEXT_TYPE_client_authz == ext_type)
|
||||
server_provided_client_authz
|
||||
= (memchr(in, TLSEXT_AUTHZDATAFORMAT_dtcp, inlen) != NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int authz_tlsext_generate_cb(SSL *s, unsigned short ext_type,
|
||||
const unsigned char **out, unsigned short *outlen,
|
||||
int *al, void *arg)
|
||||
{
|
||||
if (c_auth)
|
||||
{
|
||||
/*if auth_require_reneg flag is set, only send extensions if
|
||||
renegotiation has occurred */
|
||||
if (!c_auth_require_reneg || (c_auth_require_reneg && SSL_num_renegotiations(s)))
|
||||
{
|
||||
*out = auth_ext_data;
|
||||
*outlen = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* no auth extension to send */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int suppdata_cb(SSL *s, unsigned short supp_data_type,
|
||||
const unsigned char *in,
|
||||
unsigned short inlen, int *al,
|
||||
void *arg)
|
||||
{
|
||||
if (supp_data_type == TLSEXT_SUPPLEMENTALDATATYPE_authz_data)
|
||||
{
|
||||
most_recent_supplemental_data = in;
|
||||
most_recent_supplemental_data_length = inlen;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int auth_suppdata_generate_cb(SSL *s, unsigned short supp_data_type,
|
||||
const unsigned char **out,
|
||||
unsigned short *outlen, int *al, void *arg)
|
||||
{
|
||||
if (c_auth && server_provided_client_authz && server_provided_server_authz)
|
||||
{
|
||||
/*if auth_require_reneg flag is set, only send supplemental data if
|
||||
renegotiation has occurred */
|
||||
if (!c_auth_require_reneg
|
||||
|| (c_auth_require_reneg && SSL_num_renegotiations(s)))
|
||||
{
|
||||
generated_supp_data = OPENSSL_malloc(10);
|
||||
memcpy(generated_supp_data, "5432154321", 10);
|
||||
*out = generated_supp_data;
|
||||
*outlen = 10;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* no supplemental data to send */
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
960
apps/s_server.c
960
apps/s_server.c
File diff suppressed because it is too large
Load Diff
@@ -284,7 +284,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
|
||||
return(1);
|
||||
}
|
||||
|
||||
int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
|
||||
int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, int stype, unsigned char *context), unsigned char *context, int naccept)
|
||||
{
|
||||
int sock;
|
||||
char *name = NULL;
|
||||
@@ -310,11 +310,13 @@ int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, uns
|
||||
}
|
||||
else
|
||||
sock = accept_socket;
|
||||
i=(*cb)(name,sock, context);
|
||||
i=(*cb)(name,sock, type, context);
|
||||
if (name != NULL) OPENSSL_free(name);
|
||||
if (type==SOCK_STREAM)
|
||||
SHUTDOWN2(sock);
|
||||
if (i < 0)
|
||||
if (naccept != -1)
|
||||
naccept--;
|
||||
if (i < 0 || naccept == 0)
|
||||
{
|
||||
SHUTDOWN2(accept_socket);
|
||||
return(i);
|
||||
|
||||
@@ -254,7 +254,7 @@ static const char *names[ALGOR_NUM]={
|
||||
"aes-128 cbc","aes-192 cbc","aes-256 cbc",
|
||||
"camellia-128 cbc","camellia-192 cbc","camellia-256 cbc",
|
||||
"evp","sha256","sha512","whirlpool",
|
||||
"aes-128 ige","aes-192 ige","aes-256 ige","ghash"};
|
||||
"aes-128 ige","aes-192 ige","aes-256 ige","ghash" };
|
||||
static double results[ALGOR_NUM][SIZE_NUM];
|
||||
static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
@@ -299,7 +299,7 @@ static SIGRETTYPE sig_done(int sig)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#if !defined(SIGALRM)
|
||||
#define SIGALRM
|
||||
# define SIGALRM
|
||||
#endif
|
||||
static unsigned int lapse,schlock;
|
||||
static void alarm_win32(unsigned int secs) { lapse = secs*1000; }
|
||||
|
||||
30
apps/srp.c
30
apps/srp.c
@@ -125,13 +125,13 @@ static int get_index(CA_DB *db, char* id, char type)
|
||||
if (type == DB_SRP_INDEX)
|
||||
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
|
||||
{
|
||||
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id, pp[DB_srpid]))
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
|
||||
if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
|
||||
return i;
|
||||
}
|
||||
else for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
|
||||
{
|
||||
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
|
||||
|
||||
if (pp[DB_srptype][0] != DB_SRP_INDEX && !strcmp(id,pp[DB_srpid]))
|
||||
return i;
|
||||
@@ -145,7 +145,7 @@ static void print_entry(CA_DB *db, BIO *bio, int indx, int verbose, char *s)
|
||||
if (indx >= 0 && verbose)
|
||||
{
|
||||
int j;
|
||||
char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, indx);
|
||||
char **pp = sk_OPENSSL_PSTRING_value(db->db->data, indx);
|
||||
BIO_printf(bio, "%s \"%s\"\n", s, pp[DB_srpid]);
|
||||
for (j = 0; j < DB_NUMBER; j++)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ static void print_user(CA_DB *db, BIO *bio, int userindex, int verbose)
|
||||
{
|
||||
if (verbose > 0)
|
||||
{
|
||||
char **pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
char **pp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
|
||||
|
||||
if (pp[DB_srptype][0] != 'I')
|
||||
{
|
||||
@@ -517,7 +517,7 @@ bad:
|
||||
/* Lets check some fields */
|
||||
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
|
||||
{
|
||||
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
|
||||
if (pp[DB_srptype][0] == DB_SRP_INDEX)
|
||||
{
|
||||
@@ -533,8 +533,8 @@ bad:
|
||||
|
||||
if (gNindex >= 0)
|
||||
{
|
||||
gNrow = (char **)sk_OPENSSL_PSTRING_value(db->db->data, gNindex);
|
||||
print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N") ;
|
||||
gNrow = sk_OPENSSL_PSTRING_value(db->db->data,gNindex);
|
||||
print_entry(db, bio_err, gNindex, verbose > 1, "Default g and N");
|
||||
}
|
||||
else if (maxgN > 0 && !SRP_get_default_gN(gN))
|
||||
{
|
||||
@@ -587,7 +587,7 @@ bad:
|
||||
if (userindex >= 0)
|
||||
{
|
||||
/* reactivation of a new user */
|
||||
char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
BIO_printf(bio_err, "user \"%s\" reactivated.\n", user);
|
||||
row[DB_srptype][0] = 'V';
|
||||
|
||||
@@ -634,7 +634,7 @@ bad:
|
||||
else
|
||||
{
|
||||
|
||||
char **row = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
char **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
char type = row[DB_srptype][0];
|
||||
if (type == 'v')
|
||||
{
|
||||
@@ -664,9 +664,9 @@ bad:
|
||||
|
||||
if (!(gNid=srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:NULL, gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose)))
|
||||
{
|
||||
BIO_printf(bio_err, "Cannot create srp verifier for user \"%s\", operation abandoned.\n", user);
|
||||
errors++;
|
||||
goto err;
|
||||
BIO_printf(bio_err, "Cannot create srp verifier for user \"%s\", operation abandoned.\n", user);
|
||||
errors++;
|
||||
goto err;
|
||||
}
|
||||
|
||||
row[DB_srptype][0] = 'v';
|
||||
@@ -689,7 +689,7 @@ bad:
|
||||
}
|
||||
else
|
||||
{
|
||||
char **xpp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, userindex);
|
||||
char **xpp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);
|
||||
BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
|
||||
|
||||
xpp[DB_srptype][0] = 'R';
|
||||
@@ -714,7 +714,7 @@ bad:
|
||||
/* Lets check some fields */
|
||||
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
|
||||
{
|
||||
pp = (char **)sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data,i);
|
||||
|
||||
if (pp[DB_srptype][0] == 'v')
|
||||
{
|
||||
|
||||
@@ -88,6 +88,7 @@ int MAIN(int argc, char **argv)
|
||||
X509_STORE *cert_ctx=NULL;
|
||||
X509_LOOKUP *lookup=NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
int crl_download = 0;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine=NULL;
|
||||
#endif
|
||||
@@ -145,6 +146,8 @@ int MAIN(int argc, char **argv)
|
||||
if (argc-- < 1) goto end;
|
||||
crlfile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-crl_download") == 0)
|
||||
crl_download = 1;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv,"-engine") == 0)
|
||||
{
|
||||
@@ -222,11 +225,22 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, crls, e);
|
||||
ret = 0;
|
||||
|
||||
if (crl_download)
|
||||
store_setup_crl_download(cert_ctx);
|
||||
if (argc < 1)
|
||||
{
|
||||
if (1 != check(cert_ctx, NULL, untrusted, trusted, crls, e))
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<argc; i++)
|
||||
check(cert_ctx,argv[i], untrusted, trusted, crls, e);
|
||||
ret=0;
|
||||
if (1 != check(cert_ctx,argv[i], untrusted, trusted, crls, e))
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
end:
|
||||
if (ret == 1) {
|
||||
BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
|
||||
@@ -235,13 +249,16 @@ end:
|
||||
BIO_printf(bio_err," [-engine e]");
|
||||
#endif
|
||||
BIO_printf(bio_err," cert1 cert2 ...\n");
|
||||
|
||||
BIO_printf(bio_err,"recognized usages:\n");
|
||||
for(i = 0; i < X509_PURPOSE_get_count(); i++) {
|
||||
for(i = 0; i < X509_PURPOSE_get_count(); i++)
|
||||
{
|
||||
X509_PURPOSE *ptmp;
|
||||
ptmp = X509_PURPOSE_get0(i);
|
||||
BIO_printf(bio_err, "\t%-10s\t%s\n", X509_PURPOSE_get0_sname(ptmp),
|
||||
X509_PURPOSE_get0_name(ptmp));
|
||||
}
|
||||
BIO_printf(bio_err, "\t%-10s\t%s\n",
|
||||
X509_PURPOSE_get0_sname(ptmp),
|
||||
X509_PURPOSE_get0_name(ptmp));
|
||||
}
|
||||
}
|
||||
if (vpm) X509_VERIFY_PARAM_free(vpm);
|
||||
if (cert_ctx != NULL) X509_STORE_free(cert_ctx);
|
||||
@@ -249,7 +266,7 @@ end:
|
||||
sk_X509_pop_free(trusted, X509_free);
|
||||
sk_X509_CRL_pop_free(crls, X509_CRL_free);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
OPENSSL_EXIT(ret < 0 ? 2 : ret);
|
||||
}
|
||||
|
||||
static int check(X509_STORE *ctx, char *file,
|
||||
|
||||
79
apps/x509.c
79
apps/x509.c
@@ -150,6 +150,9 @@ static const char *x509_usage[]={
|
||||
" -engine e - use engine e, possibly a hardware device.\n",
|
||||
#endif
|
||||
" -certopt arg - various certificate text options\n",
|
||||
" -checkhost host - check certificate matches \"host\"\n",
|
||||
" -checkemail email - check certificate matches \"email\"\n",
|
||||
" -checkip ipaddr - check certificate matches \"ipaddr\"\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -163,6 +166,9 @@ static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
|
||||
CONF *conf, char *section, ASN1_INTEGER *sno);
|
||||
static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
|
||||
static int reqfile=0;
|
||||
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
|
||||
static int force_version=2;
|
||||
#endif
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
@@ -174,15 +180,16 @@ int MAIN(int argc, char **argv)
|
||||
X509 *x=NULL,*xca=NULL;
|
||||
ASN1_OBJECT *objtmp;
|
||||
STACK_OF(OPENSSL_STRING) *sigopts = NULL;
|
||||
EVP_PKEY *Upkey=NULL,*CApkey=NULL;
|
||||
EVP_PKEY *Upkey=NULL,*CApkey=NULL, *fkey = NULL;
|
||||
ASN1_INTEGER *sno = NULL;
|
||||
int i,num,badops=0;
|
||||
int i,num,badops=0, badsig=0;
|
||||
BIO *out=NULL;
|
||||
BIO *STDout=NULL;
|
||||
STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL;
|
||||
int informat,outformat,keyformat,CAformat,CAkeyformat;
|
||||
char *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL;
|
||||
char *CAkeyfile=NULL,*CAserial=NULL;
|
||||
char *fkeyfile=NULL;
|
||||
char *alias=NULL;
|
||||
int text=0,serial=0,subject=0,issuer=0,startdate=0,enddate=0;
|
||||
int next_serial=0;
|
||||
@@ -207,6 +214,8 @@ int MAIN(int argc, char **argv)
|
||||
int need_rand = 0;
|
||||
int checkend=0,checkoffset=0;
|
||||
unsigned long nmflag = 0, certflag = 0;
|
||||
unsigned char *checkhost = NULL, *checkemail = NULL;
|
||||
char *checkip = NULL;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine=NULL;
|
||||
#endif
|
||||
@@ -282,13 +291,20 @@ int MAIN(int argc, char **argv)
|
||||
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
|
||||
goto bad;
|
||||
}
|
||||
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
|
||||
else if (strcmp(*argv,"-force_version") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
force_version=atoi(*(++argv)) - 1;
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv,"-days") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
days=atoi(*(++argv));
|
||||
if (days == 0)
|
||||
{
|
||||
BIO_printf(STDout,"bad number of days\n");
|
||||
BIO_printf(bio_err,"bad number of days\n");
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
@@ -347,6 +363,11 @@ int MAIN(int argc, char **argv)
|
||||
if (!(sno = s2i_ASN1_INTEGER(NULL, *(++argv))))
|
||||
goto bad;
|
||||
}
|
||||
else if (strcmp(*argv,"-force_pubkey") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
fkeyfile= *(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-addtrust") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -450,6 +471,21 @@ int MAIN(int argc, char **argv)
|
||||
checkoffset=atoi(*(++argv));
|
||||
checkend=1;
|
||||
}
|
||||
else if (strcmp(*argv,"-checkhost") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
checkhost=(unsigned char *)*(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-checkemail") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
checkemail=(unsigned char *)*(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-checkip") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
checkip=*(++argv);
|
||||
}
|
||||
else if (strcmp(*argv,"-noout") == 0)
|
||||
noout= ++num;
|
||||
else if (strcmp(*argv,"-trustout") == 0)
|
||||
@@ -473,6 +509,8 @@ int MAIN(int argc, char **argv)
|
||||
#endif
|
||||
else if (strcmp(*argv,"-ocspid") == 0)
|
||||
ocspid= ++num;
|
||||
else if (strcmp(*argv,"-badsig") == 0)
|
||||
badsig = 1;
|
||||
else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
|
||||
{
|
||||
/* ok */
|
||||
@@ -517,6 +555,13 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (fkeyfile)
|
||||
{
|
||||
fkey = load_pubkey(bio_err, fkeyfile, keyformat, 0,
|
||||
NULL, e, "Forced key");
|
||||
if (fkey == NULL) goto end;
|
||||
}
|
||||
|
||||
if ((CAkeyfile == NULL) && (CA_flag) && (CAformat == FORMAT_PEM))
|
||||
{ CAkeyfile=CAfile; }
|
||||
else if ((CA_flag) && (CAkeyfile == NULL))
|
||||
@@ -653,10 +698,14 @@ bad:
|
||||
|
||||
X509_gmtime_adj(X509_get_notBefore(x),0);
|
||||
X509_time_adj_ex(X509_get_notAfter(x),days, 0, NULL);
|
||||
|
||||
pkey = X509_REQ_get_pubkey(req);
|
||||
X509_set_pubkey(x,pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
if (fkey)
|
||||
X509_set_pubkey(x, fkey);
|
||||
else
|
||||
{
|
||||
pkey = X509_REQ_get_pubkey(req);
|
||||
X509_set_pubkey(x,pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
}
|
||||
else
|
||||
x=load_cert(bio_err,infile,informat,NULL,e,"Certificate");
|
||||
@@ -912,7 +961,7 @@ bad:
|
||||
}
|
||||
else if (text == i)
|
||||
{
|
||||
X509_print_ex(out,x,nmflag, certflag);
|
||||
X509_print_ex(STDout,x,nmflag, certflag);
|
||||
}
|
||||
else if (startdate == i)
|
||||
{
|
||||
@@ -1044,12 +1093,17 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
|
||||
print_cert_checks(STDout, x, checkhost, checkemail, checkip);
|
||||
|
||||
if (noout)
|
||||
{
|
||||
ret=0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (badsig)
|
||||
x->signature->data[x->signature->length - 1] ^= 0x1;
|
||||
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i=i2d_X509_bio(out,x);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
@@ -1093,6 +1147,7 @@ end:
|
||||
X509_free(xca);
|
||||
EVP_PKEY_free(Upkey);
|
||||
EVP_PKEY_free(CApkey);
|
||||
EVP_PKEY_free(fkey);
|
||||
if (sigopts)
|
||||
sk_OPENSSL_STRING_free(sigopts);
|
||||
X509_REQ_free(rq);
|
||||
@@ -1202,7 +1257,11 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
|
||||
if (conf)
|
||||
{
|
||||
X509V3_CTX ctx2;
|
||||
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
|
||||
X509_set_version(x, force_version);
|
||||
#else
|
||||
X509_set_version(x,2); /* version 3 certificate */
|
||||
#endif
|
||||
X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);
|
||||
X509V3_set_nconf(&ctx2, conf);
|
||||
if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end;
|
||||
@@ -1280,7 +1339,11 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *dig
|
||||
if (conf)
|
||||
{
|
||||
X509V3_CTX ctx;
|
||||
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
|
||||
X509_set_version(x, force_version);
|
||||
#else
|
||||
X509_set_version(x,2); /* version 3 certificate */
|
||||
#endif
|
||||
X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
|
||||
X509V3_set_nconf(&ctx, conf);
|
||||
if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;
|
||||
|
||||
27
config
27
config
@@ -587,15 +587,33 @@ case "$GUESSOS" in
|
||||
fi
|
||||
;;
|
||||
ppc64-*-linux2)
|
||||
if [ -z "$KERNEL_BITS" ]; then
|
||||
echo "WARNING! If you wish to build 64-bit library, then you have to"
|
||||
echo " invoke './Configure linux-ppc64' *manually*."
|
||||
if [ "$TEST" = "false" -a -t 1 ]; then
|
||||
echo " You have about 5 seconds to press Ctrl-C to abort."
|
||||
(trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
|
||||
fi
|
||||
fi
|
||||
if [ "$KERNEL_BITS" = "64" ]; then
|
||||
OUT="linux-ppc64"
|
||||
else
|
||||
OUT="linux-ppc"
|
||||
(echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null) || options="$options -m32"
|
||||
fi
|
||||
;;
|
||||
ppc64le-*-linux2) OUT="linux-ppc64le" ;;
|
||||
ppc-*-linux2) OUT="linux-ppc" ;;
|
||||
mips64*-*-linux2)
|
||||
echo "WARNING! If you wish to build 64-bit library, then you have to"
|
||||
echo " invoke './Configure linux-ppc64' *manually*."
|
||||
echo " invoke './Configure linux64-mips64' *manually*."
|
||||
if [ "$TEST" = "false" -a -t 1 ]; then
|
||||
echo " You have about 5 seconds to press Ctrl-C to abort."
|
||||
(trap "stty `stty -g`" 2 0; stty -icanon min 0 time 50; read waste) <&1
|
||||
fi
|
||||
OUT="linux-ppc"
|
||||
OUT="linux-mips64"
|
||||
;;
|
||||
ppc-*-linux2) OUT="linux-ppc" ;;
|
||||
mips*-*-linux2) OUT="linux-mips32" ;;
|
||||
ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
|
||||
ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
|
||||
pentium-*-vxworks*) OUT="vxworks-pentium" ;;
|
||||
@@ -644,6 +662,7 @@ case "$GUESSOS" in
|
||||
armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
|
||||
armv[7-9]*-*-linux2) OUT="linux-armv4"; options="$options -march=armv7-a" ;;
|
||||
arm*-*-linux2) OUT="linux-armv4" ;;
|
||||
aarch64-*-linux2) OUT="linux-generic64" ;;
|
||||
sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
|
||||
sh*-*-linux2) OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
|
||||
m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
|
||||
@@ -739,7 +758,7 @@ case "$GUESSOS" in
|
||||
libc=/usr/lib/libc.so
|
||||
else # OpenBSD
|
||||
# ld searches for highest libc.so.* and so do we
|
||||
libc=`(ls /usr/lib/libc.so.* | tail -1) 2>/dev/null`
|
||||
libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
|
||||
fi
|
||||
case "`(file -L $libc) 2>/dev/null`" in
|
||||
*ELF*) OUT="BSD-x86-elf" ;;
|
||||
|
||||
@@ -77,7 +77,9 @@ ia64cpuid.s: ia64cpuid.S; $(CC) $(CFLAGS) -E ia64cpuid.S > $@
|
||||
ppccpuid.s: ppccpuid.pl; $(PERL) ppccpuid.pl $(PERLASM_SCHEME) $@
|
||||
pariscid.s: pariscid.pl; $(PERL) pariscid.pl $(PERLASM_SCHEME) $@
|
||||
alphacpuid.s: alphacpuid.pl
|
||||
$(PERL) $< | $(CC) -E - | tee $@ > /dev/null
|
||||
(preproc=/tmp/$$$$.$@; trap "rm $$preproc" INT; \
|
||||
$(PERL) alphacpuid.pl > $$preproc && \
|
||||
$(CC) -E $$preproc > $@ && rm $$preproc)
|
||||
|
||||
testapps:
|
||||
[ -z "$(THIS)" ] || ( if echo $(SDIRS) | fgrep ' des '; \
|
||||
@@ -89,7 +91,7 @@ subdirs:
|
||||
@target=all; $(RECURSIVE_MAKE)
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
$(PERL) $(TOP)/util/files.pl "CPUID_OBJ=$(CPUID_OBJ)" Makefile >> $(TOP)/MINFO
|
||||
@target=files; $(RECURSIVE_MAKE)
|
||||
|
||||
links:
|
||||
|
||||
@@ -3,3 +3,6 @@ Makefile.save
|
||||
*.flc
|
||||
semantic.cache
|
||||
aes-*.s
|
||||
aesni-*.s
|
||||
bsaes-*.s
|
||||
vpaes-*.s
|
||||
|
||||
@@ -65,12 +65,20 @@ aesni-x86_64.s: asm/aesni-x86_64.pl
|
||||
$(PERL) asm/aesni-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
aesni-sha1-x86_64.s: asm/aesni-sha1-x86_64.pl
|
||||
$(PERL) asm/aesni-sha1-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
aesni-sha256-x86_64.s: asm/aesni-sha256-x86_64.pl
|
||||
$(PERL) asm/aesni-sha256-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
aesni-mb-x86_64.s: asm/aesni-mb-x86_64.pl
|
||||
$(PERL) asm/aesni-mb-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
|
||||
aes-sparcv9.s: asm/aes-sparcv9.pl
|
||||
$(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@
|
||||
aest4-sparcv9.s: asm/aest4-sparcv9.pl
|
||||
$(PERL) asm/aest4-sparcv9.pl $(CFLAGS) > $@
|
||||
|
||||
aes-ppc.s: asm/aes-ppc.pl
|
||||
$(PERL) asm/aes-ppc.pl $(PERLASM_SCHEME) $@
|
||||
vpaes-ppc.s: asm/vpaes-ppc.pl
|
||||
$(PERL) asm/vpaes-ppc.pl $(PERLASM_SCHEME) $@
|
||||
|
||||
aes-parisc.s: asm/aes-parisc.pl
|
||||
$(PERL) asm/aes-parisc.pl $(PERLASM_SCHEME) $@
|
||||
@@ -81,9 +89,11 @@ aes-mips.S: asm/aes-mips.pl
|
||||
# GNU make "catch all"
|
||||
aes-%.S: asm/aes-%.pl; $(PERL) $< $(PERLASM_SCHEME) > $@
|
||||
aes-armv4.o: aes-armv4.S
|
||||
bsaes-%.S: asm/bsaes-%.pl; $(PERL) $< $(PERLASM_SCHEME) $@
|
||||
bsaes-armv7.o: bsaes-armv7.S
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
$(PERL) $(TOP)/util/files.pl "AES_ENC=$(AES_ENC)" Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@@ -147,7 +157,7 @@ aes_wrap.o: ../../e_os.h ../../include/openssl/aes.h
|
||||
aes_wrap.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
aes_wrap.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
aes_wrap.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
aes_wrap.o: ../../include/openssl/opensslconf.h
|
||||
aes_wrap.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
|
||||
aes_wrap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
aes_wrap.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
aes_wrap.o: ../../include/openssl/symhacks.h ../cryptlib.h aes_wrap.c
|
||||
|
||||
@@ -53,207 +53,18 @@
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/bio.h>
|
||||
|
||||
static const unsigned char default_iv[] = {
|
||||
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
|
||||
};
|
||||
#include <openssl/modes.h>
|
||||
|
||||
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen)
|
||||
{
|
||||
unsigned char *A, B[16], *R;
|
||||
unsigned int i, j, t;
|
||||
if ((inlen & 0x7) || (inlen < 8))
|
||||
return -1;
|
||||
A = B;
|
||||
t = 1;
|
||||
memcpy(out + 8, in, inlen);
|
||||
if (!iv)
|
||||
iv = default_iv;
|
||||
|
||||
memcpy(A, iv, 8);
|
||||
|
||||
for (j = 0; j < 6; j++)
|
||||
{
|
||||
R = out + 8;
|
||||
for (i = 0; i < inlen; i += 8, t++, R += 8)
|
||||
{
|
||||
memcpy(B + 8, R, 8);
|
||||
AES_encrypt(B, B, key);
|
||||
A[7] ^= (unsigned char)(t & 0xff);
|
||||
if (t > 0xff)
|
||||
{
|
||||
A[6] ^= (unsigned char)((t >> 8) & 0xff);
|
||||
A[5] ^= (unsigned char)((t >> 16) & 0xff);
|
||||
A[4] ^= (unsigned char)((t >> 24) & 0xff);
|
||||
}
|
||||
memcpy(R, B + 8, 8);
|
||||
}
|
||||
}
|
||||
memcpy(out, A, 8);
|
||||
return inlen + 8;
|
||||
return CRYPTO_128_wrap(key, iv, out, in, inlen, (block128_f)AES_encrypt);
|
||||
}
|
||||
|
||||
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
|
||||
unsigned char *out,
|
||||
const unsigned char *in, unsigned int inlen)
|
||||
{
|
||||
unsigned char *A, B[16], *R;
|
||||
unsigned int i, j, t;
|
||||
inlen -= 8;
|
||||
if (inlen & 0x7)
|
||||
return -1;
|
||||
if (inlen < 8)
|
||||
return -1;
|
||||
A = B;
|
||||
t = 6 * (inlen >> 3);
|
||||
memcpy(A, in, 8);
|
||||
memcpy(out, in + 8, inlen);
|
||||
for (j = 0; j < 6; j++)
|
||||
{
|
||||
R = out + inlen - 8;
|
||||
for (i = 0; i < inlen; i += 8, t--, R -= 8)
|
||||
{
|
||||
A[7] ^= (unsigned char)(t & 0xff);
|
||||
if (t > 0xff)
|
||||
{
|
||||
A[6] ^= (unsigned char)((t >> 8) & 0xff);
|
||||
A[5] ^= (unsigned char)((t >> 16) & 0xff);
|
||||
A[4] ^= (unsigned char)((t >> 24) & 0xff);
|
||||
}
|
||||
memcpy(B + 8, R, 8);
|
||||
AES_decrypt(B, B, key);
|
||||
memcpy(R, B + 8, 8);
|
||||
}
|
||||
}
|
||||
if (!iv)
|
||||
iv = default_iv;
|
||||
if (memcmp(A, iv, 8))
|
||||
{
|
||||
OPENSSL_cleanse(out, inlen);
|
||||
return 0;
|
||||
}
|
||||
return inlen;
|
||||
return CRYPTO_128_unwrap(key, iv, out, in, inlen, (block128_f)AES_decrypt);
|
||||
}
|
||||
|
||||
#ifdef AES_WRAP_TEST
|
||||
|
||||
int AES_wrap_unwrap_test(const unsigned char *kek, int keybits,
|
||||
const unsigned char *iv,
|
||||
const unsigned char *eout,
|
||||
const unsigned char *key, int keylen)
|
||||
{
|
||||
unsigned char *otmp = NULL, *ptmp = NULL;
|
||||
int r, ret = 0;
|
||||
AES_KEY wctx;
|
||||
otmp = OPENSSL_malloc(keylen + 8);
|
||||
ptmp = OPENSSL_malloc(keylen);
|
||||
if (!otmp || !ptmp)
|
||||
return 0;
|
||||
if (AES_set_encrypt_key(kek, keybits, &wctx))
|
||||
goto err;
|
||||
r = AES_wrap_key(&wctx, iv, otmp, key, keylen);
|
||||
if (r <= 0)
|
||||
goto err;
|
||||
|
||||
if (eout && memcmp(eout, otmp, keylen))
|
||||
goto err;
|
||||
|
||||
if (AES_set_decrypt_key(kek, keybits, &wctx))
|
||||
goto err;
|
||||
r = AES_unwrap_key(&wctx, iv, ptmp, otmp, r);
|
||||
|
||||
if (memcmp(key, ptmp, keylen))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
if (otmp)
|
||||
OPENSSL_free(otmp);
|
||||
if (ptmp)
|
||||
OPENSSL_free(ptmp);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
static const unsigned char kek[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
|
||||
};
|
||||
|
||||
static const unsigned char key[] = {
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
||||
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
|
||||
};
|
||||
|
||||
static const unsigned char e1[] = {
|
||||
0x1f, 0xa6, 0x8b, 0x0a, 0x81, 0x12, 0xb4, 0x47,
|
||||
0xae, 0xf3, 0x4b, 0xd8, 0xfb, 0x5a, 0x7b, 0x82,
|
||||
0x9d, 0x3e, 0x86, 0x23, 0x71, 0xd2, 0xcf, 0xe5
|
||||
};
|
||||
|
||||
static const unsigned char e2[] = {
|
||||
0x96, 0x77, 0x8b, 0x25, 0xae, 0x6c, 0xa4, 0x35,
|
||||
0xf9, 0x2b, 0x5b, 0x97, 0xc0, 0x50, 0xae, 0xd2,
|
||||
0x46, 0x8a, 0xb8, 0xa1, 0x7a, 0xd8, 0x4e, 0x5d
|
||||
};
|
||||
|
||||
static const unsigned char e3[] = {
|
||||
0x64, 0xe8, 0xc3, 0xf9, 0xce, 0x0f, 0x5b, 0xa2,
|
||||
0x63, 0xe9, 0x77, 0x79, 0x05, 0x81, 0x8a, 0x2a,
|
||||
0x93, 0xc8, 0x19, 0x1e, 0x7d, 0x6e, 0x8a, 0xe7
|
||||
};
|
||||
|
||||
static const unsigned char e4[] = {
|
||||
0x03, 0x1d, 0x33, 0x26, 0x4e, 0x15, 0xd3, 0x32,
|
||||
0x68, 0xf2, 0x4e, 0xc2, 0x60, 0x74, 0x3e, 0xdc,
|
||||
0xe1, 0xc6, 0xc7, 0xdd, 0xee, 0x72, 0x5a, 0x93,
|
||||
0x6b, 0xa8, 0x14, 0x91, 0x5c, 0x67, 0x62, 0xd2
|
||||
};
|
||||
|
||||
static const unsigned char e5[] = {
|
||||
0xa8, 0xf9, 0xbc, 0x16, 0x12, 0xc6, 0x8b, 0x3f,
|
||||
0xf6, 0xe6, 0xf4, 0xfb, 0xe3, 0x0e, 0x71, 0xe4,
|
||||
0x76, 0x9c, 0x8b, 0x80, 0xa3, 0x2c, 0xb8, 0x95,
|
||||
0x8c, 0xd5, 0xd1, 0x7d, 0x6b, 0x25, 0x4d, 0xa1
|
||||
};
|
||||
|
||||
static const unsigned char e6[] = {
|
||||
0x28, 0xc9, 0xf4, 0x04, 0xc4, 0xb8, 0x10, 0xf4,
|
||||
0xcb, 0xcc, 0xb3, 0x5c, 0xfb, 0x87, 0xf8, 0x26,
|
||||
0x3f, 0x57, 0x86, 0xe2, 0xd8, 0x0e, 0xd3, 0x26,
|
||||
0xcb, 0xc7, 0xf0, 0xe7, 0x1a, 0x99, 0xf4, 0x3b,
|
||||
0xfb, 0x98, 0x8b, 0x9b, 0x7a, 0x02, 0xdd, 0x21
|
||||
};
|
||||
|
||||
AES_KEY wctx, xctx;
|
||||
int ret;
|
||||
ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
|
||||
fprintf(stderr, "Key test result %d\n", ret);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -89,8 +89,10 @@ typedef unsigned long long u64;
|
||||
#endif
|
||||
|
||||
#undef ROTATE
|
||||
#if defined(_MSC_VER) || defined(__ICC)
|
||||
#if defined(_MSC_VER)
|
||||
# define ROTATE(a,n) _lrotl(a,n)
|
||||
#elif defined(__ICC)
|
||||
# define ROTATE(a,n) _rotl(a,n)
|
||||
#elif defined(__GNUC__) && __GNUC__>=2
|
||||
# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
|
||||
# define ROTATE(a,n) ({ register unsigned int ret; \
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
# but exhibits up to 10% improvement on other cores.
|
||||
#
|
||||
# Second version is "monolithic" replacement for aes_core.c, which in
|
||||
# addition to AES_[de|en]crypt implements private_AES_set_[de|en]cryption_key.
|
||||
# addition to AES_[de|en]crypt implements AES_set_[de|en]cryption_key.
|
||||
# This made it possible to implement little-endian variant of the
|
||||
# algorithm without modifying the base C code. Motivating factor for
|
||||
# the undertaken effort was that it appeared that in tight IA-32
|
||||
@@ -103,11 +103,12 @@
|
||||
# byte for 128-bit key.
|
||||
#
|
||||
# ECB encrypt ECB decrypt CBC large chunk
|
||||
# P4 56[60] 84[100] 23
|
||||
# AMD K8 48[44] 70[79] 18
|
||||
# PIII 41[50] 61[91] 24
|
||||
# Core 2 32[38] 45[70] 18.5
|
||||
# Pentium 120 160 77
|
||||
# P4 52[54] 83[95] 23
|
||||
# AMD K8 46[41] 66[70] 18
|
||||
# PIII 41[50] 60[77] 24
|
||||
# Core 2 31[36] 45[64] 18.5
|
||||
# Atom 76[100] 96[138] 60
|
||||
# Pentium 115 150 77
|
||||
#
|
||||
# Version 4.1 switches to compact S-box even in key schedule setup.
|
||||
#
|
||||
@@ -242,7 +243,7 @@ $vertical_spin=0; # shift "verticaly" defaults to 0, because of
|
||||
|
||||
sub encvert()
|
||||
{ my ($te,@s) = @_;
|
||||
my $v0 = $acc, $v1 = $key;
|
||||
my ($v0,$v1) = ($acc,$key);
|
||||
|
||||
&mov ($v0,$s[3]); # copy s3
|
||||
&mov (&DWP(4,"esp"),$s[2]); # save s2
|
||||
@@ -299,7 +300,7 @@ sub encvert()
|
||||
# Another experimental routine, which features "horizontal spin," but
|
||||
# eliminates one reference to stack. Strangely enough runs slower...
|
||||
sub enchoriz()
|
||||
{ my $v0 = $key, $v1 = $acc;
|
||||
{ my ($v0,$v1) = ($key,$acc);
|
||||
|
||||
&movz ($v0,&LB($s0)); # 3, 2, 1, 0*
|
||||
&rotr ($s2,8); # 8,11,10, 9
|
||||
@@ -427,7 +428,7 @@ sub sse_encbody()
|
||||
######################################################################
|
||||
|
||||
sub enccompact()
|
||||
{ my $Fn = mov;
|
||||
{ my $Fn = \&mov;
|
||||
while ($#_>5) { pop(@_); $Fn=sub{}; }
|
||||
my ($i,$te,@s)=@_;
|
||||
my $tmp = $key;
|
||||
@@ -476,24 +477,25 @@ sub enctransform()
|
||||
my $tmp = $tbl;
|
||||
my $r2 = $key ;
|
||||
|
||||
&mov ($acc,$s[$i]);
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&shr ($tmp,7);
|
||||
&and ($tmp,$s[$i]);
|
||||
&lea ($r2,&DWP(0,$s[$i],$s[$i]));
|
||||
&sub ($acc,$tmp);
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&and ($r2,0xfefefefe);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&sub ($acc,$tmp);
|
||||
&mov ($tmp,$s[$i]);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&rotr ($tmp,16);
|
||||
&xor ($acc,$r2); # r2
|
||||
&mov ($r2,$s[$i]);
|
||||
|
||||
&xor ($s[$i],$acc); # r0 ^ r2
|
||||
&rotr ($r2,16+8);
|
||||
&xor ($acc,$tmp);
|
||||
&rotl ($s[$i],24);
|
||||
&xor ($s[$i],$acc) # ROTATE(r2^r0,24) ^ r2
|
||||
&rotr ($tmp,16);
|
||||
&xor ($s[$i],$tmp);
|
||||
&rotr ($tmp,8);
|
||||
&xor ($s[$i],$tmp);
|
||||
&xor ($acc,$r2);
|
||||
&mov ($tmp,0x80808080) if ($i!=1);
|
||||
&xor ($s[$i],$acc); # ROTATE(r2^r0,24) ^ r2
|
||||
}
|
||||
|
||||
&function_begin_B("_x86_AES_encrypt_compact");
|
||||
@@ -526,6 +528,7 @@ sub enctransform()
|
||||
&enccompact(1,$tbl,$s1,$s2,$s3,$s0,1);
|
||||
&enccompact(2,$tbl,$s2,$s3,$s0,$s1,1);
|
||||
&enccompact(3,$tbl,$s3,$s0,$s1,$s2,1);
|
||||
&mov ($tbl,0x80808080);
|
||||
&enctransform(2);
|
||||
&enctransform(3);
|
||||
&enctransform(0);
|
||||
@@ -607,82 +610,84 @@ sub sse_enccompact()
|
||||
&pshufw ("mm5","mm4",0x0d); # 15,14,11,10
|
||||
&movd ("eax","mm1"); # 5, 4, 1, 0
|
||||
&movd ("ebx","mm5"); # 15,14,11,10
|
||||
&mov ($__key,$key);
|
||||
|
||||
&movz ($acc,&LB("eax")); # 0
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
|
||||
&pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
|
||||
&movz ("edx",&HB("eax")); # 1
|
||||
&pshufw ("mm2","mm0",0x0d); # 7, 6, 3, 2
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
|
||||
&movz ($key,&LB("ebx")); # 10
|
||||
&movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
|
||||
&shl ("edx",8); # 1
|
||||
&shr ("eax",16); # 5, 4
|
||||
&shl ("edx",8); # 1
|
||||
|
||||
&movz ($acc,&LB("ebx")); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 10
|
||||
&movz ($key,&HB("ebx")); # 11
|
||||
&shl ($acc,16); # 10
|
||||
&or ("ecx",$acc); # 10
|
||||
&pshufw ("mm6","mm4",0x08); # 13,12, 9, 8
|
||||
&movz ($acc,&HB("ebx")); # 11
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 11
|
||||
&or ("ecx",$acc); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 11
|
||||
&movz ($key,&HB("eax")); # 5
|
||||
&shl ($acc,24); # 11
|
||||
&or ("edx",$acc); # 11
|
||||
&shr ("ebx",16); # 15,14
|
||||
&or ("edx",$acc); # 11
|
||||
|
||||
&movz ($acc,&HB("eax")); # 5
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 5
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 5
|
||||
&movz ($key,&HB("ebx")); # 15
|
||||
&shl ($acc,8); # 5
|
||||
&or ("ecx",$acc); # 5
|
||||
&movz ($acc,&HB("ebx")); # 15
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 15
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 15
|
||||
&movz ($key,&LB("eax")); # 4
|
||||
&shl ($acc,24); # 15
|
||||
&or ("ecx",$acc); # 15
|
||||
&movd ("mm0","ecx"); # t[0] collected
|
||||
|
||||
&movz ($acc,&LB("eax")); # 4
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 4
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 4
|
||||
&movz ($key,&LB("ebx")); # 14
|
||||
&movd ("eax","mm2"); # 7, 6, 3, 2
|
||||
&movz ($acc,&LB("ebx")); # 14
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 14
|
||||
&shl ($acc,16); # 14
|
||||
&movd ("mm0","ecx"); # t[0] collected
|
||||
&movz ("ecx",&BP(-128,$tbl,$key,1)); # 14
|
||||
&movz ($key,&HB("eax")); # 3
|
||||
&shl ("ecx",16); # 14
|
||||
&movd ("ebx","mm6"); # 13,12, 9, 8
|
||||
&or ("ecx",$acc); # 14
|
||||
|
||||
&movd ("ebx","mm6"); # 13,12, 9, 8
|
||||
&movz ($acc,&HB("eax")); # 3
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 3
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 3
|
||||
&movz ($key,&HB("ebx")); # 9
|
||||
&shl ($acc,24); # 3
|
||||
&or ("ecx",$acc); # 3
|
||||
&movz ($acc,&HB("ebx")); # 9
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 9
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 9
|
||||
&movz ($key,&LB("ebx")); # 8
|
||||
&shl ($acc,8); # 9
|
||||
&or ("ecx",$acc); # 9
|
||||
&movd ("mm1","ecx"); # t[1] collected
|
||||
|
||||
&movz ($acc,&LB("ebx")); # 8
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 8
|
||||
&shr ("ebx",16); # 13,12
|
||||
&movz ($acc,&LB("eax")); # 2
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
|
||||
&shl ($acc,16); # 2
|
||||
&or ("ecx",$acc); # 2
|
||||
&or ("ecx",$acc); # 9
|
||||
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 8
|
||||
&movz ($key,&LB("eax")); # 2
|
||||
&shr ("eax",16); # 7, 6
|
||||
&movd ("mm1","ecx"); # t[1] collected
|
||||
&movz ("ecx",&BP(-128,$tbl,$key,1)); # 2
|
||||
&movz ($key,&HB("eax")); # 7
|
||||
&shl ("ecx",16); # 2
|
||||
&and ("eax",0xff); # 6
|
||||
&or ("ecx",$acc); # 2
|
||||
|
||||
&punpckldq ("mm0","mm1"); # t[0,1] collected
|
||||
|
||||
&movz ($acc,&HB("eax")); # 7
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 7
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 7
|
||||
&movz ($key,&HB("ebx")); # 13
|
||||
&shl ($acc,24); # 7
|
||||
&or ("ecx",$acc); # 7
|
||||
&and ("eax",0xff); # 6
|
||||
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 6
|
||||
&shl ("eax",16); # 6
|
||||
&or ("edx","eax"); # 6
|
||||
&movz ($acc,&HB("ebx")); # 13
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 13
|
||||
&shl ($acc,8); # 13
|
||||
&or ("ecx",$acc); # 13
|
||||
&movd ("mm4","ecx"); # t[2] collected
|
||||
&and ("ebx",0xff); # 12
|
||||
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 6
|
||||
&or ("ecx",$acc); # 7
|
||||
&shl ("eax",16); # 6
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 13
|
||||
&or ("edx","eax"); # 6
|
||||
&shl ($acc,8); # 13
|
||||
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 12
|
||||
&or ("ecx",$acc); # 13
|
||||
&or ("edx","ebx"); # 12
|
||||
&mov ($key,$__key);
|
||||
&movd ("mm4","ecx"); # t[2] collected
|
||||
&movd ("mm5","edx"); # t[3] collected
|
||||
|
||||
&punpckldq ("mm4","mm5"); # t[2,3] collected
|
||||
@@ -1222,7 +1227,7 @@ sub enclast()
|
||||
######################################################################
|
||||
|
||||
sub deccompact()
|
||||
{ my $Fn = mov;
|
||||
{ my $Fn = \&mov;
|
||||
while ($#_>5) { pop(@_); $Fn=sub{}; }
|
||||
my ($i,$td,@s)=@_;
|
||||
my $tmp = $key;
|
||||
@@ -1270,30 +1275,30 @@ sub dectransform()
|
||||
my $tp4 = @s[($i+3)%4]; $tp4 = @s[3] if ($i==1);
|
||||
my $tp8 = $tbl;
|
||||
|
||||
&mov ($acc,$s[$i]);
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&mov ($tmp,0x80808080);
|
||||
&and ($tmp,$s[$i]);
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&lea ($tp2,&DWP(0,$s[$i],$s[$i]));
|
||||
&sub ($acc,$tmp);
|
||||
&and ($tp2,0xfefefefe);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&xor ($acc,$tp2);
|
||||
&mov ($tp2,$acc);
|
||||
&xor ($tp2,$acc);
|
||||
&mov ($tmp,0x80808080);
|
||||
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&and ($tmp,$tp2);
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&lea ($tp4,&DWP(0,$tp2,$tp2));
|
||||
&sub ($acc,$tmp);
|
||||
&and ($tp4,0xfefefefe);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&xor ($tp2,$s[$i]); # tp2^tp1
|
||||
&xor ($acc,$tp4);
|
||||
&mov ($tp4,$acc);
|
||||
&xor ($tp4,$acc);
|
||||
&mov ($tmp,0x80808080);
|
||||
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&and ($tmp,$tp4);
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&lea ($tp8,&DWP(0,$tp4,$tp4));
|
||||
&sub ($acc,$tmp);
|
||||
@@ -1305,13 +1310,13 @@ sub dectransform()
|
||||
|
||||
&xor ($s[$i],$tp2);
|
||||
&xor ($tp2,$tp8);
|
||||
&rotl ($tp2,24);
|
||||
&xor ($s[$i],$tp4);
|
||||
&xor ($tp4,$tp8);
|
||||
&rotl ($tp4,16);
|
||||
&rotl ($tp2,24);
|
||||
&xor ($s[$i],$tp8); # ^= tp8^(tp4^tp1)^(tp2^tp1)
|
||||
&rotl ($tp8,8);
|
||||
&rotl ($tp4,16);
|
||||
&xor ($s[$i],$tp2); # ^= ROTATE(tp8^tp2^tp1,24)
|
||||
&rotl ($tp8,8);
|
||||
&xor ($s[$i],$tp4); # ^= ROTATE(tp8^tp4^tp1,16)
|
||||
&mov ($s[0],$__s0) if($i==2); #prefetch $s0
|
||||
&mov ($s[1],$__s1) if($i==3); #prefetch $s1
|
||||
@@ -1389,85 +1394,87 @@ sub dectransform()
|
||||
sub sse_deccompact()
|
||||
{
|
||||
&pshufw ("mm1","mm0",0x0c); # 7, 6, 1, 0
|
||||
&movd ("eax","mm1"); # 7, 6, 1, 0
|
||||
|
||||
&pshufw ("mm5","mm4",0x09); # 13,12,11,10
|
||||
&movz ($acc,&LB("eax")); # 0
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
|
||||
&movd ("eax","mm1"); # 7, 6, 1, 0
|
||||
&movd ("ebx","mm5"); # 13,12,11,10
|
||||
&mov ($__key,$key);
|
||||
|
||||
&movz ($acc,&LB("eax")); # 0
|
||||
&movz ("edx",&HB("eax")); # 1
|
||||
&pshufw ("mm2","mm0",0x06); # 3, 2, 5, 4
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 0
|
||||
&movz ($key,&LB("ebx")); # 10
|
||||
&movz ("edx",&BP(-128,$tbl,"edx",1)); # 1
|
||||
&shr ("eax",16); # 7, 6
|
||||
&shl ("edx",8); # 1
|
||||
|
||||
&pshufw ("mm2","mm0",0x06); # 3, 2, 5, 4
|
||||
&movz ($acc,&LB("ebx")); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 10
|
||||
&movz ($key,&HB("ebx")); # 11
|
||||
&shl ($acc,16); # 10
|
||||
&or ("ecx",$acc); # 10
|
||||
&shr ("eax",16); # 7, 6
|
||||
&movz ($acc,&HB("ebx")); # 11
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 11
|
||||
&shl ($acc,24); # 11
|
||||
&or ("edx",$acc); # 11
|
||||
&shr ("ebx",16); # 13,12
|
||||
|
||||
&pshufw ("mm6","mm4",0x03); # 9, 8,15,14
|
||||
&movz ($acc,&HB("eax")); # 7
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 7
|
||||
&or ("ecx",$acc); # 10
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 11
|
||||
&movz ($key,&HB("eax")); # 7
|
||||
&shl ($acc,24); # 11
|
||||
&shr ("ebx",16); # 13,12
|
||||
&or ("edx",$acc); # 11
|
||||
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 7
|
||||
&movz ($key,&HB("ebx")); # 13
|
||||
&shl ($acc,24); # 7
|
||||
&or ("ecx",$acc); # 7
|
||||
&movz ($acc,&HB("ebx")); # 13
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 13
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 13
|
||||
&movz ($key,&LB("eax")); # 6
|
||||
&shl ($acc,8); # 13
|
||||
&or ("ecx",$acc); # 13
|
||||
&movd ("mm0","ecx"); # t[0] collected
|
||||
|
||||
&movz ($acc,&LB("eax")); # 6
|
||||
&movd ("eax","mm2"); # 3, 2, 5, 4
|
||||
&movz ("ecx",&BP(-128,$tbl,$acc,1)); # 6
|
||||
&shl ("ecx",16); # 6
|
||||
&movz ($acc,&LB("ebx")); # 12
|
||||
&or ("ecx",$acc); # 13
|
||||
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 6
|
||||
&movz ($key,&LB("ebx")); # 12
|
||||
&shl ($acc,16); # 6
|
||||
&movd ("ebx","mm6"); # 9, 8,15,14
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 12
|
||||
&movd ("mm0","ecx"); # t[0] collected
|
||||
&movz ("ecx",&BP(-128,$tbl,$key,1)); # 12
|
||||
&movz ($key,&LB("eax")); # 4
|
||||
&or ("ecx",$acc); # 12
|
||||
|
||||
&movz ($acc,&LB("eax")); # 4
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 4
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 4
|
||||
&movz ($key,&LB("ebx")); # 14
|
||||
&or ("edx",$acc); # 4
|
||||
&movz ($acc,&LB("ebx")); # 14
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 14
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 14
|
||||
&movz ($key,&HB("eax")); # 5
|
||||
&shl ($acc,16); # 14
|
||||
&or ("edx",$acc); # 14
|
||||
&movd ("mm1","edx"); # t[1] collected
|
||||
|
||||
&movz ($acc,&HB("eax")); # 5
|
||||
&movz ("edx",&BP(-128,$tbl,$acc,1)); # 5
|
||||
&shl ("edx",8); # 5
|
||||
&movz ($acc,&HB("ebx")); # 15
|
||||
&shr ("eax",16); # 3, 2
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 15
|
||||
&shl ($acc,24); # 15
|
||||
&or ("edx",$acc); # 15
|
||||
&or ("edx",$acc); # 14
|
||||
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 5
|
||||
&movz ($key,&HB("ebx")); # 15
|
||||
&shr ("ebx",16); # 9, 8
|
||||
&shl ($acc,8); # 5
|
||||
&movd ("mm1","edx"); # t[1] collected
|
||||
&movz ("edx",&BP(-128,$tbl,$key,1)); # 15
|
||||
&movz ($key,&HB("ebx")); # 9
|
||||
&shl ("edx",24); # 15
|
||||
&and ("ebx",0xff); # 8
|
||||
&or ("edx",$acc); # 15
|
||||
|
||||
&punpckldq ("mm0","mm1"); # t[0,1] collected
|
||||
|
||||
&movz ($acc,&HB("ebx")); # 9
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 9
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 9
|
||||
&movz ($key,&LB("eax")); # 2
|
||||
&shl ($acc,8); # 9
|
||||
&or ("ecx",$acc); # 9
|
||||
&and ("ebx",0xff); # 8
|
||||
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 8
|
||||
&or ("edx","ebx"); # 8
|
||||
&movz ($acc,&LB("eax")); # 2
|
||||
&movz ($acc,&BP(-128,$tbl,$acc,1)); # 2
|
||||
&shl ($acc,16); # 2
|
||||
&or ("edx",$acc); # 2
|
||||
&movd ("mm4","edx"); # t[2] collected
|
||||
&movz ("eax",&HB("eax")); # 3
|
||||
&movz ("ebx",&BP(-128,$tbl,"ebx",1)); # 8
|
||||
&or ("ecx",$acc); # 9
|
||||
&movz ($acc,&BP(-128,$tbl,$key,1)); # 2
|
||||
&or ("edx","ebx"); # 8
|
||||
&shl ($acc,16); # 2
|
||||
&movz ("eax",&BP(-128,$tbl,"eax",1)); # 3
|
||||
&or ("edx",$acc); # 2
|
||||
&shl ("eax",24); # 3
|
||||
&or ("ecx","eax"); # 3
|
||||
&mov ($key,$__key);
|
||||
&movd ("mm4","edx"); # t[2] collected
|
||||
&movd ("mm5","ecx"); # t[3] collected
|
||||
|
||||
&punpckldq ("mm4","mm5"); # t[2,3] collected
|
||||
@@ -2181,8 +2188,8 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
|
||||
&mov ("ecx",240/4);
|
||||
&xor ("eax","eax");
|
||||
&align (4);
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_ezero")
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_ezero");
|
||||
&mov ("esp",$_esp);
|
||||
&popf ();
|
||||
&set_label("drop_out");
|
||||
@@ -2301,8 +2308,8 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
|
||||
&mov ("ecx",240/4);
|
||||
&xor ("eax","eax");
|
||||
&align (4);
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_dzero")
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_dzero");
|
||||
&mov ("esp",$_esp);
|
||||
&popf ();
|
||||
&function_end_A();
|
||||
@@ -2865,32 +2872,32 @@ sub deckey()
|
||||
{ my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_;
|
||||
my $tmp = $tbl;
|
||||
|
||||
&mov ($acc,$tp1);
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&shr ($tmp,7);
|
||||
&mov ($tmp,0x80808080);
|
||||
&and ($tmp,$tp1);
|
||||
&lea ($tp2,&DWP(0,$tp1,$tp1));
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&sub ($acc,$tmp);
|
||||
&and ($tp2,0xfefefefe);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&xor ($acc,$tp2);
|
||||
&mov ($tp2,$acc);
|
||||
&xor ($tp2,$acc);
|
||||
&mov ($tmp,0x80808080);
|
||||
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&shr ($tmp,7);
|
||||
&and ($tmp,$tp2);
|
||||
&lea ($tp4,&DWP(0,$tp2,$tp2));
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&sub ($acc,$tmp);
|
||||
&and ($tp4,0xfefefefe);
|
||||
&and ($acc,0x1b1b1b1b);
|
||||
&xor ($tp2,$tp1); # tp2^tp1
|
||||
&xor ($acc,$tp4);
|
||||
&mov ($tp4,$acc);
|
||||
&xor ($tp4,$acc);
|
||||
&mov ($tmp,0x80808080);
|
||||
|
||||
&and ($acc,0x80808080);
|
||||
&mov ($tmp,$acc);
|
||||
&shr ($tmp,7);
|
||||
&and ($tmp,$tp4);
|
||||
&lea ($tp8,&DWP(0,$tp4,$tp4));
|
||||
&mov ($acc,$tmp);
|
||||
&shr ($tmp,7);
|
||||
&xor ($tp4,$tp1); # tp4^tp1
|
||||
&sub ($acc,$tmp);
|
||||
&and ($tp8,0xfefefefe);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# ====================================================================
|
||||
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
|
||||
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||
# project. The module is, however, dual licensed under OpenSSL and
|
||||
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
||||
# details see http://www.openssl.org/~appro/cryptogams/.
|
||||
@@ -51,9 +51,23 @@ $key="r11";
|
||||
$rounds="r12";
|
||||
|
||||
$code=<<___;
|
||||
#include "arm_arch.h"
|
||||
#ifndef __KERNEL__
|
||||
# include "arm_arch.h"
|
||||
#else
|
||||
# define __ARM_ARCH__ __LINUX_ARM_ARCH__
|
||||
#endif
|
||||
|
||||
.text
|
||||
#if __ARM_ARCH__<7
|
||||
.code 32
|
||||
#else
|
||||
.syntax unified
|
||||
# ifdef __thumb2__
|
||||
.thumb
|
||||
# else
|
||||
.code 32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
.type AES_Te,%object
|
||||
.align 5
|
||||
@@ -167,7 +181,11 @@ AES_Te:
|
||||
.type AES_encrypt,%function
|
||||
.align 5
|
||||
AES_encrypt:
|
||||
#if __ARM_ARCH__<7
|
||||
sub r3,pc,#8 @ AES_encrypt
|
||||
#else
|
||||
adr r3,AES_encrypt
|
||||
#endif
|
||||
stmdb sp!,{r1,r4-r12,lr}
|
||||
mov $rounds,r0 @ inp
|
||||
mov $key,r2
|
||||
@@ -408,11 +426,22 @@ _armv4_AES_encrypt:
|
||||
.type private_AES_set_encrypt_key,%function
|
||||
.align 5
|
||||
private_AES_set_encrypt_key:
|
||||
_armv4_AES_set_encrypt_key:
|
||||
#if __ARM_ARCH__<7
|
||||
sub r3,pc,#8 @ AES_set_encrypt_key
|
||||
#else
|
||||
adr r3,private_AES_set_encrypt_key
|
||||
#endif
|
||||
teq r0,#0
|
||||
#if __ARM_ARCH__>=7
|
||||
itt eq @ Thumb2 thing, sanity check in ARM
|
||||
#endif
|
||||
moveq r0,#-1
|
||||
beq .Labrt
|
||||
teq r2,#0
|
||||
#if __ARM_ARCH__>=7
|
||||
itt eq @ Thumb2 thing, sanity check in ARM
|
||||
#endif
|
||||
moveq r0,#-1
|
||||
beq .Labrt
|
||||
|
||||
@@ -421,11 +450,14 @@ private_AES_set_encrypt_key:
|
||||
teq r1,#192
|
||||
beq .Lok
|
||||
teq r1,#256
|
||||
#if __ARM_ARCH__>=7
|
||||
itt ne @ Thumb2 thing, sanity check in ARM
|
||||
#endif
|
||||
movne r0,#-1
|
||||
bne .Labrt
|
||||
|
||||
.Lok: stmdb sp!,{r4-r12,lr}
|
||||
sub $tbl,r3,#private_AES_set_encrypt_key-AES_Te-1024 @ Te4
|
||||
sub $tbl,r3,#_armv4_AES_set_encrypt_key-AES_Te-1024 @ Te4
|
||||
|
||||
mov $rounds,r0 @ inp
|
||||
mov lr,r1 @ bits
|
||||
@@ -575,6 +607,9 @@ private_AES_set_encrypt_key:
|
||||
str $s2,[$key,#-16]
|
||||
subs $rounds,$rounds,#1
|
||||
str $s3,[$key,#-12]
|
||||
#if __ARM_ARCH__>=7
|
||||
itt eq @ Thumb2 thing, sanity check in ARM
|
||||
#endif
|
||||
subeq r2,$key,#216
|
||||
beq .Ldone
|
||||
|
||||
@@ -644,6 +679,9 @@ private_AES_set_encrypt_key:
|
||||
str $s2,[$key,#-24]
|
||||
subs $rounds,$rounds,#1
|
||||
str $s3,[$key,#-20]
|
||||
#if __ARM_ARCH__>=7
|
||||
itt eq @ Thumb2 thing, sanity check in ARM
|
||||
#endif
|
||||
subeq r2,$key,#256
|
||||
beq .Ldone
|
||||
|
||||
@@ -673,11 +711,17 @@ private_AES_set_encrypt_key:
|
||||
str $i3,[$key,#-4]
|
||||
b .L256_loop
|
||||
|
||||
.align 2
|
||||
.Ldone: mov r0,#0
|
||||
ldmia sp!,{r4-r12,lr}
|
||||
.Labrt: tst lr,#1
|
||||
.Labrt:
|
||||
#if defined(__thumb2__) && __ARM_ARCH__>=7
|
||||
.short 0x4770 @ bx lr in Thumb2 encoding
|
||||
#else
|
||||
tst lr,#1
|
||||
moveq pc,lr @ be binary compatible with V4, yet
|
||||
bx lr @ interoperable with Thumb ISA:-)
|
||||
#endif
|
||||
.size private_AES_set_encrypt_key,.-private_AES_set_encrypt_key
|
||||
|
||||
.global private_AES_set_decrypt_key
|
||||
@@ -685,36 +729,59 @@ private_AES_set_encrypt_key:
|
||||
.align 5
|
||||
private_AES_set_decrypt_key:
|
||||
str lr,[sp,#-4]! @ push lr
|
||||
bl private_AES_set_encrypt_key
|
||||
bl _armv4_AES_set_encrypt_key
|
||||
teq r0,#0
|
||||
ldrne lr,[sp],#4 @ pop lr
|
||||
ldr lr,[sp],#4 @ pop lr
|
||||
bne .Labrt
|
||||
|
||||
stmdb sp!,{r4-r12}
|
||||
mov r0,r2 @ AES_set_encrypt_key preserves r2,
|
||||
mov r1,r2 @ which is AES_KEY *key
|
||||
b _armv4_AES_set_enc2dec_key
|
||||
.size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key
|
||||
|
||||
ldr $rounds,[r2,#240] @ AES_set_encrypt_key preserves r2,
|
||||
mov $key,r2 @ which is AES_KEY *key
|
||||
mov $i1,r2
|
||||
add $i2,r2,$rounds,lsl#4
|
||||
@ void AES_set_enc2dec_key(const AES_KEY *inp,AES_KEY *out)
|
||||
.global AES_set_enc2dec_key
|
||||
.type AES_set_enc2dec_key,%function
|
||||
.align 5
|
||||
AES_set_enc2dec_key:
|
||||
_armv4_AES_set_enc2dec_key:
|
||||
stmdb sp!,{r4-r12,lr}
|
||||
|
||||
.Linv: ldr $s0,[$i1]
|
||||
ldr $rounds,[r0,#240]
|
||||
mov $i1,r0 @ input
|
||||
add $i2,r0,$rounds,lsl#4
|
||||
mov $key,r1 @ ouput
|
||||
add $tbl,r1,$rounds,lsl#4
|
||||
str $rounds,[r1,#240]
|
||||
|
||||
.Linv: ldr $s0,[$i1],#16
|
||||
ldr $s1,[$i1,#-12]
|
||||
ldr $s2,[$i1,#-8]
|
||||
ldr $s3,[$i1,#-4]
|
||||
ldr $t1,[$i2],#-16
|
||||
ldr $t2,[$i2,#16+4]
|
||||
ldr $t3,[$i2,#16+8]
|
||||
ldr $i3,[$i2,#16+12]
|
||||
str $s0,[$tbl],#-16
|
||||
str $s1,[$tbl,#16+4]
|
||||
str $s2,[$tbl,#16+8]
|
||||
str $s3,[$tbl,#16+12]
|
||||
str $t1,[$key],#16
|
||||
str $t2,[$key,#-12]
|
||||
str $t3,[$key,#-8]
|
||||
str $i3,[$key,#-4]
|
||||
teq $i1,$i2
|
||||
bne .Linv
|
||||
|
||||
ldr $s0,[$i1]
|
||||
ldr $s1,[$i1,#4]
|
||||
ldr $s2,[$i1,#8]
|
||||
ldr $s3,[$i1,#12]
|
||||
ldr $t1,[$i2]
|
||||
ldr $t2,[$i2,#4]
|
||||
ldr $t3,[$i2,#8]
|
||||
ldr $i3,[$i2,#12]
|
||||
str $s0,[$i2],#-16
|
||||
str $s1,[$i2,#16+4]
|
||||
str $s2,[$i2,#16+8]
|
||||
str $s3,[$i2,#16+12]
|
||||
str $t1,[$i1],#16
|
||||
str $t2,[$i1,#-12]
|
||||
str $t3,[$i1,#-8]
|
||||
str $i3,[$i1,#-4]
|
||||
teq $i1,$i2
|
||||
bne .Linv
|
||||
str $s0,[$key]
|
||||
str $s1,[$key,#4]
|
||||
str $s2,[$key,#8]
|
||||
str $s3,[$key,#12]
|
||||
sub $key,$key,$rounds,lsl#3
|
||||
___
|
||||
$mask80=$i1;
|
||||
$mask1b=$i2;
|
||||
@@ -772,7 +839,7 @@ $code.=<<___;
|
||||
moveq pc,lr @ be binary compatible with V4, yet
|
||||
bx lr @ interoperable with Thumb ISA:-)
|
||||
#endif
|
||||
.size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key
|
||||
.size AES_set_enc2dec_key,.-AES_set_enc2dec_key
|
||||
|
||||
.type AES_Td,%object
|
||||
.align 5
|
||||
@@ -882,7 +949,11 @@ AES_Td:
|
||||
.type AES_decrypt,%function
|
||||
.align 5
|
||||
AES_decrypt:
|
||||
#if __ARM_ARCH__<7
|
||||
sub r3,pc,#8 @ AES_decrypt
|
||||
#else
|
||||
adr r3,AES_decrypt
|
||||
#endif
|
||||
stmdb sp!,{r1,r4-r12,lr}
|
||||
mov $rounds,r0 @ inp
|
||||
mov $key,r2
|
||||
@@ -1079,8 +1150,9 @@ _armv4_AES_decrypt:
|
||||
ldrb $t3,[$tbl,$i3] @ Td4[s0>>0]
|
||||
and $i3,lr,$s1,lsr#8
|
||||
|
||||
add $s1,$tbl,$s1,lsr#24
|
||||
ldrb $i1,[$tbl,$i1] @ Td4[s1>>0]
|
||||
ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24]
|
||||
ldrb $s1,[$s1] @ Td4[s1>>24]
|
||||
ldrb $i2,[$tbl,$i2] @ Td4[s1>>16]
|
||||
eor $s0,$i1,$s0,lsl#24
|
||||
ldrb $i3,[$tbl,$i3] @ Td4[s1>>8]
|
||||
@@ -1093,7 +1165,8 @@ _armv4_AES_decrypt:
|
||||
ldrb $i2,[$tbl,$i2] @ Td4[s2>>0]
|
||||
and $i3,lr,$s2,lsr#16
|
||||
|
||||
ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24]
|
||||
add $s2,$tbl,$s2,lsr#24
|
||||
ldrb $s2,[$s2] @ Td4[s2>>24]
|
||||
eor $s0,$s0,$i1,lsl#8
|
||||
ldrb $i3,[$tbl,$i3] @ Td4[s2>>16]
|
||||
eor $s1,$i2,$s1,lsl#16
|
||||
@@ -1105,8 +1178,9 @@ _armv4_AES_decrypt:
|
||||
ldrb $i2,[$tbl,$i2] @ Td4[s3>>8]
|
||||
and $i3,lr,$s3 @ i2
|
||||
|
||||
add $s3,$tbl,$s3,lsr#24
|
||||
ldrb $i3,[$tbl,$i3] @ Td4[s3>>0]
|
||||
ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24]
|
||||
ldrb $s3,[$s3] @ Td4[s3>>24]
|
||||
eor $s0,$s0,$i1,lsl#16
|
||||
ldr $i1,[$key,#0]
|
||||
eor $s1,$s1,$i2,lsl#8
|
||||
@@ -1129,5 +1203,14 @@ _armv4_AES_decrypt:
|
||||
___
|
||||
|
||||
$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4
|
||||
|
||||
open SELF,$0;
|
||||
while(<SELF>) {
|
||||
next if (/^#!/);
|
||||
last if (!s/^#/@/ and !/^$/);
|
||||
print;
|
||||
}
|
||||
close SELF;
|
||||
|
||||
print $code;
|
||||
close STDOUT; # enforce flush
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1015,7 +1015,8 @@ foreach (split("\n",$code)) {
|
||||
$SIZE_T==4 ? sprintf("extru%s,%d,8,",$1,31-$2)
|
||||
: sprintf("extrd,u%s,%d,8,",$1,63-$2)/e;
|
||||
|
||||
s/,\*/,/ if ($SIZE_T==4);
|
||||
s/,\*/,/ if ($SIZE_T==4);
|
||||
s/\bbv\b(.*\(%r2\))/bve$1/ if ($SIZE_T==8);
|
||||
print $_,"\n";
|
||||
}
|
||||
close STDOUT;
|
||||
|
||||
@@ -45,6 +45,8 @@ if ($flavour =~ /64/) {
|
||||
$PUSH ="stw";
|
||||
} else { die "nonsense $flavour"; }
|
||||
|
||||
$LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
@@ -68,7 +70,7 @@ $key="r5";
|
||||
$Tbl0="r3";
|
||||
$Tbl1="r6";
|
||||
$Tbl2="r7";
|
||||
$Tbl3="r2";
|
||||
$Tbl3=$out; # stay away from "r2"; $out is offloaded to stack
|
||||
|
||||
$s0="r8";
|
||||
$s1="r9";
|
||||
@@ -76,7 +78,7 @@ $s2="r10";
|
||||
$s3="r11";
|
||||
|
||||
$t0="r12";
|
||||
$t1="r13";
|
||||
$t1="r0"; # stay away from "r13";
|
||||
$t2="r14";
|
||||
$t3="r15";
|
||||
|
||||
@@ -100,9 +102,6 @@ $acc13="r29";
|
||||
$acc14="r30";
|
||||
$acc15="r31";
|
||||
|
||||
# stay away from TLS pointer
|
||||
if ($SIZE_T==8) { die if ($t1 ne "r13"); $t1="r0"; }
|
||||
else { die if ($Tbl3 ne "r2"); $Tbl3=$t0; $t0="r0"; }
|
||||
$mask80=$Tbl2;
|
||||
$mask1b=$Tbl3;
|
||||
|
||||
@@ -337,8 +336,7 @@ $code.=<<___;
|
||||
$STU $sp,-$FRAME($sp)
|
||||
mflr r0
|
||||
|
||||
$PUSH $toc,`$FRAME-$SIZE_T*20`($sp)
|
||||
$PUSH r13,`$FRAME-$SIZE_T*19`($sp)
|
||||
$PUSH $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
$PUSH r14,`$FRAME-$SIZE_T*18`($sp)
|
||||
$PUSH r15,`$FRAME-$SIZE_T*17`($sp)
|
||||
$PUSH r16,`$FRAME-$SIZE_T*16`($sp)
|
||||
@@ -365,16 +363,61 @@ $code.=<<___;
|
||||
bne Lenc_unaligned
|
||||
|
||||
Lenc_unaligned_ok:
|
||||
___
|
||||
$code.=<<___ if (!$LITTLE_ENDIAN);
|
||||
lwz $s0,0($inp)
|
||||
lwz $s1,4($inp)
|
||||
lwz $s2,8($inp)
|
||||
lwz $s3,12($inp)
|
||||
___
|
||||
$code.=<<___ if ($LITTLE_ENDIAN);
|
||||
lwz $t0,0($inp)
|
||||
lwz $t1,4($inp)
|
||||
lwz $t2,8($inp)
|
||||
lwz $t3,12($inp)
|
||||
rotlwi $s0,$t0,8
|
||||
rotlwi $s1,$t1,8
|
||||
rotlwi $s2,$t2,8
|
||||
rotlwi $s3,$t3,8
|
||||
rlwimi $s0,$t0,24,0,7
|
||||
rlwimi $s1,$t1,24,0,7
|
||||
rlwimi $s2,$t2,24,0,7
|
||||
rlwimi $s3,$t3,24,0,7
|
||||
rlwimi $s0,$t0,24,16,23
|
||||
rlwimi $s1,$t1,24,16,23
|
||||
rlwimi $s2,$t2,24,16,23
|
||||
rlwimi $s3,$t3,24,16,23
|
||||
___
|
||||
$code.=<<___;
|
||||
bl LAES_Te
|
||||
bl Lppc_AES_encrypt_compact
|
||||
$POP $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
___
|
||||
$code.=<<___ if ($LITTLE_ENDIAN);
|
||||
rotlwi $t0,$s0,8
|
||||
rotlwi $t1,$s1,8
|
||||
rotlwi $t2,$s2,8
|
||||
rotlwi $t3,$s3,8
|
||||
rlwimi $t0,$s0,24,0,7
|
||||
rlwimi $t1,$s1,24,0,7
|
||||
rlwimi $t2,$s2,24,0,7
|
||||
rlwimi $t3,$s3,24,0,7
|
||||
rlwimi $t0,$s0,24,16,23
|
||||
rlwimi $t1,$s1,24,16,23
|
||||
rlwimi $t2,$s2,24,16,23
|
||||
rlwimi $t3,$s3,24,16,23
|
||||
stw $t0,0($out)
|
||||
stw $t1,4($out)
|
||||
stw $t2,8($out)
|
||||
stw $t3,12($out)
|
||||
___
|
||||
$code.=<<___ if (!$LITTLE_ENDIAN);
|
||||
stw $s0,0($out)
|
||||
stw $s1,4($out)
|
||||
stw $s2,8($out)
|
||||
stw $s3,12($out)
|
||||
___
|
||||
$code.=<<___;
|
||||
b Lenc_done
|
||||
|
||||
Lenc_unaligned:
|
||||
@@ -417,6 +460,7 @@ Lenc_xpage:
|
||||
|
||||
bl LAES_Te
|
||||
bl Lppc_AES_encrypt_compact
|
||||
$POP $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
|
||||
extrwi $acc00,$s0,8,0
|
||||
extrwi $acc01,$s0,8,8
|
||||
@@ -449,8 +493,6 @@ Lenc_xpage:
|
||||
|
||||
Lenc_done:
|
||||
$POP r0,`$FRAME+$LRSAVE`($sp)
|
||||
$POP $toc,`$FRAME-$SIZE_T*20`($sp)
|
||||
$POP r13,`$FRAME-$SIZE_T*19`($sp)
|
||||
$POP r14,`$FRAME-$SIZE_T*18`($sp)
|
||||
$POP r15,`$FRAME-$SIZE_T*17`($sp)
|
||||
$POP r16,`$FRAME-$SIZE_T*16`($sp)
|
||||
@@ -764,6 +806,7 @@ Lenc_compact_done:
|
||||
blr
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,0,0
|
||||
.size .AES_encrypt,.-.AES_encrypt
|
||||
|
||||
.globl .AES_decrypt
|
||||
.align 7
|
||||
@@ -771,8 +814,7 @@ Lenc_compact_done:
|
||||
$STU $sp,-$FRAME($sp)
|
||||
mflr r0
|
||||
|
||||
$PUSH $toc,`$FRAME-$SIZE_T*20`($sp)
|
||||
$PUSH r13,`$FRAME-$SIZE_T*19`($sp)
|
||||
$PUSH $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
$PUSH r14,`$FRAME-$SIZE_T*18`($sp)
|
||||
$PUSH r15,`$FRAME-$SIZE_T*17`($sp)
|
||||
$PUSH r16,`$FRAME-$SIZE_T*16`($sp)
|
||||
@@ -799,16 +841,61 @@ Lenc_compact_done:
|
||||
bne Ldec_unaligned
|
||||
|
||||
Ldec_unaligned_ok:
|
||||
___
|
||||
$code.=<<___ if (!$LITTLE_ENDIAN);
|
||||
lwz $s0,0($inp)
|
||||
lwz $s1,4($inp)
|
||||
lwz $s2,8($inp)
|
||||
lwz $s3,12($inp)
|
||||
___
|
||||
$code.=<<___ if ($LITTLE_ENDIAN);
|
||||
lwz $t0,0($inp)
|
||||
lwz $t1,4($inp)
|
||||
lwz $t2,8($inp)
|
||||
lwz $t3,12($inp)
|
||||
rotlwi $s0,$t0,8
|
||||
rotlwi $s1,$t1,8
|
||||
rotlwi $s2,$t2,8
|
||||
rotlwi $s3,$t3,8
|
||||
rlwimi $s0,$t0,24,0,7
|
||||
rlwimi $s1,$t1,24,0,7
|
||||
rlwimi $s2,$t2,24,0,7
|
||||
rlwimi $s3,$t3,24,0,7
|
||||
rlwimi $s0,$t0,24,16,23
|
||||
rlwimi $s1,$t1,24,16,23
|
||||
rlwimi $s2,$t2,24,16,23
|
||||
rlwimi $s3,$t3,24,16,23
|
||||
___
|
||||
$code.=<<___;
|
||||
bl LAES_Td
|
||||
bl Lppc_AES_decrypt_compact
|
||||
$POP $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
___
|
||||
$code.=<<___ if ($LITTLE_ENDIAN);
|
||||
rotlwi $t0,$s0,8
|
||||
rotlwi $t1,$s1,8
|
||||
rotlwi $t2,$s2,8
|
||||
rotlwi $t3,$s3,8
|
||||
rlwimi $t0,$s0,24,0,7
|
||||
rlwimi $t1,$s1,24,0,7
|
||||
rlwimi $t2,$s2,24,0,7
|
||||
rlwimi $t3,$s3,24,0,7
|
||||
rlwimi $t0,$s0,24,16,23
|
||||
rlwimi $t1,$s1,24,16,23
|
||||
rlwimi $t2,$s2,24,16,23
|
||||
rlwimi $t3,$s3,24,16,23
|
||||
stw $t0,0($out)
|
||||
stw $t1,4($out)
|
||||
stw $t2,8($out)
|
||||
stw $t3,12($out)
|
||||
___
|
||||
$code.=<<___ if (!$LITTLE_ENDIAN);
|
||||
stw $s0,0($out)
|
||||
stw $s1,4($out)
|
||||
stw $s2,8($out)
|
||||
stw $s3,12($out)
|
||||
___
|
||||
$code.=<<___;
|
||||
b Ldec_done
|
||||
|
||||
Ldec_unaligned:
|
||||
@@ -851,6 +938,7 @@ Ldec_xpage:
|
||||
|
||||
bl LAES_Td
|
||||
bl Lppc_AES_decrypt_compact
|
||||
$POP $out,`$FRAME-$SIZE_T*19`($sp)
|
||||
|
||||
extrwi $acc00,$s0,8,0
|
||||
extrwi $acc01,$s0,8,8
|
||||
@@ -883,8 +971,6 @@ Ldec_xpage:
|
||||
|
||||
Ldec_done:
|
||||
$POP r0,`$FRAME+$LRSAVE`($sp)
|
||||
$POP $toc,`$FRAME-$SIZE_T*20`($sp)
|
||||
$POP r13,`$FRAME-$SIZE_T*19`($sp)
|
||||
$POP r14,`$FRAME-$SIZE_T*18`($sp)
|
||||
$POP r15,`$FRAME-$SIZE_T*17`($sp)
|
||||
$POP r16,`$FRAME-$SIZE_T*16`($sp)
|
||||
@@ -1355,6 +1441,7 @@ Ldec_compact_done:
|
||||
blr
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,0,0
|
||||
.size .AES_decrypt,.-.AES_decrypt
|
||||
|
||||
.asciz "AES for PPC, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 7
|
||||
|
||||
@@ -783,6 +783,7 @@ $code.=<<___;
|
||||
.type private_AES_set_encrypt_key,\@function
|
||||
.align 16
|
||||
private_AES_set_encrypt_key:
|
||||
_s390x_AES_set_encrypt_key:
|
||||
lghi $t0,0
|
||||
cl${g}r $inp,$t0
|
||||
je .Lminus1
|
||||
@@ -836,7 +837,8 @@ $code.=<<___ if (!$softonly);
|
||||
je 1f
|
||||
lg %r1,24($inp)
|
||||
stg %r1,24($key)
|
||||
1: st $bits,236($key) # save bits
|
||||
1: st $bits,236($key) # save bits [for debugging purposes]
|
||||
lgr $t0,%r5
|
||||
st %r5,240($key) # save km code
|
||||
lghi %r2,0
|
||||
br %r14
|
||||
@@ -844,7 +846,7 @@ ___
|
||||
$code.=<<___;
|
||||
.align 16
|
||||
.Lekey_internal:
|
||||
stm${g} %r6,%r13,6*$SIZE_T($sp) # all non-volatile regs
|
||||
stm${g} %r4,%r13,4*$SIZE_T($sp) # all non-volatile regs and $key
|
||||
|
||||
larl $tbl,AES_Te+2048
|
||||
|
||||
@@ -904,8 +906,9 @@ $code.=<<___;
|
||||
la $key,16($key) # key+=4
|
||||
la $t3,4($t3) # i++
|
||||
brct $rounds,.L128_loop
|
||||
lghi $t0,10
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -952,8 +955,9 @@ $code.=<<___;
|
||||
st $s2,32($key)
|
||||
st $s3,36($key)
|
||||
brct $rounds,.L192_continue
|
||||
lghi $t0,12
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -1014,8 +1018,9 @@ $code.=<<___;
|
||||
st $s2,40($key)
|
||||
st $s3,44($key)
|
||||
brct $rounds,.L256_continue
|
||||
lghi $t0,14
|
||||
lghi %r2,0
|
||||
lm${g} %r6,%r13,6*$SIZE_T($sp)
|
||||
lm${g} %r4,%r13,4*$SIZE_T($sp)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
@@ -1066,34 +1071,26 @@ $code.=<<___;
|
||||
.type private_AES_set_decrypt_key,\@function
|
||||
.align 16
|
||||
private_AES_set_decrypt_key:
|
||||
st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to
|
||||
st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers!
|
||||
bras $ra,AES_set_encrypt_key
|
||||
l${g} $key,4*$SIZE_T($sp)
|
||||
#st${g} $key,4*$SIZE_T($sp) # I rely on AES_set_encrypt_key to
|
||||
st${g} $ra,14*$SIZE_T($sp) # save non-volatile registers and $key!
|
||||
bras $ra,_s390x_AES_set_encrypt_key
|
||||
#l${g} $key,4*$SIZE_T($sp)
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
ltgr %r2,%r2
|
||||
bnzr $ra
|
||||
___
|
||||
$code.=<<___ if (!$softonly);
|
||||
l $t0,240($key)
|
||||
#l $t0,240($key)
|
||||
lhi $t1,16
|
||||
cr $t0,$t1
|
||||
jl .Lgo
|
||||
oill $t0,0x80 # set "decrypt" bit
|
||||
st $t0,240($key)
|
||||
br $ra
|
||||
|
||||
.align 16
|
||||
.Ldkey_internal:
|
||||
st${g} $key,4*$SIZE_T($sp)
|
||||
st${g} $ra,14*$SIZE_T($sp)
|
||||
bras $ra,.Lekey_internal
|
||||
l${g} $key,4*$SIZE_T($sp)
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
___
|
||||
$code.=<<___;
|
||||
|
||||
.Lgo: llgf $rounds,240($key)
|
||||
.align 16
|
||||
.Lgo: lgr $rounds,$t0 #llgf $rounds,240($key)
|
||||
la $i1,0($key)
|
||||
sllg $i2,$rounds,4
|
||||
la $i2,0($i2,$key)
|
||||
@@ -1601,11 +1598,11 @@ $code.=<<___ if(1);
|
||||
lghi $s1,0x7f
|
||||
nr $s1,%r0
|
||||
lghi %r0,0 # query capability vector
|
||||
la %r1,2*$SIZE_T($sp)
|
||||
la %r1,$tweak-16($sp)
|
||||
.long 0xb92e0042 # km %r4,%r2
|
||||
llihh %r1,0x8000
|
||||
srlg %r1,%r1,32($s1) # check for 32+function code
|
||||
ng %r1,2*$SIZE_T($sp)
|
||||
ng %r1,$tweak-16($sp)
|
||||
lgr %r0,$s0 # restore the function code
|
||||
la %r1,0($key1) # restore $key1
|
||||
jz .Lxts_km_vanilla
|
||||
@@ -1631,7 +1628,7 @@ $code.=<<___ if(1);
|
||||
|
||||
lrvg $s0,$tweak+0($sp) # load the last tweak
|
||||
lrvg $s1,$tweak+8($sp)
|
||||
stmg %r0,%r3,$tweak-32(%r1) # wipe copy of the key
|
||||
stmg %r0,%r3,$tweak-32($sp) # wipe copy of the key
|
||||
|
||||
nill %r0,0xffdf # switch back to original function code
|
||||
la %r1,0($key1) # restore pointer to $key1
|
||||
@@ -1687,11 +1684,9 @@ $code.=<<___;
|
||||
lghi $i1,0x87
|
||||
srag $i2,$s1,63 # broadcast upper bit
|
||||
ngr $i1,$i2 # rem
|
||||
srlg $i2,$s0,63 # carry bit from lower half
|
||||
sllg $s0,$s0,1
|
||||
sllg $s1,$s1,1
|
||||
algr $s0,$s0
|
||||
alcgr $s1,$s1
|
||||
xgr $s0,$i1
|
||||
ogr $s1,$i2
|
||||
.Lxts_km_start:
|
||||
lrvgr $i1,$s0 # flip byte order
|
||||
lrvgr $i2,$s1
|
||||
@@ -1748,11 +1743,9 @@ $code.=<<___;
|
||||
lghi $i1,0x87
|
||||
srag $i2,$s1,63 # broadcast upper bit
|
||||
ngr $i1,$i2 # rem
|
||||
srlg $i2,$s0,63 # carry bit from lower half
|
||||
sllg $s0,$s0,1
|
||||
sllg $s1,$s1,1
|
||||
algr $s0,$s0
|
||||
alcgr $s1,$s1
|
||||
xgr $s0,$i1
|
||||
ogr $s1,$i2
|
||||
|
||||
ltr $len,$len # clear zero flag
|
||||
br $ra
|
||||
@@ -1784,8 +1777,8 @@ $code.=<<___ if (!$softonly);
|
||||
clr %r0,%r1
|
||||
jl .Lxts_enc_software
|
||||
|
||||
st${g} $ra,5*$SIZE_T($sp)
|
||||
stm${g} %r6,$s3,6*$SIZE_T($sp)
|
||||
st${g} $ra,14*$SIZE_T($sp)
|
||||
|
||||
sllg $len,$len,4 # $len&=~15
|
||||
slgr $out,$inp
|
||||
@@ -1833,9 +1826,9 @@ $code.=<<___ if (!$softonly);
|
||||
stg $i2,8($i3)
|
||||
|
||||
.Lxts_enc_km_done:
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
st${g} $sp,$tweak($sp) # wipe tweak
|
||||
st${g} $sp,$tweak($sp)
|
||||
stg $sp,$tweak+0($sp) # wipe tweak
|
||||
stg $sp,$tweak+8($sp)
|
||||
l${g} $ra,5*$SIZE_T($sp)
|
||||
lm${g} %r6,$s3,6*$SIZE_T($sp)
|
||||
br $ra
|
||||
.align 16
|
||||
@@ -1846,12 +1839,11 @@ $code.=<<___;
|
||||
|
||||
slgr $out,$inp
|
||||
|
||||
xgr $s0,$s0 # clear upper half
|
||||
xgr $s1,$s1
|
||||
lrv $s0,$stdframe+4($sp) # load secno
|
||||
lrv $s1,$stdframe+0($sp)
|
||||
xgr $s2,$s2
|
||||
xgr $s3,$s3
|
||||
l${g} $s3,$stdframe($sp) # ivp
|
||||
llgf $s0,0($s3) # load iv
|
||||
llgf $s1,4($s3)
|
||||
llgf $s2,8($s3)
|
||||
llgf $s3,12($s3)
|
||||
stm${g} %r2,%r5,2*$SIZE_T($sp)
|
||||
la $key,0($key2)
|
||||
larl $tbl,AES_Te
|
||||
@@ -1867,11 +1859,9 @@ $code.=<<___;
|
||||
lghi %r1,0x87
|
||||
srag %r0,$s3,63 # broadcast upper bit
|
||||
ngr %r1,%r0 # rem
|
||||
srlg %r0,$s1,63 # carry bit from lower half
|
||||
sllg $s1,$s1,1
|
||||
sllg $s3,$s3,1
|
||||
algr $s1,$s1
|
||||
alcgr $s3,$s3
|
||||
xgr $s1,%r1
|
||||
ogr $s3,%r0
|
||||
lrvgr $s1,$s1 # flip byte order
|
||||
lrvgr $s3,$s3
|
||||
srlg $s0,$s1,32 # smash the tweak to 4x32-bits
|
||||
@@ -1920,11 +1910,9 @@ $code.=<<___;
|
||||
lghi %r1,0x87
|
||||
srag %r0,$s3,63 # broadcast upper bit
|
||||
ngr %r1,%r0 # rem
|
||||
srlg %r0,$s1,63 # carry bit from lower half
|
||||
sllg $s1,$s1,1
|
||||
sllg $s3,$s3,1
|
||||
algr $s1,$s1
|
||||
alcgr $s3,$s3
|
||||
xgr $s1,%r1
|
||||
ogr $s3,%r0
|
||||
lrvgr $s1,$s1 # flip byte order
|
||||
lrvgr $s3,$s3
|
||||
srlg $s0,$s1,32 # smash the tweak to 4x32-bits
|
||||
@@ -1959,7 +1947,8 @@ $code.=<<___;
|
||||
.size AES_xts_encrypt,.-AES_xts_encrypt
|
||||
___
|
||||
# void AES_xts_decrypt(const char *inp,char *out,size_t len,
|
||||
# const AES_KEY *key1, const AES_KEY *key2,u64 secno);
|
||||
# const AES_KEY *key1, const AES_KEY *key2,
|
||||
# const unsigned char iv[16]);
|
||||
#
|
||||
$code.=<<___;
|
||||
.globl AES_xts_decrypt
|
||||
@@ -1991,8 +1980,8 @@ $code.=<<___ if (!$softonly);
|
||||
clr %r0,%r1
|
||||
jl .Lxts_dec_software
|
||||
|
||||
st${g} $ra,5*$SIZE_T($sp)
|
||||
stm${g} %r6,$s3,6*$SIZE_T($sp)
|
||||
st${g} $ra,14*$SIZE_T($sp)
|
||||
|
||||
nill $len,0xfff0 # $len&=~15
|
||||
slgr $out,$inp
|
||||
@@ -2031,11 +2020,9 @@ $code.=<<___ if (!$softonly);
|
||||
lghi $i1,0x87
|
||||
srag $i2,$s1,63 # broadcast upper bit
|
||||
ngr $i1,$i2 # rem
|
||||
srlg $i2,$s0,63 # carry bit from lower half
|
||||
sllg $s0,$s0,1
|
||||
sllg $s1,$s1,1
|
||||
algr $s0,$s0
|
||||
alcgr $s1,$s1
|
||||
xgr $s0,$i1
|
||||
ogr $s1,$i2
|
||||
lrvgr $i1,$s0 # flip byte order
|
||||
lrvgr $i2,$s1
|
||||
|
||||
@@ -2078,9 +2065,9 @@ $code.=<<___ if (!$softonly);
|
||||
stg $s2,0($i3)
|
||||
stg $s3,8($i3)
|
||||
.Lxts_dec_km_done:
|
||||
l${g} $ra,14*$SIZE_T($sp)
|
||||
st${g} $sp,$tweak($sp) # wipe tweak
|
||||
st${g} $sp,$tweak($sp)
|
||||
stg $sp,$tweak+0($sp) # wipe tweak
|
||||
stg $sp,$tweak+8($sp)
|
||||
l${g} $ra,5*$SIZE_T($sp)
|
||||
lm${g} %r6,$s3,6*$SIZE_T($sp)
|
||||
br $ra
|
||||
.align 16
|
||||
@@ -2092,12 +2079,11 @@ $code.=<<___;
|
||||
srlg $len,$len,4
|
||||
slgr $out,$inp
|
||||
|
||||
xgr $s0,$s0 # clear upper half
|
||||
xgr $s1,$s1
|
||||
lrv $s0,$stdframe+4($sp) # load secno
|
||||
lrv $s1,$stdframe+0($sp)
|
||||
xgr $s2,$s2
|
||||
xgr $s3,$s3
|
||||
l${g} $s3,$stdframe($sp) # ivp
|
||||
llgf $s0,0($s3) # load iv
|
||||
llgf $s1,4($s3)
|
||||
llgf $s2,8($s3)
|
||||
llgf $s3,12($s3)
|
||||
stm${g} %r2,%r5,2*$SIZE_T($sp)
|
||||
la $key,0($key2)
|
||||
larl $tbl,AES_Te
|
||||
@@ -2116,11 +2102,9 @@ $code.=<<___;
|
||||
lghi %r1,0x87
|
||||
srag %r0,$s3,63 # broadcast upper bit
|
||||
ngr %r1,%r0 # rem
|
||||
srlg %r0,$s1,63 # carry bit from lower half
|
||||
sllg $s1,$s1,1
|
||||
sllg $s3,$s3,1
|
||||
algr $s1,$s1
|
||||
alcgr $s3,$s3
|
||||
xgr $s1,%r1
|
||||
ogr $s3,%r0
|
||||
lrvgr $s1,$s1 # flip byte order
|
||||
lrvgr $s3,$s3
|
||||
srlg $s0,$s1,32 # smash the tweak to 4x32-bits
|
||||
@@ -2159,11 +2143,9 @@ $code.=<<___;
|
||||
lghi %r1,0x87
|
||||
srag %r0,$s3,63 # broadcast upper bit
|
||||
ngr %r1,%r0 # rem
|
||||
srlg %r0,$s1,63 # carry bit from lower half
|
||||
sllg $s1,$s1,1
|
||||
sllg $s3,$s3,1
|
||||
algr $s1,$s1
|
||||
alcgr $s3,$s3
|
||||
xgr $s1,%r1
|
||||
ogr $s3,%r0
|
||||
lrvgr $i2,$s1 # flip byte order
|
||||
lrvgr $i3,$s3
|
||||
stmg $i2,$i3,$tweak($sp) # save the 1st tweak
|
||||
@@ -2179,11 +2161,9 @@ $code.=<<___;
|
||||
lghi %r1,0x87
|
||||
srag %r0,$s3,63 # broadcast upper bit
|
||||
ngr %r1,%r0 # rem
|
||||
srlg %r0,$s1,63 # carry bit from lower half
|
||||
sllg $s1,$s1,1
|
||||
sllg $s3,$s3,1
|
||||
algr $s1,$s1
|
||||
alcgr $s3,$s3
|
||||
xgr $s1,%r1
|
||||
ogr $s3,%r0
|
||||
lrvgr $s1,$s1 # flip byte order
|
||||
lrvgr $s3,$s3
|
||||
srlg $s0,$s1,32 # smash the tweak to 4x32-bits
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
# Performance in number of cycles per processed byte for 128-bit key:
|
||||
#
|
||||
# ECB encrypt ECB decrypt CBC large chunk
|
||||
# AMD64 33 41 13.0
|
||||
# EM64T 38 59 18.6(*)
|
||||
# Core 2 30 43 14.5(*)
|
||||
# AMD64 33 43 13.0
|
||||
# EM64T 38 56 18.6(*)
|
||||
# Core 2 30 42 14.5(*)
|
||||
# Atom 65 86 32.1(*)
|
||||
#
|
||||
# (*) with hyper-threading off
|
||||
|
||||
@@ -36,7 +37,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$verticalspin=1; # unlike 32-bit version $verticalspin performs
|
||||
# ~15% better on both AMD and Intel cores
|
||||
@@ -365,68 +367,66 @@ $code.=<<___;
|
||||
movzb `&lo("$s0")`,$t0
|
||||
movzb `&lo("$s1")`,$t1
|
||||
movzb `&lo("$s2")`,$t2
|
||||
movzb ($sbox,$t0,1),$t0
|
||||
movzb ($sbox,$t1,1),$t1
|
||||
movzb ($sbox,$t2,1),$t2
|
||||
|
||||
movzb `&lo("$s3")`,$t3
|
||||
movzb `&hi("$s1")`,$acc0
|
||||
movzb `&hi("$s2")`,$acc1
|
||||
movzb ($sbox,$t3,1),$t3
|
||||
movzb ($sbox,$acc0,1),$t4 #$t0
|
||||
movzb ($sbox,$acc1,1),$t5 #$t1
|
||||
|
||||
movzb `&hi("$s3")`,$acc2
|
||||
movzb `&hi("$s0")`,$acc0
|
||||
shr \$16,$s2
|
||||
movzb `&hi("$s3")`,$acc2
|
||||
movzb ($sbox,$t0,1),$t0
|
||||
movzb ($sbox,$t1,1),$t1
|
||||
movzb ($sbox,$t2,1),$t2
|
||||
movzb ($sbox,$t3,1),$t3
|
||||
|
||||
movzb ($sbox,$acc0,1),$t4 #$t0
|
||||
movzb `&hi("$s0")`,$acc0
|
||||
movzb ($sbox,$acc1,1),$t5 #$t1
|
||||
movzb `&lo("$s2")`,$acc1
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t2
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t3
|
||||
shr \$16,$s3
|
||||
|
||||
movzb `&lo("$s2")`,$acc1
|
||||
shl \$8,$t4
|
||||
shr \$16,$s3
|
||||
shl \$8,$t5
|
||||
movzb ($sbox,$acc1,1),$acc1 #$t0
|
||||
xor $t4,$t0
|
||||
xor $t5,$t1
|
||||
|
||||
movzb `&lo("$s3")`,$t4
|
||||
shr \$16,$s0
|
||||
movzb `&lo("$s3")`,$t4
|
||||
shr \$16,$s1
|
||||
movzb `&lo("$s0")`,$t5
|
||||
xor $t5,$t1
|
||||
shl \$8,$acc2
|
||||
shl \$8,$acc0
|
||||
movzb ($sbox,$t4,1),$t4 #$t1
|
||||
movzb ($sbox,$t5,1),$t5 #$t2
|
||||
movzb `&lo("$s0")`,$t5
|
||||
movzb ($sbox,$acc1,1),$acc1 #$t0
|
||||
xor $acc2,$t2
|
||||
xor $acc0,$t3
|
||||
|
||||
shl \$8,$acc0
|
||||
movzb `&lo("$s1")`,$acc2
|
||||
movzb `&hi("$s3")`,$acc0
|
||||
shl \$16,$acc1
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t3
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t0
|
||||
xor $acc0,$t3
|
||||
movzb ($sbox,$t4,1),$t4 #$t1
|
||||
movzb `&hi("$s3")`,$acc0
|
||||
movzb ($sbox,$t5,1),$t5 #$t2
|
||||
xor $acc1,$t0
|
||||
|
||||
movzb `&hi("$s0")`,$acc1
|
||||
shr \$8,$s2
|
||||
movzb `&hi("$s0")`,$acc1
|
||||
shl \$16,$t4
|
||||
shr \$8,$s1
|
||||
shl \$16,$t5
|
||||
xor $t4,$t1
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t3
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t0
|
||||
movzb ($sbox,$acc1,1),$acc1 #$t1
|
||||
movzb ($sbox,$s2,1),$s3 #$t3
|
||||
movzb ($sbox,$s1,1),$s2 #$t2
|
||||
shl \$16,$t4
|
||||
shl \$16,$t5
|
||||
shl \$16,$acc2
|
||||
xor $t4,$t1
|
||||
xor $t5,$t2
|
||||
xor $acc2,$t3
|
||||
|
||||
shl \$16,$acc2
|
||||
xor $t5,$t2
|
||||
shl \$24,$acc0
|
||||
xor $acc2,$t3
|
||||
shl \$24,$acc1
|
||||
shl \$24,$s3
|
||||
xor $acc0,$t0
|
||||
shl \$24,$s2
|
||||
shl \$24,$s3
|
||||
xor $acc1,$t1
|
||||
shl \$24,$s2
|
||||
mov $t0,$s0
|
||||
mov $t1,$s1
|
||||
xor $t2,$s2
|
||||
@@ -465,12 +465,12 @@ sub enctransform()
|
||||
{ my ($t3,$r20,$r21)=($acc2,"%r8d","%r9d");
|
||||
|
||||
$code.=<<___;
|
||||
mov $s0,$acc0
|
||||
mov $s1,$acc1
|
||||
and \$0x80808080,$acc0
|
||||
and \$0x80808080,$acc1
|
||||
mov $acc0,$t0
|
||||
mov $acc1,$t1
|
||||
mov \$0x80808080,$t0
|
||||
mov \$0x80808080,$t1
|
||||
and $s0,$t0
|
||||
and $s1,$t1
|
||||
mov $t0,$acc0
|
||||
mov $t1,$acc1
|
||||
shr \$7,$t0
|
||||
lea ($s0,$s0),$r20
|
||||
shr \$7,$t1
|
||||
@@ -488,25 +488,25 @@ $code.=<<___;
|
||||
|
||||
xor $r20,$s0
|
||||
xor $r21,$s1
|
||||
mov $s2,$acc0
|
||||
mov $s3,$acc1
|
||||
mov \$0x80808080,$t2
|
||||
rol \$24,$s0
|
||||
mov \$0x80808080,$t3
|
||||
rol \$24,$s1
|
||||
and \$0x80808080,$acc0
|
||||
and \$0x80808080,$acc1
|
||||
and $s2,$t2
|
||||
and $s3,$t3
|
||||
xor $r20,$s0
|
||||
xor $r21,$s1
|
||||
mov $acc0,$t2
|
||||
mov $acc1,$t3
|
||||
mov $t2,$acc0
|
||||
ror \$16,$t0
|
||||
mov $t3,$acc1
|
||||
ror \$16,$t1
|
||||
shr \$7,$t2
|
||||
lea ($s2,$s2),$r20
|
||||
shr \$7,$t2
|
||||
xor $t0,$s0
|
||||
xor $t1,$s1
|
||||
shr \$7,$t3
|
||||
lea ($s3,$s3),$r21
|
||||
xor $t1,$s1
|
||||
ror \$8,$t0
|
||||
lea ($s3,$s3),$r21
|
||||
ror \$8,$t1
|
||||
sub $t2,$acc0
|
||||
sub $t3,$acc1
|
||||
@@ -522,23 +522,23 @@ $code.=<<___;
|
||||
xor $acc0,$r20
|
||||
xor $acc1,$r21
|
||||
|
||||
ror \$16,$t2
|
||||
xor $r20,$s2
|
||||
ror \$16,$t3
|
||||
xor $r21,$s3
|
||||
rol \$24,$s2
|
||||
mov 0($sbox),$acc0 # prefetch Te4
|
||||
rol \$24,$s3
|
||||
xor $r20,$s2
|
||||
xor $r21,$s3
|
||||
mov 0($sbox),$acc0 # prefetch Te4
|
||||
ror \$16,$t2
|
||||
ror \$16,$t3
|
||||
mov 64($sbox),$acc1
|
||||
xor $t2,$s2
|
||||
xor $t3,$s3
|
||||
xor $r21,$s3
|
||||
mov 128($sbox),$r20
|
||||
ror \$8,$t2
|
||||
ror \$8,$t3
|
||||
mov 192($sbox),$r21
|
||||
xor $t2,$s2
|
||||
ror \$8,$t2
|
||||
xor $t3,$s3
|
||||
ror \$8,$t3
|
||||
xor $t2,$s2
|
||||
mov 192($sbox),$r21
|
||||
xor $t3,$s3
|
||||
___
|
||||
}
|
||||
@@ -935,70 +935,69 @@ $code.=<<___;
|
||||
movzb `&lo("$s0")`,$t0
|
||||
movzb `&lo("$s1")`,$t1
|
||||
movzb `&lo("$s2")`,$t2
|
||||
movzb ($sbox,$t0,1),$t0
|
||||
movzb ($sbox,$t1,1),$t1
|
||||
movzb ($sbox,$t2,1),$t2
|
||||
|
||||
movzb `&lo("$s3")`,$t3
|
||||
movzb `&hi("$s3")`,$acc0
|
||||
movzb `&hi("$s0")`,$acc1
|
||||
movzb ($sbox,$t3,1),$t3
|
||||
movzb ($sbox,$acc0,1),$t4 #$t0
|
||||
movzb ($sbox,$acc1,1),$t5 #$t1
|
||||
|
||||
shr \$16,$s3
|
||||
movzb `&hi("$s1")`,$acc2
|
||||
movzb ($sbox,$t0,1),$t0
|
||||
movzb ($sbox,$t1,1),$t1
|
||||
movzb ($sbox,$t2,1),$t2
|
||||
movzb ($sbox,$t3,1),$t3
|
||||
|
||||
movzb ($sbox,$acc0,1),$t4 #$t0
|
||||
movzb `&hi("$s2")`,$acc0
|
||||
shr \$16,$s2
|
||||
movzb ($sbox,$acc1,1),$t5 #$t1
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t2
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t3
|
||||
shr \$16,$s3
|
||||
|
||||
movzb `&lo("$s2")`,$acc1
|
||||
shl \$8,$t4
|
||||
shr \$16,$s2
|
||||
shl \$8,$t5
|
||||
movzb ($sbox,$acc1,1),$acc1 #$t0
|
||||
xor $t4,$t0
|
||||
xor $t5,$t1
|
||||
|
||||
movzb `&lo("$s3")`,$t4
|
||||
shl \$8,$t4
|
||||
movzb `&lo("$s2")`,$acc1
|
||||
shr \$16,$s0
|
||||
xor $t4,$t0
|
||||
shr \$16,$s1
|
||||
movzb `&lo("$s0")`,$t5
|
||||
movzb `&lo("$s3")`,$t4
|
||||
|
||||
shl \$8,$acc2
|
||||
xor $t5,$t1
|
||||
shl \$8,$acc0
|
||||
movzb ($sbox,$t4,1),$t4 #$t1
|
||||
movzb ($sbox,$t5,1),$t5 #$t2
|
||||
movzb `&lo("$s0")`,$t5
|
||||
movzb ($sbox,$acc1,1),$acc1 #$t0
|
||||
xor $acc2,$t2
|
||||
xor $acc0,$t3
|
||||
|
||||
movzb `&lo("$s1")`,$acc2
|
||||
movzb `&hi("$s1")`,$acc0
|
||||
shl \$16,$acc1
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t3
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t0
|
||||
xor $acc1,$t0
|
||||
|
||||
shl \$16,$acc1
|
||||
xor $acc0,$t3
|
||||
movzb ($sbox,$t4,1),$t4 #$t1
|
||||
movzb `&hi("$s1")`,$acc0
|
||||
movzb ($sbox,$acc2,1),$acc2 #$t3
|
||||
xor $acc1,$t0
|
||||
movzb ($sbox,$t5,1),$t5 #$t2
|
||||
movzb `&hi("$s2")`,$acc1
|
||||
|
||||
shl \$16,$acc2
|
||||
shl \$16,$t4
|
||||
shl \$16,$t5
|
||||
movzb ($sbox,$acc1,1),$s1 #$t1
|
||||
xor $acc2,$t3
|
||||
movzb `&hi("$s3")`,$acc2
|
||||
xor $t4,$t1
|
||||
shr \$8,$s0
|
||||
xor $t5,$t2
|
||||
|
||||
movzb `&hi("$s3")`,$acc1
|
||||
shr \$8,$s0
|
||||
shl \$16,$acc2
|
||||
movzb ($sbox,$acc1,1),$s2 #$t2
|
||||
movzb ($sbox,$acc0,1),$acc0 #$t0
|
||||
movzb ($sbox,$acc1,1),$s1 #$t1
|
||||
movzb ($sbox,$acc2,1),$s2 #$t2
|
||||
movzb ($sbox,$s0,1),$s3 #$t3
|
||||
xor $acc2,$t3
|
||||
|
||||
mov $t0,$s0
|
||||
shl \$24,$acc0
|
||||
shl \$24,$s1
|
||||
shl \$24,$s2
|
||||
xor $acc0,$t0
|
||||
xor $acc0,$s0
|
||||
shl \$24,$s3
|
||||
xor $t1,$s1
|
||||
mov $t0,$s0
|
||||
xor $t2,$s2
|
||||
xor $t3,$s3
|
||||
___
|
||||
@@ -1013,12 +1012,12 @@ sub dectransform()
|
||||
my $prefetch = shift;
|
||||
|
||||
$code.=<<___;
|
||||
mov $tp10,$acc0
|
||||
mov $tp18,$acc8
|
||||
and $mask80,$acc0
|
||||
and $mask80,$acc8
|
||||
mov $acc0,$tp40
|
||||
mov $acc8,$tp48
|
||||
mov $mask80,$tp40
|
||||
mov $mask80,$tp48
|
||||
and $tp10,$tp40
|
||||
and $tp18,$tp48
|
||||
mov $tp40,$acc0
|
||||
mov $tp48,$acc8
|
||||
shr \$7,$tp40
|
||||
lea ($tp10,$tp10),$tp20
|
||||
shr \$7,$tp48
|
||||
@@ -1029,15 +1028,15 @@ $code.=<<___;
|
||||
and $maskfe,$tp28
|
||||
and $mask1b,$acc0
|
||||
and $mask1b,$acc8
|
||||
xor $tp20,$acc0
|
||||
xor $tp28,$acc8
|
||||
mov $acc0,$tp20
|
||||
mov $acc8,$tp28
|
||||
xor $acc0,$tp20
|
||||
xor $acc8,$tp28
|
||||
mov $mask80,$tp80
|
||||
mov $mask80,$tp88
|
||||
|
||||
and $mask80,$acc0
|
||||
and $mask80,$acc8
|
||||
mov $acc0,$tp80
|
||||
mov $acc8,$tp88
|
||||
and $tp20,$tp80
|
||||
and $tp28,$tp88
|
||||
mov $tp80,$acc0
|
||||
mov $tp88,$acc8
|
||||
shr \$7,$tp80
|
||||
lea ($tp20,$tp20),$tp40
|
||||
shr \$7,$tp88
|
||||
@@ -1048,15 +1047,15 @@ $code.=<<___;
|
||||
and $maskfe,$tp48
|
||||
and $mask1b,$acc0
|
||||
and $mask1b,$acc8
|
||||
xor $tp40,$acc0
|
||||
xor $tp48,$acc8
|
||||
mov $acc0,$tp40
|
||||
mov $acc8,$tp48
|
||||
xor $acc0,$tp40
|
||||
xor $acc8,$tp48
|
||||
mov $mask80,$tp80
|
||||
mov $mask80,$tp88
|
||||
|
||||
and $mask80,$acc0
|
||||
and $mask80,$acc8
|
||||
mov $acc0,$tp80
|
||||
mov $acc8,$tp88
|
||||
and $tp40,$tp80
|
||||
and $tp48,$tp88
|
||||
mov $tp80,$acc0
|
||||
mov $tp88,$acc8
|
||||
shr \$7,$tp80
|
||||
xor $tp10,$tp20 # tp2^=tp1
|
||||
shr \$7,$tp88
|
||||
@@ -1081,51 +1080,51 @@ $code.=<<___;
|
||||
mov $tp10,$acc0
|
||||
mov $tp18,$acc8
|
||||
xor $tp80,$tp40 # tp4^tp1^=tp8
|
||||
xor $tp88,$tp48 # tp4^tp1^=tp8
|
||||
shr \$32,$acc0
|
||||
xor $tp88,$tp48 # tp4^tp1^=tp8
|
||||
shr \$32,$acc8
|
||||
xor $tp20,$tp80 # tp8^=tp8^tp2^tp1=tp2^tp1
|
||||
xor $tp28,$tp88 # tp8^=tp8^tp2^tp1=tp2^tp1
|
||||
rol \$8,`&LO("$tp10")` # ROTATE(tp1^tp8,8)
|
||||
xor $tp28,$tp88 # tp8^=tp8^tp2^tp1=tp2^tp1
|
||||
rol \$8,`&LO("$tp18")` # ROTATE(tp1^tp8,8)
|
||||
xor $tp40,$tp80 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
|
||||
rol \$8,`&LO("$acc0")` # ROTATE(tp1^tp8,8)
|
||||
xor $tp48,$tp88 # tp2^tp1^=tp8^tp4^tp1=tp8^tp4^tp2
|
||||
|
||||
rol \$8,`&LO("$acc0")` # ROTATE(tp1^tp8,8)
|
||||
rol \$8,`&LO("$acc8")` # ROTATE(tp1^tp8,8)
|
||||
xor `&LO("$tp80")`,`&LO("$tp10")`
|
||||
xor `&LO("$tp88")`,`&LO("$tp18")`
|
||||
shr \$32,$tp80
|
||||
xor `&LO("$tp88")`,`&LO("$tp18")`
|
||||
shr \$32,$tp88
|
||||
xor `&LO("$tp80")`,`&LO("$acc0")`
|
||||
xor `&LO("$tp88")`,`&LO("$acc8")`
|
||||
|
||||
mov $tp20,$tp80
|
||||
mov $tp28,$tp88
|
||||
shr \$32,$tp80
|
||||
shr \$32,$tp88
|
||||
rol \$24,`&LO("$tp20")` # ROTATE(tp2^tp1^tp8,24)
|
||||
mov $tp28,$tp88
|
||||
rol \$24,`&LO("$tp28")` # ROTATE(tp2^tp1^tp8,24)
|
||||
rol \$24,`&LO("$tp80")` # ROTATE(tp2^tp1^tp8,24)
|
||||
rol \$24,`&LO("$tp88")` # ROTATE(tp2^tp1^tp8,24)
|
||||
shr \$32,$tp80
|
||||
xor `&LO("$tp20")`,`&LO("$tp10")`
|
||||
shr \$32,$tp88
|
||||
xor `&LO("$tp28")`,`&LO("$tp18")`
|
||||
rol \$24,`&LO("$tp80")` # ROTATE(tp2^tp1^tp8,24)
|
||||
mov $tp40,$tp20
|
||||
rol \$24,`&LO("$tp88")` # ROTATE(tp2^tp1^tp8,24)
|
||||
mov $tp48,$tp28
|
||||
shr \$32,$tp20
|
||||
xor `&LO("$tp80")`,`&LO("$acc0")`
|
||||
shr \$32,$tp28
|
||||
xor `&LO("$tp88")`,`&LO("$acc8")`
|
||||
|
||||
`"mov 0($sbox),$mask80" if ($prefetch)`
|
||||
shr \$32,$tp20
|
||||
shr \$32,$tp28
|
||||
`"mov 64($sbox),$maskfe" if ($prefetch)`
|
||||
rol \$16,`&LO("$tp40")` # ROTATE(tp4^tp1^tp8,16)
|
||||
`"mov 64($sbox),$maskfe" if ($prefetch)`
|
||||
rol \$16,`&LO("$tp48")` # ROTATE(tp4^tp1^tp8,16)
|
||||
`"mov 128($sbox),$mask1b" if ($prefetch)`
|
||||
rol \$16,`&LO("$tp20")` # ROTATE(tp4^tp1^tp8,16)
|
||||
rol \$16,`&LO("$tp28")` # ROTATE(tp4^tp1^tp8,16)
|
||||
`"mov 192($sbox),$tp80" if ($prefetch)`
|
||||
xor `&LO("$tp40")`,`&LO("$tp10")`
|
||||
rol \$16,`&LO("$tp28")` # ROTATE(tp4^tp1^tp8,16)
|
||||
xor `&LO("$tp48")`,`&LO("$tp18")`
|
||||
`"mov 256($sbox),$tp88" if ($prefetch)`
|
||||
xor `&LO("$tp20")`,`&LO("$acc0")`
|
||||
@@ -1301,10 +1300,6 @@ private_AES_set_encrypt_key:
|
||||
|
||||
call _x86_64_AES_set_encrypt_key
|
||||
|
||||
mov 8(%rsp),%r15
|
||||
mov 16(%rsp),%r14
|
||||
mov 24(%rsp),%r13
|
||||
mov 32(%rsp),%r12
|
||||
mov 40(%rsp),%rbp
|
||||
mov 48(%rsp),%rbx
|
||||
add \$56,%rsp
|
||||
|
||||
1231
crypto/aes/asm/aesni-mb-x86_64.pl
Normal file
1231
crypto/aes/asm/aesni-mb-x86_64.pl
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1352
crypto/aes/asm/aesni-sha256-x86_64.pl
Normal file
1352
crypto/aes/asm/aesni-sha256-x86_64.pl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# ====================================================================
|
||||
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
|
||||
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||
# project. The module is, however, dual licensed under OpenSSL and
|
||||
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
||||
# details see http://www.openssl.org/~appro/cryptogams/.
|
||||
@@ -43,6 +43,17 @@
|
||||
# Add aesni_xts_[en|de]crypt. Westmere spends 1.50 cycles processing
|
||||
# one byte out of 8KB with 128-bit key, Sandy Bridge - 1.09.
|
||||
|
||||
######################################################################
|
||||
# Current large-block performance in cycles per byte processed with
|
||||
# 128-bit key (less is better).
|
||||
#
|
||||
# CBC en-/decrypt CTR XTS ECB
|
||||
# Westmere 3.77/1.37 1.37 1.52 1.27
|
||||
# * Bridge 5.07/0.98 0.99 1.09 0.91
|
||||
# Haswell 4.44/0.80 0.97 1.03 0.72
|
||||
# Atom 5.77/3.56 3.67 4.03 3.46
|
||||
# Bulldozer 5.80/0.98 1.05 1.24 0.93
|
||||
|
||||
$PREFIX="aesni"; # if $PREFIX is set to "AES", the script
|
||||
# generates drop-in replacement for
|
||||
# crypto/aes/asm/aes-586.pl:-)
|
||||
@@ -54,8 +65,8 @@ require "x86asm.pl";
|
||||
|
||||
&asm_init($ARGV[0],$0);
|
||||
|
||||
if ($PREFIX eq "aesni") { $movekey=*movups; }
|
||||
else { $movekey=*movups; }
|
||||
if ($PREFIX eq "aesni") { $movekey=\&movups; }
|
||||
else { $movekey=\&movups; }
|
||||
|
||||
$len="eax";
|
||||
$rounds="ecx";
|
||||
@@ -196,37 +207,71 @@ sub aesni_generate1 # fully unrolled loop
|
||||
# every *2nd* cycle. Thus 3x interleave was the one providing optimal
|
||||
# utilization, i.e. when subroutine's throughput is virtually same as
|
||||
# of non-interleaved subroutine [for number of input blocks up to 3].
|
||||
# This is why it makes no sense to implement 2x subroutine.
|
||||
# aes[enc|dec] latency in next processor generation is 8, but the
|
||||
# instructions can be scheduled every cycle. Optimal interleave for
|
||||
# new processor is therefore 8x, but it's unfeasible to accommodate it
|
||||
# in XMM registers addreassable in 32-bit mode and therefore 6x is
|
||||
# used instead...
|
||||
# This is why it originally made no sense to implement 2x subroutine.
|
||||
# But times change and it became appropriate to spend extra 192 bytes
|
||||
# on 2x subroutine on Atom Silvermont account. For processors that
|
||||
# can schedule aes[enc|dec] every cycle optimal interleave factor
|
||||
# equals to corresponding instructions latency. 8x is optimal for
|
||||
# * Bridge, but it's unfeasible to accommodate such implementation
|
||||
# in XMM registers addreassable in 32-bit mode and therefore maximum
|
||||
# of 6x is used instead...
|
||||
|
||||
sub aesni_generate2
|
||||
{ my $p=shift;
|
||||
|
||||
&function_begin_B("_aesni_${p}rypt2");
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&shl ($rounds,4);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&pxor ($inout1,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(32,$key));
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&neg ($rounds);
|
||||
&add ($rounds,16);
|
||||
|
||||
&set_label("${p}2_loop");
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
eval"&aes${p} ($inout0,$rndkey0)";
|
||||
eval"&aes${p} ($inout1,$rndkey0)";
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("${p}2_loop"));
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
eval"&aes${p}last ($inout0,$rndkey0)";
|
||||
eval"&aes${p}last ($inout1,$rndkey0)";
|
||||
&ret();
|
||||
&function_end_B("_aesni_${p}rypt2");
|
||||
}
|
||||
|
||||
sub aesni_generate3
|
||||
{ my $p=shift;
|
||||
|
||||
&function_begin_B("_aesni_${p}rypt3");
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&shr ($rounds,1);
|
||||
&shl ($rounds,4);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&lea ($key,&DWP(32,$key));
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&pxor ($inout1,$rndkey0);
|
||||
&pxor ($inout2,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(32,$key));
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&neg ($rounds);
|
||||
&add ($rounds,16);
|
||||
|
||||
&set_label("${p}3_loop");
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
&dec ($rounds);
|
||||
eval"&aes${p} ($inout2,$rndkey1)";
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
eval"&aes${p} ($inout0,$rndkey0)";
|
||||
eval"&aes${p} ($inout1,$rndkey0)";
|
||||
&lea ($key,&DWP(32,$key));
|
||||
eval"&aes${p} ($inout2,$rndkey0)";
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("${p}3_loop"));
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
@@ -248,27 +293,29 @@ sub aesni_generate4
|
||||
&function_begin_B("_aesni_${p}rypt4");
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&shr ($rounds,1);
|
||||
&lea ($key,&DWP(32,$key));
|
||||
&shl ($rounds,4);
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&pxor ($inout1,$rndkey0);
|
||||
&pxor ($inout2,$rndkey0);
|
||||
&pxor ($inout3,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(32,$key));
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&neg ($rounds);
|
||||
&data_byte (0x0f,0x1f,0x40,0x00);
|
||||
&add ($rounds,16);
|
||||
|
||||
&set_label("${p}4_loop");
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
&dec ($rounds);
|
||||
eval"&aes${p} ($inout2,$rndkey1)";
|
||||
eval"&aes${p} ($inout3,$rndkey1)";
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
eval"&aes${p} ($inout0,$rndkey0)";
|
||||
eval"&aes${p} ($inout1,$rndkey0)";
|
||||
&lea ($key,&DWP(32,$key));
|
||||
eval"&aes${p} ($inout2,$rndkey0)";
|
||||
eval"&aes${p} ($inout3,$rndkey0)";
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("${p}4_loop"));
|
||||
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
@@ -289,43 +336,43 @@ sub aesni_generate6
|
||||
&function_begin_B("_aesni_${p}rypt6");
|
||||
&static_label("_aesni_${p}rypt6_enter");
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&shr ($rounds,1);
|
||||
&shl ($rounds,4);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&lea ($key,&DWP(32,$key));
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&pxor ($inout1,$rndkey0); # pxor does better here
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
&pxor ($inout2,$rndkey0);
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
&pxor ($inout3,$rndkey0);
|
||||
&dec ($rounds);
|
||||
eval"&aes${p} ($inout2,$rndkey1)";
|
||||
&pxor ($inout4,$rndkey0);
|
||||
eval"&aes${p} ($inout3,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&neg ($rounds);
|
||||
eval"&aes${p} ($inout2,$rndkey1)";
|
||||
&pxor ($inout5,$rndkey0);
|
||||
&add ($rounds,16);
|
||||
eval"&aes${p} ($inout3,$rndkey1)";
|
||||
eval"&aes${p} ($inout4,$rndkey1)";
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
eval"&aes${p} ($inout5,$rndkey1)";
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jmp (&label("_aesni_${p}rypt6_enter"));
|
||||
|
||||
&set_label("${p}6_loop",16);
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
eval"&aes${p} ($inout1,$rndkey1)";
|
||||
&dec ($rounds);
|
||||
eval"&aes${p} ($inout2,$rndkey1)";
|
||||
eval"&aes${p} ($inout3,$rndkey1)";
|
||||
eval"&aes${p} ($inout4,$rndkey1)";
|
||||
eval"&aes${p} ($inout5,$rndkey1)";
|
||||
&set_label("_aesni_${p}rypt6_enter",16);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&set_label("_aesni_${p}rypt6_enter");
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
eval"&aes${p} ($inout0,$rndkey0)";
|
||||
eval"&aes${p} ($inout1,$rndkey0)";
|
||||
&lea ($key,&DWP(32,$key));
|
||||
eval"&aes${p} ($inout2,$rndkey0)";
|
||||
eval"&aes${p} ($inout3,$rndkey0)";
|
||||
eval"&aes${p} ($inout4,$rndkey0)";
|
||||
eval"&aes${p} ($inout5,$rndkey0)";
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("${p}6_loop"));
|
||||
|
||||
eval"&aes${p} ($inout0,$rndkey1)";
|
||||
@@ -343,6 +390,8 @@ sub aesni_generate6
|
||||
&ret();
|
||||
&function_end_B("_aesni_${p}rypt6");
|
||||
}
|
||||
&aesni_generate2("enc") if ($PREFIX eq "aesni");
|
||||
&aesni_generate2("dec");
|
||||
&aesni_generate3("enc") if ($PREFIX eq "aesni");
|
||||
&aesni_generate3("dec");
|
||||
&aesni_generate4("enc") if ($PREFIX eq "aesni");
|
||||
@@ -446,8 +495,7 @@ if ($PREFIX eq "aesni") {
|
||||
&jmp (&label("ecb_ret"));
|
||||
|
||||
&set_label("ecb_enc_two",16);
|
||||
&xorps ($inout2,$inout2);
|
||||
&call ("_aesni_encrypt3");
|
||||
&call ("_aesni_encrypt2");
|
||||
&movups (&QWP(0,$out),$inout0);
|
||||
&movups (&QWP(0x10,$out),$inout1);
|
||||
&jmp (&label("ecb_ret"));
|
||||
@@ -547,8 +595,7 @@ if ($PREFIX eq "aesni") {
|
||||
&jmp (&label("ecb_ret"));
|
||||
|
||||
&set_label("ecb_dec_two",16);
|
||||
&xorps ($inout2,$inout2);
|
||||
&call ("_aesni_decrypt3");
|
||||
&call ("_aesni_decrypt2");
|
||||
&movups (&QWP(0,$out),$inout0);
|
||||
&movups (&QWP(0x10,$out),$inout1);
|
||||
&jmp (&label("ecb_ret"));
|
||||
@@ -610,11 +657,13 @@ if ($PREFIX eq "aesni") {
|
||||
&mov (&DWP(24,"esp"),$key_);
|
||||
&mov (&DWP(28,"esp"),$key_);
|
||||
|
||||
&shr ($rounds,1);
|
||||
&shl ($rounds,4);
|
||||
&mov ($rounds_,16);
|
||||
&lea ($key_,&DWP(0,$key));
|
||||
&movdqa ($inout3,&QWP(0,"esp"));
|
||||
&movdqa ($inout0,$ivec);
|
||||
&mov ($rounds_,$rounds);
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&sub ($rounds_,$rounds);
|
||||
&pshufb ($ivec,$inout3);
|
||||
|
||||
&set_label("ccm64_enc_outer");
|
||||
@@ -625,33 +674,31 @@ if ($PREFIX eq "aesni") {
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&xorps ($rndkey0,$in0);
|
||||
&lea ($key,&DWP(32,$key_));
|
||||
&xorps ($cmac,$rndkey0); # cmac^=inp
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(32,$key_));
|
||||
|
||||
&set_label("ccm64_enc2_loop");
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&dec ($rounds);
|
||||
&aesenc ($cmac,$rndkey1);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
&aesenc ($inout0,$rndkey0);
|
||||
&lea ($key,&DWP(32,$key));
|
||||
&aesenc ($cmac,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("ccm64_enc2_loop"));
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&aesenc ($cmac,$rndkey1);
|
||||
&paddq ($ivec,&QWP(16,"esp"));
|
||||
&dec ($len);
|
||||
&aesenclast ($inout0,$rndkey0);
|
||||
&aesenclast ($cmac,$rndkey0);
|
||||
|
||||
&dec ($len);
|
||||
&lea ($inp,&DWP(16,$inp));
|
||||
&xorps ($in0,$inout0); # inp^=E(ivec)
|
||||
&movdqa ($inout0,$ivec);
|
||||
&movups (&QWP(0,$out),$in0); # save output
|
||||
&lea ($out,&DWP(16,$out));
|
||||
&pshufb ($inout0,$inout3);
|
||||
&lea ($out,&DWP(16,$out));
|
||||
&jnz (&label("ccm64_enc_outer"));
|
||||
|
||||
&mov ("esp",&DWP(48,"esp"));
|
||||
@@ -700,15 +747,19 @@ if ($PREFIX eq "aesni") {
|
||||
{ &aesni_inline_generate1("enc"); }
|
||||
else
|
||||
{ &call ("_aesni_encrypt1"); }
|
||||
&shl ($rounds_,4);
|
||||
&mov ($rounds,16);
|
||||
&movups ($in0,&QWP(0,$inp)); # load inp
|
||||
&paddq ($ivec,&QWP(16,"esp"));
|
||||
&lea ($inp,&QWP(16,$inp));
|
||||
&sub ($rounds,$rounds_);
|
||||
&lea ($key,&DWP(32,$key_,$rounds_));
|
||||
&mov ($rounds_,$rounds);
|
||||
&jmp (&label("ccm64_dec_outer"));
|
||||
|
||||
&set_label("ccm64_dec_outer",16);
|
||||
&xorps ($in0,$inout0); # inp ^= E(ivec)
|
||||
&movdqa ($inout0,$ivec);
|
||||
&mov ($rounds,$rounds_);
|
||||
&movups (&QWP(0,$out),$in0); # save output
|
||||
&lea ($out,&DWP(16,$out));
|
||||
&pshufb ($inout0,$inout3);
|
||||
@@ -717,34 +768,33 @@ if ($PREFIX eq "aesni") {
|
||||
&jz (&label("ccm64_dec_break"));
|
||||
|
||||
&$movekey ($rndkey0,&QWP(0,$key_));
|
||||
&shr ($rounds,1);
|
||||
&mov ($rounds,$rounds_);
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&xorps ($in0,$rndkey0);
|
||||
&lea ($key,&DWP(32,$key_));
|
||||
&xorps ($inout0,$rndkey0);
|
||||
&xorps ($cmac,$in0); # cmac^=out
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(32,$key_));
|
||||
|
||||
&set_label("ccm64_dec2_loop");
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&dec ($rounds);
|
||||
&aesenc ($cmac,$rndkey1);
|
||||
&$movekey ($rndkey1,&QWP(16,$key));
|
||||
&$movekey ($rndkey1,&QWP(0,$key,$rounds));
|
||||
&add ($rounds,32);
|
||||
&aesenc ($inout0,$rndkey0);
|
||||
&lea ($key,&DWP(32,$key));
|
||||
&aesenc ($cmac,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&$movekey ($rndkey0,&QWP(-16,$key,$rounds));
|
||||
&jnz (&label("ccm64_dec2_loop"));
|
||||
&movups ($in0,&QWP(0,$inp)); # load inp
|
||||
&paddq ($ivec,&QWP(16,"esp"));
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&aesenc ($cmac,$rndkey1);
|
||||
&lea ($inp,&QWP(16,$inp));
|
||||
&aesenclast ($inout0,$rndkey0);
|
||||
&aesenclast ($cmac,$rndkey0);
|
||||
&lea ($inp,&QWP(16,$inp));
|
||||
&jmp (&label("ccm64_dec_outer"));
|
||||
|
||||
&set_label("ccm64_dec_break",16);
|
||||
&mov ($rounds,&DWP(240,$key_));
|
||||
&mov ($key,$key_);
|
||||
if ($inline)
|
||||
{ &aesni_inline_generate1("enc",$cmac,$in0); }
|
||||
@@ -763,7 +813,7 @@ if ($PREFIX eq "aesni") {
|
||||
# const char *ivec);
|
||||
#
|
||||
# Handles only complete blocks, operates on 32-bit counter and
|
||||
# does not update *ivec! (see engine/eng_aesni.c for details)
|
||||
# does not update *ivec! (see crypto/modes/ctr128.c for details)
|
||||
#
|
||||
# stack layout:
|
||||
# 0 pshufb mask
|
||||
@@ -810,66 +860,61 @@ if ($PREFIX eq "aesni") {
|
||||
|
||||
# compose 2 vectors of 3x32-bit counters
|
||||
&bswap ($rounds_);
|
||||
&pxor ($rndkey1,$rndkey1);
|
||||
&pxor ($rndkey0,$rndkey0);
|
||||
&pxor ($rndkey1,$rndkey1);
|
||||
&movdqa ($inout0,&QWP(0,"esp")); # load byte-swap mask
|
||||
&pinsrd ($rndkey1,$rounds_,0);
|
||||
&pinsrd ($rndkey0,$rounds_,0);
|
||||
&lea ($key_,&DWP(3,$rounds_));
|
||||
&pinsrd ($rndkey0,$key_,0);
|
||||
&pinsrd ($rndkey1,$key_,0);
|
||||
&inc ($rounds_);
|
||||
&pinsrd ($rndkey1,$rounds_,1);
|
||||
&pinsrd ($rndkey0,$rounds_,1);
|
||||
&inc ($key_);
|
||||
&pinsrd ($rndkey0,$key_,1);
|
||||
&pinsrd ($rndkey1,$key_,1);
|
||||
&inc ($rounds_);
|
||||
&pinsrd ($rndkey1,$rounds_,2);
|
||||
&pinsrd ($rndkey0,$rounds_,2);
|
||||
&inc ($key_);
|
||||
&pinsrd ($rndkey0,$key_,2);
|
||||
&movdqa (&QWP(48,"esp"),$rndkey1); # save 1st triplet
|
||||
&pshufb ($rndkey1,$inout0); # byte swap
|
||||
&movdqa (&QWP(64,"esp"),$rndkey0); # save 2nd triplet
|
||||
&pinsrd ($rndkey1,$key_,2);
|
||||
&movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet
|
||||
&pshufb ($rndkey0,$inout0); # byte swap
|
||||
&movdqu ($inout4,&QWP(0,$key)); # key[0]
|
||||
&movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet
|
||||
&pshufb ($rndkey1,$inout0); # byte swap
|
||||
|
||||
&pshufd ($inout0,$rndkey1,3<<6); # place counter to upper dword
|
||||
&pshufd ($inout1,$rndkey1,2<<6);
|
||||
&pshufd ($inout0,$rndkey0,3<<6); # place counter to upper dword
|
||||
&pshufd ($inout1,$rndkey0,2<<6);
|
||||
&cmp ($len,6);
|
||||
&jb (&label("ctr32_tail"));
|
||||
&movdqa (&QWP(32,"esp"),$inout5); # save counter-less ivec
|
||||
&shr ($rounds,1);
|
||||
&pxor ($inout5,$inout4); # counter-less ivec^key[0]
|
||||
&shl ($rounds,4);
|
||||
&mov ($rounds_,16);
|
||||
&movdqa (&QWP(32,"esp"),$inout5); # save counter-less ivec^key[0]
|
||||
&mov ($key_,$key); # backup $key
|
||||
&mov ($rounds_,$rounds); # backup $rounds
|
||||
&sub ($rounds_,$rounds); # backup twisted $rounds
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&sub ($len,6);
|
||||
&jmp (&label("ctr32_loop6"));
|
||||
|
||||
&set_label("ctr32_loop6",16);
|
||||
&pshufd ($inout2,$rndkey1,1<<6);
|
||||
&movdqa ($rndkey1,&QWP(32,"esp")); # pull counter-less ivec
|
||||
&pshufd ($inout3,$rndkey0,3<<6);
|
||||
&por ($inout0,$rndkey1); # merge counter-less ivec
|
||||
&pshufd ($inout4,$rndkey0,2<<6);
|
||||
&por ($inout1,$rndkey1);
|
||||
&pshufd ($inout5,$rndkey0,1<<6);
|
||||
&por ($inout2,$rndkey1);
|
||||
&por ($inout3,$rndkey1);
|
||||
&por ($inout4,$rndkey1);
|
||||
&por ($inout5,$rndkey1);
|
||||
|
||||
# inlining _aesni_encrypt6's prologue gives ~4% improvement...
|
||||
&$movekey ($rndkey0,&QWP(0,$key_));
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&lea ($key,&DWP(32,$key_));
|
||||
&dec ($rounds);
|
||||
&pxor ($inout0,$rndkey0);
|
||||
# inlining _aesni_encrypt6's prologue gives ~6% improvement...
|
||||
&pshufd ($inout2,$rndkey0,1<<6);
|
||||
&movdqa ($rndkey0,&QWP(32,"esp")); # pull counter-less ivec
|
||||
&pshufd ($inout3,$rndkey1,3<<6);
|
||||
&pxor ($inout0,$rndkey0); # merge counter-less ivec
|
||||
&pshufd ($inout4,$rndkey1,2<<6);
|
||||
&pxor ($inout1,$rndkey0);
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&pshufd ($inout5,$rndkey1,1<<6);
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&pxor ($inout2,$rndkey0);
|
||||
&aesenc ($inout1,$rndkey1);
|
||||
&pxor ($inout3,$rndkey0);
|
||||
&aesenc ($inout2,$rndkey1);
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&pxor ($inout4,$rndkey0);
|
||||
&aesenc ($inout3,$rndkey1);
|
||||
&pxor ($inout5,$rndkey0);
|
||||
&aesenc ($inout1,$rndkey1);
|
||||
&$movekey ($rndkey0,&QWP(32,$key_));
|
||||
&mov ($rounds,$rounds_);
|
||||
&aesenc ($inout2,$rndkey1);
|
||||
&aesenc ($inout3,$rndkey1);
|
||||
&aesenc ($inout4,$rndkey1);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&aesenc ($inout5,$rndkey1);
|
||||
|
||||
&call (&label("_aesni_encrypt6_enter"));
|
||||
@@ -882,12 +927,12 @@ if ($PREFIX eq "aesni") {
|
||||
&movups (&QWP(0,$out),$inout0);
|
||||
&movdqa ($rndkey0,&QWP(16,"esp")); # load increment
|
||||
&xorps ($inout2,$rndkey1);
|
||||
&movdqa ($rndkey1,&QWP(48,"esp")); # load 1st triplet
|
||||
&movdqa ($rndkey1,&QWP(64,"esp")); # load 2nd triplet
|
||||
&movups (&QWP(0x10,$out),$inout1);
|
||||
&movups (&QWP(0x20,$out),$inout2);
|
||||
|
||||
&paddd ($rndkey1,$rndkey0); # 1st triplet increment
|
||||
&paddd ($rndkey0,&QWP(64,"esp")); # 2nd triplet increment
|
||||
&paddd ($rndkey1,$rndkey0); # 2nd triplet increment
|
||||
&paddd ($rndkey0,&QWP(48,"esp")); # 1st triplet increment
|
||||
&movdqa ($inout0,&QWP(0,"esp")); # load byte swap mask
|
||||
|
||||
&movups ($inout1,&QWP(0x30,$inp));
|
||||
@@ -895,44 +940,44 @@ if ($PREFIX eq "aesni") {
|
||||
&xorps ($inout3,$inout1);
|
||||
&movups ($inout1,&QWP(0x50,$inp));
|
||||
&lea ($inp,&DWP(0x60,$inp));
|
||||
&movdqa (&QWP(48,"esp"),$rndkey1); # save 1st triplet
|
||||
&pshufb ($rndkey1,$inout0); # byte swap
|
||||
&movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet
|
||||
&pshufb ($rndkey0,$inout0); # byte swap
|
||||
&xorps ($inout4,$inout2);
|
||||
&movups (&QWP(0x30,$out),$inout3);
|
||||
&xorps ($inout5,$inout1);
|
||||
&movdqa (&QWP(64,"esp"),$rndkey0); # save 2nd triplet
|
||||
&pshufb ($rndkey0,$inout0); # byte swap
|
||||
&movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet
|
||||
&pshufb ($rndkey1,$inout0); # byte swap
|
||||
&movups (&QWP(0x40,$out),$inout4);
|
||||
&pshufd ($inout0,$rndkey1,3<<6);
|
||||
&pshufd ($inout0,$rndkey0,3<<6);
|
||||
&movups (&QWP(0x50,$out),$inout5);
|
||||
&lea ($out,&DWP(0x60,$out));
|
||||
|
||||
&mov ($rounds,$rounds_);
|
||||
&pshufd ($inout1,$rndkey1,2<<6);
|
||||
&pshufd ($inout1,$rndkey0,2<<6);
|
||||
&sub ($len,6);
|
||||
&jnc (&label("ctr32_loop6"));
|
||||
|
||||
&add ($len,6);
|
||||
&jz (&label("ctr32_ret"));
|
||||
&movdqu ($inout5,&QWP(0,$key_));
|
||||
&mov ($key,$key_);
|
||||
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds
|
||||
&movdqa ($inout5,&QWP(32,"esp")); # pull count-less ivec
|
||||
&pxor ($inout5,&QWP(32,"esp")); # restore count-less ivec
|
||||
&mov ($rounds,&DWP(240,$key_)); # restore $rounds
|
||||
|
||||
&set_label("ctr32_tail");
|
||||
&por ($inout0,$inout5);
|
||||
&cmp ($len,2);
|
||||
&jb (&label("ctr32_one"));
|
||||
|
||||
&pshufd ($inout2,$rndkey1,1<<6);
|
||||
&pshufd ($inout2,$rndkey0,1<<6);
|
||||
&por ($inout1,$inout5);
|
||||
&je (&label("ctr32_two"));
|
||||
|
||||
&pshufd ($inout3,$rndkey0,3<<6);
|
||||
&pshufd ($inout3,$rndkey1,3<<6);
|
||||
&por ($inout2,$inout5);
|
||||
&cmp ($len,4);
|
||||
&jb (&label("ctr32_three"));
|
||||
|
||||
&pshufd ($inout4,$rndkey0,2<<6);
|
||||
&pshufd ($inout4,$rndkey1,2<<6);
|
||||
&por ($inout3,$inout5);
|
||||
&je (&label("ctr32_four"));
|
||||
|
||||
@@ -970,7 +1015,7 @@ if ($PREFIX eq "aesni") {
|
||||
&jmp (&label("ctr32_ret"));
|
||||
|
||||
&set_label("ctr32_two",16);
|
||||
&call ("_aesni_encrypt3");
|
||||
&call ("_aesni_encrypt2");
|
||||
&movups ($inout3,&QWP(0,$inp));
|
||||
&movups ($inout4,&QWP(0x10,$inp));
|
||||
&xorps ($inout0,$inout3);
|
||||
@@ -1057,8 +1102,10 @@ if ($PREFIX eq "aesni") {
|
||||
&sub ($len,16*6);
|
||||
&jc (&label("xts_enc_short"));
|
||||
|
||||
&shr ($rounds,1);
|
||||
&mov ($rounds_,$rounds);
|
||||
&shl ($rounds,4);
|
||||
&mov ($rounds_,16);
|
||||
&sub ($rounds_,$rounds);
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&jmp (&label("xts_enc_loop6"));
|
||||
|
||||
&set_label("xts_enc_loop6",16);
|
||||
@@ -1080,6 +1127,7 @@ if ($PREFIX eq "aesni") {
|
||||
&pxor ($inout5,$tweak);
|
||||
|
||||
# inline _aesni_encrypt6 prologue and flip xor with tweak and key[0]
|
||||
&mov ($rounds,$rounds_); # restore $rounds
|
||||
&movdqu ($inout1,&QWP(16*1,$inp));
|
||||
&xorps ($inout0,$rndkey0); # input^=rndkey[0]
|
||||
&movdqu ($inout2,&QWP(16*2,$inp));
|
||||
@@ -1096,19 +1144,17 @@ if ($PREFIX eq "aesni") {
|
||||
&pxor ($inout5,$rndkey1);
|
||||
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&lea ($key,&DWP(32,$key_));
|
||||
&pxor ($inout1,&QWP(16*1,"esp"));
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&pxor ($inout2,&QWP(16*2,"esp"));
|
||||
&aesenc ($inout1,$rndkey1);
|
||||
&aesenc ($inout0,$rndkey1);
|
||||
&pxor ($inout3,&QWP(16*3,"esp"));
|
||||
&dec ($rounds);
|
||||
&aesenc ($inout2,$rndkey1);
|
||||
&pxor ($inout4,&QWP(16*4,"esp"));
|
||||
&aesenc ($inout3,$rndkey1);
|
||||
&aesenc ($inout1,$rndkey1);
|
||||
&pxor ($inout5,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(32,$key_));
|
||||
&aesenc ($inout2,$rndkey1);
|
||||
&aesenc ($inout3,$rndkey1);
|
||||
&aesenc ($inout4,$rndkey1);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&aesenc ($inout5,$rndkey1);
|
||||
&call (&label("_aesni_encrypt6_enter"));
|
||||
|
||||
@@ -1135,13 +1181,12 @@ if ($PREFIX eq "aesni") {
|
||||
&paddq ($tweak,$tweak); # &psllq($tweak,1);
|
||||
&pand ($twres,$twmask); # isolate carry and residue
|
||||
&pcmpgtd($twtmp,$tweak); # broadcast upper bits
|
||||
&mov ($rounds,$rounds_); # restore $rounds
|
||||
&pxor ($tweak,$twres);
|
||||
|
||||
&sub ($len,16*6);
|
||||
&jnc (&label("xts_enc_loop6"));
|
||||
|
||||
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds
|
||||
&mov ($rounds,&DWP(240,$key_)); # restore $rounds
|
||||
&mov ($key,$key_); # restore $key
|
||||
&mov ($rounds_,$rounds);
|
||||
|
||||
@@ -1241,9 +1286,8 @@ if ($PREFIX eq "aesni") {
|
||||
&lea ($inp,&DWP(16*2,$inp));
|
||||
&xorps ($inout0,$inout3); # input^=tweak
|
||||
&xorps ($inout1,$inout4);
|
||||
&xorps ($inout2,$inout2);
|
||||
|
||||
&call ("_aesni_encrypt3");
|
||||
&call ("_aesni_encrypt2");
|
||||
|
||||
&xorps ($inout0,$inout3); # output^=tweak
|
||||
&xorps ($inout1,$inout4);
|
||||
@@ -1399,8 +1443,10 @@ if ($PREFIX eq "aesni") {
|
||||
&sub ($len,16*6);
|
||||
&jc (&label("xts_dec_short"));
|
||||
|
||||
&shr ($rounds,1);
|
||||
&mov ($rounds_,$rounds);
|
||||
&shl ($rounds,4);
|
||||
&mov ($rounds_,16);
|
||||
&sub ($rounds_,$rounds);
|
||||
&lea ($key,&DWP(32,$key,$rounds));
|
||||
&jmp (&label("xts_dec_loop6"));
|
||||
|
||||
&set_label("xts_dec_loop6",16);
|
||||
@@ -1422,6 +1468,7 @@ if ($PREFIX eq "aesni") {
|
||||
&pxor ($inout5,$tweak);
|
||||
|
||||
# inline _aesni_encrypt6 prologue and flip xor with tweak and key[0]
|
||||
&mov ($rounds,$rounds_);
|
||||
&movdqu ($inout1,&QWP(16*1,$inp));
|
||||
&xorps ($inout0,$rndkey0); # input^=rndkey[0]
|
||||
&movdqu ($inout2,&QWP(16*2,$inp));
|
||||
@@ -1438,19 +1485,17 @@ if ($PREFIX eq "aesni") {
|
||||
&pxor ($inout5,$rndkey1);
|
||||
|
||||
&$movekey ($rndkey1,&QWP(16,$key_));
|
||||
&lea ($key,&DWP(32,$key_));
|
||||
&pxor ($inout1,&QWP(16*1,"esp"));
|
||||
&aesdec ($inout0,$rndkey1);
|
||||
&pxor ($inout2,&QWP(16*2,"esp"));
|
||||
&aesdec ($inout1,$rndkey1);
|
||||
&aesdec ($inout0,$rndkey1);
|
||||
&pxor ($inout3,&QWP(16*3,"esp"));
|
||||
&dec ($rounds);
|
||||
&aesdec ($inout2,$rndkey1);
|
||||
&pxor ($inout4,&QWP(16*4,"esp"));
|
||||
&aesdec ($inout3,$rndkey1);
|
||||
&aesdec ($inout1,$rndkey1);
|
||||
&pxor ($inout5,$rndkey0);
|
||||
&$movekey ($rndkey0,&QWP(32,$key_));
|
||||
&aesdec ($inout2,$rndkey1);
|
||||
&aesdec ($inout3,$rndkey1);
|
||||
&aesdec ($inout4,$rndkey1);
|
||||
&$movekey ($rndkey0,&QWP(0,$key));
|
||||
&aesdec ($inout5,$rndkey1);
|
||||
&call (&label("_aesni_decrypt6_enter"));
|
||||
|
||||
@@ -1477,13 +1522,12 @@ if ($PREFIX eq "aesni") {
|
||||
&paddq ($tweak,$tweak); # &psllq($tweak,1);
|
||||
&pand ($twres,$twmask); # isolate carry and residue
|
||||
&pcmpgtd($twtmp,$tweak); # broadcast upper bits
|
||||
&mov ($rounds,$rounds_); # restore $rounds
|
||||
&pxor ($tweak,$twres);
|
||||
|
||||
&sub ($len,16*6);
|
||||
&jnc (&label("xts_dec_loop6"));
|
||||
|
||||
&lea ($rounds,&DWP(1,"",$rounds,2)); # restore $rounds
|
||||
&mov ($rounds,&DWP(240,$key_)); # restore $rounds
|
||||
&mov ($key,$key_); # restore $key
|
||||
&mov ($rounds_,$rounds);
|
||||
|
||||
@@ -1584,7 +1628,7 @@ if ($PREFIX eq "aesni") {
|
||||
&xorps ($inout0,$inout3); # input^=tweak
|
||||
&xorps ($inout1,$inout4);
|
||||
|
||||
&call ("_aesni_decrypt3");
|
||||
&call ("_aesni_decrypt2");
|
||||
|
||||
&xorps ($inout0,$inout3); # output^=tweak
|
||||
&xorps ($inout1,$inout4);
|
||||
@@ -1816,7 +1860,7 @@ if ($PREFIX eq "aesni") {
|
||||
&movups (&QWP(0x10,$out),$inout1);
|
||||
&lea ($inp,&DWP(0x60,$inp));
|
||||
&movups (&QWP(0x20,$out),$inout2);
|
||||
&mov ($rounds,$rounds_) # restore $rounds
|
||||
&mov ($rounds,$rounds_); # restore $rounds
|
||||
&movups (&QWP(0x30,$out),$inout3);
|
||||
&mov ($key,$key_); # restore $key
|
||||
&movups (&QWP(0x40,$out),$inout4);
|
||||
@@ -1884,8 +1928,7 @@ if ($PREFIX eq "aesni") {
|
||||
&jmp (&label("cbc_dec_tail_collected"));
|
||||
|
||||
&set_label("cbc_dec_two",16);
|
||||
&xorps ($inout2,$inout2);
|
||||
&call ("_aesni_decrypt3");
|
||||
&call ("_aesni_decrypt2");
|
||||
&xorps ($inout0,$ivec);
|
||||
&xorps ($inout1,$in0);
|
||||
&movups (&QWP(0,$out),$inout0);
|
||||
@@ -2015,7 +2058,7 @@ if ($PREFIX eq "aesni") {
|
||||
&set_label("12rounds",16);
|
||||
&movq ("xmm2",&QWP(16,"eax")); # remaining 1/3 of *userKey
|
||||
&mov ($rounds,11);
|
||||
&$movekey (&QWP(-16,$key),"xmm0") # round 0
|
||||
&$movekey (&QWP(-16,$key),"xmm0"); # round 0
|
||||
&aeskeygenassist("xmm1","xmm2",0x01); # round 1,2
|
||||
&call (&label("key_192a_cold"));
|
||||
&aeskeygenassist("xmm1","xmm2",0x02); # round 2,3
|
||||
@@ -2152,7 +2195,7 @@ if ($PREFIX eq "aesni") {
|
||||
&mov ($key,&wparam(2));
|
||||
&call ("_aesni_set_encrypt_key");
|
||||
&mov ($key,&wparam(2));
|
||||
&shl ($rounds,4) # rounds-1 after _aesni_set_encrypt_key
|
||||
&shl ($rounds,4); # rounds-1 after _aesni_set_encrypt_key
|
||||
&test ("eax","eax");
|
||||
&jnz (&label("dec_key_ret"));
|
||||
&lea ("eax",&DWP(16,$key,$rounds)); # end of key schedule
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
919
crypto/aes/asm/aest4-sparcv9.pl
Normal file
919
crypto/aes/asm/aest4-sparcv9.pl
Normal file
@@ -0,0 +1,919 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# ====================================================================
|
||||
# Written by David S. Miller <davem@devemloft.net> and Andy Polyakov
|
||||
# <appro@openssl.org>. The module is licensed under 2-clause BSD
|
||||
# license. October 2012. All rights reserved.
|
||||
# ====================================================================
|
||||
|
||||
######################################################################
|
||||
# AES for SPARC T4.
|
||||
#
|
||||
# AES round instructions complete in 3 cycles and can be issued every
|
||||
# cycle. It means that round calculations should take 4*rounds cycles,
|
||||
# because any given round instruction depends on result of *both*
|
||||
# previous instructions:
|
||||
#
|
||||
# |0 |1 |2 |3 |4
|
||||
# |01|01|01|
|
||||
# |23|23|23|
|
||||
# |01|01|...
|
||||
# |23|...
|
||||
#
|
||||
# Provided that fxor [with IV] takes 3 cycles to complete, critical
|
||||
# path length for CBC encrypt would be 3+4*rounds, or in other words
|
||||
# it should process one byte in at least (3+4*rounds)/16 cycles. This
|
||||
# estimate doesn't account for "collateral" instructions, such as
|
||||
# fetching input from memory, xor-ing it with zero-round key and
|
||||
# storing the result. Yet, *measured* performance [for data aligned
|
||||
# at 64-bit boundary!] deviates from this equation by less than 0.5%:
|
||||
#
|
||||
# 128-bit key 192- 256-
|
||||
# CBC encrypt 2.70/2.90(*) 3.20/3.40 3.70/3.90
|
||||
# (*) numbers after slash are for
|
||||
# misaligned data.
|
||||
#
|
||||
# Out-of-order execution logic managed to fully overlap "collateral"
|
||||
# instructions with those on critical path. Amazing!
|
||||
#
|
||||
# As with Intel AES-NI, question is if it's possible to improve
|
||||
# performance of parallelizeable modes by interleaving round
|
||||
# instructions. Provided round instruction latency and throughput
|
||||
# optimal interleave factor is 2. But can we expect 2x performance
|
||||
# improvement? Well, as round instructions can be issued one per
|
||||
# cycle, they don't saturate the 2-way issue pipeline and therefore
|
||||
# there is room for "collateral" calculations... Yet, 2x speed-up
|
||||
# over CBC encrypt remains unattaintable:
|
||||
#
|
||||
# 128-bit key 192- 256-
|
||||
# CBC decrypt 1.64/2.11 1.89/2.37 2.23/2.61
|
||||
# CTR 1.64/2.08(*) 1.89/2.33 2.23/2.61
|
||||
# (*) numbers after slash are for
|
||||
# misaligned data.
|
||||
#
|
||||
# Estimates based on amount of instructions under assumption that
|
||||
# round instructions are not pairable with any other instruction
|
||||
# suggest that latter is the actual case and pipeline runs
|
||||
# underutilized. It should be noted that T4 out-of-order execution
|
||||
# logic is so capable that performance gain from 2x interleave is
|
||||
# not even impressive, ~7-13% over non-interleaved code, largest
|
||||
# for 256-bit keys.
|
||||
|
||||
# To anchor to something else, software implementation processes
|
||||
# one byte in 29 cycles with 128-bit key on same processor. Intel
|
||||
# Sandy Bridge encrypts byte in 5.07 cycles in CBC mode and decrypts
|
||||
# in 0.93, naturally with AES-NI.
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "sparcv9_modes.pl";
|
||||
|
||||
&asm_init(@ARGV);
|
||||
|
||||
$::evp=1; # if $evp is set to 0, script generates module with
|
||||
# AES_[en|de]crypt, AES_set_[en|de]crypt_key and AES_cbc_encrypt entry
|
||||
# points. These however are not fully compatible with openssl/aes.h,
|
||||
# because they expect AES_KEY to be aligned at 64-bit boundary. When
|
||||
# used through EVP, alignment is arranged at EVP layer. Second thing
|
||||
# that is arranged by EVP is at least 32-bit alignment of IV.
|
||||
|
||||
######################################################################
|
||||
# single-round subroutines
|
||||
#
|
||||
{
|
||||
my ($inp,$out,$key,$rounds,$tmp,$mask)=map("%o$_",(0..5));
|
||||
|
||||
$code.=<<___ if ($::abibits==64);
|
||||
.register %g2,#scratch
|
||||
.register %g3,#scratch
|
||||
|
||||
___
|
||||
$code.=<<___;
|
||||
.text
|
||||
|
||||
.globl aes_t4_encrypt
|
||||
.align 32
|
||||
aes_t4_encrypt:
|
||||
andcc $inp, 7, %g1 ! is input aligned?
|
||||
andn $inp, 7, $inp
|
||||
|
||||
ldx [$key + 0], %g4
|
||||
ldx [$key + 8], %g5
|
||||
|
||||
ldx [$inp + 0], %o4
|
||||
bz,pt %icc, 1f
|
||||
ldx [$inp + 8], %o5
|
||||
ldx [$inp + 16], $inp
|
||||
sll %g1, 3, %g1
|
||||
sub %g0, %g1, %o3
|
||||
sllx %o4, %g1, %o4
|
||||
sllx %o5, %g1, %g1
|
||||
srlx %o5, %o3, %o5
|
||||
srlx $inp, %o3, %o3
|
||||
or %o5, %o4, %o4
|
||||
or %o3, %g1, %o5
|
||||
1:
|
||||
ld [$key + 240], $rounds
|
||||
ldd [$key + 16], %f12
|
||||
ldd [$key + 24], %f14
|
||||
xor %g4, %o4, %o4
|
||||
xor %g5, %o5, %o5
|
||||
movxtod %o4, %f0
|
||||
movxtod %o5, %f2
|
||||
srl $rounds, 1, $rounds
|
||||
ldd [$key + 32], %f16
|
||||
sub $rounds, 1, $rounds
|
||||
ldd [$key + 40], %f18
|
||||
add $key, 48, $key
|
||||
|
||||
.Lenc:
|
||||
aes_eround01 %f12, %f0, %f2, %f4
|
||||
aes_eround23 %f14, %f0, %f2, %f2
|
||||
ldd [$key + 0], %f12
|
||||
ldd [$key + 8], %f14
|
||||
sub $rounds,1,$rounds
|
||||
aes_eround01 %f16, %f4, %f2, %f0
|
||||
aes_eround23 %f18, %f4, %f2, %f2
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
brnz,pt $rounds, .Lenc
|
||||
add $key, 32, $key
|
||||
|
||||
andcc $out, 7, $tmp ! is output aligned?
|
||||
aes_eround01 %f12, %f0, %f2, %f4
|
||||
aes_eround23 %f14, %f0, %f2, %f2
|
||||
aes_eround01_l %f16, %f4, %f2, %f0
|
||||
aes_eround23_l %f18, %f4, %f2, %f2
|
||||
|
||||
bnz,pn %icc, 2f
|
||||
nop
|
||||
|
||||
std %f0, [$out + 0]
|
||||
retl
|
||||
std %f2, [$out + 8]
|
||||
|
||||
2: alignaddrl $out, %g0, $out
|
||||
mov 0xff, $mask
|
||||
srl $mask, $tmp, $mask
|
||||
|
||||
faligndata %f0, %f0, %f4
|
||||
faligndata %f0, %f2, %f6
|
||||
faligndata %f2, %f2, %f8
|
||||
|
||||
stda %f4, [$out + $mask]0xc0 ! partial store
|
||||
std %f6, [$out + 8]
|
||||
add $out, 16, $out
|
||||
orn %g0, $mask, $mask
|
||||
retl
|
||||
stda %f8, [$out + $mask]0xc0 ! partial store
|
||||
.type aes_t4_encrypt,#function
|
||||
.size aes_t4_encrypt,.-aes_t4_encrypt
|
||||
|
||||
.globl aes_t4_decrypt
|
||||
.align 32
|
||||
aes_t4_decrypt:
|
||||
andcc $inp, 7, %g1 ! is input aligned?
|
||||
andn $inp, 7, $inp
|
||||
|
||||
ldx [$key + 0], %g4
|
||||
ldx [$key + 8], %g5
|
||||
|
||||
ldx [$inp + 0], %o4
|
||||
bz,pt %icc, 1f
|
||||
ldx [$inp + 8], %o5
|
||||
ldx [$inp + 16], $inp
|
||||
sll %g1, 3, %g1
|
||||
sub %g0, %g1, %o3
|
||||
sllx %o4, %g1, %o4
|
||||
sllx %o5, %g1, %g1
|
||||
srlx %o5, %o3, %o5
|
||||
srlx $inp, %o3, %o3
|
||||
or %o5, %o4, %o4
|
||||
or %o3, %g1, %o5
|
||||
1:
|
||||
ld [$key + 240], $rounds
|
||||
ldd [$key + 16], %f12
|
||||
ldd [$key + 24], %f14
|
||||
xor %g4, %o4, %o4
|
||||
xor %g5, %o5, %o5
|
||||
movxtod %o4, %f0
|
||||
movxtod %o5, %f2
|
||||
srl $rounds, 1, $rounds
|
||||
ldd [$key + 32], %f16
|
||||
sub $rounds, 1, $rounds
|
||||
ldd [$key + 40], %f18
|
||||
add $key, 48, $key
|
||||
|
||||
.Ldec:
|
||||
aes_dround01 %f12, %f0, %f2, %f4
|
||||
aes_dround23 %f14, %f0, %f2, %f2
|
||||
ldd [$key + 0], %f12
|
||||
ldd [$key + 8], %f14
|
||||
sub $rounds,1,$rounds
|
||||
aes_dround01 %f16, %f4, %f2, %f0
|
||||
aes_dround23 %f18, %f4, %f2, %f2
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
brnz,pt $rounds, .Ldec
|
||||
add $key, 32, $key
|
||||
|
||||
andcc $out, 7, $tmp ! is output aligned?
|
||||
aes_dround01 %f12, %f0, %f2, %f4
|
||||
aes_dround23 %f14, %f0, %f2, %f2
|
||||
aes_dround01_l %f16, %f4, %f2, %f0
|
||||
aes_dround23_l %f18, %f4, %f2, %f2
|
||||
|
||||
bnz,pn %icc, 2f
|
||||
nop
|
||||
|
||||
std %f0, [$out + 0]
|
||||
retl
|
||||
std %f2, [$out + 8]
|
||||
|
||||
2: alignaddrl $out, %g0, $out
|
||||
mov 0xff, $mask
|
||||
srl $mask, $tmp, $mask
|
||||
|
||||
faligndata %f0, %f0, %f4
|
||||
faligndata %f0, %f2, %f6
|
||||
faligndata %f2, %f2, %f8
|
||||
|
||||
stda %f4, [$out + $mask]0xc0 ! partial store
|
||||
std %f6, [$out + 8]
|
||||
add $out, 16, $out
|
||||
orn %g0, $mask, $mask
|
||||
retl
|
||||
stda %f8, [$out + $mask]0xc0 ! partial store
|
||||
.type aes_t4_decrypt,#function
|
||||
.size aes_t4_decrypt,.-aes_t4_decrypt
|
||||
___
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# key setup subroutines
|
||||
#
|
||||
{
|
||||
my ($inp,$bits,$out,$tmp)=map("%o$_",(0..5));
|
||||
$code.=<<___;
|
||||
.globl aes_t4_set_encrypt_key
|
||||
.align 32
|
||||
aes_t4_set_encrypt_key:
|
||||
.Lset_encrypt_key:
|
||||
and $inp, 7, $tmp
|
||||
alignaddr $inp, %g0, $inp
|
||||
cmp $bits, 192
|
||||
ldd [$inp + 0], %f0
|
||||
bl,pt %icc,.L128
|
||||
ldd [$inp + 8], %f2
|
||||
|
||||
be,pt %icc,.L192
|
||||
ldd [$inp + 16], %f4
|
||||
brz,pt $tmp, .L256aligned
|
||||
ldd [$inp + 24], %f6
|
||||
|
||||
ldd [$inp + 32], %f8
|
||||
faligndata %f0, %f2, %f0
|
||||
faligndata %f2, %f4, %f2
|
||||
faligndata %f4, %f6, %f4
|
||||
faligndata %f6, %f8, %f6
|
||||
.L256aligned:
|
||||
___
|
||||
for ($i=0; $i<6; $i++) {
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `32*$i+0`]
|
||||
aes_kexpand1 %f0, %f6, $i, %f0
|
||||
std %f2, [$out + `32*$i+8`]
|
||||
aes_kexpand2 %f2, %f0, %f2
|
||||
std %f4, [$out + `32*$i+16`]
|
||||
aes_kexpand0 %f4, %f2, %f4
|
||||
std %f6, [$out + `32*$i+24`]
|
||||
aes_kexpand2 %f6, %f4, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `32*$i+0`]
|
||||
aes_kexpand1 %f0, %f6, $i, %f0
|
||||
std %f2, [$out + `32*$i+8`]
|
||||
aes_kexpand2 %f2, %f0, %f2
|
||||
std %f4, [$out + `32*$i+16`]
|
||||
std %f6, [$out + `32*$i+24`]
|
||||
std %f0, [$out + `32*$i+32`]
|
||||
std %f2, [$out + `32*$i+40`]
|
||||
|
||||
mov 14, $tmp
|
||||
st $tmp, [$out + 240]
|
||||
retl
|
||||
xor %o0, %o0, %o0
|
||||
|
||||
.align 16
|
||||
.L192:
|
||||
brz,pt $tmp, .L192aligned
|
||||
nop
|
||||
|
||||
ldd [$inp + 24], %f6
|
||||
faligndata %f0, %f2, %f0
|
||||
faligndata %f2, %f4, %f2
|
||||
faligndata %f4, %f6, %f4
|
||||
.L192aligned:
|
||||
___
|
||||
for ($i=0; $i<7; $i++) {
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `24*$i+0`]
|
||||
aes_kexpand1 %f0, %f4, $i, %f0
|
||||
std %f2, [$out + `24*$i+8`]
|
||||
aes_kexpand2 %f2, %f0, %f2
|
||||
std %f4, [$out + `24*$i+16`]
|
||||
aes_kexpand2 %f4, %f2, %f4
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `24*$i+0`]
|
||||
aes_kexpand1 %f0, %f4, $i, %f0
|
||||
std %f2, [$out + `24*$i+8`]
|
||||
aes_kexpand2 %f2, %f0, %f2
|
||||
std %f4, [$out + `24*$i+16`]
|
||||
std %f0, [$out + `24*$i+24`]
|
||||
std %f2, [$out + `24*$i+32`]
|
||||
|
||||
mov 12, $tmp
|
||||
st $tmp, [$out + 240]
|
||||
retl
|
||||
xor %o0, %o0, %o0
|
||||
|
||||
.align 16
|
||||
.L128:
|
||||
brz,pt $tmp, .L128aligned
|
||||
nop
|
||||
|
||||
ldd [$inp + 16], %f4
|
||||
faligndata %f0, %f2, %f0
|
||||
faligndata %f2, %f4, %f2
|
||||
.L128aligned:
|
||||
___
|
||||
for ($i=0; $i<10; $i++) {
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `16*$i+0`]
|
||||
aes_kexpand1 %f0, %f2, $i, %f0
|
||||
std %f2, [$out + `16*$i+8`]
|
||||
aes_kexpand2 %f2, %f0, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
std %f0, [$out + `16*$i+0`]
|
||||
std %f2, [$out + `16*$i+8`]
|
||||
|
||||
mov 10, $tmp
|
||||
st $tmp, [$out + 240]
|
||||
retl
|
||||
xor %o0, %o0, %o0
|
||||
.type aes_t4_set_encrypt_key,#function
|
||||
.size aes_t4_set_encrypt_key,.-aes_t4_set_encrypt_key
|
||||
|
||||
.globl aes_t4_set_decrypt_key
|
||||
.align 32
|
||||
aes_t4_set_decrypt_key:
|
||||
mov %o7, %o5
|
||||
call .Lset_encrypt_key
|
||||
nop
|
||||
|
||||
mov %o5, %o7
|
||||
sll $tmp, 4, $inp ! $tmp is number of rounds
|
||||
add $tmp, 2, $tmp
|
||||
add $out, $inp, $inp ! $inp=$out+16*rounds
|
||||
srl $tmp, 2, $tmp ! $tmp=(rounds+2)/4
|
||||
|
||||
.Lkey_flip:
|
||||
ldd [$out + 0], %f0
|
||||
ldd [$out + 8], %f2
|
||||
ldd [$out + 16], %f4
|
||||
ldd [$out + 24], %f6
|
||||
ldd [$inp + 0], %f8
|
||||
ldd [$inp + 8], %f10
|
||||
ldd [$inp - 16], %f12
|
||||
ldd [$inp - 8], %f14
|
||||
sub $tmp, 1, $tmp
|
||||
std %f0, [$inp + 0]
|
||||
std %f2, [$inp + 8]
|
||||
std %f4, [$inp - 16]
|
||||
std %f6, [$inp - 8]
|
||||
std %f8, [$out + 0]
|
||||
std %f10, [$out + 8]
|
||||
std %f12, [$out + 16]
|
||||
std %f14, [$out + 24]
|
||||
add $out, 32, $out
|
||||
brnz $tmp, .Lkey_flip
|
||||
sub $inp, 32, $inp
|
||||
|
||||
retl
|
||||
xor %o0, %o0, %o0
|
||||
.type aes_t4_set_decrypt_key,#function
|
||||
.size aes_t4_set_decrypt_key,.-aes_t4_set_decrypt_key
|
||||
___
|
||||
}
|
||||
|
||||
{{{
|
||||
my ($inp,$out,$len,$key,$ivec,$enc)=map("%i$_",(0..5));
|
||||
my ($ileft,$iright,$ooff,$omask,$ivoff)=map("%l$_",(1..7));
|
||||
|
||||
$code.=<<___;
|
||||
.align 32
|
||||
_aes128_encrypt_1x:
|
||||
___
|
||||
for ($i=0; $i<4; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f48, %f0, %f2, %f4
|
||||
aes_eround23 %f50, %f0, %f2, %f2
|
||||
aes_eround01_l %f52, %f4, %f2, %f0
|
||||
retl
|
||||
aes_eround23_l %f54, %f4, %f2, %f2
|
||||
.type _aes128_encrypt_1x,#function
|
||||
.size _aes128_encrypt_1x,.-_aes128_encrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes128_encrypt_2x:
|
||||
___
|
||||
for ($i=0; $i<4; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f48, %f0, %f2, %f8
|
||||
aes_eround23 %f50, %f0, %f2, %f2
|
||||
aes_eround01 %f48, %f4, %f6, %f10
|
||||
aes_eround23 %f50, %f4, %f6, %f6
|
||||
aes_eround01_l %f52, %f8, %f2, %f0
|
||||
aes_eround23_l %f54, %f8, %f2, %f2
|
||||
aes_eround01_l %f52, %f10, %f6, %f4
|
||||
retl
|
||||
aes_eround23_l %f54, %f10, %f6, %f6
|
||||
.type _aes128_encrypt_2x,#function
|
||||
.size _aes128_encrypt_2x,.-_aes128_encrypt_2x
|
||||
|
||||
.align 32
|
||||
_aes128_loadkey:
|
||||
ldx [$key + 0], %g4
|
||||
ldx [$key + 8], %g5
|
||||
___
|
||||
for ($i=2; $i<22;$i++) { # load key schedule
|
||||
$code.=<<___;
|
||||
ldd [$key + `8*$i`], %f`12+2*$i`
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
retl
|
||||
nop
|
||||
.type _aes128_loadkey,#function
|
||||
.size _aes128_loadkey,.-_aes128_loadkey
|
||||
_aes128_load_enckey=_aes128_loadkey
|
||||
_aes128_load_deckey=_aes128_loadkey
|
||||
|
||||
___
|
||||
|
||||
&alg_cbc_encrypt_implement("aes",128);
|
||||
if ($::evp) {
|
||||
&alg_ctr32_implement("aes",128);
|
||||
&alg_xts_implement("aes",128,"en");
|
||||
&alg_xts_implement("aes",128,"de");
|
||||
}
|
||||
&alg_cbc_decrypt_implement("aes",128);
|
||||
|
||||
$code.=<<___;
|
||||
.align 32
|
||||
_aes128_decrypt_1x:
|
||||
___
|
||||
for ($i=0; $i<4; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f48, %f0, %f2, %f4
|
||||
aes_dround23 %f50, %f0, %f2, %f2
|
||||
aes_dround01_l %f52, %f4, %f2, %f0
|
||||
retl
|
||||
aes_dround23_l %f54, %f4, %f2, %f2
|
||||
.type _aes128_decrypt_1x,#function
|
||||
.size _aes128_decrypt_1x,.-_aes128_decrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes128_decrypt_2x:
|
||||
___
|
||||
for ($i=0; $i<4; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f48, %f0, %f2, %f8
|
||||
aes_dround23 %f50, %f0, %f2, %f2
|
||||
aes_dround01 %f48, %f4, %f6, %f10
|
||||
aes_dround23 %f50, %f4, %f6, %f6
|
||||
aes_dround01_l %f52, %f8, %f2, %f0
|
||||
aes_dround23_l %f54, %f8, %f2, %f2
|
||||
aes_dround01_l %f52, %f10, %f6, %f4
|
||||
retl
|
||||
aes_dround23_l %f54, %f10, %f6, %f6
|
||||
.type _aes128_decrypt_2x,#function
|
||||
.size _aes128_decrypt_2x,.-_aes128_decrypt_2x
|
||||
___
|
||||
|
||||
$code.=<<___;
|
||||
.align 32
|
||||
_aes192_encrypt_1x:
|
||||
___
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f56, %f0, %f2, %f4
|
||||
aes_eround23 %f58, %f0, %f2, %f2
|
||||
aes_eround01_l %f60, %f4, %f2, %f0
|
||||
retl
|
||||
aes_eround23_l %f62, %f4, %f2, %f2
|
||||
.type _aes192_encrypt_1x,#function
|
||||
.size _aes192_encrypt_1x,.-_aes192_encrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes192_encrypt_2x:
|
||||
___
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f56, %f0, %f2, %f8
|
||||
aes_eround23 %f58, %f0, %f2, %f2
|
||||
aes_eround01 %f56, %f4, %f6, %f10
|
||||
aes_eround23 %f58, %f4, %f6, %f6
|
||||
aes_eround01_l %f60, %f8, %f2, %f0
|
||||
aes_eround23_l %f62, %f8, %f2, %f2
|
||||
aes_eround01_l %f60, %f10, %f6, %f4
|
||||
retl
|
||||
aes_eround23_l %f62, %f10, %f6, %f6
|
||||
.type _aes192_encrypt_2x,#function
|
||||
.size _aes192_encrypt_2x,.-_aes192_encrypt_2x
|
||||
|
||||
.align 32
|
||||
_aes256_encrypt_1x:
|
||||
aes_eround01 %f16, %f0, %f2, %f4
|
||||
aes_eround23 %f18, %f0, %f2, %f2
|
||||
ldd [$key + 208], %f16
|
||||
ldd [$key + 216], %f18
|
||||
aes_eround01 %f20, %f4, %f2, %f0
|
||||
aes_eround23 %f22, %f4, %f2, %f2
|
||||
ldd [$key + 224], %f20
|
||||
ldd [$key + 232], %f22
|
||||
___
|
||||
for ($i=1; $i<6; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f16, %f0, %f2, %f4
|
||||
aes_eround23 %f18, %f0, %f2, %f2
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
aes_eround01_l %f20, %f4, %f2, %f0
|
||||
aes_eround23_l %f22, %f4, %f2, %f2
|
||||
ldd [$key + 32], %f20
|
||||
retl
|
||||
ldd [$key + 40], %f22
|
||||
.type _aes256_encrypt_1x,#function
|
||||
.size _aes256_encrypt_1x,.-_aes256_encrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes256_encrypt_2x:
|
||||
aes_eround01 %f16, %f0, %f2, %f8
|
||||
aes_eround23 %f18, %f0, %f2, %f2
|
||||
aes_eround01 %f16, %f4, %f6, %f10
|
||||
aes_eround23 %f18, %f4, %f6, %f6
|
||||
ldd [$key + 208], %f16
|
||||
ldd [$key + 216], %f18
|
||||
aes_eround01 %f20, %f8, %f2, %f0
|
||||
aes_eround23 %f22, %f8, %f2, %f2
|
||||
aes_eround01 %f20, %f10, %f6, %f4
|
||||
aes_eround23 %f22, %f10, %f6, %f6
|
||||
ldd [$key + 224], %f20
|
||||
ldd [$key + 232], %f22
|
||||
___
|
||||
for ($i=1; $i<6; $i++) {
|
||||
$code.=<<___;
|
||||
aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_eround01 %f16, %f0, %f2, %f8
|
||||
aes_eround23 %f18, %f0, %f2, %f2
|
||||
aes_eround01 %f16, %f4, %f6, %f10
|
||||
aes_eround23 %f18, %f4, %f6, %f6
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
aes_eround01_l %f20, %f8, %f2, %f0
|
||||
aes_eround23_l %f22, %f8, %f2, %f2
|
||||
aes_eround01_l %f20, %f10, %f6, %f4
|
||||
aes_eround23_l %f22, %f10, %f6, %f6
|
||||
ldd [$key + 32], %f20
|
||||
retl
|
||||
ldd [$key + 40], %f22
|
||||
.type _aes256_encrypt_2x,#function
|
||||
.size _aes256_encrypt_2x,.-_aes256_encrypt_2x
|
||||
|
||||
.align 32
|
||||
_aes192_loadkey:
|
||||
ldx [$key + 0], %g4
|
||||
ldx [$key + 8], %g5
|
||||
___
|
||||
for ($i=2; $i<26;$i++) { # load key schedule
|
||||
$code.=<<___;
|
||||
ldd [$key + `8*$i`], %f`12+2*$i`
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
retl
|
||||
nop
|
||||
.type _aes192_loadkey,#function
|
||||
.size _aes192_loadkey,.-_aes192_loadkey
|
||||
_aes256_loadkey=_aes192_loadkey
|
||||
_aes192_load_enckey=_aes192_loadkey
|
||||
_aes192_load_deckey=_aes192_loadkey
|
||||
_aes256_load_enckey=_aes192_loadkey
|
||||
_aes256_load_deckey=_aes192_loadkey
|
||||
___
|
||||
|
||||
&alg_cbc_encrypt_implement("aes",256);
|
||||
&alg_cbc_encrypt_implement("aes",192);
|
||||
if ($::evp) {
|
||||
&alg_ctr32_implement("aes",256);
|
||||
&alg_xts_implement("aes",256,"en");
|
||||
&alg_xts_implement("aes",256,"de");
|
||||
&alg_ctr32_implement("aes",192);
|
||||
}
|
||||
&alg_cbc_decrypt_implement("aes",192);
|
||||
&alg_cbc_decrypt_implement("aes",256);
|
||||
|
||||
$code.=<<___;
|
||||
.align 32
|
||||
_aes256_decrypt_1x:
|
||||
aes_dround01 %f16, %f0, %f2, %f4
|
||||
aes_dround23 %f18, %f0, %f2, %f2
|
||||
ldd [$key + 208], %f16
|
||||
ldd [$key + 216], %f18
|
||||
aes_dround01 %f20, %f4, %f2, %f0
|
||||
aes_dround23 %f22, %f4, %f2, %f2
|
||||
ldd [$key + 224], %f20
|
||||
ldd [$key + 232], %f22
|
||||
___
|
||||
for ($i=1; $i<6; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f16, %f0, %f2, %f4
|
||||
aes_dround23 %f18, %f0, %f2, %f2
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
aes_dround01_l %f20, %f4, %f2, %f0
|
||||
aes_dround23_l %f22, %f4, %f2, %f2
|
||||
ldd [$key + 32], %f20
|
||||
retl
|
||||
ldd [$key + 40], %f22
|
||||
.type _aes256_decrypt_1x,#function
|
||||
.size _aes256_decrypt_1x,.-_aes256_decrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes256_decrypt_2x:
|
||||
aes_dround01 %f16, %f0, %f2, %f8
|
||||
aes_dround23 %f18, %f0, %f2, %f2
|
||||
aes_dround01 %f16, %f4, %f6, %f10
|
||||
aes_dround23 %f18, %f4, %f6, %f6
|
||||
ldd [$key + 208], %f16
|
||||
ldd [$key + 216], %f18
|
||||
aes_dround01 %f20, %f8, %f2, %f0
|
||||
aes_dround23 %f22, %f8, %f2, %f2
|
||||
aes_dround01 %f20, %f10, %f6, %f4
|
||||
aes_dround23 %f22, %f10, %f6, %f6
|
||||
ldd [$key + 224], %f20
|
||||
ldd [$key + 232], %f22
|
||||
___
|
||||
for ($i=1; $i<6; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f16, %f0, %f2, %f8
|
||||
aes_dround23 %f18, %f0, %f2, %f2
|
||||
aes_dround01 %f16, %f4, %f6, %f10
|
||||
aes_dround23 %f18, %f4, %f6, %f6
|
||||
ldd [$key + 16], %f16
|
||||
ldd [$key + 24], %f18
|
||||
aes_dround01_l %f20, %f8, %f2, %f0
|
||||
aes_dround23_l %f22, %f8, %f2, %f2
|
||||
aes_dround01_l %f20, %f10, %f6, %f4
|
||||
aes_dround23_l %f22, %f10, %f6, %f6
|
||||
ldd [$key + 32], %f20
|
||||
retl
|
||||
ldd [$key + 40], %f22
|
||||
.type _aes256_decrypt_2x,#function
|
||||
.size _aes256_decrypt_2x,.-_aes256_decrypt_2x
|
||||
|
||||
.align 32
|
||||
_aes192_decrypt_1x:
|
||||
___
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f56, %f0, %f2, %f4
|
||||
aes_dround23 %f58, %f0, %f2, %f2
|
||||
aes_dround01_l %f60, %f4, %f2, %f0
|
||||
retl
|
||||
aes_dround23_l %f62, %f4, %f2, %f2
|
||||
.type _aes192_decrypt_1x,#function
|
||||
.size _aes192_decrypt_1x,.-_aes192_decrypt_1x
|
||||
|
||||
.align 32
|
||||
_aes192_decrypt_2x:
|
||||
___
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$code.=<<___;
|
||||
aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
|
||||
aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
|
||||
aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
|
||||
aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
|
||||
aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
|
||||
aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
|
||||
aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
aes_dround01 %f56, %f0, %f2, %f8
|
||||
aes_dround23 %f58, %f0, %f2, %f2
|
||||
aes_dround01 %f56, %f4, %f6, %f10
|
||||
aes_dround23 %f58, %f4, %f6, %f6
|
||||
aes_dround01_l %f60, %f8, %f2, %f0
|
||||
aes_dround23_l %f62, %f8, %f2, %f2
|
||||
aes_dround01_l %f60, %f10, %f6, %f4
|
||||
retl
|
||||
aes_dround23_l %f62, %f10, %f6, %f6
|
||||
.type _aes192_decrypt_2x,#function
|
||||
.size _aes192_decrypt_2x,.-_aes192_decrypt_2x
|
||||
___
|
||||
}}}
|
||||
|
||||
if (!$::evp) {
|
||||
$code.=<<___;
|
||||
.global AES_encrypt
|
||||
AES_encrypt=aes_t4_encrypt
|
||||
.global AES_decrypt
|
||||
AES_decrypt=aes_t4_decrypt
|
||||
.global AES_set_encrypt_key
|
||||
.align 32
|
||||
AES_set_encrypt_key:
|
||||
andcc %o2, 7, %g0 ! check alignment
|
||||
bnz,a,pn %icc, 1f
|
||||
mov -1, %o0
|
||||
brz,a,pn %o0, 1f
|
||||
mov -1, %o0
|
||||
brz,a,pn %o2, 1f
|
||||
mov -1, %o0
|
||||
andncc %o1, 0x1c0, %g0
|
||||
bnz,a,pn %icc, 1f
|
||||
mov -2, %o0
|
||||
cmp %o1, 128
|
||||
bl,a,pn %icc, 1f
|
||||
mov -2, %o0
|
||||
b aes_t4_set_encrypt_key
|
||||
nop
|
||||
1: retl
|
||||
nop
|
||||
.type AES_set_encrypt_key,#function
|
||||
.size AES_set_encrypt_key,.-AES_set_encrypt_key
|
||||
|
||||
.global AES_set_decrypt_key
|
||||
.align 32
|
||||
AES_set_decrypt_key:
|
||||
andcc %o2, 7, %g0 ! check alignment
|
||||
bnz,a,pn %icc, 1f
|
||||
mov -1, %o0
|
||||
brz,a,pn %o0, 1f
|
||||
mov -1, %o0
|
||||
brz,a,pn %o2, 1f
|
||||
mov -1, %o0
|
||||
andncc %o1, 0x1c0, %g0
|
||||
bnz,a,pn %icc, 1f
|
||||
mov -2, %o0
|
||||
cmp %o1, 128
|
||||
bl,a,pn %icc, 1f
|
||||
mov -2, %o0
|
||||
b aes_t4_set_decrypt_key
|
||||
nop
|
||||
1: retl
|
||||
nop
|
||||
.type AES_set_decrypt_key,#function
|
||||
.size AES_set_decrypt_key,.-AES_set_decrypt_key
|
||||
___
|
||||
|
||||
my ($inp,$out,$len,$key,$ivec,$enc)=map("%o$_",(0..5));
|
||||
|
||||
$code.=<<___;
|
||||
.globl AES_cbc_encrypt
|
||||
.align 32
|
||||
AES_cbc_encrypt:
|
||||
ld [$key + 240], %g1
|
||||
nop
|
||||
brz $enc, .Lcbc_decrypt
|
||||
cmp %g1, 12
|
||||
|
||||
bl,pt %icc, aes128_t4_cbc_encrypt
|
||||
nop
|
||||
be,pn %icc, aes192_t4_cbc_encrypt
|
||||
nop
|
||||
ba aes256_t4_cbc_encrypt
|
||||
nop
|
||||
|
||||
.Lcbc_decrypt:
|
||||
bl,pt %icc, aes128_t4_cbc_decrypt
|
||||
nop
|
||||
be,pn %icc, aes192_t4_cbc_decrypt
|
||||
nop
|
||||
ba aes256_t4_cbc_decrypt
|
||||
nop
|
||||
.type AES_cbc_encrypt,#function
|
||||
.size AES_cbc_encrypt,.-AES_cbc_encrypt
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
.asciz "AES for SPARC T4, David S. Miller, Andy Polyakov"
|
||||
.align 4
|
||||
___
|
||||
|
||||
&emit_assembler();
|
||||
|
||||
close STDOUT;
|
||||
2467
crypto/aes/asm/bsaes-armv7.pl
Normal file
2467
crypto/aes/asm/bsaes-armv7.pl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -83,9 +83,9 @@
|
||||
# Add decryption procedure. Performance in CPU cycles spent to decrypt
|
||||
# one byte out of 4096-byte buffer with 128-bit key is:
|
||||
#
|
||||
# Core 2 11.0
|
||||
# Nehalem 9.16
|
||||
# Atom 20.9
|
||||
# Core 2 9.83
|
||||
# Nehalem 7.74
|
||||
# Atom 19.0
|
||||
#
|
||||
# November 2011.
|
||||
#
|
||||
@@ -105,7 +105,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
|
||||
my @XMM=map("%xmm$_",(15,0..14)); # best on Atom, +10% over (0..15)
|
||||
@@ -455,6 +456,7 @@ sub MixColumns {
|
||||
# modified to emit output in order suitable for feeding back to aesenc[last]
|
||||
my @x=@_[0..7];
|
||||
my @t=@_[8..15];
|
||||
my $inv=@_[16]; # optional
|
||||
$code.=<<___;
|
||||
pshufd \$0x93, @x[0], @t[0] # x0 <<< 32
|
||||
pshufd \$0x93, @x[1], @t[1]
|
||||
@@ -496,7 +498,8 @@ $code.=<<___;
|
||||
pxor @t[4], @t[0]
|
||||
pshufd \$0x4E, @x[2], @x[6]
|
||||
pxor @t[5], @t[1]
|
||||
|
||||
___
|
||||
$code.=<<___ if (!$inv);
|
||||
pxor @t[3], @x[4]
|
||||
pxor @t[7], @x[5]
|
||||
pxor @t[6], @x[3]
|
||||
@@ -504,9 +507,20 @@ $code.=<<___;
|
||||
pxor @t[2], @x[6]
|
||||
movdqa @t[1], @x[7]
|
||||
___
|
||||
$code.=<<___ if ($inv);
|
||||
pxor @x[4], @t[3]
|
||||
pxor @t[7], @x[5]
|
||||
pxor @x[3], @t[6]
|
||||
movdqa @t[0], @x[3]
|
||||
pxor @t[2], @x[6]
|
||||
movdqa @t[6], @x[2]
|
||||
movdqa @t[1], @x[7]
|
||||
movdqa @x[6], @x[4]
|
||||
movdqa @t[3], @x[6]
|
||||
___
|
||||
}
|
||||
|
||||
sub InvMixColumns {
|
||||
sub InvMixColumns_orig {
|
||||
my @x=@_[0..7];
|
||||
my @t=@_[8..15];
|
||||
|
||||
@@ -660,6 +674,54 @@ $code.=<<___;
|
||||
___
|
||||
}
|
||||
|
||||
sub InvMixColumns {
|
||||
my @x=@_[0..7];
|
||||
my @t=@_[8..15];
|
||||
|
||||
# Thanks to Jussi Kivilinna for providing pointer to
|
||||
#
|
||||
# | 0e 0b 0d 09 | | 02 03 01 01 | | 05 00 04 00 |
|
||||
# | 09 0e 0b 0d | = | 01 02 03 01 | x | 00 05 00 04 |
|
||||
# | 0d 09 0e 0b | | 01 01 02 03 | | 04 00 05 00 |
|
||||
# | 0b 0d 09 0e | | 03 01 01 02 | | 00 04 00 05 |
|
||||
|
||||
$code.=<<___;
|
||||
# multiplication by 0x05-0x00-0x04-0x00
|
||||
pshufd \$0x4E, @x[0], @t[0]
|
||||
pshufd \$0x4E, @x[6], @t[6]
|
||||
pxor @x[0], @t[0]
|
||||
pshufd \$0x4E, @x[7], @t[7]
|
||||
pxor @x[6], @t[6]
|
||||
pshufd \$0x4E, @x[1], @t[1]
|
||||
pxor @x[7], @t[7]
|
||||
pshufd \$0x4E, @x[2], @t[2]
|
||||
pxor @x[1], @t[1]
|
||||
pshufd \$0x4E, @x[3], @t[3]
|
||||
pxor @x[2], @t[2]
|
||||
pxor @t[6], @x[0]
|
||||
pxor @t[6], @x[1]
|
||||
pshufd \$0x4E, @x[4], @t[4]
|
||||
pxor @x[3], @t[3]
|
||||
pxor @t[0], @x[2]
|
||||
pxor @t[1], @x[3]
|
||||
pshufd \$0x4E, @x[5], @t[5]
|
||||
pxor @x[4], @t[4]
|
||||
pxor @t[7], @x[1]
|
||||
pxor @t[2], @x[4]
|
||||
pxor @x[5], @t[5]
|
||||
|
||||
pxor @t[7], @x[2]
|
||||
pxor @t[6], @x[3]
|
||||
pxor @t[6], @x[4]
|
||||
pxor @t[3], @x[5]
|
||||
pxor @t[4], @x[6]
|
||||
pxor @t[7], @x[4]
|
||||
pxor @t[7], @x[5]
|
||||
pxor @t[5], @x[7]
|
||||
___
|
||||
&MixColumns (@x,@t,1); # flipped 2<->3 and 4<->6
|
||||
}
|
||||
|
||||
sub aesenc { # not used
|
||||
my @b=@_[0..7];
|
||||
my @t=@_[8..15];
|
||||
@@ -2027,6 +2089,8 @@ ___
|
||||
# const unsigned char iv[16]);
|
||||
#
|
||||
my ($twmask,$twres,$twtmp)=@XMM[13..15];
|
||||
$arg6=~s/d$//;
|
||||
|
||||
$code.=<<___;
|
||||
.globl bsaes_xts_encrypt
|
||||
.type bsaes_xts_encrypt,\@abi-omnipotent
|
||||
|
||||
1507
crypto/aes/asm/vpaes-ppc.pl
Normal file
1507
crypto/aes/asm/vpaes-ppc.pl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -27,9 +27,9 @@
|
||||
#
|
||||
# aes-586.pl vpaes-x86.pl
|
||||
#
|
||||
# Core 2(**) 29.1/42.3/18.3 22.0/25.6(***)
|
||||
# Nehalem 27.9/40.4/18.1 10.3/12.0
|
||||
# Atom 102./119./60.1 64.5/85.3(***)
|
||||
# Core 2(**) 28.1/41.4/18.3 21.9/25.2(***)
|
||||
# Nehalem 27.9/40.4/18.1 10.2/11.9
|
||||
# Atom 70.7/92.1/60.1 61.1/75.4(***)
|
||||
#
|
||||
# (*) "Hyper-threading" in the context refers rather to cache shared
|
||||
# among multiple cores, than to specifically Intel HTT. As vast
|
||||
@@ -40,8 +40,8 @@
|
||||
# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
|
||||
#
|
||||
# (***) Less impressive improvement on Core 2 and Atom is due to slow
|
||||
# pshufb, yet it's respectable +32%/65% improvement on Core 2
|
||||
# and +58%/40% on Atom (as implied, over "hyper-threading-safe"
|
||||
# pshufb, yet it's respectable +28%/64% improvement on Core 2
|
||||
# and +15% on Atom (as implied, over "hyper-threading-safe"
|
||||
# code path).
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
@@ -183,35 +183,35 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&movdqa ("xmm1","xmm6")
|
||||
&movdqa ("xmm2",&QWP($k_ipt,$const));
|
||||
&pandn ("xmm1","xmm0");
|
||||
&movdqu ("xmm5",&QWP(0,$key));
|
||||
&psrld ("xmm1",4);
|
||||
&pand ("xmm0","xmm6");
|
||||
&movdqu ("xmm5",&QWP(0,$key));
|
||||
&pshufb ("xmm2","xmm0");
|
||||
&movdqa ("xmm0",&QWP($k_ipt+16,$const));
|
||||
&pshufb ("xmm0","xmm1");
|
||||
&pxor ("xmm2","xmm5");
|
||||
&pxor ("xmm0","xmm2");
|
||||
&psrld ("xmm1",4);
|
||||
&add ($key,16);
|
||||
&pshufb ("xmm0","xmm1");
|
||||
&lea ($base,&DWP($k_mc_backward,$const));
|
||||
&pxor ("xmm0","xmm2");
|
||||
&jmp (&label("enc_entry"));
|
||||
|
||||
|
||||
&set_label("enc_loop",16);
|
||||
# middle of middle round
|
||||
&movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sb1u
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sb1u
|
||||
&pxor ("xmm4","xmm5"); # 4 = sb1u + k
|
||||
&movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sb1t
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sb1u
|
||||
&pshufb ("xmm0","xmm3"); # 0 = sb1t
|
||||
&pxor ("xmm0","xmm4"); # 0 = A
|
||||
&pxor ("xmm4","xmm5"); # 4 = sb1u + k
|
||||
&movdqa ("xmm5",&QWP($k_sb2,$const)); # 4 : sb2u
|
||||
&pshufb ("xmm5","xmm2"); # 4 = sb2u
|
||||
&pxor ("xmm0","xmm4"); # 0 = A
|
||||
&movdqa ("xmm1",&QWP(-0x40,$base,$magic));# .Lk_mc_forward[]
|
||||
&pshufb ("xmm5","xmm2"); # 4 = sb2u
|
||||
&movdqa ("xmm2",&QWP($k_sb2+16,$const));# 2 : sb2t
|
||||
&pshufb ("xmm2","xmm3"); # 2 = sb2t
|
||||
&pxor ("xmm2","xmm5"); # 2 = 2A
|
||||
&movdqa ("xmm4",&QWP(0,$base,$magic)); # .Lk_mc_backward[]
|
||||
&pshufb ("xmm2","xmm3"); # 2 = sb2t
|
||||
&movdqa ("xmm3","xmm0"); # 3 = A
|
||||
&pxor ("xmm2","xmm5"); # 2 = 2A
|
||||
&pshufb ("xmm0","xmm1"); # 0 = B
|
||||
&add ($key,16); # next key
|
||||
&pxor ("xmm0","xmm2"); # 0 = 2A+B
|
||||
@@ -220,30 +220,30 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&pxor ("xmm3","xmm0"); # 3 = 2A+B+D
|
||||
&pshufb ("xmm0","xmm1"); # 0 = 2B+C
|
||||
&and ($magic,0x30); # ... mod 4
|
||||
&pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D
|
||||
&sub ($round,1); # nr--
|
||||
&pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D
|
||||
|
||||
&set_label("enc_entry");
|
||||
# top of round
|
||||
&movdqa ("xmm1","xmm6"); # 1 : i
|
||||
&movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k
|
||||
&pandn ("xmm1","xmm0"); # 1 = i<<4
|
||||
&psrld ("xmm1",4); # 1 = i
|
||||
&pand ("xmm0","xmm6"); # 0 = k
|
||||
&movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k
|
||||
&pshufb ("xmm5","xmm0"); # 2 = a/k
|
||||
&pxor ("xmm0","xmm1"); # 0 = j
|
||||
&movdqa ("xmm3","xmm7"); # 3 : 1/i
|
||||
&pxor ("xmm0","xmm1"); # 0 = j
|
||||
&pshufb ("xmm3","xmm1"); # 3 = 1/i
|
||||
&pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k
|
||||
&movdqa ("xmm4","xmm7"); # 4 : 1/j
|
||||
&pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k
|
||||
&pshufb ("xmm4","xmm0"); # 4 = 1/j
|
||||
&pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k
|
||||
&movdqa ("xmm2","xmm7"); # 2 : 1/iak
|
||||
&pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k
|
||||
&pshufb ("xmm2","xmm3"); # 2 = 1/iak
|
||||
&pxor ("xmm2","xmm0"); # 2 = io
|
||||
&movdqa ("xmm3","xmm7"); # 3 : 1/jak
|
||||
&movdqu ("xmm5",&QWP(0,$key));
|
||||
&pxor ("xmm2","xmm0"); # 2 = io
|
||||
&pshufb ("xmm3","xmm4"); # 3 = 1/jak
|
||||
&movdqu ("xmm5",&QWP(0,$key));
|
||||
&pxor ("xmm3","xmm1"); # 3 = jo
|
||||
&jnz (&label("enc_loop"));
|
||||
|
||||
@@ -265,8 +265,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
## Same API as encryption core.
|
||||
##
|
||||
&function_begin_B("_vpaes_decrypt_core");
|
||||
&mov ($round,&DWP(240,$key));
|
||||
&lea ($base,&DWP($k_dsbd,$const));
|
||||
&mov ($round,&DWP(240,$key));
|
||||
&movdqa ("xmm1","xmm6");
|
||||
&movdqa ("xmm2",&QWP($k_dipt-$k_dsbd,$base));
|
||||
&pandn ("xmm1","xmm0");
|
||||
@@ -292,62 +292,61 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
## Inverse mix columns
|
||||
##
|
||||
&movdqa ("xmm4",&QWP(-0x20,$base)); # 4 : sb9u
|
||||
&movdqa ("xmm1",&QWP(-0x10,$base)); # 0 : sb9t
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sb9u
|
||||
&pxor ("xmm4","xmm0");
|
||||
&movdqa ("xmm0",&QWP(-0x10,$base)); # 0 : sb9t
|
||||
&pshufb ("xmm0","xmm3"); # 0 = sb9t
|
||||
&pxor ("xmm0","xmm4"); # 0 = ch
|
||||
&add ($key,16); # next round key
|
||||
|
||||
&pshufb ("xmm0","xmm5"); # MC ch
|
||||
&pshufb ("xmm1","xmm3"); # 0 = sb9t
|
||||
&pxor ("xmm0","xmm4");
|
||||
&movdqa ("xmm4",&QWP(0,$base)); # 4 : sbdu
|
||||
&pxor ("xmm0","xmm1"); # 0 = ch
|
||||
&movdqa ("xmm1",&QWP(0x10,$base)); # 0 : sbdt
|
||||
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sbdu
|
||||
&pxor ("xmm4","xmm0"); # 4 = ch
|
||||
&movdqa ("xmm0",&QWP(0x10,$base)); # 0 : sbdt
|
||||
&pshufb ("xmm0","xmm3"); # 0 = sbdt
|
||||
&pxor ("xmm0","xmm4"); # 0 = ch
|
||||
&sub ($round,1); # nr--
|
||||
|
||||
&pshufb ("xmm0","xmm5"); # MC ch
|
||||
&pshufb ("xmm1","xmm3"); # 0 = sbdt
|
||||
&pxor ("xmm0","xmm4"); # 4 = ch
|
||||
&movdqa ("xmm4",&QWP(0x20,$base)); # 4 : sbbu
|
||||
&pxor ("xmm0","xmm1"); # 0 = ch
|
||||
&movdqa ("xmm1",&QWP(0x30,$base)); # 0 : sbbt
|
||||
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sbbu
|
||||
&pxor ("xmm4","xmm0"); # 4 = ch
|
||||
&movdqa ("xmm0",&QWP(0x30,$base)); # 0 : sbbt
|
||||
&pshufb ("xmm0","xmm3"); # 0 = sbbt
|
||||
&pxor ("xmm0","xmm4"); # 0 = ch
|
||||
|
||||
&pshufb ("xmm0","xmm5"); # MC ch
|
||||
&pshufb ("xmm1","xmm3"); # 0 = sbbt
|
||||
&pxor ("xmm0","xmm4"); # 4 = ch
|
||||
&movdqa ("xmm4",&QWP(0x40,$base)); # 4 : sbeu
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sbeu
|
||||
&pxor ("xmm4","xmm0"); # 4 = ch
|
||||
&movdqa ("xmm0",&QWP(0x50,$base)); # 0 : sbet
|
||||
&pshufb ("xmm0","xmm3"); # 0 = sbet
|
||||
&pxor ("xmm0","xmm4"); # 0 = ch
|
||||
&pxor ("xmm0","xmm1"); # 0 = ch
|
||||
&movdqa ("xmm1",&QWP(0x50,$base)); # 0 : sbet
|
||||
|
||||
&pshufb ("xmm4","xmm2"); # 4 = sbeu
|
||||
&pshufb ("xmm0","xmm5"); # MC ch
|
||||
&pshufb ("xmm1","xmm3"); # 0 = sbet
|
||||
&pxor ("xmm0","xmm4"); # 4 = ch
|
||||
&add ($key,16); # next round key
|
||||
&palignr("xmm5","xmm5",12);
|
||||
&pxor ("xmm0","xmm1"); # 0 = ch
|
||||
&sub ($round,1); # nr--
|
||||
|
||||
&set_label("dec_entry");
|
||||
# top of round
|
||||
&movdqa ("xmm1","xmm6"); # 1 : i
|
||||
&pandn ("xmm1","xmm0"); # 1 = i<<4
|
||||
&psrld ("xmm1",4); # 1 = i
|
||||
&pand ("xmm0","xmm6"); # 0 = k
|
||||
&movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k
|
||||
&pandn ("xmm1","xmm0"); # 1 = i<<4
|
||||
&pand ("xmm0","xmm6"); # 0 = k
|
||||
&psrld ("xmm1",4); # 1 = i
|
||||
&pshufb ("xmm2","xmm0"); # 2 = a/k
|
||||
&pxor ("xmm0","xmm1"); # 0 = j
|
||||
&movdqa ("xmm3","xmm7"); # 3 : 1/i
|
||||
&pxor ("xmm0","xmm1"); # 0 = j
|
||||
&pshufb ("xmm3","xmm1"); # 3 = 1/i
|
||||
&pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
|
||||
&movdqa ("xmm4","xmm7"); # 4 : 1/j
|
||||
&pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k
|
||||
&pshufb ("xmm4","xmm0"); # 4 = 1/j
|
||||
&pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k
|
||||
&movdqa ("xmm2","xmm7"); # 2 : 1/iak
|
||||
&pshufb ("xmm2","xmm3"); # 2 = 1/iak
|
||||
&pxor ("xmm2","xmm0"); # 2 = io
|
||||
&movdqa ("xmm3","xmm7"); # 3 : 1/jak
|
||||
&pxor ("xmm2","xmm0"); # 2 = io
|
||||
&pshufb ("xmm3","xmm4"); # 3 = 1/jak
|
||||
&pxor ("xmm3","xmm1"); # 3 = jo
|
||||
&movdqu ("xmm0",&QWP(0,$key));
|
||||
&pxor ("xmm3","xmm1"); # 3 = jo
|
||||
&jnz (&label("dec_loop"));
|
||||
|
||||
# middle of last round
|
||||
@@ -542,12 +541,12 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
## %xmm0: b+c+d b+c b a
|
||||
##
|
||||
&function_begin_B("_vpaes_schedule_192_smear");
|
||||
&pshufd ("xmm0","xmm6",0x80); # d c 0 0 -> c 0 0 0
|
||||
&pxor ("xmm6","xmm0"); # -> c+d c 0 0
|
||||
&pshufd ("xmm1","xmm6",0x80); # d c 0 0 -> c 0 0 0
|
||||
&pshufd ("xmm0","xmm7",0xFE); # b a _ _ -> b b b a
|
||||
&pxor ("xmm6","xmm1"); # -> c+d c 0 0
|
||||
&pxor ("xmm1","xmm1");
|
||||
&pxor ("xmm6","xmm0"); # -> b+c+d b+c b a
|
||||
&movdqa ("xmm0","xmm6");
|
||||
&pxor ("xmm1","xmm1");
|
||||
&movhlps("xmm6","xmm1"); # clobber low side with zeros
|
||||
&ret ();
|
||||
&function_end_B("_vpaes_schedule_192_smear");
|
||||
@@ -843,6 +842,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov ($out,&wparam(1)); # out
|
||||
&mov ($round,&wparam(2)); # len
|
||||
&mov ($key,&wparam(3)); # key
|
||||
&sub ($round,16);
|
||||
&jc (&label("cbc_abort"));
|
||||
&lea ($base,&DWP(-56,"esp"));
|
||||
&mov ($const,&wparam(4)); # ivp
|
||||
&and ($base,-16);
|
||||
@@ -853,7 +854,6 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov (&DWP(48,"esp"),$base);
|
||||
|
||||
&mov (&DWP(0,"esp"),$out); # save out
|
||||
&sub ($round,16);
|
||||
&mov (&DWP(4,"esp"),$key) # save key
|
||||
&mov (&DWP(8,"esp"),$const); # save ivp
|
||||
&mov ($out,$round); # $out works as $len
|
||||
@@ -896,6 +896,7 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
||||
&mov ($base,&DWP(8,"esp")); # restore ivp
|
||||
&mov ("esp",&DWP(48,"esp"));
|
||||
&movdqu (&QWP(0,$base),"xmm1"); # write IV
|
||||
&set_label("cbc_abort");
|
||||
&function_end("${PREFIX}_cbc_encrypt");
|
||||
|
||||
&asm_finish();
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#
|
||||
# aes-x86_64.pl vpaes-x86_64.pl
|
||||
#
|
||||
# Core 2(**) 30.5/43.7/14.3 21.8/25.7(***)
|
||||
# Nehalem 30.5/42.2/14.6 9.8/11.8
|
||||
# Atom 63.9/79.0/32.1 64.0/84.8(***)
|
||||
# Core 2(**) 29.6/41.1/14.3 21.9/25.2(***)
|
||||
# Nehalem 29.6/40.3/14.6 10.0/11.8
|
||||
# Atom 57.3/74.2/32.1 60.9/77.2(***)
|
||||
#
|
||||
# (*) "Hyper-threading" in the context refers rather to cache shared
|
||||
# among multiple cores, than to specifically Intel HTT. As vast
|
||||
@@ -40,7 +40,7 @@
|
||||
# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe.
|
||||
#
|
||||
# (***) Less impressive improvement on Core 2 and Atom is due to slow
|
||||
# pshufb, yet it's respectable +40%/78% improvement on Core 2
|
||||
# pshufb, yet it's respectable +36%/62% improvement on Core 2
|
||||
# (as implied, over "hyper-threading-safe" code path).
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
@@ -56,7 +56,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$PREFIX="vpaes";
|
||||
|
||||
@@ -94,8 +95,8 @@ _vpaes_encrypt_core:
|
||||
movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi
|
||||
pshufb %xmm1, %xmm0
|
||||
pxor %xmm5, %xmm2
|
||||
pxor %xmm2, %xmm0
|
||||
add \$16, %r9
|
||||
pxor %xmm2, %xmm0
|
||||
lea .Lk_mc_backward(%rip),%r10
|
||||
jmp .Lenc_entry
|
||||
|
||||
@@ -103,19 +104,19 @@ _vpaes_encrypt_core:
|
||||
.Lenc_loop:
|
||||
# middle of middle round
|
||||
movdqa %xmm13, %xmm4 # 4 : sb1u
|
||||
pshufb %xmm2, %xmm4 # 4 = sb1u
|
||||
pxor %xmm5, %xmm4 # 4 = sb1u + k
|
||||
movdqa %xmm12, %xmm0 # 0 : sb1t
|
||||
pshufb %xmm2, %xmm4 # 4 = sb1u
|
||||
pshufb %xmm3, %xmm0 # 0 = sb1t
|
||||
pxor %xmm4, %xmm0 # 0 = A
|
||||
pxor %xmm5, %xmm4 # 4 = sb1u + k
|
||||
movdqa %xmm15, %xmm5 # 4 : sb2u
|
||||
pshufb %xmm2, %xmm5 # 4 = sb2u
|
||||
pxor %xmm4, %xmm0 # 0 = A
|
||||
movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[]
|
||||
pshufb %xmm2, %xmm5 # 4 = sb2u
|
||||
movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
|
||||
movdqa %xmm14, %xmm2 # 2 : sb2t
|
||||
pshufb %xmm3, %xmm2 # 2 = sb2t
|
||||
pxor %xmm5, %xmm2 # 2 = 2A
|
||||
movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[]
|
||||
movdqa %xmm0, %xmm3 # 3 = A
|
||||
pxor %xmm5, %xmm2 # 2 = 2A
|
||||
pshufb %xmm1, %xmm0 # 0 = B
|
||||
add \$16, %r9 # next key
|
||||
pxor %xmm2, %xmm0 # 0 = 2A+B
|
||||
@@ -124,30 +125,30 @@ _vpaes_encrypt_core:
|
||||
pxor %xmm0, %xmm3 # 3 = 2A+B+D
|
||||
pshufb %xmm1, %xmm0 # 0 = 2B+C
|
||||
and \$0x30, %r11 # ... mod 4
|
||||
pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
|
||||
sub \$1,%rax # nr--
|
||||
pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D
|
||||
|
||||
.Lenc_entry:
|
||||
# top of round
|
||||
movdqa %xmm9, %xmm1 # 1 : i
|
||||
movdqa %xmm11, %xmm5 # 2 : a/k
|
||||
pandn %xmm0, %xmm1 # 1 = i<<4
|
||||
psrld \$4, %xmm1 # 1 = i
|
||||
pand %xmm9, %xmm0 # 0 = k
|
||||
movdqa %xmm11, %xmm5 # 2 : a/k
|
||||
pshufb %xmm0, %xmm5 # 2 = a/k
|
||||
pxor %xmm1, %xmm0 # 0 = j
|
||||
movdqa %xmm10, %xmm3 # 3 : 1/i
|
||||
pxor %xmm1, %xmm0 # 0 = j
|
||||
pshufb %xmm1, %xmm3 # 3 = 1/i
|
||||
pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
|
||||
movdqa %xmm10, %xmm4 # 4 : 1/j
|
||||
pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k
|
||||
pshufb %xmm0, %xmm4 # 4 = 1/j
|
||||
pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
|
||||
movdqa %xmm10, %xmm2 # 2 : 1/iak
|
||||
pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k
|
||||
pshufb %xmm3, %xmm2 # 2 = 1/iak
|
||||
pxor %xmm0, %xmm2 # 2 = io
|
||||
movdqa %xmm10, %xmm3 # 3 : 1/jak
|
||||
movdqu (%r9), %xmm5
|
||||
pxor %xmm0, %xmm2 # 2 = io
|
||||
pshufb %xmm4, %xmm3 # 3 = 1/jak
|
||||
movdqu (%r9), %xmm5
|
||||
pxor %xmm1, %xmm3 # 3 = jo
|
||||
jnz .Lenc_loop
|
||||
|
||||
@@ -200,62 +201,61 @@ _vpaes_decrypt_core:
|
||||
## Inverse mix columns
|
||||
##
|
||||
movdqa -0x20(%r10),%xmm4 # 4 : sb9u
|
||||
movdqa -0x10(%r10),%xmm1 # 0 : sb9t
|
||||
pshufb %xmm2, %xmm4 # 4 = sb9u
|
||||
pxor %xmm0, %xmm4
|
||||
movdqa -0x10(%r10),%xmm0 # 0 : sb9t
|
||||
pshufb %xmm3, %xmm0 # 0 = sb9t
|
||||
pxor %xmm4, %xmm0 # 0 = ch
|
||||
add \$16, %r9 # next round key
|
||||
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
pshufb %xmm3, %xmm1 # 0 = sb9t
|
||||
pxor %xmm4, %xmm0
|
||||
movdqa 0x00(%r10),%xmm4 # 4 : sbdu
|
||||
pshufb %xmm2, %xmm4 # 4 = sbdu
|
||||
pxor %xmm0, %xmm4 # 4 = ch
|
||||
movdqa 0x10(%r10),%xmm0 # 0 : sbdt
|
||||
pshufb %xmm3, %xmm0 # 0 = sbdt
|
||||
pxor %xmm4, %xmm0 # 0 = ch
|
||||
sub \$1,%rax # nr--
|
||||
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
movdqa 0x20(%r10),%xmm4 # 4 : sbbu
|
||||
pshufb %xmm2, %xmm4 # 4 = sbbu
|
||||
pxor %xmm0, %xmm4 # 4 = ch
|
||||
movdqa 0x30(%r10),%xmm0 # 0 : sbbt
|
||||
pshufb %xmm3, %xmm0 # 0 = sbbt
|
||||
pxor %xmm4, %xmm0 # 0 = ch
|
||||
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
movdqa 0x40(%r10),%xmm4 # 4 : sbeu
|
||||
pshufb %xmm2, %xmm4 # 4 = sbeu
|
||||
pxor %xmm0, %xmm4 # 4 = ch
|
||||
movdqa 0x50(%r10),%xmm0 # 0 : sbet
|
||||
pshufb %xmm3, %xmm0 # 0 = sbet
|
||||
pxor %xmm4, %xmm0 # 0 = ch
|
||||
pxor %xmm1, %xmm0 # 0 = ch
|
||||
movdqa 0x10(%r10),%xmm1 # 0 : sbdt
|
||||
|
||||
pshufb %xmm2, %xmm4 # 4 = sbdu
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
pshufb %xmm3, %xmm1 # 0 = sbdt
|
||||
pxor %xmm4, %xmm0 # 4 = ch
|
||||
movdqa 0x20(%r10),%xmm4 # 4 : sbbu
|
||||
pxor %xmm1, %xmm0 # 0 = ch
|
||||
movdqa 0x30(%r10),%xmm1 # 0 : sbbt
|
||||
|
||||
pshufb %xmm2, %xmm4 # 4 = sbbu
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
pshufb %xmm3, %xmm1 # 0 = sbbt
|
||||
pxor %xmm4, %xmm0 # 4 = ch
|
||||
movdqa 0x40(%r10),%xmm4 # 4 : sbeu
|
||||
pxor %xmm1, %xmm0 # 0 = ch
|
||||
movdqa 0x50(%r10),%xmm1 # 0 : sbet
|
||||
|
||||
pshufb %xmm2, %xmm4 # 4 = sbeu
|
||||
pshufb %xmm5, %xmm0 # MC ch
|
||||
pshufb %xmm3, %xmm1 # 0 = sbet
|
||||
pxor %xmm4, %xmm0 # 4 = ch
|
||||
add \$16, %r9 # next round key
|
||||
palignr \$12, %xmm5, %xmm5
|
||||
|
||||
pxor %xmm1, %xmm0 # 0 = ch
|
||||
sub \$1,%rax # nr--
|
||||
|
||||
.Ldec_entry:
|
||||
# top of round
|
||||
movdqa %xmm9, %xmm1 # 1 : i
|
||||
pandn %xmm0, %xmm1 # 1 = i<<4
|
||||
movdqa %xmm11, %xmm2 # 2 : a/k
|
||||
psrld \$4, %xmm1 # 1 = i
|
||||
pand %xmm9, %xmm0 # 0 = k
|
||||
movdqa %xmm11, %xmm2 # 2 : a/k
|
||||
pshufb %xmm0, %xmm2 # 2 = a/k
|
||||
pxor %xmm1, %xmm0 # 0 = j
|
||||
movdqa %xmm10, %xmm3 # 3 : 1/i
|
||||
pxor %xmm1, %xmm0 # 0 = j
|
||||
pshufb %xmm1, %xmm3 # 3 = 1/i
|
||||
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
|
||||
movdqa %xmm10, %xmm4 # 4 : 1/j
|
||||
pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k
|
||||
pshufb %xmm0, %xmm4 # 4 = 1/j
|
||||
pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k
|
||||
movdqa %xmm10, %xmm2 # 2 : 1/iak
|
||||
pshufb %xmm3, %xmm2 # 2 = 1/iak
|
||||
pxor %xmm0, %xmm2 # 2 = io
|
||||
movdqa %xmm10, %xmm3 # 3 : 1/jak
|
||||
pxor %xmm0, %xmm2 # 2 = io
|
||||
pshufb %xmm4, %xmm3 # 3 = 1/jak
|
||||
pxor %xmm1, %xmm3 # 3 = jo
|
||||
movdqu (%r9), %xmm0
|
||||
pxor %xmm1, %xmm3 # 3 = jo
|
||||
jnz .Ldec_loop
|
||||
|
||||
# middle of last round
|
||||
@@ -263,7 +263,7 @@ _vpaes_decrypt_core:
|
||||
pshufb %xmm2, %xmm4 # 4 = sbou
|
||||
pxor %xmm0, %xmm4 # 4 = sb1u + k
|
||||
movdqa 0x70(%r10), %xmm0 # 0 : sbot
|
||||
movdqa .Lk_sr-.Lk_dsbd(%r11), %xmm2
|
||||
movdqa -0x160(%r11), %xmm2 # .Lk_sr-.Lk_dsbd=-0x160
|
||||
pshufb %xmm3, %xmm0 # 0 = sb1t
|
||||
pxor %xmm4, %xmm0 # 0 = A
|
||||
pshufb %xmm2, %xmm0
|
||||
@@ -463,12 +463,12 @@ _vpaes_schedule_core:
|
||||
.type _vpaes_schedule_192_smear,\@abi-omnipotent
|
||||
.align 16
|
||||
_vpaes_schedule_192_smear:
|
||||
pshufd \$0x80, %xmm6, %xmm0 # d c 0 0 -> c 0 0 0
|
||||
pxor %xmm0, %xmm6 # -> c+d c 0 0
|
||||
pshufd \$0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0
|
||||
pshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a
|
||||
pxor %xmm1, %xmm6 # -> c+d c 0 0
|
||||
pxor %xmm1, %xmm1
|
||||
pxor %xmm0, %xmm6 # -> b+c+d b+c b a
|
||||
movdqa %xmm6, %xmm0
|
||||
pxor %xmm1, %xmm1
|
||||
movhlps %xmm1, %xmm6 # clobber low side with zeros
|
||||
ret
|
||||
.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear
|
||||
@@ -869,6 +869,8 @@ ${PREFIX}_cbc_encrypt:
|
||||
___
|
||||
($len,$key)=($key,$len);
|
||||
$code.=<<___;
|
||||
sub \$16,$len
|
||||
jc .Lcbc_abort
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea -0xb8(%rsp),%rsp
|
||||
@@ -887,7 +889,6 @@ ___
|
||||
$code.=<<___;
|
||||
movdqu ($ivp),%xmm6 # load IV
|
||||
sub $inp,$out
|
||||
sub \$16,$len
|
||||
call _vpaes_preheat
|
||||
cmp \$0,${enc}d
|
||||
je .Lcbc_dec_loop
|
||||
@@ -932,6 +933,7 @@ $code.=<<___ if ($win64);
|
||||
.Lcbc_epilogue:
|
||||
___
|
||||
$code.=<<___;
|
||||
.Lcbc_abort:
|
||||
ret
|
||||
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
|
||||
___
|
||||
|
||||
@@ -23,7 +23,7 @@ unsigned int _armv7_tick(void);
|
||||
|
||||
unsigned int OPENSSL_rdtsc(void)
|
||||
{
|
||||
if (OPENSSL_armcap_P|ARMV7_TICK)
|
||||
if (OPENSSL_armcap_P & ARMV7_TICK)
|
||||
return _armv7_tick();
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -174,7 +174,7 @@ a_gentm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
a_gentm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
a_gentm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
a_gentm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
a_gentm.o: ../cryptlib.h ../o_time.h a_gentm.c
|
||||
a_gentm.o: ../cryptlib.h ../o_time.h a_gentm.c asn1_locl.h
|
||||
a_i2d_fp.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
a_i2d_fp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
@@ -275,6 +275,7 @@ a_time.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
a_time.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
a_time.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
a_time.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_time.c
|
||||
a_time.o: asn1_locl.h
|
||||
a_type.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
|
||||
a_type.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
@@ -291,7 +292,7 @@ a_utctm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
a_utctm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
a_utctm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
a_utctm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
a_utctm.o: ../cryptlib.h ../o_time.h a_utctm.c
|
||||
a_utctm.o: ../cryptlib.h ../o_time.h a_utctm.c asn1_locl.h
|
||||
a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
a_utf8.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
a_utf8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
@@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
BUF_MEM *b;
|
||||
unsigned char *p;
|
||||
int i;
|
||||
int ret=-1;
|
||||
ASN1_const_CTX c;
|
||||
int want=HEADER_SIZE;
|
||||
size_t want=HEADER_SIZE;
|
||||
int eos=0;
|
||||
#if defined(__GNUC__) && defined(__ia64)
|
||||
/* pathetic compiler bug in all known versions as of Nov. 2002 */
|
||||
long off=0;
|
||||
#else
|
||||
int off=0;
|
||||
#endif
|
||||
int len=0;
|
||||
size_t off=0;
|
||||
size_t len=0;
|
||||
|
||||
b=BUF_MEM_new();
|
||||
if (b == NULL)
|
||||
@@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
want-=(len-off);
|
||||
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
if (len + want < len || !BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
goto err;
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (len+i < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
len+=i;
|
||||
}
|
||||
}
|
||||
/* else data already loaded */
|
||||
|
||||
@@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
/* no data body so go round again */
|
||||
eos++;
|
||||
if (eos < 0)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
want=HEADER_SIZE;
|
||||
}
|
||||
else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))
|
||||
@@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
else
|
||||
{
|
||||
/* suck in c.slen bytes of data */
|
||||
want=(int)c.slen;
|
||||
want=c.slen;
|
||||
if (want > (len-off))
|
||||
{
|
||||
want-=(len-off);
|
||||
if (want > INT_MAX /* BIO_read takes an int length */ ||
|
||||
len+want < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
@@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
ASN1_R_NOT_ENOUGH_DATA);
|
||||
goto err;
|
||||
}
|
||||
/* This can't overflow because
|
||||
* |len+want| didn't overflow. */
|
||||
len+=i;
|
||||
want -= i;
|
||||
want-=i;
|
||||
}
|
||||
}
|
||||
off+=(int)c.slen;
|
||||
if (off + c.slen < off)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
off+=c.slen;
|
||||
if (eos <= 0)
|
||||
{
|
||||
break;
|
||||
@@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
}
|
||||
}
|
||||
|
||||
if (off > INT_MAX)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*pb = b;
|
||||
return off;
|
||||
err:
|
||||
if (b != NULL) BUF_MEM_free(b);
|
||||
return(ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "o_time.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -115,7 +116,7 @@ err:
|
||||
|
||||
#endif
|
||||
|
||||
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
|
||||
{
|
||||
static const int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
|
||||
static const int max[9]={99, 99,12,31,23,59,59,12,59};
|
||||
@@ -135,7 +136,12 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
|
||||
{
|
||||
if ((i == 6) && ((a[o] == 'Z') ||
|
||||
(a[o] == '+') || (a[o] == '-')))
|
||||
{ i++; break; }
|
||||
{
|
||||
i++;
|
||||
if (tm)
|
||||
tm->tm_sec = 0;
|
||||
break;
|
||||
}
|
||||
if ((a[o] < '0') || (a[o] > '9')) goto err;
|
||||
n= a[o]-'0';
|
||||
if (++o > l) goto err;
|
||||
@@ -145,6 +151,33 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
|
||||
if (++o > l) goto err;
|
||||
|
||||
if ((n < min[i]) || (n > max[i])) goto err;
|
||||
if (tm)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
tm->tm_year = n * 100 - 1900;
|
||||
break;
|
||||
case 1:
|
||||
tm->tm_year += n;
|
||||
break;
|
||||
case 2:
|
||||
tm->tm_mon = n - 1;
|
||||
break;
|
||||
case 3:
|
||||
tm->tm_mday = n;
|
||||
break;
|
||||
case 4:
|
||||
tm->tm_hour = n;
|
||||
break;
|
||||
case 5:
|
||||
tm->tm_min = n;
|
||||
break;
|
||||
case 6:
|
||||
tm->tm_sec = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Optional fractional seconds: decimal point followed by one
|
||||
* or more digits.
|
||||
@@ -163,6 +196,7 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
|
||||
o++;
|
||||
else if ((a[o] == '+') || (a[o] == '-'))
|
||||
{
|
||||
int offsign = a[o] == '-' ? -1 : 1, offset = 0;
|
||||
o++;
|
||||
if (o+4 > l) goto err;
|
||||
for (i=7; i<9; i++)
|
||||
@@ -173,10 +207,19 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
|
||||
if ((a[o] < '0') || (a[o] > '9')) goto err;
|
||||
n=(n*10)+ a[o]-'0';
|
||||
if ((n < min[i]) || (n > max[i])) goto err;
|
||||
if (tm)
|
||||
{
|
||||
if (i == 7)
|
||||
offset = n * 3600;
|
||||
else if (i == 8)
|
||||
offset += n * 60;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
else if (a[o])
|
||||
{
|
||||
/* Missing time zone information. */
|
||||
goto err;
|
||||
@@ -186,6 +229,11 @@ err:
|
||||
return(0);
|
||||
}
|
||||
|
||||
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
|
||||
{
|
||||
return asn1_generalizedtime_to_tm(NULL, d);
|
||||
}
|
||||
|
||||
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
|
||||
{
|
||||
ASN1_GENERALIZEDTIME t;
|
||||
|
||||
@@ -116,7 +116,7 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
int pad=0,ret,i,neg;
|
||||
unsigned char *p,*n,pb=0;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL)) return(0);
|
||||
if (a == NULL) return(0);
|
||||
neg=a->type & V_ASN1_NEG;
|
||||
if (a->length == 0)
|
||||
ret=1;
|
||||
|
||||
@@ -567,6 +567,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
|
||||
if(mbflag == -1) return -1;
|
||||
mbflag |= MBSTRING_FLAG;
|
||||
stmp.data = NULL;
|
||||
stmp.length = 0;
|
||||
ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
|
||||
if(ret < 0) return ret;
|
||||
*out = stmp.data;
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "o_time.h"
|
||||
#include <openssl/asn1t.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
|
||||
|
||||
@@ -196,3 +197,33 @@ int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
|
||||
{
|
||||
if (t == NULL)
|
||||
{
|
||||
time_t now_t;
|
||||
time(&now_t);
|
||||
if (OPENSSL_gmtime(&now_t, tm))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (t->type == V_ASN1_UTCTIME)
|
||||
return asn1_utctime_to_tm(tm, t);
|
||||
else if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||
return asn1_generalizedtime_to_tm(tm, t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_TIME_diff(int *pday, int *psec,
|
||||
const ASN1_TIME *from, const ASN1_TIME *to)
|
||||
{
|
||||
struct tm tm_from, tm_to;
|
||||
if (!asn1_time_to_tm(&tm_from, from))
|
||||
return 0;
|
||||
if (!asn1_time_to_tm(&tm_to, to))
|
||||
return 0;
|
||||
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "o_time.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
#if 0
|
||||
int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
|
||||
@@ -112,7 +113,7 @@ err:
|
||||
|
||||
#endif
|
||||
|
||||
int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
|
||||
{
|
||||
static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
|
||||
static const int max[8]={99,12,31,23,59,59,12,59};
|
||||
@@ -129,7 +130,12 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
|
||||
{
|
||||
if ((i == 5) && ((a[o] == 'Z') ||
|
||||
(a[o] == '+') || (a[o] == '-')))
|
||||
{ i++; break; }
|
||||
{
|
||||
i++;
|
||||
if (tm)
|
||||
tm->tm_sec = 0;
|
||||
break;
|
||||
}
|
||||
if ((a[o] < '0') || (a[o] > '9')) goto err;
|
||||
n= a[o]-'0';
|
||||
if (++o > l) goto err;
|
||||
@@ -139,11 +145,36 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
|
||||
if (++o > l) goto err;
|
||||
|
||||
if ((n < min[i]) || (n > max[i])) goto err;
|
||||
if (tm)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
tm->tm_year = n < 50 ? n + 100 : n;
|
||||
break;
|
||||
case 1:
|
||||
tm->tm_mon = n - 1;
|
||||
break;
|
||||
case 2:
|
||||
tm->tm_mday = n;
|
||||
break;
|
||||
case 3:
|
||||
tm->tm_hour = n;
|
||||
break;
|
||||
case 4:
|
||||
tm->tm_min = n;
|
||||
break;
|
||||
case 5:
|
||||
tm->tm_sec = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a[o] == 'Z')
|
||||
o++;
|
||||
else if ((a[o] == '+') || (a[o] == '-'))
|
||||
{
|
||||
int offsign = a[o] == '-' ? -1 : 1, offset = 0;
|
||||
o++;
|
||||
if (o+4 > l) goto err;
|
||||
for (i=6; i<8; i++)
|
||||
@@ -154,12 +185,26 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
|
||||
if ((a[o] < '0') || (a[o] > '9')) goto err;
|
||||
n=(n*10)+ a[o]-'0';
|
||||
if ((n < min[i]) || (n > max[i])) goto err;
|
||||
if (tm)
|
||||
{
|
||||
if (i == 6)
|
||||
offset = n * 3600;
|
||||
else if (i == 7)
|
||||
offset += n * 60;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||
return 0;
|
||||
}
|
||||
return(o == l);
|
||||
return o == l;
|
||||
err:
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
|
||||
{
|
||||
return asn1_utctime_to_tm(NULL, d);
|
||||
}
|
||||
|
||||
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
|
||||
@@ -242,39 +287,26 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||
|
||||
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||
{
|
||||
struct tm *tm;
|
||||
struct tm data;
|
||||
int offset;
|
||||
int year;
|
||||
struct tm stm, ttm;
|
||||
int day, sec;
|
||||
|
||||
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
|
||||
if (!asn1_utctime_to_tm(&stm, s))
|
||||
return -2;
|
||||
|
||||
if (s->data[12] == 'Z')
|
||||
offset=0;
|
||||
else
|
||||
{
|
||||
offset = g2(s->data+13)*60+g2(s->data+15);
|
||||
if (s->data[12] == '-')
|
||||
offset = -offset;
|
||||
}
|
||||
if (!OPENSSL_gmtime(&t, &ttm))
|
||||
return -2;
|
||||
|
||||
t -= offset*60; /* FIXME: may overflow in extreme cases */
|
||||
|
||||
tm = OPENSSL_gmtime(&t, &data);
|
||||
|
||||
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
|
||||
year = g2(s->data);
|
||||
if (year < 50)
|
||||
year += 100;
|
||||
return_cmp(year, tm->tm_year);
|
||||
return_cmp(g2(s->data+2) - 1, tm->tm_mon);
|
||||
return_cmp(g2(s->data+4), tm->tm_mday);
|
||||
return_cmp(g2(s->data+6), tm->tm_hour);
|
||||
return_cmp(g2(s->data+8), tm->tm_min);
|
||||
return_cmp(g2(s->data+10), tm->tm_sec);
|
||||
#undef g2
|
||||
#undef return_cmp
|
||||
if (!OPENSSL_gmtime_diff(&day, &sec, &stm, &ttm))
|
||||
return -2;
|
||||
|
||||
if (day > 0)
|
||||
return 1;
|
||||
if (day < 0)
|
||||
return -1;
|
||||
if (sec > 0)
|
||||
return 1;
|
||||
if (sec < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[];
|
||||
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[];
|
||||
extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
|
||||
extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
|
||||
@@ -92,7 +93,10 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] =
|
||||
&eckey_asn1_meth,
|
||||
#endif
|
||||
&hmac_asn1_meth,
|
||||
&cmac_asn1_meth
|
||||
&cmac_asn1_meth,
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dhx_asn1_meth
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef int sk_cmp_fn_type(const char * const *a, const char * const *b);
|
||||
|
||||
@@ -208,14 +208,14 @@ typedef struct asn1_const_ctx_st
|
||||
#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */
|
||||
#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */
|
||||
#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */
|
||||
typedef struct asn1_object_st
|
||||
struct asn1_object_st
|
||||
{
|
||||
const char *sn,*ln;
|
||||
int nid;
|
||||
int length;
|
||||
const unsigned char *data; /* data remains const after init */
|
||||
int flags; /* Should we free this one */
|
||||
} ASN1_OBJECT;
|
||||
};
|
||||
|
||||
#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
|
||||
/* This indicates that the ASN1_STRING is not a real value but just a place
|
||||
@@ -839,7 +839,7 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
|
||||
|
||||
int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
|
||||
int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
|
||||
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
|
||||
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||
int offset_day, long offset_sec);
|
||||
@@ -849,11 +849,13 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
|
||||
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
|
||||
#endif
|
||||
|
||||
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
|
||||
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
|
||||
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
|
||||
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
|
||||
time_t t, int offset_day, long offset_sec);
|
||||
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
|
||||
int ASN1_TIME_diff(int *pday, int *psec,
|
||||
const ASN1_TIME *from, const ASN1_TIME *to);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
|
||||
ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
|
||||
|
||||
@@ -305,7 +305,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),"unknown signature algorithm"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"},
|
||||
{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unkown format"},
|
||||
{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unknown format"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"},
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
|
||||
/* Internal ASN1 structures and functions: not for application use */
|
||||
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
|
||||
|
||||
/* ASN1 print context structure */
|
||||
|
||||
struct asn1_pctx_st
|
||||
|
||||
@@ -225,6 +225,24 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
|
||||
}
|
||||
}
|
||||
|
||||
if(!(cflag & X509_FLAG_NO_IDS))
|
||||
{
|
||||
if (ci->issuerUID)
|
||||
{
|
||||
if (BIO_printf(bp,"%8sIssuer Unique ID: ","") <= 0)
|
||||
goto err;
|
||||
if (!X509_signature_dump(bp, ci->issuerUID, 12))
|
||||
goto err;
|
||||
}
|
||||
if (ci->subjectUID)
|
||||
{
|
||||
if (BIO_printf(bp,"%8sSubject Unique ID: ","") <= 0)
|
||||
goto err;
|
||||
if (!X509_signature_dump(bp, ci->subjectUID, 12))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cflag & X509_FLAG_NO_EXTENSIONS))
|
||||
X509V3_extensions_print(bp, "X509v3 extensions",
|
||||
ci->extensions, cflag, 8);
|
||||
|
||||
@@ -446,11 +446,11 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_print_boolean_ctx(BIO *out, const int bool,
|
||||
static int asn1_print_boolean_ctx(BIO *out, int boolval,
|
||||
const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *str;
|
||||
switch (bool)
|
||||
switch (boolval)
|
||||
{
|
||||
case -1:
|
||||
str = "BOOL ABSENT";
|
||||
@@ -574,10 +574,10 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
{
|
||||
case V_ASN1_BOOLEAN:
|
||||
{
|
||||
int bool = *(int *)fld;
|
||||
if (bool == -1)
|
||||
bool = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, bool, pctx);
|
||||
int boolval = *(int *)fld;
|
||||
if (boolval == -1)
|
||||
boolval = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, boolval, pctx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "asn1_locl.h"
|
||||
#include <openssl/asn1t.h>
|
||||
#include "asn1_locl.h"
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
@@ -356,6 +356,7 @@ ASN1_SEQUENCE_ref(X509_CRL, crl_cb, CRYPTO_LOCK_X509_CRL) = {
|
||||
} ASN1_SEQUENCE_END_ref(X509_CRL, X509_CRL)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(X509_REVOKED)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(X509_REVOKED)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(X509_CRL_INFO)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(X509_CRL)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(X509_CRL)
|
||||
|
||||
@@ -175,12 +175,15 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
|
||||
if (key->pkey)
|
||||
{
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
EVP_PKEY_free(ret);
|
||||
ret = key->pkey;
|
||||
}
|
||||
else
|
||||
{
|
||||
key->pkey = ret;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
}
|
||||
CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -192,3 +192,17 @@ int i2d_X509_AUX(X509 *a, unsigned char **pp)
|
||||
if(a) length += i2d_X509_CERT_AUX(a->aux, pp);
|
||||
return length;
|
||||
}
|
||||
|
||||
void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
|
||||
const X509 *x)
|
||||
{
|
||||
if (psig)
|
||||
*psig = x->signature;
|
||||
if (palg)
|
||||
*palg = x->sig_alg;
|
||||
}
|
||||
|
||||
int X509_get_signature_nid(const X509 *x)
|
||||
{
|
||||
return OBJ_obj2nid(x->sig_alg->algorithm);
|
||||
}
|
||||
|
||||
@@ -185,3 +185,25 @@ int BIO_dump_indent(BIO *bp, const char *s, int len, int indent)
|
||||
return BIO_dump_indent_cb(write_bio, bp, s, len, indent);
|
||||
}
|
||||
|
||||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||
int datalen)
|
||||
{
|
||||
int i, j = 0;
|
||||
|
||||
if (datalen < 1)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < datalen - 1; i++)
|
||||
{
|
||||
if (i && !j) BIO_printf(out, "%*s", indent, "");
|
||||
|
||||
BIO_printf(out, "%02X:", data[i]);
|
||||
|
||||
j = (j + 1) % width;
|
||||
if (!j) BIO_printf(out, "\n");
|
||||
}
|
||||
|
||||
if (i && !j) BIO_printf(out, "%*s", indent, "");
|
||||
BIO_printf(out, "%02X", data[datalen - 1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -233,13 +233,14 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
|
||||
int BIO_sock_error(int sock)
|
||||
{
|
||||
int j,i;
|
||||
int size;
|
||||
union { size_t s; int i; } size;
|
||||
|
||||
#if defined(OPENSSL_SYS_BEOS_R5)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
size=sizeof(int);
|
||||
|
||||
/* heuristic way to adapt for platforms that expect 64-bit optlen */
|
||||
size.s=0, size.i=sizeof(j);
|
||||
/* Note: under Windows the third parameter is of type (char *)
|
||||
* whereas under other systems it is (void *) if you don't have
|
||||
* a cast it will choke the compiler: if you do have a cast then
|
||||
@@ -960,7 +961,6 @@ int BIO_set_tcp_ndelay(int s, int on)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BIO_socket_nbio(int s, int mode)
|
||||
{
|
||||
@@ -973,3 +973,4 @@ int BIO_socket_nbio(int s, int mode)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -174,6 +174,7 @@ extern "C" {
|
||||
|
||||
#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45 /* Next DTLS handshake timeout to
|
||||
* adjust socket timeouts */
|
||||
#define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
|
||||
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP stuff */
|
||||
@@ -706,6 +707,9 @@ int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
|
||||
int BIO_dump_fp(FILE *fp, const char *s, int len);
|
||||
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
|
||||
#endif
|
||||
int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
|
||||
int datalen);
|
||||
|
||||
struct hostent *BIO_gethostbyname(const char *name);
|
||||
/* We might want a thread-safe interface too:
|
||||
* struct hostent *BIO_gethostbyname_r(const char *name,
|
||||
@@ -738,8 +742,8 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b);
|
||||
int BIO_dgram_sctp_msg_waiting(BIO *b);
|
||||
#endif
|
||||
BIO *BIO_new_fd(int fd, int close_flag);
|
||||
BIO *BIO_new_connect(char *host_port);
|
||||
BIO *BIO_new_accept(char *host_port);
|
||||
BIO *BIO_new_connect(const char *host_port);
|
||||
BIO *BIO_new_accept(const char *host_port);
|
||||
|
||||
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
|
||||
BIO **bio2, size_t writebuf2);
|
||||
|
||||
@@ -521,40 +521,40 @@ void BIO_free_all(BIO *bio)
|
||||
|
||||
BIO *BIO_dup_chain(BIO *in)
|
||||
{
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new;
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new_bio;
|
||||
|
||||
for (bio=in; bio != NULL; bio=bio->next_bio)
|
||||
{
|
||||
if ((new=BIO_new(bio->method)) == NULL) goto err;
|
||||
new->callback=bio->callback;
|
||||
new->cb_arg=bio->cb_arg;
|
||||
new->init=bio->init;
|
||||
new->shutdown=bio->shutdown;
|
||||
new->flags=bio->flags;
|
||||
if ((new_bio=BIO_new(bio->method)) == NULL) goto err;
|
||||
new_bio->callback=bio->callback;
|
||||
new_bio->cb_arg=bio->cb_arg;
|
||||
new_bio->init=bio->init;
|
||||
new_bio->shutdown=bio->shutdown;
|
||||
new_bio->flags=bio->flags;
|
||||
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new->num=bio->num;
|
||||
new_bio->num=bio->num;
|
||||
|
||||
if (!BIO_dup_state(bio,(char *)new))
|
||||
if (!BIO_dup_state(bio,(char *)new_bio))
|
||||
{
|
||||
BIO_free(new);
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
|
||||
&bio->ex_data))
|
||||
goto err;
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
eoc=new;
|
||||
eoc=new_bio;
|
||||
ret=eoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_push(eoc,new);
|
||||
eoc=new;
|
||||
BIO_push(eoc,new_bio);
|
||||
eoc=new_bio;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
|
||||
@@ -460,7 +460,7 @@ static int acpt_puts(BIO *bp, const char *str)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_accept(char *str)
|
||||
BIO *BIO_new_accept(const char *str)
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
|
||||
@@ -633,7 +633,7 @@ static int conn_puts(BIO *bp, const char *str)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
BIO *BIO_new_connect(char *str)
|
||||
BIO *BIO_new_connect(const char *str)
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#include <openssl/bio.h>
|
||||
#ifndef OPENSSL_NO_DGRAM
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
|
||||
#if defined(OPENSSL_SYS_VMS)
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
@@ -77,10 +77,24 @@
|
||||
#define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && !defined(IP_MTU)
|
||||
#define IP_MTU 14 /* linux is lame */
|
||||
#endif
|
||||
|
||||
#if OPENSSL_USE_IPV6 && !defined(IPPROTO_IPV6)
|
||||
#define IPPROTO_IPV6 41 /* windows is lame */
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) && defined(IN6_IS_ADDR_V4MAPPED)
|
||||
/* Standard definition causes type-punning problems. */
|
||||
#undef IN6_IS_ADDR_V4MAPPED
|
||||
#define s6_addr32 __u6_addr.__u6_addr32
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == htonl(0x0000ffff)))
|
||||
#endif
|
||||
|
||||
#ifdef WATT32
|
||||
#define sock_write SockWrite /* Watt-32 uses same names */
|
||||
#define sock_read SockRead
|
||||
@@ -255,7 +269,7 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
{
|
||||
#if defined(SO_RCVTIMEO)
|
||||
bio_dgram_data *data = (bio_dgram_data *)b->ptr;
|
||||
int sz = sizeof(int);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
|
||||
/* Is a timer active? */
|
||||
if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
|
||||
@@ -265,8 +279,10 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
/* Read current socket timeout */
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); }
|
||||
else
|
||||
{
|
||||
@@ -274,9 +290,12 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
data->socket_timeout.tv_usec = (timeout % 1000) * 1000;
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(data->socket_timeout);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
&(data->socket_timeout), (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
OPENSSL_assert(sz.s<=sizeof(data->socket_timeout));
|
||||
#endif
|
||||
|
||||
/* Get current time */
|
||||
@@ -445,11 +464,10 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
int *ip;
|
||||
struct sockaddr *to = NULL;
|
||||
bio_dgram_data *data = NULL;
|
||||
#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
|
||||
long sockopt_val = 0;
|
||||
unsigned int sockopt_len = 0;
|
||||
#endif
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
int sockopt_val = 0;
|
||||
#if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
|
||||
socklen_t sockopt_len; /* assume that system supporting IP_MTU is
|
||||
* modern enough to define socklen_t */
|
||||
socklen_t addr_len;
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
@@ -531,7 +549,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
break;
|
||||
/* (Linux)kernel sets DF bit on outgoing IP packets */
|
||||
case BIO_CTRL_DGRAM_MTU_DISCOVER:
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
||||
addr_len = (socklen_t)sizeof(addr);
|
||||
memset((void *)&addr, 0, sizeof(addr));
|
||||
if (getsockname(b->num, &addr.sa, &addr_len) < 0)
|
||||
@@ -539,7 +557,6 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
sockopt_len = sizeof(sockopt_val);
|
||||
switch (addr.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
@@ -548,7 +565,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
perror("setsockopt");
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER)
|
||||
#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO)
|
||||
case AF_INET6:
|
||||
sockopt_val = IPV6_PMTUDISC_DO;
|
||||
if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
|
||||
@@ -565,7 +582,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_QUERY_MTU:
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU)
|
||||
addr_len = (socklen_t)sizeof(addr);
|
||||
memset((void *)&addr, 0, sizeof(addr));
|
||||
if (getsockname(b->num, &addr.sa, &addr_len) < 0)
|
||||
@@ -727,12 +744,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
{
|
||||
int timeout, sz = sizeof(timeout);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
struct timeval *tv = (struct timeval *)ptr;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else
|
||||
{
|
||||
@@ -740,12 +760,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
tv->tv_usec = (timeout % 1000) * 1000;
|
||||
ret = sizeof(*tv);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(struct timeval);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
ptr, (void *)&ret) < 0)
|
||||
ptr, (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
{
|
||||
OPENSSL_assert(sz.s<=sizeof(struct timeval));
|
||||
ret = (int)sz.s;
|
||||
}
|
||||
else
|
||||
ret = sz.i;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(SO_SNDTIMEO)
|
||||
@@ -765,12 +793,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
{
|
||||
int timeout, sz = sizeof(timeout);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
struct timeval *tv = (struct timeval *)ptr;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else
|
||||
{
|
||||
@@ -778,12 +809,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
tv->tv_usec = (timeout % 1000) * 1000;
|
||||
ret = sizeof(*tv);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(struct timeval);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
|
||||
ptr, (void *)&ret) < 0)
|
||||
ptr, (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
{
|
||||
OPENSSL_assert(sz.s<=sizeof(struct timeval));
|
||||
ret = (int)sz.s;
|
||||
}
|
||||
else
|
||||
ret = sz.i;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
|
||||
@@ -812,6 +851,50 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_SET_DONT_FRAG:
|
||||
sockopt_val = num ? 1 : 0;
|
||||
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
#if defined(IP_DONTFRAG)
|
||||
if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAG,
|
||||
&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
{ perror("setsockopt"); ret = -1; }
|
||||
#elif defined(OPENSSL_SYS_LINUX) && defined(IP_MTUDISCOVER)
|
||||
if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
|
||||
(ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
|
||||
&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
{ perror("setsockopt"); ret = -1; }
|
||||
#elif defined(OPENSSL_SYS_WINDOWS) && defined(IP_DONTFRAGMENT)
|
||||
if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAGMENT,
|
||||
(const char *)&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
{ perror("setsockopt"); ret = -1; }
|
||||
#else
|
||||
ret = -1;
|
||||
#endif
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#if defined(IPV6_DONTFRAG)
|
||||
if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_DONTFRAG,
|
||||
(const void *)&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
{ perror("setsockopt"); ret = -1; }
|
||||
#elif defined(OPENSSL_SYS_LINUX) && defined(IPV6_MTUDISCOVER)
|
||||
if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
|
||||
(ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
|
||||
&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
{ perror("setsockopt"); ret = -1; }
|
||||
#else
|
||||
ret = -1;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
@@ -871,8 +954,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
memset(authchunks, 0, sizeof(sockopt_len));
|
||||
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
|
||||
for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t);
|
||||
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + sockopt_len;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
@@ -955,7 +1038,6 @@ static int dgram_sctp_free(BIO *a)
|
||||
#ifdef SCTP_AUTHENTICATION_EVENT
|
||||
void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
|
||||
{
|
||||
unsigned int sockopt_len = 0;
|
||||
int ret;
|
||||
struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event;
|
||||
|
||||
@@ -965,9 +1047,8 @@ void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp)
|
||||
|
||||
/* delete key */
|
||||
authkeyid.scact_keynumber = authkeyevent->auth_keynumber;
|
||||
sockopt_len = sizeof(struct sctp_authkeyid);
|
||||
ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY,
|
||||
&authkeyid, sockopt_len);
|
||||
&authkeyid, sizeof(struct sctp_authkeyid));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1164,7 +1245,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
|
||||
OPENSSL_assert(ii >= 0);
|
||||
|
||||
for (p = (unsigned char*) authchunks + sizeof(sctp_assoc_t);
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + optlen;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
@@ -1298,7 +1379,7 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
bio_dgram_sctp_data *data = NULL;
|
||||
unsigned int sockopt_len = 0;
|
||||
socklen_t sockopt_len = 0;
|
||||
struct sctp_authkeyid authkeyid;
|
||||
struct sctp_authkey *authkey;
|
||||
|
||||
@@ -1814,11 +1895,15 @@ int BIO_dgram_non_fatal_error(int err)
|
||||
|
||||
static void get_current_time(struct timeval *t)
|
||||
{
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
struct _timeb tb;
|
||||
_ftime(&tb);
|
||||
t->tv_sec = (long)tb.time;
|
||||
t->tv_usec = (long)tb.millitm * 1000;
|
||||
#if defined(_WIN32)
|
||||
SYSTEMTIME st;
|
||||
union { unsigned __int64 ul; FILETIME ft; } now;
|
||||
|
||||
GetSystemTime(&st);
|
||||
SystemTimeToFileTime(&st,&now.ft);
|
||||
now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */
|
||||
t->tv_sec = (long)(now.ul/10000000);
|
||||
t->tv_usec = ((int)(now.ul%10000000))/10;
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
struct timeb tb;
|
||||
ftime(&tb);
|
||||
|
||||
@@ -63,9 +63,25 @@
|
||||
|
||||
#if defined(OPENSSL_NO_POSIX_IO)
|
||||
/*
|
||||
* One can argue that one should implement dummy placeholder for
|
||||
* BIO_s_fd here...
|
||||
* Dummy placeholder for BIO_s_fd...
|
||||
*/
|
||||
BIO *BIO_new_fd(int fd,int close_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
int BIO_fd_non_fatal_error(int err)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int BIO_fd_should_retry(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIO_METHOD *BIO_s_fd(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* As for unconditional usage of "UPLINK" interface in this module.
|
||||
|
||||
@@ -5,3 +5,6 @@ semantic.cache
|
||||
co-*.s
|
||||
bn-*.s
|
||||
*-mont.s
|
||||
modexp512-x86_64.s
|
||||
*-gf2m.s
|
||||
x86_64-mont5.s
|
||||
|
||||
@@ -77,6 +77,12 @@ sparcv9a-mont.s: asm/sparcv9a-mont.pl
|
||||
$(PERL) asm/sparcv9a-mont.pl $(CFLAGS) > $@
|
||||
sparcv9-mont.s: asm/sparcv9-mont.pl
|
||||
$(PERL) asm/sparcv9-mont.pl $(CFLAGS) > $@
|
||||
vis3-mont.s: asm/vis3-mont.pl
|
||||
$(PERL) asm/vis3-mont.pl $(CFLAGS) > $@
|
||||
sparct4-mont.S: asm/sparct4-mont.pl
|
||||
$(PERL) asm/sparct4-mont.pl $(CFLAGS) > $@
|
||||
sparcv9-gf2m.S: asm/sparcv9-gf2m.pl
|
||||
$(PERL) asm/sparcv9-gf2m.pl $(CFLAGS) > $@
|
||||
|
||||
bn-mips3.o: asm/mips3.s
|
||||
@if [ "$(CC)" = "gcc" ]; then \
|
||||
@@ -104,6 +110,10 @@ x86_64-gf2m.s: asm/x86_64-gf2m.pl
|
||||
$(PERL) asm/x86_64-gf2m.pl $(PERLASM_SCHEME) > $@
|
||||
modexp512-x86_64.s: asm/modexp512-x86_64.pl
|
||||
$(PERL) asm/modexp512-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
rsaz-x86_64.s: asm/rsaz-x86_64.pl
|
||||
$(PERL) asm/rsaz-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
rsaz-avx2.s: asm/rsaz-avx2.pl
|
||||
$(PERL) asm/rsaz-avx2.pl $(PERLASM_SCHEME) > $@
|
||||
|
||||
bn-ia64.s: asm/ia64.S
|
||||
$(CC) $(CFLAGS) -E asm/ia64.S > $@
|
||||
@@ -125,12 +135,15 @@ ppc-mont.s: asm/ppc-mont.pl;$(PERL) asm/ppc-mont.pl $(PERLASM_SCHEME) $@
|
||||
ppc64-mont.s: asm/ppc64-mont.pl;$(PERL) asm/ppc64-mont.pl $(PERLASM_SCHEME) $@
|
||||
|
||||
alpha-mont.s: asm/alpha-mont.pl
|
||||
$(PERL) $< | $(CC) -E - | tee $@ > /dev/null
|
||||
(preproc=/tmp/$$$$.$@; trap "rm $$preproc" INT; \
|
||||
$(PERL) asm/alpha-mont.pl > $$preproc && \
|
||||
$(CC) -E $$preproc > $@ && rm $$preproc)
|
||||
|
||||
# GNU make "catch all"
|
||||
%-mont.s: asm/%-mont.pl; $(PERL) $< $(PERLASM_SCHEME) $@
|
||||
%-mont.S: asm/%-mont.pl; $(PERL) $< $(PERLASM_SCHEME) $@
|
||||
%-gf2m.S: asm/%-gf2m.pl; $(PERL) $< $(PERLASM_SCHEME) $@
|
||||
|
||||
armv4-mont.o: armv4-mont.S
|
||||
armv4-gf2m.o: armv4-gf2m.S
|
||||
|
||||
files:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# ====================================================================
|
||||
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
|
||||
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||
# project. The module is, however, dual licensed under OpenSSL and
|
||||
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
||||
# details see http://www.openssl.org/~appro/cryptogams/.
|
||||
@@ -23,6 +23,21 @@
|
||||
# than 1/2KB. Windows CE port would be trivial, as it's exclusively
|
||||
# about decorations, ABI and instruction syntax are identical.
|
||||
|
||||
# November 2013
|
||||
#
|
||||
# Add NEON code path, which handles lengths divisible by 8. RSA/DSA
|
||||
# performance improvement on Cortex-A8 is ~45-100% depending on key
|
||||
# length, more for longer keys. On Cortex-A15 the span is ~10-105%.
|
||||
# On Snapdragon S4 improvement was measured to vary from ~70% to
|
||||
# incredible ~380%, yes, 4.8x faster, for RSA4096 sign. But this is
|
||||
# rather because original integer-only code seems to perform
|
||||
# suboptimally on S4. Situation on Cortex-A9 is unfortunately
|
||||
# different. It's being looked into, but the trouble is that
|
||||
# performance for vectors longer than 256 bits is actually couple
|
||||
# of percent worse than for integer-only code. The code is chosen
|
||||
# for execution on all NEON-capable processors, because gain on
|
||||
# others outweighs the marginal loss on Cortex-A9.
|
||||
|
||||
while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
|
||||
@@ -52,16 +67,40 @@ $_n0="$num,#14*4";
|
||||
$_num="$num,#15*4"; $_bpend=$_num;
|
||||
|
||||
$code=<<___;
|
||||
#include "arm_arch.h"
|
||||
|
||||
.text
|
||||
.code 32
|
||||
|
||||
#if __ARM_ARCH__>=7
|
||||
.align 5
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-bn_mul_mont
|
||||
#endif
|
||||
|
||||
.global bn_mul_mont
|
||||
.type bn_mul_mont,%function
|
||||
|
||||
.align 2
|
||||
.align 5
|
||||
bn_mul_mont:
|
||||
ldr ip,[sp,#4] @ load num
|
||||
stmdb sp!,{r0,r2} @ sp points at argument block
|
||||
ldr $num,[sp,#3*4] @ load num
|
||||
cmp $num,#2
|
||||
#if __ARM_ARCH__>=7
|
||||
tst ip,#7
|
||||
bne .Lialu
|
||||
adr r0,bn_mul_mont
|
||||
ldr r2,.LOPENSSL_armcap
|
||||
ldr r0,[r0,r2]
|
||||
tst r0,#1 @ NEON available?
|
||||
ldmia sp, {r0,r2}
|
||||
beq .Lialu
|
||||
add sp,sp,#8
|
||||
b bn_mul8x_mont_neon
|
||||
.align 4
|
||||
.Lialu:
|
||||
#endif
|
||||
cmp ip,#2
|
||||
mov $num,ip @ load num
|
||||
movlt r0,#0
|
||||
addlt sp,sp,#2*4
|
||||
blt .Labrt
|
||||
@@ -195,10 +234,436 @@ bn_mul_mont:
|
||||
moveq pc,lr @ be binary compatible with V4, yet
|
||||
bx lr @ interoperable with Thumb ISA:-)
|
||||
.size bn_mul_mont,.-bn_mul_mont
|
||||
.asciz "Montgomery multiplication for ARMv4, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
___
|
||||
{
|
||||
sub Dlo() { shift=~m|q([1]?[0-9])|?"d".($1*2):""; }
|
||||
sub Dhi() { shift=~m|q([1]?[0-9])|?"d".($1*2+1):""; }
|
||||
|
||||
my ($A0,$A1,$A2,$A3)=map("d$_",(0..3));
|
||||
my ($N0,$N1,$N2,$N3)=map("d$_",(4..7));
|
||||
my ($Z,$Temp)=("q4","q5");
|
||||
my ($A0xB,$A1xB,$A2xB,$A3xB,$A4xB,$A5xB,$A6xB,$A7xB)=map("q$_",(6..13));
|
||||
my ($Bi,$Ni,$M0)=map("d$_",(28..31));
|
||||
my $zero=&Dlo($Z);
|
||||
my $temp=&Dlo($Temp);
|
||||
|
||||
my ($rptr,$aptr,$bptr,$nptr,$n0,$num)=map("r$_",(0..5));
|
||||
my ($tinptr,$toutptr,$inner,$outer)=map("r$_",(6..9));
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
.fpu neon
|
||||
|
||||
.type bn_mul8x_mont_neon,%function
|
||||
.align 5
|
||||
bn_mul8x_mont_neon:
|
||||
mov ip,sp
|
||||
stmdb sp!,{r4-r11}
|
||||
vstmdb sp!,{d8-d15} @ ABI specification says so
|
||||
ldmia ip,{r4-r5} @ load rest of parameter block
|
||||
|
||||
sub $toutptr,sp,#16
|
||||
vld1.32 {${Bi}[0]}, [$bptr,:32]!
|
||||
sub $toutptr,$toutptr,$num,lsl#4
|
||||
vld1.32 {$A0-$A3}, [$aptr]! @ can't specify :32 :-(
|
||||
and $toutptr,$toutptr,#-64
|
||||
vld1.32 {${M0}[0]}, [$n0,:32]
|
||||
mov sp,$toutptr @ alloca
|
||||
veor $zero,$zero,$zero
|
||||
subs $inner,$num,#8
|
||||
vzip.16 $Bi,$zero
|
||||
|
||||
vmull.u32 $A0xB,$Bi,${A0}[0]
|
||||
vmull.u32 $A1xB,$Bi,${A0}[1]
|
||||
vmull.u32 $A2xB,$Bi,${A1}[0]
|
||||
vshl.i64 $temp,`&Dhi("$A0xB")`,#16
|
||||
vmull.u32 $A3xB,$Bi,${A1}[1]
|
||||
|
||||
vadd.u64 $temp,$temp,`&Dlo("$A0xB")`
|
||||
veor $zero,$zero,$zero
|
||||
vmul.u32 $Ni,$temp,$M0
|
||||
|
||||
vmull.u32 $A4xB,$Bi,${A2}[0]
|
||||
vld1.32 {$N0-$N3}, [$nptr]!
|
||||
vmull.u32 $A5xB,$Bi,${A2}[1]
|
||||
vmull.u32 $A6xB,$Bi,${A3}[0]
|
||||
vzip.16 $Ni,$zero
|
||||
vmull.u32 $A7xB,$Bi,${A3}[1]
|
||||
|
||||
bne .LNEON_1st
|
||||
|
||||
@ special case for num=8, everything is in register bank...
|
||||
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
sub $outer,$num,#1
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vmov $Temp,$A0xB
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vmov $A0xB,$A1xB
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vmov $A1xB,$A2xB
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
vmov $A2xB,$A3xB
|
||||
vmov $A3xB,$A4xB
|
||||
vshr.u64 $temp,$temp,#16
|
||||
vmov $A4xB,$A5xB
|
||||
vmov $A5xB,$A6xB
|
||||
vadd.u64 $temp,$temp,`&Dhi("$Temp")`
|
||||
vmov $A6xB,$A7xB
|
||||
veor $A7xB,$A7xB
|
||||
vshr.u64 $temp,$temp,#16
|
||||
|
||||
b .LNEON_outer8
|
||||
|
||||
.align 4
|
||||
.LNEON_outer8:
|
||||
vld1.32 {${Bi}[0]}, [$bptr,:32]!
|
||||
veor $zero,$zero,$zero
|
||||
vzip.16 $Bi,$zero
|
||||
vadd.u64 `&Dlo("$A0xB")`,`&Dlo("$A0xB")`,$temp
|
||||
|
||||
vmlal.u32 $A0xB,$Bi,${A0}[0]
|
||||
vmlal.u32 $A1xB,$Bi,${A0}[1]
|
||||
vmlal.u32 $A2xB,$Bi,${A1}[0]
|
||||
vshl.i64 $temp,`&Dhi("$A0xB")`,#16
|
||||
vmlal.u32 $A3xB,$Bi,${A1}[1]
|
||||
|
||||
vadd.u64 $temp,$temp,`&Dlo("$A0xB")`
|
||||
veor $zero,$zero,$zero
|
||||
subs $outer,$outer,#1
|
||||
vmul.u32 $Ni,$temp,$M0
|
||||
|
||||
vmlal.u32 $A4xB,$Bi,${A2}[0]
|
||||
vmlal.u32 $A5xB,$Bi,${A2}[1]
|
||||
vmlal.u32 $A6xB,$Bi,${A3}[0]
|
||||
vzip.16 $Ni,$zero
|
||||
vmlal.u32 $A7xB,$Bi,${A3}[1]
|
||||
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vmov $Temp,$A0xB
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vmov $A0xB,$A1xB
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vmov $A1xB,$A2xB
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
vmov $A2xB,$A3xB
|
||||
vmov $A3xB,$A4xB
|
||||
vshr.u64 $temp,$temp,#16
|
||||
vmov $A4xB,$A5xB
|
||||
vmov $A5xB,$A6xB
|
||||
vadd.u64 $temp,$temp,`&Dhi("$Temp")`
|
||||
vmov $A6xB,$A7xB
|
||||
veor $A7xB,$A7xB
|
||||
vshr.u64 $temp,$temp,#16
|
||||
|
||||
bne .LNEON_outer8
|
||||
|
||||
vadd.u64 `&Dlo("$A0xB")`,`&Dlo("$A0xB")`,$temp
|
||||
mov $toutptr,sp
|
||||
vshr.u64 $temp,`&Dlo("$A0xB")`,#16
|
||||
mov $inner,$num
|
||||
vadd.u64 `&Dhi("$A0xB")`,`&Dhi("$A0xB")`,$temp
|
||||
add $tinptr,sp,#16
|
||||
vshr.u64 $temp,`&Dhi("$A0xB")`,#16
|
||||
vzip.16 `&Dlo("$A0xB")`,`&Dhi("$A0xB")`
|
||||
|
||||
b .LNEON_tail2
|
||||
|
||||
.align 4
|
||||
.LNEON_1st:
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
vld1.32 {$A0-$A3}, [$aptr]!
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
subs $inner,$inner,#8
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vld1.32 {$N0-$N1}, [$nptr]!
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vst1.64 {$A0xB-$A1xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
vst1.64 {$A2xB-$A3xB}, [$toutptr,:256]!
|
||||
|
||||
vmull.u32 $A0xB,$Bi,${A0}[0]
|
||||
vld1.32 {$N2-$N3}, [$nptr]!
|
||||
vmull.u32 $A1xB,$Bi,${A0}[1]
|
||||
vst1.64 {$A4xB-$A5xB}, [$toutptr,:256]!
|
||||
vmull.u32 $A2xB,$Bi,${A1}[0]
|
||||
vmull.u32 $A3xB,$Bi,${A1}[1]
|
||||
vst1.64 {$A6xB-$A7xB}, [$toutptr,:256]!
|
||||
|
||||
vmull.u32 $A4xB,$Bi,${A2}[0]
|
||||
vmull.u32 $A5xB,$Bi,${A2}[1]
|
||||
vmull.u32 $A6xB,$Bi,${A3}[0]
|
||||
vmull.u32 $A7xB,$Bi,${A3}[1]
|
||||
|
||||
bne .LNEON_1st
|
||||
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
add $tinptr,sp,#16
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
sub $aptr,$aptr,$num,lsl#2 @ rewind $aptr
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vld1.64 {$Temp}, [sp,:128]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
sub $outer,$num,#1
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vst1.64 {$A0xB-$A1xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vshr.u64 $temp,$temp,#16
|
||||
vld1.64 {$A0xB}, [$tinptr, :128]!
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vst1.64 {$A2xB-$A3xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
|
||||
vst1.64 {$A4xB-$A5xB}, [$toutptr,:256]!
|
||||
vadd.u64 $temp,$temp,`&Dhi("$Temp")`
|
||||
veor $Z,$Z,$Z
|
||||
vst1.64 {$A6xB-$A7xB}, [$toutptr,:256]!
|
||||
vld1.64 {$A1xB-$A2xB}, [$tinptr, :256]!
|
||||
vst1.64 {$Z}, [$toutptr,:128]
|
||||
vshr.u64 $temp,$temp,#16
|
||||
|
||||
b .LNEON_outer
|
||||
|
||||
.align 4
|
||||
.LNEON_outer:
|
||||
vld1.32 {${Bi}[0]}, [$bptr,:32]!
|
||||
sub $nptr,$nptr,$num,lsl#2 @ rewind $nptr
|
||||
vld1.32 {$A0-$A3}, [$aptr]!
|
||||
veor $zero,$zero,$zero
|
||||
mov $toutptr,sp
|
||||
vzip.16 $Bi,$zero
|
||||
sub $inner,$num,#8
|
||||
vadd.u64 `&Dlo("$A0xB")`,`&Dlo("$A0xB")`,$temp
|
||||
|
||||
vmlal.u32 $A0xB,$Bi,${A0}[0]
|
||||
vld1.64 {$A3xB-$A4xB},[$tinptr,:256]!
|
||||
vmlal.u32 $A1xB,$Bi,${A0}[1]
|
||||
vmlal.u32 $A2xB,$Bi,${A1}[0]
|
||||
vld1.64 {$A5xB-$A6xB},[$tinptr,:256]!
|
||||
vmlal.u32 $A3xB,$Bi,${A1}[1]
|
||||
|
||||
vshl.i64 $temp,`&Dhi("$A0xB")`,#16
|
||||
veor $zero,$zero,$zero
|
||||
vadd.u64 $temp,$temp,`&Dlo("$A0xB")`
|
||||
vld1.64 {$A7xB},[$tinptr,:128]!
|
||||
vmul.u32 $Ni,$temp,$M0
|
||||
|
||||
vmlal.u32 $A4xB,$Bi,${A2}[0]
|
||||
vld1.32 {$N0-$N3}, [$nptr]!
|
||||
vmlal.u32 $A5xB,$Bi,${A2}[1]
|
||||
vmlal.u32 $A6xB,$Bi,${A3}[0]
|
||||
vzip.16 $Ni,$zero
|
||||
vmlal.u32 $A7xB,$Bi,${A3}[1]
|
||||
|
||||
.LNEON_inner:
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
vld1.32 {$A0-$A3}, [$aptr]!
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
subs $inner,$inner,#8
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
vst1.64 {$A0xB-$A1xB}, [$toutptr,:256]!
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vld1.64 {$A0xB}, [$tinptr, :128]!
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vst1.64 {$A2xB-$A3xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vld1.64 {$A1xB-$A2xB}, [$tinptr, :256]!
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
vst1.64 {$A4xB-$A5xB}, [$toutptr,:256]!
|
||||
|
||||
vmlal.u32 $A0xB,$Bi,${A0}[0]
|
||||
vld1.64 {$A3xB-$A4xB}, [$tinptr, :256]!
|
||||
vmlal.u32 $A1xB,$Bi,${A0}[1]
|
||||
vst1.64 {$A6xB-$A7xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A2xB,$Bi,${A1}[0]
|
||||
vld1.64 {$A5xB-$A6xB}, [$tinptr, :256]!
|
||||
vmlal.u32 $A3xB,$Bi,${A1}[1]
|
||||
vld1.32 {$N0-$N3}, [$nptr]!
|
||||
|
||||
vmlal.u32 $A4xB,$Bi,${A2}[0]
|
||||
vld1.64 {$A7xB}, [$tinptr, :128]!
|
||||
vmlal.u32 $A5xB,$Bi,${A2}[1]
|
||||
vmlal.u32 $A6xB,$Bi,${A3}[0]
|
||||
vmlal.u32 $A7xB,$Bi,${A3}[1]
|
||||
|
||||
bne .LNEON_inner
|
||||
|
||||
vmlal.u32 $A0xB,$Ni,${N0}[0]
|
||||
add $tinptr,sp,#16
|
||||
vmlal.u32 $A1xB,$Ni,${N0}[1]
|
||||
sub $aptr,$aptr,$num,lsl#2 @ rewind $aptr
|
||||
vmlal.u32 $A2xB,$Ni,${N1}[0]
|
||||
vld1.64 {$Temp}, [sp,:128]
|
||||
vmlal.u32 $A3xB,$Ni,${N1}[1]
|
||||
subs $outer,$outer,#1
|
||||
|
||||
vmlal.u32 $A4xB,$Ni,${N2}[0]
|
||||
vst1.64 {$A0xB-$A1xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A5xB,$Ni,${N2}[1]
|
||||
vld1.64 {$A0xB}, [$tinptr, :128]!
|
||||
vshr.u64 $temp,$temp,#16
|
||||
vst1.64 {$A2xB-$A3xB}, [$toutptr,:256]!
|
||||
vmlal.u32 $A6xB,$Ni,${N3}[0]
|
||||
vld1.64 {$A1xB-$A2xB}, [$tinptr, :256]!
|
||||
vmlal.u32 $A7xB,$Ni,${N3}[1]
|
||||
|
||||
vst1.64 {$A4xB-$A5xB}, [$toutptr,:256]!
|
||||
vadd.u64 $temp,$temp,`&Dhi("$Temp")`
|
||||
vst1.64 {$A6xB-$A7xB}, [$toutptr,:256]!
|
||||
vshr.u64 $temp,$temp,#16
|
||||
|
||||
bne .LNEON_outer
|
||||
|
||||
mov $toutptr,sp
|
||||
mov $inner,$num
|
||||
|
||||
.LNEON_tail:
|
||||
vadd.u64 `&Dlo("$A0xB")`,`&Dlo("$A0xB")`,$temp
|
||||
vld1.64 {$A3xB-$A4xB}, [$tinptr, :256]!
|
||||
vshr.u64 $temp,`&Dlo("$A0xB")`,#16
|
||||
vadd.u64 `&Dhi("$A0xB")`,`&Dhi("$A0xB")`,$temp
|
||||
vld1.64 {$A5xB-$A6xB}, [$tinptr, :256]!
|
||||
vshr.u64 $temp,`&Dhi("$A0xB")`,#16
|
||||
vld1.64 {$A7xB}, [$tinptr, :128]!
|
||||
vzip.16 `&Dlo("$A0xB")`,`&Dhi("$A0xB")`
|
||||
|
||||
.LNEON_tail2:
|
||||
vadd.u64 `&Dlo("$A1xB")`,`&Dlo("$A1xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A0xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A1xB")`,#16
|
||||
vadd.u64 `&Dhi("$A1xB")`,`&Dhi("$A1xB")`,$temp
|
||||
vshr.u64 $temp,`&Dhi("$A1xB")`,#16
|
||||
vzip.16 `&Dlo("$A1xB")`,`&Dhi("$A1xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A2xB")`,`&Dlo("$A2xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A1xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A2xB")`,#16
|
||||
vadd.u64 `&Dhi("$A2xB")`,`&Dhi("$A2xB")`,$temp
|
||||
vshr.u64 $temp,`&Dhi("$A2xB")`,#16
|
||||
vzip.16 `&Dlo("$A2xB")`,`&Dhi("$A2xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A3xB")`,`&Dlo("$A3xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A2xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A3xB")`,#16
|
||||
vadd.u64 `&Dhi("$A3xB")`,`&Dhi("$A3xB")`,$temp
|
||||
vshr.u64 $temp,`&Dhi("$A3xB")`,#16
|
||||
vzip.16 `&Dlo("$A3xB")`,`&Dhi("$A3xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A4xB")`,`&Dlo("$A4xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A3xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A4xB")`,#16
|
||||
vadd.u64 `&Dhi("$A4xB")`,`&Dhi("$A4xB")`,$temp
|
||||
vshr.u64 $temp,`&Dhi("$A4xB")`,#16
|
||||
vzip.16 `&Dlo("$A4xB")`,`&Dhi("$A4xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A5xB")`,`&Dlo("$A5xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A4xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A5xB")`,#16
|
||||
vadd.u64 `&Dhi("$A5xB")`,`&Dhi("$A5xB")`,$temp
|
||||
vshr.u64 $temp,`&Dhi("$A5xB")`,#16
|
||||
vzip.16 `&Dlo("$A5xB")`,`&Dhi("$A5xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A6xB")`,`&Dlo("$A6xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A5xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A6xB")`,#16
|
||||
vadd.u64 `&Dhi("$A6xB")`,`&Dhi("$A6xB")`,$temp
|
||||
vld1.64 {$A0xB}, [$tinptr, :128]!
|
||||
vshr.u64 $temp,`&Dhi("$A6xB")`,#16
|
||||
vzip.16 `&Dlo("$A6xB")`,`&Dhi("$A6xB")`
|
||||
|
||||
vadd.u64 `&Dlo("$A7xB")`,`&Dlo("$A7xB")`,$temp
|
||||
vst1.32 {`&Dlo("$A6xB")`[0]}, [$toutptr, :32]!
|
||||
vshr.u64 $temp,`&Dlo("$A7xB")`,#16
|
||||
vadd.u64 `&Dhi("$A7xB")`,`&Dhi("$A7xB")`,$temp
|
||||
vld1.64 {$A1xB-$A2xB}, [$tinptr, :256]!
|
||||
vshr.u64 $temp,`&Dhi("$A7xB")`,#16
|
||||
vzip.16 `&Dlo("$A7xB")`,`&Dhi("$A7xB")`
|
||||
subs $inner,$inner,#8
|
||||
vst1.32 {`&Dlo("$A7xB")`[0]}, [$toutptr, :32]!
|
||||
|
||||
bne .LNEON_tail
|
||||
|
||||
vst1.32 {${temp}[0]}, [$toutptr, :32] @ top-most bit
|
||||
sub $nptr,$nptr,$num,lsl#2 @ rewind $nptr
|
||||
subs $aptr,sp,#0 @ clear carry flag
|
||||
add $bptr,sp,$num,lsl#2
|
||||
|
||||
.LNEON_sub:
|
||||
ldmia $aptr!, {r4-r7}
|
||||
ldmia $nptr!, {r8-r11}
|
||||
sbcs r8, r4,r8
|
||||
sbcs r9, r5,r9
|
||||
sbcs r10,r6,r10
|
||||
sbcs r11,r7,r11
|
||||
teq $aptr,$bptr @ preserves carry
|
||||
stmia $rptr!, {r8-r11}
|
||||
bne .LNEON_sub
|
||||
|
||||
ldr r10, [$aptr] @ load top-most bit
|
||||
veor q0,q0,q0
|
||||
sub r11,$bptr,sp @ this is num*4
|
||||
veor q1,q1,q1
|
||||
mov $aptr,sp
|
||||
sub $rptr,$rptr,r11 @ rewind $rptr
|
||||
mov $nptr,$bptr @ second 3/4th of frame
|
||||
sbcs r10,r10,#0 @ result is carry flag
|
||||
|
||||
.LNEON_copy_n_zap:
|
||||
ldmia $aptr!, {r4-r7}
|
||||
ldmia $rptr, {r8-r11}
|
||||
movcc r8, r4
|
||||
vst1.64 {q0-q1}, [$nptr,:256]! @ wipe
|
||||
movcc r9, r5
|
||||
movcc r10,r6
|
||||
vst1.64 {q0-q1}, [$nptr,:256]! @ wipe
|
||||
movcc r11,r7
|
||||
ldmia $aptr, {r4-r7}
|
||||
stmia $rptr!, {r8-r11}
|
||||
sub $aptr,$aptr,#16
|
||||
ldmia $rptr, {r8-r11}
|
||||
movcc r8, r4
|
||||
vst1.64 {q0-q1}, [$aptr,:256]! @ wipe
|
||||
movcc r9, r5
|
||||
movcc r10,r6
|
||||
vst1.64 {q0-q1}, [$nptr,:256]! @ wipe
|
||||
movcc r11,r7
|
||||
teq $aptr,$bptr @ preserves carry
|
||||
stmia $rptr!, {r8-r11}
|
||||
bne .LNEON_copy_n_zap
|
||||
|
||||
sub sp,ip,#96
|
||||
vldmia sp!,{d8-d15}
|
||||
ldmia sp!,{r4-r11}
|
||||
bx lr
|
||||
.size bn_mul8x_mont_neon,.-bn_mul8x_mont_neon
|
||||
#endif
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
.asciz "Montgomery multiplication for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 2
|
||||
#if __ARM_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
||||
$code =~ s/\`([^\`]*)\`/eval $1/gem;
|
||||
$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4
|
||||
print $code;
|
||||
close STDOUT;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23));
|
||||
# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31));
|
||||
#
|
||||
$flavour = shift; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
$flavour = shift || "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$PTR_ADD="dadd"; # incidentally works even on n32
|
||||
@@ -133,7 +133,7 @@ $code.=<<___;
|
||||
bnez $at,1f
|
||||
li $t0,0
|
||||
slt $at,$num,17 # on in-order CPU
|
||||
bnezl $at,bn_mul_mont_internal
|
||||
bnez $at,bn_mul_mont_internal
|
||||
nop
|
||||
1: jr $ra
|
||||
li $a0,0
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
# has to content with 40-85% improvement depending on benchmark and
|
||||
# key length, more for longer keys.
|
||||
|
||||
$flavour = shift;
|
||||
$flavour = shift || "o32";
|
||||
while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
|
||||
@@ -140,10 +140,10 @@ $code.=<<___;
|
||||
.set reorder
|
||||
li $minus4,-4
|
||||
and $ta0,$a2,$minus4
|
||||
$LD $t0,0($a1)
|
||||
beqz $ta0,.L_bn_mul_add_words_tail
|
||||
|
||||
.L_bn_mul_add_words_loop:
|
||||
$LD $t0,0($a1)
|
||||
$MULTU $t0,$a3
|
||||
$LD $t1,0($a0)
|
||||
$LD $t2,$BNSZ($a1)
|
||||
@@ -200,10 +200,9 @@ $code.=<<___;
|
||||
$ADDU $v0,$ta2
|
||||
sltu $at,$ta3,$at
|
||||
$ST $ta3,-$BNSZ($a0)
|
||||
$ADDU $v0,$at
|
||||
.set noreorder
|
||||
bgtzl $ta0,.L_bn_mul_add_words_loop
|
||||
$LD $t0,0($a1)
|
||||
bgtz $ta0,.L_bn_mul_add_words_loop
|
||||
$ADDU $v0,$at
|
||||
|
||||
beqz $a2,.L_bn_mul_add_words_return
|
||||
nop
|
||||
@@ -300,10 +299,10 @@ $code.=<<___;
|
||||
.set reorder
|
||||
li $minus4,-4
|
||||
and $ta0,$a2,$minus4
|
||||
$LD $t0,0($a1)
|
||||
beqz $ta0,.L_bn_mul_words_tail
|
||||
|
||||
.L_bn_mul_words_loop:
|
||||
$LD $t0,0($a1)
|
||||
$MULTU $t0,$a3
|
||||
$LD $t2,$BNSZ($a1)
|
||||
$LD $ta0,2*$BNSZ($a1)
|
||||
@@ -341,10 +340,9 @@ $code.=<<___;
|
||||
$ADDU $v0,$at
|
||||
sltu $ta3,$v0,$at
|
||||
$ST $v0,-$BNSZ($a0)
|
||||
$ADDU $v0,$ta3,$ta2
|
||||
.set noreorder
|
||||
bgtzl $ta0,.L_bn_mul_words_loop
|
||||
$LD $t0,0($a1)
|
||||
bgtz $ta0,.L_bn_mul_words_loop
|
||||
$ADDU $v0,$ta3,$ta2
|
||||
|
||||
beqz $a2,.L_bn_mul_words_return
|
||||
nop
|
||||
@@ -429,10 +427,10 @@ $code.=<<___;
|
||||
.set reorder
|
||||
li $minus4,-4
|
||||
and $ta0,$a2,$minus4
|
||||
$LD $t0,0($a1)
|
||||
beqz $ta0,.L_bn_sqr_words_tail
|
||||
|
||||
.L_bn_sqr_words_loop:
|
||||
$LD $t0,0($a1)
|
||||
$MULTU $t0,$t0
|
||||
$LD $t2,$BNSZ($a1)
|
||||
$LD $ta0,2*$BNSZ($a1)
|
||||
@@ -463,11 +461,10 @@ $code.=<<___;
|
||||
mflo $ta3
|
||||
mfhi $ta2
|
||||
$ST $ta3,-2*$BNSZ($a0)
|
||||
$ST $ta2,-$BNSZ($a0)
|
||||
|
||||
.set noreorder
|
||||
bgtzl $ta0,.L_bn_sqr_words_loop
|
||||
$LD $t0,0($a1)
|
||||
bgtz $ta0,.L_bn_sqr_words_loop
|
||||
$ST $ta2,-$BNSZ($a0)
|
||||
|
||||
beqz $a2,.L_bn_sqr_words_return
|
||||
nop
|
||||
@@ -547,10 +544,10 @@ $code.=<<___;
|
||||
.set reorder
|
||||
li $minus4,-4
|
||||
and $at,$a3,$minus4
|
||||
$LD $t0,0($a1)
|
||||
beqz $at,.L_bn_add_words_tail
|
||||
|
||||
.L_bn_add_words_loop:
|
||||
$LD $t0,0($a1)
|
||||
$LD $ta0,0($a2)
|
||||
subu $a3,4
|
||||
$LD $t1,$BNSZ($a1)
|
||||
@@ -589,11 +586,10 @@ $code.=<<___;
|
||||
$ADDU $t3,$ta3,$v0
|
||||
sltu $v0,$t3,$ta3
|
||||
$ST $t3,-$BNSZ($a0)
|
||||
$ADDU $v0,$t9
|
||||
|
||||
.set noreorder
|
||||
bgtzl $at,.L_bn_add_words_loop
|
||||
$LD $t0,0($a1)
|
||||
bgtz $at,.L_bn_add_words_loop
|
||||
$ADDU $v0,$t9
|
||||
|
||||
beqz $a3,.L_bn_add_words_return
|
||||
nop
|
||||
@@ -679,10 +675,10 @@ $code.=<<___;
|
||||
.set reorder
|
||||
li $minus4,-4
|
||||
and $at,$a3,$minus4
|
||||
$LD $t0,0($a1)
|
||||
beqz $at,.L_bn_sub_words_tail
|
||||
|
||||
.L_bn_sub_words_loop:
|
||||
$LD $t0,0($a1)
|
||||
$LD $ta0,0($a2)
|
||||
subu $a3,4
|
||||
$LD $t1,$BNSZ($a1)
|
||||
@@ -722,11 +718,10 @@ $code.=<<___;
|
||||
$SUBU $t3,$ta3,$v0
|
||||
sgtu $v0,$t3,$ta3
|
||||
$ST $t3,-$BNSZ($a0)
|
||||
$ADDU $v0,$t9
|
||||
|
||||
.set noreorder
|
||||
bgtzl $at,.L_bn_sub_words_loop
|
||||
$LD $t0,0($a1)
|
||||
bgtz $at,.L_bn_sub_words_loop
|
||||
$ADDU $v0,$t9
|
||||
|
||||
beqz $a3,.L_bn_sub_words_return
|
||||
nop
|
||||
@@ -819,7 +814,7 @@ ___
|
||||
$code.=<<___;
|
||||
.set reorder
|
||||
move $ta3,$ra
|
||||
bal bn_div_words
|
||||
bal bn_div_words_internal
|
||||
move $ra,$ta3
|
||||
$MULTU $ta2,$v0
|
||||
$LD $t2,-2*$BNSZ($a3)
|
||||
@@ -840,8 +835,9 @@ $code.=<<___;
|
||||
sltu $ta0,$a1,$a2
|
||||
or $t8,$ta0
|
||||
.set noreorder
|
||||
beqzl $at,.L_bn_div_3_words_inner_loop
|
||||
beqz $at,.L_bn_div_3_words_inner_loop
|
||||
$SUBU $v0,1
|
||||
$ADDU $v0,1
|
||||
.set reorder
|
||||
.L_bn_div_3_words_inner_loop_done:
|
||||
.set noreorder
|
||||
@@ -902,7 +898,8 @@ $code.=<<___;
|
||||
and $t2,$a0
|
||||
$SRL $at,$a1,$t1
|
||||
.set noreorder
|
||||
bnezl $t2,.+8
|
||||
beqz $t2,.+12
|
||||
nop
|
||||
break 6 # signal overflow
|
||||
.set reorder
|
||||
$SLL $a0,$t9
|
||||
@@ -917,7 +914,8 @@ $code.=<<___;
|
||||
$SRL $DH,$a2,4*$BNSZ # bits
|
||||
sgeu $at,$a0,$a2
|
||||
.set noreorder
|
||||
bnezl $at,.+8
|
||||
beqz $at,.+12
|
||||
nop
|
||||
$SUBU $a0,$a2
|
||||
.set reorder
|
||||
|
||||
|
||||
@@ -68,7 +68,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
use strict;
|
||||
my $code=".text\n\n";
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
# of arithmetic operations, most notably multiplications. It requires
|
||||
# more memory references, most notably to tp[num], but this doesn't
|
||||
# seem to exhaust memory port capacity. And indeed, dedicated PA-RISC
|
||||
# 2.0 code path, provides virtually same performance as pa-risc2[W].s:
|
||||
# 2.0 code path provides virtually same performance as pa-risc2[W].s:
|
||||
# it's ~10% better for shortest key length and ~10% worse for longest
|
||||
# one.
|
||||
#
|
||||
@@ -988,6 +988,8 @@ foreach (split("\n",$code)) {
|
||||
# assemble 2.0 instructions in 32-bit mode...
|
||||
s/^\s+([a-z]+)([\S]*)\s+([\S]*)/&assemble($1,$2,$3)/e if ($BN_SZ==4);
|
||||
|
||||
s/\bbv\b/bve/gm if ($SIZE_T==8);
|
||||
|
||||
print $_,"\n";
|
||||
}
|
||||
close STDOUT;
|
||||
|
||||
@@ -325,6 +325,7 @@ Lcopy: ; copy or in-place refresh
|
||||
.long 0
|
||||
.byte 0,12,4,0,0x80,12,6,0
|
||||
.long 0
|
||||
.size .bn_mul_mont_int,.-.bn_mul_mont_int
|
||||
|
||||
.asciz "Montgomery Multiplication for PPC, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
___
|
||||
|
||||
@@ -392,6 +392,7 @@ $data=<<EOF;
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,2,0
|
||||
.long 0
|
||||
.size .bn_sqr_comba4,.-.bn_sqr_comba4
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -819,6 +820,7 @@ $data=<<EOF;
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,2,0
|
||||
.long 0
|
||||
.size .bn_sqr_comba8,.-.bn_sqr_comba8
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -972,6 +974,7 @@ $data=<<EOF;
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,3,0
|
||||
.long 0
|
||||
.size .bn_mul_comba4,.-.bn_mul_comba4
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1510,6 +1513,7 @@ $data=<<EOF;
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,3,0
|
||||
.long 0
|
||||
.size .bn_mul_comba8,.-.bn_mul_comba8
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1560,6 +1564,7 @@ Lppcasm_sub_adios:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,4,0
|
||||
.long 0
|
||||
.size .bn_sub_words,.-.bn_sub_words
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1605,6 +1610,7 @@ Lppcasm_add_adios:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,4,0
|
||||
.long 0
|
||||
.size .bn_add_words,.-.bn_add_words
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1720,6 +1726,7 @@ Lppcasm_div9:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,3,0
|
||||
.long 0
|
||||
.size .bn_div_words,.-.bn_div_words
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1761,6 +1768,7 @@ Lppcasm_sqr_adios:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,3,0
|
||||
.long 0
|
||||
.size .bn_sqr_words,.-.bn_sqr_words
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1866,6 +1874,7 @@ Lppcasm_mw_OVER:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,4,0
|
||||
.long 0
|
||||
.size bn_mul_words,.-bn_mul_words
|
||||
|
||||
#
|
||||
# NOTE: The following label name should be changed to
|
||||
@@ -1991,6 +2000,7 @@ Lppcasm_maw_adios:
|
||||
.long 0
|
||||
.byte 0,12,0x14,0,0,0,4,0
|
||||
.long 0
|
||||
.size .bn_mul_add_words,.-.bn_mul_add_words
|
||||
.align 4
|
||||
EOF
|
||||
$data =~ s/\`([^\`]*)\`/eval $1/gem;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# ====================================================================
|
||||
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
|
||||
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||
# project. The module is, however, dual licensed under OpenSSL and
|
||||
# CRYPTOGAMS licenses depending on where you obtain it. For further
|
||||
# details see http://www.openssl.org/~appro/cryptogams/.
|
||||
@@ -65,6 +65,14 @@
|
||||
# others alternative would be to break dependence on upper halves of
|
||||
# GPRs by sticking to 32-bit integer operations...
|
||||
|
||||
# December 2012
|
||||
|
||||
# Remove above mentioned dependence on GPRs' upper halves in 32-bit
|
||||
# build. No signal masking overhead, but integer instructions are
|
||||
# *more* numerous... It's still "universally" faster than 32-bit
|
||||
# ppc-mont.pl, but improvement coefficient is not as impressive
|
||||
# for longer keys...
|
||||
|
||||
$flavour = shift;
|
||||
|
||||
if ($flavour =~ /32/) {
|
||||
@@ -110,6 +118,9 @@ $tp="r10";
|
||||
$j="r11";
|
||||
$i="r12";
|
||||
# non-volatile registers
|
||||
$c1="r19";
|
||||
$n1="r20";
|
||||
$a1="r21";
|
||||
$nap_d="r22"; # interleaved ap and np in double format
|
||||
$a0="r23"; # ap[0]
|
||||
$t0="r24"; # temporary registers
|
||||
@@ -180,8 +191,8 @@ $T3a="f30"; $T3b="f31";
|
||||
# . .
|
||||
# +-------------------------------+
|
||||
# . .
|
||||
# -12*size_t +-------------------------------+
|
||||
# | 10 saved gpr, r22-r31 |
|
||||
# -13*size_t +-------------------------------+
|
||||
# | 13 saved gpr, r19-r31 |
|
||||
# . .
|
||||
# . .
|
||||
# -12*8 +-------------------------------+
|
||||
@@ -215,6 +226,9 @@ $code=<<___;
|
||||
mr $i,$sp
|
||||
$STUX $sp,$sp,$tp ; alloca
|
||||
|
||||
$PUSH r19,`-12*8-13*$SIZE_T`($i)
|
||||
$PUSH r20,`-12*8-12*$SIZE_T`($i)
|
||||
$PUSH r21,`-12*8-11*$SIZE_T`($i)
|
||||
$PUSH r22,`-12*8-10*$SIZE_T`($i)
|
||||
$PUSH r23,`-12*8-9*$SIZE_T`($i)
|
||||
$PUSH r24,`-12*8-8*$SIZE_T`($i)
|
||||
@@ -237,40 +251,26 @@ $code=<<___;
|
||||
stfd f29,`-3*8`($i)
|
||||
stfd f30,`-2*8`($i)
|
||||
stfd f31,`-1*8`($i)
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==8);
|
||||
ld $a0,0($ap) ; pull ap[0] value
|
||||
ld $n0,0($n0) ; pull n0[0] value
|
||||
ld $t3,0($bp) ; bp[0]
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==4);
|
||||
mr $t1,$n0
|
||||
lwz $a0,0($ap) ; pull ap[0,1] value
|
||||
lwz $t0,4($ap)
|
||||
lwz $n0,0($t1) ; pull n0[0,1] value
|
||||
lwz $t1,4($t1)
|
||||
lwz $t3,0($bp) ; bp[0,1]
|
||||
lwz $t2,4($bp)
|
||||
insrdi $a0,$t0,32,0
|
||||
insrdi $n0,$t1,32,0
|
||||
insrdi $t3,$t2,32,0
|
||||
___
|
||||
$code.=<<___;
|
||||
|
||||
addi $tp,$sp,`$FRAME+$TRANSFER+8+64`
|
||||
li $i,-64
|
||||
add $nap_d,$tp,$num
|
||||
and $nap_d,$nap_d,$i ; align to 64 bytes
|
||||
|
||||
mulld $t7,$a0,$t3 ; ap[0]*bp[0]
|
||||
; nap_d is off by 1, because it's used with stfdu/lfdu
|
||||
addi $nap_d,$nap_d,-8
|
||||
srwi $j,$num,`3+1` ; counter register, num/2
|
||||
mulld $t7,$t7,$n0 ; tp[0]*n0
|
||||
addi $j,$j,-1
|
||||
addi $tp,$sp,`$FRAME+$TRANSFER-8`
|
||||
li $carry,0
|
||||
mtctr $j
|
||||
___
|
||||
|
||||
$code.=<<___ if ($SIZE_T==8);
|
||||
ld $a0,0($ap) ; pull ap[0] value
|
||||
ld $t3,0($bp) ; bp[0]
|
||||
ld $n0,0($n0) ; pull n0[0] value
|
||||
|
||||
mulld $t7,$a0,$t3 ; ap[0]*bp[0]
|
||||
; transfer bp[0] to FPU as 4x16-bit values
|
||||
extrdi $t0,$t3,16,48
|
||||
extrdi $t1,$t3,16,32
|
||||
@@ -280,6 +280,8 @@ $code.=<<___;
|
||||
std $t1,`$FRAME+8`($sp)
|
||||
std $t2,`$FRAME+16`($sp)
|
||||
std $t3,`$FRAME+24`($sp)
|
||||
|
||||
mulld $t7,$t7,$n0 ; tp[0]*n0
|
||||
; transfer (ap[0]*bp[0])*n0 to FPU as 4x16-bit values
|
||||
extrdi $t4,$t7,16,48
|
||||
extrdi $t5,$t7,16,32
|
||||
@@ -289,21 +291,61 @@ $code.=<<___;
|
||||
std $t5,`$FRAME+40`($sp)
|
||||
std $t6,`$FRAME+48`($sp)
|
||||
std $t7,`$FRAME+56`($sp)
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==8);
|
||||
lwz $t0,4($ap) ; load a[j] as 32-bit word pair
|
||||
lwz $t1,0($ap)
|
||||
lwz $t2,12($ap) ; load a[j+1] as 32-bit word pair
|
||||
|
||||
extrdi $t0,$a0,32,32 ; lwz $t0,4($ap)
|
||||
extrdi $t1,$a0,32,0 ; lwz $t1,0($ap)
|
||||
lwz $t2,12($ap) ; load a[1] as 32-bit word pair
|
||||
lwz $t3,8($ap)
|
||||
lwz $t4,4($np) ; load n[j] as 32-bit word pair
|
||||
lwz $t4,4($np) ; load n[0] as 32-bit word pair
|
||||
lwz $t5,0($np)
|
||||
lwz $t6,12($np) ; load n[j+1] as 32-bit word pair
|
||||
lwz $t6,12($np) ; load n[1] as 32-bit word pair
|
||||
lwz $t7,8($np)
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==4);
|
||||
lwz $t0,0($ap) ; load a[j..j+3] as 32-bit word pairs
|
||||
lwz $t1,4($ap)
|
||||
lwz $t2,8($ap)
|
||||
lwz $a0,0($ap) ; pull ap[0,1] value
|
||||
mr $n1,$n0
|
||||
lwz $a1,4($ap)
|
||||
li $c1,0
|
||||
lwz $t1,0($bp) ; bp[0,1]
|
||||
lwz $t3,4($bp)
|
||||
lwz $n0,0($n1) ; pull n0[0,1] value
|
||||
lwz $n1,4($n1)
|
||||
|
||||
mullw $t4,$a0,$t1 ; mulld ap[0]*bp[0]
|
||||
mulhwu $t5,$a0,$t1
|
||||
mullw $t6,$a1,$t1
|
||||
mullw $t7,$a0,$t3
|
||||
add $t5,$t5,$t6
|
||||
add $t5,$t5,$t7
|
||||
; transfer bp[0] to FPU as 4x16-bit values
|
||||
extrwi $t0,$t1,16,16
|
||||
extrwi $t1,$t1,16,0
|
||||
extrwi $t2,$t3,16,16
|
||||
extrwi $t3,$t3,16,0
|
||||
std $t0,`$FRAME+0`($sp) ; yes, std in 32-bit build
|
||||
std $t1,`$FRAME+8`($sp)
|
||||
std $t2,`$FRAME+16`($sp)
|
||||
std $t3,`$FRAME+24`($sp)
|
||||
|
||||
mullw $t0,$t4,$n0 ; mulld tp[0]*n0
|
||||
mulhwu $t1,$t4,$n0
|
||||
mullw $t2,$t5,$n0
|
||||
mullw $t3,$t4,$n1
|
||||
add $t1,$t1,$t2
|
||||
add $t1,$t1,$t3
|
||||
; transfer (ap[0]*bp[0])*n0 to FPU as 4x16-bit values
|
||||
extrwi $t4,$t0,16,16
|
||||
extrwi $t5,$t0,16,0
|
||||
extrwi $t6,$t1,16,16
|
||||
extrwi $t7,$t1,16,0
|
||||
std $t4,`$FRAME+32`($sp) ; yes, std in 32-bit build
|
||||
std $t5,`$FRAME+40`($sp)
|
||||
std $t6,`$FRAME+48`($sp)
|
||||
std $t7,`$FRAME+56`($sp)
|
||||
|
||||
mr $t0,$a0 ; lwz $t0,0($ap)
|
||||
mr $t1,$a1 ; lwz $t1,4($ap)
|
||||
lwz $t2,8($ap) ; load a[j..j+3] as 32-bit word pairs
|
||||
lwz $t3,12($ap)
|
||||
lwz $t4,0($np) ; load n[j..j+3] as 32-bit word pairs
|
||||
lwz $t5,4($np)
|
||||
@@ -319,7 +361,7 @@ $code.=<<___;
|
||||
lfd $nb,`$FRAME+40`($sp)
|
||||
lfd $nc,`$FRAME+48`($sp)
|
||||
lfd $nd,`$FRAME+56`($sp)
|
||||
std $t0,`$FRAME+64`($sp)
|
||||
std $t0,`$FRAME+64`($sp) ; yes, std even in 32-bit build
|
||||
std $t1,`$FRAME+72`($sp)
|
||||
std $t2,`$FRAME+80`($sp)
|
||||
std $t3,`$FRAME+88`($sp)
|
||||
@@ -441,7 +483,7 @@ $code.=<<___ if ($SIZE_T==4);
|
||||
lwz $t7,12($np)
|
||||
___
|
||||
$code.=<<___;
|
||||
std $t0,`$FRAME+64`($sp)
|
||||
std $t0,`$FRAME+64`($sp) ; yes, std even in 32-bit build
|
||||
std $t1,`$FRAME+72`($sp)
|
||||
std $t2,`$FRAME+80`($sp)
|
||||
std $t3,`$FRAME+88`($sp)
|
||||
@@ -449,6 +491,9 @@ $code.=<<___;
|
||||
std $t5,`$FRAME+104`($sp)
|
||||
std $t6,`$FRAME+112`($sp)
|
||||
std $t7,`$FRAME+120`($sp)
|
||||
___
|
||||
if ($SIZE_T==8 or $flavour =~ /osx/) {
|
||||
$code.=<<___;
|
||||
ld $t0,`$FRAME+0`($sp)
|
||||
ld $t1,`$FRAME+8`($sp)
|
||||
ld $t2,`$FRAME+16`($sp)
|
||||
@@ -457,6 +502,20 @@ $code.=<<___;
|
||||
ld $t5,`$FRAME+40`($sp)
|
||||
ld $t6,`$FRAME+48`($sp)
|
||||
ld $t7,`$FRAME+56`($sp)
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
lwz $t1,`$FRAME+0`($sp)
|
||||
lwz $t0,`$FRAME+4`($sp)
|
||||
lwz $t3,`$FRAME+8`($sp)
|
||||
lwz $t2,`$FRAME+12`($sp)
|
||||
lwz $t5,`$FRAME+16`($sp)
|
||||
lwz $t4,`$FRAME+20`($sp)
|
||||
lwz $t7,`$FRAME+24`($sp)
|
||||
lwz $t6,`$FRAME+28`($sp)
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
lfd $A0,`$FRAME+64`($sp)
|
||||
lfd $A1,`$FRAME+72`($sp)
|
||||
lfd $A2,`$FRAME+80`($sp)
|
||||
@@ -488,7 +547,9 @@ $code.=<<___;
|
||||
fmadd $T0b,$A0,$bb,$dotb
|
||||
stfd $A2,24($nap_d) ; save a[j+1] in double format
|
||||
stfd $A3,32($nap_d)
|
||||
|
||||
___
|
||||
if ($SIZE_T==8 or $flavour =~ /osx/) {
|
||||
$code.=<<___;
|
||||
fmadd $T1a,$A0,$bc,$T1a
|
||||
fmadd $T1b,$A0,$bd,$T1b
|
||||
fmadd $T2a,$A1,$bc,$T2a
|
||||
@@ -561,11 +622,123 @@ $code.=<<___;
|
||||
stfd $T3b,`$FRAME+56`($sp)
|
||||
std $t0,8($tp) ; tp[j-1]
|
||||
stdu $t4,16($tp) ; tp[j]
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
fmadd $T1a,$A0,$bc,$T1a
|
||||
fmadd $T1b,$A0,$bd,$T1b
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
fmadd $T2a,$A1,$bc,$T2a
|
||||
fmadd $T2b,$A1,$bd,$T2b
|
||||
stfd $N0,40($nap_d) ; save n[j] in double format
|
||||
stfd $N1,48($nap_d)
|
||||
srwi $c1,$t1,16
|
||||
insrwi $carry,$t1,16,0
|
||||
fmadd $T3a,$A2,$bc,$T3a
|
||||
fmadd $T3b,$A2,$bd,$T3b
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
fmul $dota,$A3,$bc
|
||||
fmul $dotb,$A3,$bd
|
||||
stfd $N2,56($nap_d) ; save n[j+1] in double format
|
||||
stfdu $N3,64($nap_d)
|
||||
insrwi $t0,$t2,16,0 ; 0..31 bits
|
||||
srwi $c1,$t3,16
|
||||
insrwi $carry,$t3,16,0
|
||||
|
||||
fmadd $T1a,$N1,$na,$T1a
|
||||
fmadd $T1b,$N1,$nb,$T1b
|
||||
lwz $t3,`$FRAME+32`($sp) ; permuted $t1
|
||||
lwz $t2,`$FRAME+36`($sp) ; permuted $t0
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
fmadd $T2a,$N2,$na,$T2a
|
||||
fmadd $T2b,$N2,$nb,$T2b
|
||||
srwi $c1,$t5,16
|
||||
insrwi $carry,$t5,16,0
|
||||
fmadd $T3a,$N3,$na,$T3a
|
||||
fmadd $T3b,$N3,$nb,$T3b
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
fmadd $T0a,$N0,$na,$T0a
|
||||
fmadd $T0b,$N0,$nb,$T0b
|
||||
insrwi $t4,$t6,16,0 ; 32..63 bits
|
||||
srwi $c1,$t7,16
|
||||
insrwi $carry,$t7,16,0
|
||||
|
||||
fmadd $T1a,$N0,$nc,$T1a
|
||||
fmadd $T1b,$N0,$nd,$T1b
|
||||
lwz $t7,`$FRAME+40`($sp) ; permuted $t3
|
||||
lwz $t6,`$FRAME+44`($sp) ; permuted $t2
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
fmadd $T2a,$N1,$nc,$T2a
|
||||
fmadd $T2b,$N1,$nd,$T2b
|
||||
stw $t0,12($tp) ; tp[j-1]
|
||||
stw $t4,8($tp)
|
||||
srwi $c1,$t3,16
|
||||
insrwi $carry,$t3,16,0
|
||||
fmadd $T3a,$N2,$nc,$T3a
|
||||
fmadd $T3b,$N2,$nd,$T3b
|
||||
lwz $t1,`$FRAME+48`($sp) ; permuted $t5
|
||||
lwz $t0,`$FRAME+52`($sp) ; permuted $t4
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
fmadd $dota,$N3,$nc,$dota
|
||||
fmadd $dotb,$N3,$nd,$dotb
|
||||
insrwi $t2,$t6,16,0 ; 64..95 bits
|
||||
srwi $c1,$t7,16
|
||||
insrwi $carry,$t7,16,0
|
||||
|
||||
fctid $T0a,$T0a
|
||||
fctid $T0b,$T0b
|
||||
lwz $t5,`$FRAME+56`($sp) ; permuted $t7
|
||||
lwz $t4,`$FRAME+60`($sp) ; permuted $t6
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
fctid $T1a,$T1a
|
||||
fctid $T1b,$T1b
|
||||
srwi $c1,$t1,16
|
||||
insrwi $carry,$t1,16,0
|
||||
fctid $T2a,$T2a
|
||||
fctid $T2b,$T2b
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
fctid $T3a,$T3a
|
||||
fctid $T3b,$T3b
|
||||
insrwi $t0,$t4,16,0 ; 96..127 bits
|
||||
srwi $c1,$t5,16
|
||||
insrwi $carry,$t5,16,0
|
||||
|
||||
stfd $T0a,`$FRAME+0`($sp)
|
||||
stfd $T0b,`$FRAME+8`($sp)
|
||||
stfd $T1a,`$FRAME+16`($sp)
|
||||
stfd $T1b,`$FRAME+24`($sp)
|
||||
stfd $T2a,`$FRAME+32`($sp)
|
||||
stfd $T2b,`$FRAME+40`($sp)
|
||||
stfd $T3a,`$FRAME+48`($sp)
|
||||
stfd $T3b,`$FRAME+56`($sp)
|
||||
stw $t2,20($tp) ; tp[j]
|
||||
stwu $t0,16($tp)
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
bdnz- L1st
|
||||
|
||||
fctid $dota,$dota
|
||||
fctid $dotb,$dotb
|
||||
|
||||
___
|
||||
if ($SIZE_T==8 or $flavour =~ /osx/) {
|
||||
$code.=<<___;
|
||||
ld $t0,`$FRAME+0`($sp)
|
||||
ld $t1,`$FRAME+8`($sp)
|
||||
ld $t2,`$FRAME+16`($sp)
|
||||
@@ -611,33 +784,117 @@ $code.=<<___;
|
||||
insrdi $t6,$t7,48,0
|
||||
srdi $ovf,$t7,48
|
||||
std $t6,8($tp) ; tp[num-1]
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
lwz $t1,`$FRAME+0`($sp)
|
||||
lwz $t0,`$FRAME+4`($sp)
|
||||
lwz $t3,`$FRAME+8`($sp)
|
||||
lwz $t2,`$FRAME+12`($sp)
|
||||
lwz $t5,`$FRAME+16`($sp)
|
||||
lwz $t4,`$FRAME+20`($sp)
|
||||
lwz $t7,`$FRAME+24`($sp)
|
||||
lwz $t6,`$FRAME+28`($sp)
|
||||
stfd $dota,`$FRAME+64`($sp)
|
||||
stfd $dotb,`$FRAME+72`($sp)
|
||||
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
insrwi $carry,$t1,16,0
|
||||
srwi $c1,$t1,16
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
insrwi $t0,$t2,16,0 ; 0..31 bits
|
||||
insrwi $carry,$t3,16,0
|
||||
srwi $c1,$t3,16
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
insrwi $carry,$t5,16,0
|
||||
srwi $c1,$t5,16
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
insrwi $t4,$t6,16,0 ; 32..63 bits
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
stw $t0,12($tp) ; tp[j-1]
|
||||
stw $t4,8($tp)
|
||||
|
||||
lwz $t3,`$FRAME+32`($sp) ; permuted $t1
|
||||
lwz $t2,`$FRAME+36`($sp) ; permuted $t0
|
||||
lwz $t7,`$FRAME+40`($sp) ; permuted $t3
|
||||
lwz $t6,`$FRAME+44`($sp) ; permuted $t2
|
||||
lwz $t1,`$FRAME+48`($sp) ; permuted $t5
|
||||
lwz $t0,`$FRAME+52`($sp) ; permuted $t4
|
||||
lwz $t5,`$FRAME+56`($sp) ; permuted $t7
|
||||
lwz $t4,`$FRAME+60`($sp) ; permuted $t6
|
||||
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
insrwi $carry,$t3,16,0
|
||||
srwi $c1,$t3,16
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
insrwi $t2,$t6,16,0 ; 64..95 bits
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
insrwi $carry,$t1,16,0
|
||||
srwi $c1,$t1,16
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
insrwi $t0,$t4,16,0 ; 96..127 bits
|
||||
insrwi $carry,$t5,16,0
|
||||
srwi $c1,$t5,16
|
||||
stw $t2,20($tp) ; tp[j]
|
||||
stwu $t0,16($tp)
|
||||
|
||||
lwz $t7,`$FRAME+64`($sp)
|
||||
lwz $t6,`$FRAME+68`($sp)
|
||||
lwz $t5,`$FRAME+72`($sp)
|
||||
lwz $t4,`$FRAME+76`($sp)
|
||||
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
|
||||
insrwi $t6,$t4,16,0
|
||||
srwi $t4,$t4,16
|
||||
insrwi $t4,$t5,16,0
|
||||
srwi $ovf,$t5,16
|
||||
stw $t6,12($tp) ; tp[num-1]
|
||||
stw $t4,8($tp)
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
slwi $t7,$num,2
|
||||
subf $nap_d,$t7,$nap_d ; rewind pointer
|
||||
|
||||
li $i,8 ; i=1
|
||||
.align 5
|
||||
Louter:
|
||||
addi $tp,$sp,`$FRAME+$TRANSFER`
|
||||
li $carry,0
|
||||
mtctr $j
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==8);
|
||||
ldx $t3,$bp,$i ; bp[i]
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==4);
|
||||
add $t0,$bp,$i
|
||||
lwz $t3,0($t0) ; bp[i,i+1]
|
||||
lwz $t0,4($t0)
|
||||
insrdi $t3,$t0,32,0
|
||||
___
|
||||
$code.=<<___;
|
||||
ldx $t3,$bp,$i ; bp[i]
|
||||
|
||||
ld $t6,`$FRAME+$TRANSFER+8`($sp) ; tp[0]
|
||||
mulld $t7,$a0,$t3 ; ap[0]*bp[i]
|
||||
|
||||
addi $tp,$sp,`$FRAME+$TRANSFER`
|
||||
add $t7,$t7,$t6 ; ap[0]*bp[i]+tp[0]
|
||||
li $carry,0
|
||||
mulld $t7,$t7,$n0 ; tp[0]*n0
|
||||
mtctr $j
|
||||
|
||||
mulld $t7,$a0,$t3 ; ap[0]*bp[i]
|
||||
add $t7,$t7,$t6 ; ap[0]*bp[i]+tp[0]
|
||||
; transfer bp[i] to FPU as 4x16-bit values
|
||||
extrdi $t0,$t3,16,48
|
||||
extrdi $t1,$t3,16,32
|
||||
@@ -647,6 +904,8 @@ $code.=<<___;
|
||||
std $t1,`$FRAME+8`($sp)
|
||||
std $t2,`$FRAME+16`($sp)
|
||||
std $t3,`$FRAME+24`($sp)
|
||||
|
||||
mulld $t7,$t7,$n0 ; tp[0]*n0
|
||||
; transfer (ap[0]*bp[i]+tp[0])*n0 to FPU as 4x16-bit values
|
||||
extrdi $t4,$t7,16,48
|
||||
extrdi $t5,$t7,16,32
|
||||
@@ -656,7 +915,50 @@ $code.=<<___;
|
||||
std $t5,`$FRAME+40`($sp)
|
||||
std $t6,`$FRAME+48`($sp)
|
||||
std $t7,`$FRAME+56`($sp)
|
||||
___
|
||||
$code.=<<___ if ($SIZE_T==4);
|
||||
add $t0,$bp,$i
|
||||
li $c1,0
|
||||
lwz $t1,0($t0) ; bp[i,i+1]
|
||||
lwz $t3,4($t0)
|
||||
|
||||
mullw $t4,$a0,$t1 ; ap[0]*bp[i]
|
||||
lwz $t0,`$FRAME+$TRANSFER+8+4`($sp) ; tp[0]
|
||||
mulhwu $t5,$a0,$t1
|
||||
lwz $t2,`$FRAME+$TRANSFER+8`($sp) ; tp[0]
|
||||
mullw $t6,$a1,$t1
|
||||
mullw $t7,$a0,$t3
|
||||
add $t5,$t5,$t6
|
||||
add $t5,$t5,$t7
|
||||
addc $t4,$t4,$t0 ; ap[0]*bp[i]+tp[0]
|
||||
adde $t5,$t5,$t2
|
||||
; transfer bp[i] to FPU as 4x16-bit values
|
||||
extrwi $t0,$t1,16,16
|
||||
extrwi $t1,$t1,16,0
|
||||
extrwi $t2,$t3,16,16
|
||||
extrwi $t3,$t3,16,0
|
||||
std $t0,`$FRAME+0`($sp) ; yes, std in 32-bit build
|
||||
std $t1,`$FRAME+8`($sp)
|
||||
std $t2,`$FRAME+16`($sp)
|
||||
std $t3,`$FRAME+24`($sp)
|
||||
|
||||
mullw $t0,$t4,$n0 ; mulld tp[0]*n0
|
||||
mulhwu $t1,$t4,$n0
|
||||
mullw $t2,$t5,$n0
|
||||
mullw $t3,$t4,$n1
|
||||
add $t1,$t1,$t2
|
||||
add $t1,$t1,$t3
|
||||
; transfer (ap[0]*bp[i]+tp[0])*n0 to FPU as 4x16-bit values
|
||||
extrwi $t4,$t0,16,16
|
||||
extrwi $t5,$t0,16,0
|
||||
extrwi $t6,$t1,16,16
|
||||
extrwi $t7,$t1,16,0
|
||||
std $t4,`$FRAME+32`($sp) ; yes, std in 32-bit build
|
||||
std $t5,`$FRAME+40`($sp)
|
||||
std $t6,`$FRAME+48`($sp)
|
||||
std $t7,`$FRAME+56`($sp)
|
||||
___
|
||||
$code.=<<___;
|
||||
lfd $A0,8($nap_d) ; load a[j] in double format
|
||||
lfd $A1,16($nap_d)
|
||||
lfd $A2,24($nap_d) ; load a[j+1] in double format
|
||||
@@ -769,7 +1071,9 @@ Linner:
|
||||
fmul $dotb,$A3,$bd
|
||||
lfd $A2,24($nap_d) ; load a[j+1] in double format
|
||||
lfd $A3,32($nap_d)
|
||||
|
||||
___
|
||||
if ($SIZE_T==8 or $flavour =~ /osx/) {
|
||||
$code.=<<___;
|
||||
fmadd $T1a,$N1,$na,$T1a
|
||||
fmadd $T1b,$N1,$nb,$T1b
|
||||
ld $t0,`$FRAME+0`($sp)
|
||||
@@ -856,10 +1160,131 @@ $code.=<<___;
|
||||
addze $carry,$carry
|
||||
std $t3,-16($tp) ; tp[j-1]
|
||||
std $t5,-8($tp) ; tp[j]
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
fmadd $T1a,$N1,$na,$T1a
|
||||
fmadd $T1b,$N1,$nb,$T1b
|
||||
lwz $t1,`$FRAME+0`($sp)
|
||||
lwz $t0,`$FRAME+4`($sp)
|
||||
fmadd $T2a,$N2,$na,$T2a
|
||||
fmadd $T2b,$N2,$nb,$T2b
|
||||
lwz $t3,`$FRAME+8`($sp)
|
||||
lwz $t2,`$FRAME+12`($sp)
|
||||
fmadd $T3a,$N3,$na,$T3a
|
||||
fmadd $T3b,$N3,$nb,$T3b
|
||||
lwz $t5,`$FRAME+16`($sp)
|
||||
lwz $t4,`$FRAME+20`($sp)
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
fmadd $T0a,$N0,$na,$T0a
|
||||
fmadd $T0b,$N0,$nb,$T0b
|
||||
lwz $t7,`$FRAME+24`($sp)
|
||||
lwz $t6,`$FRAME+28`($sp)
|
||||
srwi $c1,$t1,16
|
||||
insrwi $carry,$t1,16,0
|
||||
|
||||
fmadd $T1a,$N0,$nc,$T1a
|
||||
fmadd $T1b,$N0,$nd,$T1b
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
fmadd $T2a,$N1,$nc,$T2a
|
||||
fmadd $T2b,$N1,$nd,$T2b
|
||||
insrwi $t0,$t2,16,0 ; 0..31 bits
|
||||
srwi $c1,$t3,16
|
||||
insrwi $carry,$t3,16,0
|
||||
fmadd $T3a,$N2,$nc,$T3a
|
||||
fmadd $T3b,$N2,$nd,$T3b
|
||||
lwz $t2,12($tp) ; tp[j]
|
||||
lwz $t3,8($tp)
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
fmadd $dota,$N3,$nc,$dota
|
||||
fmadd $dotb,$N3,$nd,$dotb
|
||||
srwi $c1,$t5,16
|
||||
insrwi $carry,$t5,16,0
|
||||
|
||||
fctid $T0a,$T0a
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
fctid $T0b,$T0b
|
||||
insrwi $t4,$t6,16,0 ; 32..63 bits
|
||||
srwi $c1,$t7,16
|
||||
insrwi $carry,$t7,16,0
|
||||
fctid $T1a,$T1a
|
||||
addc $t0,$t0,$t2
|
||||
adde $t4,$t4,$t3
|
||||
lwz $t3,`$FRAME+32`($sp) ; permuted $t1
|
||||
lwz $t2,`$FRAME+36`($sp) ; permuted $t0
|
||||
fctid $T1b,$T1b
|
||||
addze $carry,$carry
|
||||
addze $c1,$c1
|
||||
stw $t0,4($tp) ; tp[j-1]
|
||||
stw $t4,0($tp)
|
||||
fctid $T2a,$T2a
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
lwz $t7,`$FRAME+40`($sp) ; permuted $t3
|
||||
lwz $t6,`$FRAME+44`($sp) ; permuted $t2
|
||||
fctid $T2b,$T2b
|
||||
srwi $c1,$t3,16
|
||||
insrwi $carry,$t3,16,0
|
||||
lwz $t1,`$FRAME+48`($sp) ; permuted $t5
|
||||
lwz $t0,`$FRAME+52`($sp) ; permuted $t4
|
||||
fctid $T3a,$T3a
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
lwz $t5,`$FRAME+56`($sp) ; permuted $t7
|
||||
lwz $t4,`$FRAME+60`($sp) ; permuted $t6
|
||||
fctid $T3b,$T3b
|
||||
|
||||
insrwi $t2,$t6,16,0 ; 64..95 bits
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
lwz $t6,20($tp)
|
||||
lwzu $t7,16($tp)
|
||||
addc $t0,$t0,$carry
|
||||
stfd $T0a,`$FRAME+0`($sp)
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
stfd $T0b,`$FRAME+8`($sp)
|
||||
insrwi $carry,$t1,16,0
|
||||
srwi $c1,$t1,16
|
||||
addc $t4,$t4,$carry
|
||||
stfd $T1a,`$FRAME+16`($sp)
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
insrwi $t0,$t4,16,0 ; 96..127 bits
|
||||
stfd $T1b,`$FRAME+24`($sp)
|
||||
insrwi $carry,$t5,16,0
|
||||
srwi $c1,$t5,16
|
||||
|
||||
addc $t2,$t2,$t6
|
||||
stfd $T2a,`$FRAME+32`($sp)
|
||||
adde $t0,$t0,$t7
|
||||
stfd $T2b,`$FRAME+40`($sp)
|
||||
addze $carry,$carry
|
||||
stfd $T3a,`$FRAME+48`($sp)
|
||||
addze $c1,$c1
|
||||
stfd $T3b,`$FRAME+56`($sp)
|
||||
stw $t2,-4($tp) ; tp[j]
|
||||
stw $t0,-8($tp)
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
bdnz- Linner
|
||||
|
||||
fctid $dota,$dota
|
||||
fctid $dotb,$dotb
|
||||
___
|
||||
if ($SIZE_T==8 or $flavour =~ /osx/) {
|
||||
$code.=<<___;
|
||||
ld $t0,`$FRAME+0`($sp)
|
||||
ld $t1,`$FRAME+8`($sp)
|
||||
ld $t2,`$FRAME+16`($sp)
|
||||
@@ -926,7 +1351,116 @@ $code.=<<___;
|
||||
insrdi $t6,$t7,48,0
|
||||
srdi $ovf,$t7,48
|
||||
std $t6,0($tp) ; tp[num-1]
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
lwz $t1,`$FRAME+0`($sp)
|
||||
lwz $t0,`$FRAME+4`($sp)
|
||||
lwz $t3,`$FRAME+8`($sp)
|
||||
lwz $t2,`$FRAME+12`($sp)
|
||||
lwz $t5,`$FRAME+16`($sp)
|
||||
lwz $t4,`$FRAME+20`($sp)
|
||||
lwz $t7,`$FRAME+24`($sp)
|
||||
lwz $t6,`$FRAME+28`($sp)
|
||||
stfd $dota,`$FRAME+64`($sp)
|
||||
stfd $dotb,`$FRAME+72`($sp)
|
||||
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
insrwi $carry,$t1,16,0
|
||||
srwi $c1,$t1,16
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
insrwi $t0,$t2,16,0 ; 0..31 bits
|
||||
lwz $t2,12($tp) ; tp[j]
|
||||
insrwi $carry,$t3,16,0
|
||||
srwi $c1,$t3,16
|
||||
lwz $t3,8($tp)
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
insrwi $carry,$t5,16,0
|
||||
srwi $c1,$t5,16
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
insrwi $t4,$t6,16,0 ; 32..63 bits
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
|
||||
addc $t0,$t0,$t2
|
||||
adde $t4,$t4,$t3
|
||||
addze $carry,$carry
|
||||
addze $c1,$c1
|
||||
stw $t0,4($tp) ; tp[j-1]
|
||||
stw $t4,0($tp)
|
||||
|
||||
lwz $t3,`$FRAME+32`($sp) ; permuted $t1
|
||||
lwz $t2,`$FRAME+36`($sp) ; permuted $t0
|
||||
lwz $t7,`$FRAME+40`($sp) ; permuted $t3
|
||||
lwz $t6,`$FRAME+44`($sp) ; permuted $t2
|
||||
lwz $t1,`$FRAME+48`($sp) ; permuted $t5
|
||||
lwz $t0,`$FRAME+52`($sp) ; permuted $t4
|
||||
lwz $t5,`$FRAME+56`($sp) ; permuted $t7
|
||||
lwz $t4,`$FRAME+60`($sp) ; permuted $t6
|
||||
|
||||
addc $t2,$t2,$carry
|
||||
adde $t3,$t3,$c1
|
||||
srwi $carry,$t2,16
|
||||
insrwi $carry,$t3,16,0
|
||||
srwi $c1,$t3,16
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
srwi $carry,$t6,16
|
||||
insrwi $t2,$t6,16,0 ; 64..95 bits
|
||||
lwz $t6,20($tp)
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
lwzu $t7,16($tp)
|
||||
addc $t0,$t0,$carry
|
||||
adde $t1,$t1,$c1
|
||||
srwi $carry,$t0,16
|
||||
insrwi $carry,$t1,16,0
|
||||
srwi $c1,$t1,16
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
srwi $carry,$t4,16
|
||||
insrwi $t0,$t4,16,0 ; 96..127 bits
|
||||
insrwi $carry,$t5,16,0
|
||||
srwi $c1,$t5,16
|
||||
|
||||
addc $t2,$t2,$t6
|
||||
adde $t0,$t0,$t7
|
||||
lwz $t7,`$FRAME+64`($sp)
|
||||
lwz $t6,`$FRAME+68`($sp)
|
||||
addze $carry,$carry
|
||||
addze $c1,$c1
|
||||
lwz $t5,`$FRAME+72`($sp)
|
||||
lwz $t4,`$FRAME+76`($sp)
|
||||
|
||||
addc $t6,$t6,$carry
|
||||
adde $t7,$t7,$c1
|
||||
stw $t2,-4($tp) ; tp[j]
|
||||
stw $t0,-8($tp)
|
||||
addc $t6,$t6,$ovf
|
||||
addze $t7,$t7
|
||||
srwi $carry,$t6,16
|
||||
insrwi $carry,$t7,16,0
|
||||
srwi $c1,$t7,16
|
||||
addc $t4,$t4,$carry
|
||||
adde $t5,$t5,$c1
|
||||
|
||||
insrwi $t6,$t4,16,0
|
||||
srwi $t4,$t4,16
|
||||
insrwi $t4,$t5,16,0
|
||||
srwi $ovf,$t5,16
|
||||
stw $t6,4($tp) ; tp[num-1]
|
||||
stw $t4,0($tp)
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
slwi $t7,$num,2
|
||||
addi $i,$i,8
|
||||
subf $nap_d,$t7,$nap_d ; rewind pointer
|
||||
@@ -994,14 +1528,14 @@ $code.=<<___ if ($SIZE_T==4);
|
||||
mtctr $j
|
||||
|
||||
.align 4
|
||||
Lsub: ld $t0,8($tp) ; load tp[j..j+3] in 64-bit word order
|
||||
ldu $t2,16($tp)
|
||||
Lsub: lwz $t0,12($tp) ; load tp[j..j+3] in 64-bit word order
|
||||
lwz $t1,8($tp)
|
||||
lwz $t2,20($tp)
|
||||
lwzu $t3,16($tp)
|
||||
lwz $t4,4($np) ; load np[j..j+3] in 32-bit word order
|
||||
lwz $t5,8($np)
|
||||
lwz $t6,12($np)
|
||||
lwzu $t7,16($np)
|
||||
extrdi $t1,$t0,32,0
|
||||
extrdi $t3,$t2,32,0
|
||||
subfe $t4,$t4,$t0 ; tp[j]-np[j]
|
||||
stw $t0,4($ap) ; save tp[j..j+3] in 32-bit word order
|
||||
subfe $t5,$t5,$t1 ; tp[j+1]-np[j+1]
|
||||
@@ -1052,6 +1586,9 @@ ___
|
||||
$code.=<<___;
|
||||
$POP $i,0($sp)
|
||||
li r3,1 ; signal "handled"
|
||||
$POP r19,`-12*8-13*$SIZE_T`($i)
|
||||
$POP r20,`-12*8-12*$SIZE_T`($i)
|
||||
$POP r21,`-12*8-11*$SIZE_T`($i)
|
||||
$POP r22,`-12*8-10*$SIZE_T`($i)
|
||||
$POP r23,`-12*8-9*$SIZE_T`($i)
|
||||
$POP r24,`-12*8-8*$SIZE_T`($i)
|
||||
@@ -1077,8 +1614,9 @@ $code.=<<___;
|
||||
mr $sp,$i
|
||||
blr
|
||||
.long 0
|
||||
.byte 0,12,4,0,0x8c,10,6,0
|
||||
.byte 0,12,4,0,0x8c,13,6,0
|
||||
.long 0
|
||||
.size .$fname,.-.$fname
|
||||
|
||||
.asciz "Montgomery Multiplication for PPC64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
___
|
||||
|
||||
1875
crypto/bn/asm/rsaz-avx2.pl
Executable file
1875
crypto/bn/asm/rsaz-avx2.pl
Executable file
File diff suppressed because it is too large
Load Diff
2139
crypto/bn/asm/rsaz-x86_64.pl
Executable file
2139
crypto/bn/asm/rsaz-x86_64.pl
Executable file
File diff suppressed because it is too large
Load Diff
1222
crypto/bn/asm/sparct4-mont.pl
Executable file
1222
crypto/bn/asm/sparct4-mont.pl
Executable file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user