ring-native 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGES.md +7 -0
- data/Makefile +5 -0
- data/README.md +12 -5
- data/Rakefile +4 -0
- data/ext/ring/extconf.rb +4 -5
- data/lib/ring/native.rb +3 -1
- data/lib/ring/native/version.rb +5 -1
- data/ring-native.gemspec +6 -6
- data/vendor/ring-ffi/Cargo.lock +26 -0
- data/vendor/ring-ffi/Cargo.toml +45 -0
- data/vendor/ring-ffi/LICENSE +16 -0
- data/vendor/ring-ffi/README.md +59 -0
- data/vendor/ring-ffi/src/lib.rs +79 -0
- metadata +10 -255
- data/vendor/ring/BUILDING.md +0 -40
- data/vendor/ring/Cargo.toml +0 -43
- data/vendor/ring/LICENSE +0 -185
- data/vendor/ring/Makefile +0 -35
- data/vendor/ring/PORTING.md +0 -163
- data/vendor/ring/README.md +0 -113
- data/vendor/ring/STYLE.md +0 -197
- data/vendor/ring/appveyor.yml +0 -27
- data/vendor/ring/build.rs +0 -108
- data/vendor/ring/crypto/aes/aes.c +0 -1142
- data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/aes/aes_test.cc +0 -93
- data/vendor/ring/crypto/aes/asm/aes-586.pl +0 -2368
- data/vendor/ring/crypto/aes/asm/aes-armv4.pl +0 -1249
- data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +0 -2246
- data/vendor/ring/crypto/aes/asm/aesni-x86.pl +0 -1318
- data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +0 -2084
- data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +0 -675
- data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +0 -1364
- data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +0 -1565
- data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +0 -841
- data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +0 -1116
- data/vendor/ring/crypto/aes/internal.h +0 -87
- data/vendor/ring/crypto/aes/mode_wrappers.c +0 -61
- data/vendor/ring/crypto/bn/add.c +0 -394
- data/vendor/ring/crypto/bn/asm/armv4-mont.pl +0 -694
- data/vendor/ring/crypto/bn/asm/armv8-mont.pl +0 -1503
- data/vendor/ring/crypto/bn/asm/bn-586.pl +0 -774
- data/vendor/ring/crypto/bn/asm/co-586.pl +0 -287
- data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +0 -1882
- data/vendor/ring/crypto/bn/asm/x86-mont.pl +0 -592
- data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +0 -599
- data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +0 -1393
- data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +0 -3507
- data/vendor/ring/crypto/bn/bn.c +0 -352
- data/vendor/ring/crypto/bn/bn_asn1.c +0 -74
- data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bn/bn_test.cc +0 -1696
- data/vendor/ring/crypto/bn/cmp.c +0 -200
- data/vendor/ring/crypto/bn/convert.c +0 -433
- data/vendor/ring/crypto/bn/ctx.c +0 -311
- data/vendor/ring/crypto/bn/div.c +0 -594
- data/vendor/ring/crypto/bn/exponentiation.c +0 -1335
- data/vendor/ring/crypto/bn/gcd.c +0 -711
- data/vendor/ring/crypto/bn/generic.c +0 -1019
- data/vendor/ring/crypto/bn/internal.h +0 -316
- data/vendor/ring/crypto/bn/montgomery.c +0 -516
- data/vendor/ring/crypto/bn/mul.c +0 -888
- data/vendor/ring/crypto/bn/prime.c +0 -829
- data/vendor/ring/crypto/bn/random.c +0 -334
- data/vendor/ring/crypto/bn/rsaz_exp.c +0 -262
- data/vendor/ring/crypto/bn/rsaz_exp.h +0 -53
- data/vendor/ring/crypto/bn/shift.c +0 -276
- data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bytestring/bytestring_test.cc +0 -421
- data/vendor/ring/crypto/bytestring/cbb.c +0 -399
- data/vendor/ring/crypto/bytestring/cbs.c +0 -227
- data/vendor/ring/crypto/bytestring/internal.h +0 -46
- data/vendor/ring/crypto/chacha/chacha_generic.c +0 -140
- data/vendor/ring/crypto/chacha/chacha_vec.c +0 -323
- data/vendor/ring/crypto/chacha/chacha_vec_arm.S +0 -1447
- data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +0 -153
- data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/cipher/e_aes.c +0 -390
- data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +0 -208
- data/vendor/ring/crypto/cipher/internal.h +0 -173
- data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +0 -543
- data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +0 -9
- data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +0 -475
- data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +0 -23
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +0 -422
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +0 -484
- data/vendor/ring/crypto/cipher/test/cipher_test.txt +0 -100
- data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/constant_time_test.c +0 -304
- data/vendor/ring/crypto/cpu-arm-asm.S +0 -32
- data/vendor/ring/crypto/cpu-arm.c +0 -199
- data/vendor/ring/crypto/cpu-intel.c +0 -261
- data/vendor/ring/crypto/crypto.c +0 -151
- data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +0 -2118
- data/vendor/ring/crypto/curve25519/curve25519.c +0 -4888
- data/vendor/ring/crypto/curve25519/x25519_test.cc +0 -128
- data/vendor/ring/crypto/digest/md32_common.h +0 -181
- data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +0 -2725
- data/vendor/ring/crypto/ec/ec.c +0 -193
- data/vendor/ring/crypto/ec/ec_curves.c +0 -61
- data/vendor/ring/crypto/ec/ec_key.c +0 -228
- data/vendor/ring/crypto/ec/ec_montgomery.c +0 -114
- data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ec/internal.h +0 -243
- data/vendor/ring/crypto/ec/oct.c +0 -253
- data/vendor/ring/crypto/ec/p256-64.c +0 -1794
- data/vendor/ring/crypto/ec/p256-x86_64-table.h +0 -9548
- data/vendor/ring/crypto/ec/p256-x86_64.c +0 -509
- data/vendor/ring/crypto/ec/simple.c +0 -1007
- data/vendor/ring/crypto/ec/util-64.c +0 -183
- data/vendor/ring/crypto/ec/wnaf.c +0 -508
- data/vendor/ring/crypto/ecdh/ecdh.c +0 -155
- data/vendor/ring/crypto/ecdsa/ecdsa.c +0 -304
- data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +0 -193
- data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +0 -327
- data/vendor/ring/crypto/header_removed.h +0 -17
- data/vendor/ring/crypto/internal.h +0 -495
- data/vendor/ring/crypto/libring.Windows.vcxproj +0 -101
- data/vendor/ring/crypto/mem.c +0 -98
- data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +0 -1045
- data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +0 -517
- data/vendor/ring/crypto/modes/asm/ghash-x86.pl +0 -1393
- data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +0 -1741
- data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +0 -422
- data/vendor/ring/crypto/modes/ctr.c +0 -226
- data/vendor/ring/crypto/modes/gcm.c +0 -1206
- data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/modes/gcm_test.c +0 -348
- data/vendor/ring/crypto/modes/internal.h +0 -299
- data/vendor/ring/crypto/perlasm/arm-xlate.pl +0 -170
- data/vendor/ring/crypto/perlasm/readme +0 -100
- data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +0 -1164
- data/vendor/ring/crypto/perlasm/x86asm.pl +0 -292
- data/vendor/ring/crypto/perlasm/x86gas.pl +0 -263
- data/vendor/ring/crypto/perlasm/x86masm.pl +0 -200
- data/vendor/ring/crypto/perlasm/x86nasm.pl +0 -187
- data/vendor/ring/crypto/poly1305/poly1305.c +0 -331
- data/vendor/ring/crypto/poly1305/poly1305_arm.c +0 -301
- data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +0 -2015
- data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/poly1305/poly1305_test.cc +0 -80
- data/vendor/ring/crypto/poly1305/poly1305_test.txt +0 -52
- data/vendor/ring/crypto/poly1305/poly1305_vec.c +0 -892
- data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +0 -75
- data/vendor/ring/crypto/rand/internal.h +0 -32
- data/vendor/ring/crypto/rand/rand.c +0 -189
- data/vendor/ring/crypto/rand/urandom.c +0 -219
- data/vendor/ring/crypto/rand/windows.c +0 -56
- data/vendor/ring/crypto/refcount_c11.c +0 -66
- data/vendor/ring/crypto/refcount_lock.c +0 -53
- data/vendor/ring/crypto/refcount_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/refcount_test.c +0 -58
- data/vendor/ring/crypto/rsa/blinding.c +0 -462
- data/vendor/ring/crypto/rsa/internal.h +0 -108
- data/vendor/ring/crypto/rsa/padding.c +0 -300
- data/vendor/ring/crypto/rsa/rsa.c +0 -450
- data/vendor/ring/crypto/rsa/rsa_asn1.c +0 -261
- data/vendor/ring/crypto/rsa/rsa_impl.c +0 -944
- data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/rsa/rsa_test.cc +0 -437
- data/vendor/ring/crypto/sha/asm/sha-armv8.pl +0 -436
- data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +0 -2390
- data/vendor/ring/crypto/sha/asm/sha256-586.pl +0 -1275
- data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +0 -735
- data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-586.pl +0 -911
- data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +0 -666
- data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/sha1.c +0 -271
- data/vendor/ring/crypto/sha/sha256.c +0 -204
- data/vendor/ring/crypto/sha/sha512.c +0 -355
- data/vendor/ring/crypto/test/file_test.cc +0 -326
- data/vendor/ring/crypto/test/file_test.h +0 -181
- data/vendor/ring/crypto/test/malloc.cc +0 -150
- data/vendor/ring/crypto/test/scoped_types.h +0 -95
- data/vendor/ring/crypto/test/test.Windows.vcxproj +0 -35
- data/vendor/ring/crypto/test/test_util.cc +0 -46
- data/vendor/ring/crypto/test/test_util.h +0 -41
- data/vendor/ring/crypto/thread_none.c +0 -55
- data/vendor/ring/crypto/thread_pthread.c +0 -165
- data/vendor/ring/crypto/thread_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/thread_test.c +0 -200
- data/vendor/ring/crypto/thread_win.c +0 -282
- data/vendor/ring/examples/checkdigest.rs +0 -103
- data/vendor/ring/include/openssl/aes.h +0 -121
- data/vendor/ring/include/openssl/arm_arch.h +0 -129
- data/vendor/ring/include/openssl/base.h +0 -156
- data/vendor/ring/include/openssl/bn.h +0 -794
- data/vendor/ring/include/openssl/buffer.h +0 -18
- data/vendor/ring/include/openssl/bytestring.h +0 -235
- data/vendor/ring/include/openssl/chacha.h +0 -37
- data/vendor/ring/include/openssl/cmac.h +0 -76
- data/vendor/ring/include/openssl/cpu.h +0 -184
- data/vendor/ring/include/openssl/crypto.h +0 -43
- data/vendor/ring/include/openssl/curve25519.h +0 -88
- data/vendor/ring/include/openssl/ec.h +0 -225
- data/vendor/ring/include/openssl/ec_key.h +0 -129
- data/vendor/ring/include/openssl/ecdh.h +0 -110
- data/vendor/ring/include/openssl/ecdsa.h +0 -156
- data/vendor/ring/include/openssl/err.h +0 -201
- data/vendor/ring/include/openssl/mem.h +0 -101
- data/vendor/ring/include/openssl/obj_mac.h +0 -71
- data/vendor/ring/include/openssl/opensslfeatures.h +0 -68
- data/vendor/ring/include/openssl/opensslv.h +0 -18
- data/vendor/ring/include/openssl/ossl_typ.h +0 -18
- data/vendor/ring/include/openssl/poly1305.h +0 -51
- data/vendor/ring/include/openssl/rand.h +0 -70
- data/vendor/ring/include/openssl/rsa.h +0 -399
- data/vendor/ring/include/openssl/thread.h +0 -133
- data/vendor/ring/include/openssl/type_check.h +0 -71
- data/vendor/ring/mk/Common.props +0 -63
- data/vendor/ring/mk/Windows.props +0 -42
- data/vendor/ring/mk/WindowsTest.props +0 -18
- data/vendor/ring/mk/appveyor.bat +0 -62
- data/vendor/ring/mk/bottom_of_makefile.mk +0 -54
- data/vendor/ring/mk/ring.mk +0 -266
- data/vendor/ring/mk/top_of_makefile.mk +0 -214
- data/vendor/ring/mk/travis.sh +0 -40
- data/vendor/ring/mk/update-travis-yml.py +0 -229
- data/vendor/ring/ring.sln +0 -153
- data/vendor/ring/src/aead.rs +0 -682
- data/vendor/ring/src/agreement.rs +0 -248
- data/vendor/ring/src/c.rs +0 -129
- data/vendor/ring/src/constant_time.rs +0 -37
- data/vendor/ring/src/der.rs +0 -96
- data/vendor/ring/src/digest.rs +0 -690
- data/vendor/ring/src/digest_tests.txt +0 -57
- data/vendor/ring/src/ecc.rs +0 -28
- data/vendor/ring/src/ecc_build.rs +0 -279
- data/vendor/ring/src/ecc_curves.rs +0 -117
- data/vendor/ring/src/ed25519_tests.txt +0 -2579
- data/vendor/ring/src/exe_tests.rs +0 -46
- data/vendor/ring/src/ffi.rs +0 -29
- data/vendor/ring/src/file_test.rs +0 -187
- data/vendor/ring/src/hkdf.rs +0 -153
- data/vendor/ring/src/hkdf_tests.txt +0 -59
- data/vendor/ring/src/hmac.rs +0 -414
- data/vendor/ring/src/hmac_tests.txt +0 -97
- data/vendor/ring/src/input.rs +0 -312
- data/vendor/ring/src/lib.rs +0 -41
- data/vendor/ring/src/pbkdf2.rs +0 -265
- data/vendor/ring/src/pbkdf2_tests.txt +0 -113
- data/vendor/ring/src/polyfill.rs +0 -57
- data/vendor/ring/src/rand.rs +0 -28
- data/vendor/ring/src/signature.rs +0 -314
- data/vendor/ring/third-party/NIST/README.md +0 -9
- data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/sha256sums.txt +0 -1
@@ -1,334 +0,0 @@
|
|
1
|
-
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
2
|
-
* All rights reserved.
|
3
|
-
*
|
4
|
-
* This package is an SSL implementation written
|
5
|
-
* by Eric Young (eay@cryptsoft.com).
|
6
|
-
* The implementation was written so as to conform with Netscapes SSL.
|
7
|
-
*
|
8
|
-
* This library is free for commercial and non-commercial use as long as
|
9
|
-
* the following conditions are aheared to. The following conditions
|
10
|
-
* apply to all code found in this distribution, be it the RC4, RSA,
|
11
|
-
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
12
|
-
* included with this distribution is covered by the same copyright terms
|
13
|
-
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
14
|
-
*
|
15
|
-
* Copyright remains Eric Young's, and as such any Copyright notices in
|
16
|
-
* the code are not to be removed.
|
17
|
-
* If this package is used in a product, Eric Young should be given attribution
|
18
|
-
* as the author of the parts of the library used.
|
19
|
-
* This can be in the form of a textual message at program startup or
|
20
|
-
* in documentation (online or textual) provided with the package.
|
21
|
-
*
|
22
|
-
* Redistribution and use in source and binary forms, with or without
|
23
|
-
* modification, are permitted provided that the following conditions
|
24
|
-
* are met:
|
25
|
-
* 1. Redistributions of source code must retain the copyright
|
26
|
-
* notice, this list of conditions and the following disclaimer.
|
27
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
28
|
-
* notice, this list of conditions and the following disclaimer in the
|
29
|
-
* documentation and/or other materials provided with the distribution.
|
30
|
-
* 3. All advertising materials mentioning features or use of this software
|
31
|
-
* must display the following acknowledgement:
|
32
|
-
* "This product includes cryptographic software written by
|
33
|
-
* Eric Young (eay@cryptsoft.com)"
|
34
|
-
* The word 'cryptographic' can be left out if the rouines from the library
|
35
|
-
* being used are not cryptographic related :-).
|
36
|
-
* 4. If you include any Windows specific code (or a derivative thereof) from
|
37
|
-
* the apps directory (application code) you must include an acknowledgement:
|
38
|
-
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
39
|
-
*
|
40
|
-
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
41
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
43
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
44
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
45
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
46
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
48
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
49
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
50
|
-
* SUCH DAMAGE.
|
51
|
-
*
|
52
|
-
* The licence and distribution terms for any publically available version or
|
53
|
-
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
54
|
-
* copied and put under another distribution licence
|
55
|
-
* [including the GNU Public Licence.]
|
56
|
-
*/
|
57
|
-
/* ====================================================================
|
58
|
-
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
59
|
-
*
|
60
|
-
* Redistribution and use in source and binary forms, with or without
|
61
|
-
* modification, are permitted provided that the following conditions
|
62
|
-
* are met:
|
63
|
-
*
|
64
|
-
* 1. Redistributions of source code must retain the above copyright
|
65
|
-
* notice, this list of conditions and the following disclaimer.
|
66
|
-
*
|
67
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
68
|
-
* notice, this list of conditions and the following disclaimer in
|
69
|
-
* the documentation and/or other materials provided with the
|
70
|
-
* distribution.
|
71
|
-
*
|
72
|
-
* 3. All advertising materials mentioning features or use of this
|
73
|
-
* software must display the following acknowledgment:
|
74
|
-
* "This product includes software developed by the OpenSSL Project
|
75
|
-
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
76
|
-
*
|
77
|
-
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
78
|
-
* endorse or promote products derived from this software without
|
79
|
-
* prior written permission. For written permission, please contact
|
80
|
-
* openssl-core@openssl.org.
|
81
|
-
*
|
82
|
-
* 5. Products derived from this software may not be called "OpenSSL"
|
83
|
-
* nor may "OpenSSL" appear in their names without prior written
|
84
|
-
* permission of the OpenSSL Project.
|
85
|
-
*
|
86
|
-
* 6. Redistributions of any form whatsoever must retain the following
|
87
|
-
* acknowledgment:
|
88
|
-
* "This product includes software developed by the OpenSSL Project
|
89
|
-
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
90
|
-
*
|
91
|
-
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
92
|
-
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
93
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
94
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
95
|
-
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
96
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
97
|
-
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
98
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
99
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
100
|
-
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
101
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
102
|
-
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
103
|
-
* ====================================================================
|
104
|
-
*
|
105
|
-
* This product includes cryptographic software written by Eric Young
|
106
|
-
* (eay@cryptsoft.com). This product includes software written by Tim
|
107
|
-
* Hudson (tjh@cryptsoft.com). */
|
108
|
-
|
109
|
-
#include <openssl/bn.h>
|
110
|
-
|
111
|
-
#include <string.h>
|
112
|
-
|
113
|
-
#include <openssl/err.h>
|
114
|
-
#include <openssl/mem.h>
|
115
|
-
#include <openssl/rand.h>
|
116
|
-
|
117
|
-
#include "../internal.h"
|
118
|
-
|
119
|
-
|
120
|
-
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) {
|
121
|
-
uint8_t *buf = NULL;
|
122
|
-
int ret = 0, bit, bytes, mask;
|
123
|
-
|
124
|
-
if (rnd == NULL) {
|
125
|
-
return 0;
|
126
|
-
}
|
127
|
-
|
128
|
-
if (bits == 0) {
|
129
|
-
BN_zero(rnd);
|
130
|
-
return 1;
|
131
|
-
}
|
132
|
-
|
133
|
-
bytes = (bits + 7) / 8;
|
134
|
-
bit = (bits - 1) % 8;
|
135
|
-
mask = 0xff << (bit + 1);
|
136
|
-
|
137
|
-
buf = OPENSSL_malloc(bytes);
|
138
|
-
if (buf == NULL) {
|
139
|
-
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
|
140
|
-
goto err;
|
141
|
-
}
|
142
|
-
|
143
|
-
/* Make a random number and set the top and bottom bits. */
|
144
|
-
if (!RAND_bytes(buf, bytes)) {
|
145
|
-
goto err;
|
146
|
-
}
|
147
|
-
|
148
|
-
if (top != -1) {
|
149
|
-
if (top && bits > 1) {
|
150
|
-
if (bit == 0) {
|
151
|
-
buf[0] = 1;
|
152
|
-
buf[1] |= 0x80;
|
153
|
-
} else {
|
154
|
-
buf[0] |= (3 << (bit - 1));
|
155
|
-
}
|
156
|
-
} else {
|
157
|
-
buf[0] |= (1 << bit);
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
buf[0] &= ~mask;
|
162
|
-
|
163
|
-
/* set bottom bit if requested */
|
164
|
-
if (bottom) {
|
165
|
-
buf[bytes - 1] |= 1;
|
166
|
-
}
|
167
|
-
|
168
|
-
if (!BN_bin2bn(buf, bytes, rnd)) {
|
169
|
-
goto err;
|
170
|
-
}
|
171
|
-
|
172
|
-
ret = 1;
|
173
|
-
|
174
|
-
err:
|
175
|
-
if (buf != NULL) {
|
176
|
-
OPENSSL_cleanse(buf, bytes);
|
177
|
-
OPENSSL_free(buf);
|
178
|
-
}
|
179
|
-
return (ret);
|
180
|
-
}
|
181
|
-
|
182
|
-
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) {
|
183
|
-
return BN_rand(rnd, bits, top, bottom);
|
184
|
-
}
|
185
|
-
|
186
|
-
int BN_rand_range(BIGNUM *r, const BIGNUM *range) {
|
187
|
-
unsigned n;
|
188
|
-
unsigned count = 100;
|
189
|
-
|
190
|
-
if (range->neg || BN_is_zero(range)) {
|
191
|
-
OPENSSL_PUT_ERROR(BN, BN_R_INVALID_RANGE);
|
192
|
-
return 0;
|
193
|
-
}
|
194
|
-
|
195
|
-
n = BN_num_bits(range); /* n > 0 */
|
196
|
-
|
197
|
-
/* BN_is_bit_set(range, n - 1) always holds */
|
198
|
-
if (n == 1) {
|
199
|
-
BN_zero(r);
|
200
|
-
} else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {
|
201
|
-
/* range = 100..._2,
|
202
|
-
* so 3*range (= 11..._2) is exactly one bit longer than range */
|
203
|
-
do {
|
204
|
-
if (!BN_rand(r, n + 1, -1 /* don't set most significant bits */,
|
205
|
-
0 /* don't set least significant bits */)) {
|
206
|
-
return 0;
|
207
|
-
}
|
208
|
-
|
209
|
-
/* If r < 3*range, use r := r MOD range (which is either r, r - range, or
|
210
|
-
* r - 2*range). Otherwise, iterate again. Since 3*range = 11..._2, each
|
211
|
-
* iteration succeeds with probability >= .75. */
|
212
|
-
if (BN_cmp(r, range) >= 0) {
|
213
|
-
if (!BN_sub(r, r, range)) {
|
214
|
-
return 0;
|
215
|
-
}
|
216
|
-
if (BN_cmp(r, range) >= 0) {
|
217
|
-
if (!BN_sub(r, r, range)) {
|
218
|
-
return 0;
|
219
|
-
}
|
220
|
-
}
|
221
|
-
}
|
222
|
-
|
223
|
-
if (!--count) {
|
224
|
-
OPENSSL_PUT_ERROR(BN, BN_R_TOO_MANY_ITERATIONS);
|
225
|
-
return 0;
|
226
|
-
}
|
227
|
-
} while (BN_cmp(r, range) >= 0);
|
228
|
-
} else {
|
229
|
-
do {
|
230
|
-
/* range = 11..._2 or range = 101..._2 */
|
231
|
-
if (!BN_rand(r, n, -1, 0)) {
|
232
|
-
return 0;
|
233
|
-
}
|
234
|
-
|
235
|
-
if (!--count) {
|
236
|
-
OPENSSL_PUT_ERROR(BN, BN_R_TOO_MANY_ITERATIONS);
|
237
|
-
return 0;
|
238
|
-
}
|
239
|
-
} while (BN_cmp(r, range) >= 0);
|
240
|
-
}
|
241
|
-
|
242
|
-
return 1;
|
243
|
-
}
|
244
|
-
|
245
|
-
int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range) {
|
246
|
-
return BN_rand_range(r, range);
|
247
|
-
}
|
248
|
-
|
249
|
-
extern int BN_generate_dsa_nonce_digest(uint8_t *out, size_t out_len,
|
250
|
-
const uint8_t *part1, size_t part1_len,
|
251
|
-
const uint8_t *part2, size_t part2_len,
|
252
|
-
const uint8_t *part3, size_t part3_len,
|
253
|
-
const uint8_t *part4, size_t part4_len,
|
254
|
-
const uint8_t *part5, size_t part5_len);
|
255
|
-
|
256
|
-
int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM *priv,
|
257
|
-
const uint8_t *message, size_t message_len,
|
258
|
-
BN_CTX *ctx) {
|
259
|
-
/* We use 512 bits of random data per iteration to
|
260
|
-
* ensure that we have at least |range| bits of randomness. */
|
261
|
-
uint8_t random_bytes[64];
|
262
|
-
uint8_t digest[SHA512_DIGEST_LENGTH];
|
263
|
-
size_t done, todo, attempt;
|
264
|
-
const unsigned num_k_bytes = BN_num_bytes(range);
|
265
|
-
const unsigned bits_to_mask = (8 - (BN_num_bits(range) % 8)) % 8;
|
266
|
-
uint8_t private_bytes[96];
|
267
|
-
uint8_t *k_bytes = NULL;
|
268
|
-
int ret = 0;
|
269
|
-
|
270
|
-
if (out == NULL) {
|
271
|
-
return 0;
|
272
|
-
}
|
273
|
-
|
274
|
-
if (BN_is_zero(range)) {
|
275
|
-
OPENSSL_PUT_ERROR(BN, BN_R_DIV_BY_ZERO);
|
276
|
-
goto err;
|
277
|
-
}
|
278
|
-
|
279
|
-
k_bytes = OPENSSL_malloc(num_k_bytes);
|
280
|
-
if (!k_bytes) {
|
281
|
-
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
|
282
|
-
goto err;
|
283
|
-
}
|
284
|
-
|
285
|
-
/* We copy |priv| into a local buffer to avoid furthur exposing its
|
286
|
-
* length. */
|
287
|
-
todo = sizeof(priv->d[0]) * priv->top;
|
288
|
-
if (todo > sizeof(private_bytes)) {
|
289
|
-
/* No reasonable DSA or ECDSA key should have a private key
|
290
|
-
* this large and we don't handle this case in order to avoid
|
291
|
-
* leaking the length of the private key. */
|
292
|
-
OPENSSL_PUT_ERROR(BN, BN_R_PRIVATE_KEY_TOO_LARGE);
|
293
|
-
goto err;
|
294
|
-
}
|
295
|
-
memcpy(private_bytes, priv->d, todo);
|
296
|
-
memset(private_bytes + todo, 0, sizeof(private_bytes) - todo);
|
297
|
-
|
298
|
-
for (attempt = 0;; attempt++) {
|
299
|
-
for (done = 0; done < num_k_bytes;) {
|
300
|
-
if (!RAND_bytes(random_bytes, sizeof(random_bytes)) ||
|
301
|
-
!BN_generate_dsa_nonce_digest(digest, sizeof(digest),
|
302
|
-
(const uint8_t *)attempt,
|
303
|
-
sizeof(attempt), (const uint8_t *)done,
|
304
|
-
sizeof(done), private_bytes,
|
305
|
-
sizeof(private_bytes), message,
|
306
|
-
message_len, random_bytes,
|
307
|
-
sizeof(random_bytes))) {
|
308
|
-
goto err;
|
309
|
-
}
|
310
|
-
|
311
|
-
todo = num_k_bytes - done;
|
312
|
-
if (todo > sizeof(digest)) {
|
313
|
-
todo = sizeof(digest);
|
314
|
-
}
|
315
|
-
memcpy(k_bytes + done, digest, todo);
|
316
|
-
done += todo;
|
317
|
-
}
|
318
|
-
|
319
|
-
k_bytes[0] &= 0xff >> bits_to_mask;
|
320
|
-
|
321
|
-
if (!BN_bin2bn(k_bytes, num_k_bytes, out)) {
|
322
|
-
goto err;
|
323
|
-
}
|
324
|
-
if (BN_cmp(out, range) < 0) {
|
325
|
-
break;
|
326
|
-
}
|
327
|
-
}
|
328
|
-
|
329
|
-
ret = 1;
|
330
|
-
|
331
|
-
err:
|
332
|
-
OPENSSL_free(k_bytes);
|
333
|
-
return ret;
|
334
|
-
}
|
@@ -1,262 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
* *
|
3
|
-
* Copyright (c) 2012, Intel Corporation *
|
4
|
-
* *
|
5
|
-
* All rights reserved. *
|
6
|
-
* *
|
7
|
-
* Redistribution and use in source and binary forms, with or without *
|
8
|
-
* modification, are permitted provided that the following conditions are *
|
9
|
-
* met: *
|
10
|
-
* *
|
11
|
-
* * Redistributions of source code must retain the above copyright *
|
12
|
-
* notice, this list of conditions and the following disclaimer. *
|
13
|
-
* *
|
14
|
-
* * Redistributions in binary form must reproduce the above copyright *
|
15
|
-
* notice, this list of conditions and the following disclaimer in the *
|
16
|
-
* documentation and/or other materials provided with the *
|
17
|
-
* distribution. *
|
18
|
-
* *
|
19
|
-
* * Neither the name of the Intel Corporation nor the names of its *
|
20
|
-
* contributors may be used to endorse or promote products derived from *
|
21
|
-
* this software without specific prior written permission. *
|
22
|
-
* *
|
23
|
-
* *
|
24
|
-
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY *
|
25
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
|
26
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
|
27
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR *
|
28
|
-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
|
29
|
-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
|
30
|
-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
|
31
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
32
|
-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
|
33
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
|
34
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
35
|
-
* *
|
36
|
-
******************************************************************************
|
37
|
-
* Developers and authors: *
|
38
|
-
* Shay Gueron (1, 2), and Vlad Krasnov (1) *
|
39
|
-
* (1) Intel Corporation, Israel Development Center, Haifa, Israel *
|
40
|
-
* (2) University of Haifa, Israel *
|
41
|
-
*****************************************************************************/
|
42
|
-
|
43
|
-
#include <openssl/base.h>
|
44
|
-
|
45
|
-
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64)
|
46
|
-
|
47
|
-
#include "rsaz_exp.h"
|
48
|
-
|
49
|
-
#include <openssl/mem.h>
|
50
|
-
|
51
|
-
/*
|
52
|
-
* See crypto/bn/asm/rsaz-avx2.pl for further details.
|
53
|
-
*/
|
54
|
-
void rsaz_1024_norm2red_avx2(void *red,const void *norm);
|
55
|
-
void rsaz_1024_mul_avx2(void *ret,const void *a,const void *b,const void *n,BN_ULONG k);
|
56
|
-
void rsaz_1024_sqr_avx2(void *ret,const void *a,const void *n,BN_ULONG k,int cnt);
|
57
|
-
void rsaz_1024_scatter5_avx2(void *tbl,const void *val,int i);
|
58
|
-
void rsaz_1024_gather5_avx2(void *val,const void *tbl,int i);
|
59
|
-
void rsaz_1024_red2norm_avx2(void *norm,const void *red);
|
60
|
-
|
61
|
-
#if defined(__GNUC__)
|
62
|
-
# define ALIGN64 __attribute__((aligned(64)))
|
63
|
-
#elif defined(_MSC_VER)
|
64
|
-
# define ALIGN64 __declspec(align(64))
|
65
|
-
#elif defined(__SUNPRO_C)
|
66
|
-
# define ALIGN64
|
67
|
-
# pragma align 64(one,two80)
|
68
|
-
#else
|
69
|
-
# define ALIGN64 /* not fatal, might hurt performance a little */
|
70
|
-
#endif
|
71
|
-
|
72
|
-
ALIGN64 static const BN_ULONG one[40] =
|
73
|
-
{1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
74
|
-
ALIGN64 static const BN_ULONG two80[40] =
|
75
|
-
{0,0,1<<22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
76
|
-
|
77
|
-
void RSAZ_1024_mod_exp_avx2(BN_ULONG result_norm[16],
|
78
|
-
const BN_ULONG base_norm[16], const BN_ULONG exponent[16],
|
79
|
-
const BN_ULONG m_norm[16], const BN_ULONG RR[16], BN_ULONG k0)
|
80
|
-
{
|
81
|
-
unsigned char storage[320*3+32*9*16+64]; /* 5.5KB */
|
82
|
-
unsigned char *p_str = storage + (64-((size_t)storage%64));
|
83
|
-
unsigned char *a_inv, *m, *result,
|
84
|
-
*table_s = p_str+320*3,
|
85
|
-
*R2 = table_s; /* borrow */
|
86
|
-
int index;
|
87
|
-
int wvalue;
|
88
|
-
|
89
|
-
if ((((size_t)p_str&4095)+320)>>12) {
|
90
|
-
result = p_str;
|
91
|
-
a_inv = p_str + 320;
|
92
|
-
m = p_str + 320*2; /* should not cross page */
|
93
|
-
} else {
|
94
|
-
m = p_str; /* should not cross page */
|
95
|
-
result = p_str + 320;
|
96
|
-
a_inv = p_str + 320*2;
|
97
|
-
}
|
98
|
-
|
99
|
-
rsaz_1024_norm2red_avx2(m, m_norm);
|
100
|
-
rsaz_1024_norm2red_avx2(a_inv, base_norm);
|
101
|
-
rsaz_1024_norm2red_avx2(R2, RR);
|
102
|
-
|
103
|
-
rsaz_1024_mul_avx2(R2, R2, R2, m, k0);
|
104
|
-
rsaz_1024_mul_avx2(R2, R2, two80, m, k0);
|
105
|
-
|
106
|
-
/* table[0] = 1 */
|
107
|
-
rsaz_1024_mul_avx2(result, R2, one, m, k0);
|
108
|
-
/* table[1] = a_inv^1 */
|
109
|
-
rsaz_1024_mul_avx2(a_inv, a_inv, R2, m, k0);
|
110
|
-
|
111
|
-
rsaz_1024_scatter5_avx2(table_s,result,0);
|
112
|
-
rsaz_1024_scatter5_avx2(table_s,a_inv,1);
|
113
|
-
|
114
|
-
/* table[2] = a_inv^2 */
|
115
|
-
rsaz_1024_sqr_avx2(result, a_inv, m, k0, 1);
|
116
|
-
rsaz_1024_scatter5_avx2(table_s,result,2);
|
117
|
-
#if 0
|
118
|
-
/* this is almost 2x smaller and less than 1% slower */
|
119
|
-
for (index=3; index<32; index++) {
|
120
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
121
|
-
rsaz_1024_scatter5_avx2(table_s,result,index);
|
122
|
-
}
|
123
|
-
#else
|
124
|
-
/* table[4] = a_inv^4 */
|
125
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
126
|
-
rsaz_1024_scatter5_avx2(table_s,result,4);
|
127
|
-
/* table[8] = a_inv^8 */
|
128
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
129
|
-
rsaz_1024_scatter5_avx2(table_s,result,8);
|
130
|
-
/* table[16] = a_inv^16 */
|
131
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
132
|
-
rsaz_1024_scatter5_avx2(table_s,result,16);
|
133
|
-
/* table[17] = a_inv^17 */
|
134
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
135
|
-
rsaz_1024_scatter5_avx2(table_s,result,17);
|
136
|
-
|
137
|
-
/* table[3] */
|
138
|
-
rsaz_1024_gather5_avx2(result,table_s,2);
|
139
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
140
|
-
rsaz_1024_scatter5_avx2(table_s,result,3);
|
141
|
-
/* table[6] */
|
142
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
143
|
-
rsaz_1024_scatter5_avx2(table_s,result,6);
|
144
|
-
/* table[12] */
|
145
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
146
|
-
rsaz_1024_scatter5_avx2(table_s,result,12);
|
147
|
-
/* table[24] */
|
148
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
149
|
-
rsaz_1024_scatter5_avx2(table_s,result,24);
|
150
|
-
/* table[25] */
|
151
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
152
|
-
rsaz_1024_scatter5_avx2(table_s,result,25);
|
153
|
-
|
154
|
-
/* table[5] */
|
155
|
-
rsaz_1024_gather5_avx2(result,table_s,4);
|
156
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
157
|
-
rsaz_1024_scatter5_avx2(table_s,result,5);
|
158
|
-
/* table[10] */
|
159
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
160
|
-
rsaz_1024_scatter5_avx2(table_s,result,10);
|
161
|
-
/* table[20] */
|
162
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
163
|
-
rsaz_1024_scatter5_avx2(table_s,result,20);
|
164
|
-
/* table[21] */
|
165
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
166
|
-
rsaz_1024_scatter5_avx2(table_s,result,21);
|
167
|
-
|
168
|
-
/* table[7] */
|
169
|
-
rsaz_1024_gather5_avx2(result,table_s,6);
|
170
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
171
|
-
rsaz_1024_scatter5_avx2(table_s,result,7);
|
172
|
-
/* table[14] */
|
173
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
174
|
-
rsaz_1024_scatter5_avx2(table_s,result,14);
|
175
|
-
/* table[28] */
|
176
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
177
|
-
rsaz_1024_scatter5_avx2(table_s,result,28);
|
178
|
-
/* table[29] */
|
179
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
180
|
-
rsaz_1024_scatter5_avx2(table_s,result,29);
|
181
|
-
|
182
|
-
/* table[9] */
|
183
|
-
rsaz_1024_gather5_avx2(result,table_s,8);
|
184
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
185
|
-
rsaz_1024_scatter5_avx2(table_s,result,9);
|
186
|
-
/* table[18] */
|
187
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
188
|
-
rsaz_1024_scatter5_avx2(table_s,result,18);
|
189
|
-
/* table[19] */
|
190
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
191
|
-
rsaz_1024_scatter5_avx2(table_s,result,19);
|
192
|
-
|
193
|
-
/* table[11] */
|
194
|
-
rsaz_1024_gather5_avx2(result,table_s,10);
|
195
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
196
|
-
rsaz_1024_scatter5_avx2(table_s,result,11);
|
197
|
-
/* table[22] */
|
198
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
199
|
-
rsaz_1024_scatter5_avx2(table_s,result,22);
|
200
|
-
/* table[23] */
|
201
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
202
|
-
rsaz_1024_scatter5_avx2(table_s,result,23);
|
203
|
-
|
204
|
-
/* table[13] */
|
205
|
-
rsaz_1024_gather5_avx2(result,table_s,12);
|
206
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
207
|
-
rsaz_1024_scatter5_avx2(table_s,result,13);
|
208
|
-
/* table[26] */
|
209
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
210
|
-
rsaz_1024_scatter5_avx2(table_s,result,26);
|
211
|
-
/* table[27] */
|
212
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
213
|
-
rsaz_1024_scatter5_avx2(table_s,result,27);
|
214
|
-
|
215
|
-
/* table[15] */
|
216
|
-
rsaz_1024_gather5_avx2(result,table_s,14);
|
217
|
-
rsaz_1024_mul_avx2(result,result,a_inv,m,k0);
|
218
|
-
rsaz_1024_scatter5_avx2(table_s,result,15);
|
219
|
-
/* table[30] */
|
220
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 1);
|
221
|
-
rsaz_1024_scatter5_avx2(table_s,result,30);
|
222
|
-
/* table[31] */
|
223
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
224
|
-
rsaz_1024_scatter5_avx2(table_s,result,31);
|
225
|
-
#endif
|
226
|
-
|
227
|
-
/* load first window */
|
228
|
-
p_str = (unsigned char*)exponent;
|
229
|
-
wvalue = p_str[127] >> 3;
|
230
|
-
rsaz_1024_gather5_avx2(result,table_s,wvalue);
|
231
|
-
|
232
|
-
index = 1014;
|
233
|
-
|
234
|
-
while(index > -1) { /* loop for the remaining 127 windows */
|
235
|
-
|
236
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 5);
|
237
|
-
|
238
|
-
wvalue = *((unsigned short*)&p_str[index/8]);
|
239
|
-
wvalue = (wvalue>> (index%8)) & 31;
|
240
|
-
index-=5;
|
241
|
-
|
242
|
-
rsaz_1024_gather5_avx2(a_inv,table_s,wvalue); /* borrow a_inv */
|
243
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
244
|
-
}
|
245
|
-
|
246
|
-
/* square four times */
|
247
|
-
rsaz_1024_sqr_avx2(result, result, m, k0, 4);
|
248
|
-
|
249
|
-
wvalue = p_str[0] & 15;
|
250
|
-
|
251
|
-
rsaz_1024_gather5_avx2(a_inv,table_s,wvalue); /* borrow a_inv */
|
252
|
-
rsaz_1024_mul_avx2(result, result, a_inv, m, k0);
|
253
|
-
|
254
|
-
/* from Montgomery */
|
255
|
-
rsaz_1024_mul_avx2(result, result, one, m, k0);
|
256
|
-
|
257
|
-
rsaz_1024_red2norm_avx2(result_norm, result);
|
258
|
-
|
259
|
-
OPENSSL_cleanse(storage,sizeof(storage));
|
260
|
-
}
|
261
|
-
|
262
|
-
#endif /* OPENSSL_X86_64 */
|