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,57 +0,0 @@
|
|
1
|
-
# SHA-1 tests from RFC 3174.
|
2
|
-
|
3
|
-
Hash = SHA1
|
4
|
-
Input = "abc"
|
5
|
-
Repeat = 1
|
6
|
-
Output = a9993e364706816aba3e25717850c26c9cd0d89d
|
7
|
-
|
8
|
-
Hash = SHA1
|
9
|
-
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
10
|
-
Repeat = 1
|
11
|
-
Output = 84983e441c3bd26ebaae4aa1f95129e5e54670f1
|
12
|
-
|
13
|
-
Hash = SHA1
|
14
|
-
Input = "a"
|
15
|
-
Repeat = 1000000
|
16
|
-
Output = 34aa973cd4c4daa4f61eeb2bdbad27316534016f
|
17
|
-
|
18
|
-
Hash = SHA1
|
19
|
-
Input = "0123456701234567012345670123456701234567012345670123456701234567"
|
20
|
-
Repeat = 10
|
21
|
-
Output = dea356a2cddd90c7a7ecedc5ebb563934f460452
|
22
|
-
|
23
|
-
# SHA-256 tests from NIST.
|
24
|
-
|
25
|
-
Hash = SHA256
|
26
|
-
Input = "abc"
|
27
|
-
Repeat = 1
|
28
|
-
Output = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
|
29
|
-
|
30
|
-
Hash = SHA256
|
31
|
-
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
32
|
-
Repeat = 1
|
33
|
-
Output = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
|
34
|
-
|
35
|
-
# SHA-384 tests from NIST.
|
36
|
-
|
37
|
-
Hash = SHA384
|
38
|
-
Input = "abc"
|
39
|
-
Repeat = 1
|
40
|
-
Output = cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7
|
41
|
-
|
42
|
-
Hash = SHA384
|
43
|
-
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
|
44
|
-
Repeat = 1
|
45
|
-
Output = 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
|
46
|
-
|
47
|
-
# SHA-512 tests from NIST
|
48
|
-
|
49
|
-
Hash = SHA512
|
50
|
-
Input = "abc"
|
51
|
-
Repeat = 1
|
52
|
-
Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
|
53
|
-
|
54
|
-
Hash = SHA512
|
55
|
-
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
|
56
|
-
Repeat = 1
|
57
|
-
Output = 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
|
data/vendor/ring/src/ecc.rs
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
// Copyright 2015 Brian Smith.
|
2
|
-
//
|
3
|
-
// Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
// purpose with or without fee is hereby granted, provided that the above
|
5
|
-
// copyright notice and this permission notice appear in all copies.
|
6
|
-
//
|
7
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
8
|
-
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
10
|
-
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
-
|
15
|
-
#[allow(non_camel_case_types)]
|
16
|
-
#[doc(hidden)]
|
17
|
-
pub enum EC_GROUP { }
|
18
|
-
|
19
|
-
extern {
|
20
|
-
#[doc(hidden)]
|
21
|
-
pub fn EC_GROUP_P256() -> *const EC_GROUP;
|
22
|
-
|
23
|
-
#[doc(hidden)]
|
24
|
-
pub fn EC_GROUP_P384() -> *const EC_GROUP;
|
25
|
-
|
26
|
-
#[doc(hidden)]
|
27
|
-
pub fn EC_GROUP_P521() -> *const EC_GROUP;
|
28
|
-
}
|
@@ -1,279 +0,0 @@
|
|
1
|
-
// Copyright 2015 Brian Smith.
|
2
|
-
//
|
3
|
-
// Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
// purpose with or without fee is hereby granted, provided that the above
|
5
|
-
// copyright notice and this permission notice appear in all copies.
|
6
|
-
//
|
7
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
8
|
-
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
10
|
-
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
-
|
15
|
-
use num;
|
16
|
-
use num::integer::Integer as Integral;
|
17
|
-
use num::traits::{FromPrimitive, Num, One, Signed, ToPrimitive, Zero};
|
18
|
-
use std;
|
19
|
-
use super::ecc_curves::*;
|
20
|
-
|
21
|
-
pub fn generate_code(out_dir: &str) -> std::io::Result<()> {
|
22
|
-
generate_ec_groups(out_dir)
|
23
|
-
}
|
24
|
-
|
25
|
-
// The math
|
26
|
-
|
27
|
-
type Integer = num::bigint::BigInt;
|
28
|
-
|
29
|
-
fn mod_inv(a: &Integer, m: &Integer)
|
30
|
-
-> Result<Integer, ()> {
|
31
|
-
fn extended_gcd(aa: &Integer, bb: &Integer) -> (Integer, Integer, Integer) {
|
32
|
-
let mut last_rem = aa.abs();
|
33
|
-
let mut rem = bb.abs();
|
34
|
-
let mut x = Integer::zero();
|
35
|
-
let mut last_x = Integer::one();
|
36
|
-
let mut y = Integer::one();
|
37
|
-
let mut last_y = Integer::zero();
|
38
|
-
while !rem.is_zero() {
|
39
|
-
let (quotient, new_rem) = last_rem.div_rem(&rem);
|
40
|
-
last_rem = rem;
|
41
|
-
rem = new_rem;
|
42
|
-
|
43
|
-
let new_x = last_x - "ient * &x;
|
44
|
-
last_x = x;
|
45
|
-
x = new_x;
|
46
|
-
|
47
|
-
let new_y = last_y - "ient * &y;
|
48
|
-
last_y = y;
|
49
|
-
y = new_y;
|
50
|
-
}
|
51
|
-
println!("last_rem: {}, aa: {}, bb: {}, last_x: {}, last_y: {}",
|
52
|
-
last_rem, aa, bb, last_x, last_y);
|
53
|
-
(last_rem,
|
54
|
-
if aa.is_negative() { -last_x } else { last_x },
|
55
|
-
if bb.is_negative() { -last_y } else { last_y })
|
56
|
-
}
|
57
|
-
|
58
|
-
let (g, x, _) = extended_gcd(a, m);
|
59
|
-
if g != Integer::one() {
|
60
|
-
return Err(());
|
61
|
-
}
|
62
|
-
println!("x: {}, x % m: {}", &x, &x % m);
|
63
|
-
Ok(x % m)
|
64
|
-
}
|
65
|
-
|
66
|
-
struct ModP {
|
67
|
-
rr: Integer,
|
68
|
-
r: Integer,
|
69
|
-
p: Integer,
|
70
|
-
k: u64,
|
71
|
-
}
|
72
|
-
|
73
|
-
#[cfg(target_pointer_width = "64")]
|
74
|
-
const LIMB_BITS: usize = 64;
|
75
|
-
|
76
|
-
#[cfg(target_pointer_width = "32")]
|
77
|
-
const LIMB_BITS: usize = 32;
|
78
|
-
|
79
|
-
impl ModP {
|
80
|
-
fn new(p_hex_str: &str) -> Result<ModP, ()> {
|
81
|
-
let p = integer_from_hex_str(p_hex_str);
|
82
|
-
let p_bits = (p.to_biguint().unwrap().bits() + LIMB_BITS - 1) /
|
83
|
-
LIMB_BITS * LIMB_BITS;
|
84
|
-
let neg_p = -&p;
|
85
|
-
|
86
|
-
let r = (Integer::one() << p_bits) % &p;
|
87
|
-
let rr = (&r * &r) % &p;
|
88
|
-
let tmod = Integer::one() << 64;
|
89
|
-
let k = try!(mod_inv(&neg_p, &tmod));
|
90
|
-
let mut k = k % (Integer::one() << 64);
|
91
|
-
if k.is_negative() {
|
92
|
-
k = &k + (Integer::one() << 64);
|
93
|
-
}
|
94
|
-
let k = k.to_u64().unwrap();
|
95
|
-
Ok(ModP {
|
96
|
-
p: p.clone(),
|
97
|
-
r: r.clone(),
|
98
|
-
rr: rr.clone(),
|
99
|
-
k: k.clone(),
|
100
|
-
})
|
101
|
-
}
|
102
|
-
|
103
|
-
fn encode(&self, n: &Integer) -> Integer {
|
104
|
-
(n * &self.r) % &self.p
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
fn integer_from_hex_str(hex_str: &str) -> Integer {
|
109
|
-
Integer::from_str_radix(hex_str, 16).unwrap()
|
110
|
-
}
|
111
|
-
|
112
|
-
// Generation of the C code for |EC_GROUP|
|
113
|
-
pub fn generate_ec_groups(out_dir: &str) -> std::io::Result<()> {
|
114
|
-
use std::io::Write;
|
115
|
-
|
116
|
-
let mut fragments = SUPPORTED_CURVES.into_iter()
|
117
|
-
.map(|x| ec_group(x))
|
118
|
-
.collect::<Vec<_>>();
|
119
|
-
fragments.insert(0, String::from(EC_GROUPS_BOILERPLATE));
|
120
|
-
|
121
|
-
// Ensure file ends with newline to avoid undefined behavior
|
122
|
-
let code = fragments.join("\n") + "\n";
|
123
|
-
|
124
|
-
let dest_path = std::path::Path::new(&out_dir).join("ec_curve_data.inl");
|
125
|
-
let mut f = try!(std::fs::File::create(&dest_path));
|
126
|
-
try!(f.write_all(code.as_bytes()));
|
127
|
-
Ok(())
|
128
|
-
}
|
129
|
-
|
130
|
-
fn ec_group(curve: &NISTCurve) -> String {
|
131
|
-
assert_eq!(curve.cofactor, 1);
|
132
|
-
|
133
|
-
let q = ModP::new(&curve.q).unwrap();
|
134
|
-
|
135
|
-
let n = ModP::new(&curve.n).unwrap();
|
136
|
-
let n_minus_2 = &n.p - Integer::from_i8(2).unwrap();
|
137
|
-
|
138
|
-
let one = Integer::one();
|
139
|
-
assert_eq!(curve.a, -3);
|
140
|
-
let a = &q.p + Integer::from_i8(curve.a).unwrap();
|
141
|
-
let b = integer_from_hex_str(&curve.b);
|
142
|
-
|
143
|
-
let (generator_x, generator_y) =
|
144
|
-
(integer_from_hex_str(&curve.generator.0),
|
145
|
-
integer_from_hex_str(&curve.generator.1));
|
146
|
-
|
147
|
-
let one_mont = q.encode(&one);
|
148
|
-
let a_mont = q.encode(&a);
|
149
|
-
let b_mont = q.encode(&b);
|
150
|
-
let generator_x_mont = q.encode(&generator_x);
|
151
|
-
let generator_y_mont = q.encode(&generator_y);
|
152
|
-
|
153
|
-
format!("
|
154
|
-
const EC_GROUP *{ec_group_fn_name}(void) {{
|
155
|
-
static const BN_ULONG field_limbs[] = {q};
|
156
|
-
static const BN_ULONG field_rr_limbs[] = {q_rr};
|
157
|
-
static const BN_ULONG order_limbs[] = {n};
|
158
|
-
static const BN_ULONG order_rr_limbs[] = {n_rr};
|
159
|
-
static const BN_ULONG order_minus_2_limbs[] = {n_minus_2};
|
160
|
-
#if defined({name}_NO_MONT)
|
161
|
-
static const BN_ULONG generator_x_limbs[] = {x};
|
162
|
-
static const BN_ULONG generator_y_limbs[] = {y};
|
163
|
-
static const BN_ULONG a_limbs[] = {a};
|
164
|
-
static const BN_ULONG b_limbs[] = {b};
|
165
|
-
static const BN_ULONG one_limbs[] = {one};
|
166
|
-
#else
|
167
|
-
static const BN_ULONG generator_x_limbs[] = {x_mont};
|
168
|
-
static const BN_ULONG generator_y_limbs[] = {y_mont};
|
169
|
-
static const BN_ULONG a_limbs[] = {a_mont};
|
170
|
-
static const BN_ULONG b_limbs[] = {b_mont};
|
171
|
-
static const BN_ULONG one_limbs[] = {one_mont};
|
172
|
-
#endif
|
173
|
-
static const EC_GROUP group = {{
|
174
|
-
FIELD(.meth =) &{name}_EC_METHOD,
|
175
|
-
FIELD(.generator =) {{
|
176
|
-
FIELD(.meth =) &{name}_EC_METHOD,
|
177
|
-
FIELD(.X =) STATIC_BIGNUM(generator_x_limbs),
|
178
|
-
FIELD(.Y =) STATIC_BIGNUM(generator_y_limbs),
|
179
|
-
FIELD(.Z =) STATIC_BIGNUM(one_limbs),
|
180
|
-
}},
|
181
|
-
FIELD(.order =) STATIC_BIGNUM(order_limbs),
|
182
|
-
FIELD(.order_mont =) {{
|
183
|
-
FIELD(.RR =) STATIC_BIGNUM(order_rr_limbs),
|
184
|
-
FIELD(.N =) STATIC_BIGNUM(order_limbs),
|
185
|
-
FIELD(.n0 =) {{ BN_MONT_CTX_N0(0x{n_n1:x}, 0x{n_n0:x}) }},
|
186
|
-
}},
|
187
|
-
FIELD(.order_minus_2 =) STATIC_BIGNUM(order_minus_2_limbs),
|
188
|
-
FIELD(.curve_name =) {nid},
|
189
|
-
FIELD(.field =) STATIC_BIGNUM(field_limbs),
|
190
|
-
FIELD(.a =) STATIC_BIGNUM(a_limbs),
|
191
|
-
FIELD(.b =) STATIC_BIGNUM(b_limbs),
|
192
|
-
FIELD(.mont =) {{
|
193
|
-
FIELD(.RR =) STATIC_BIGNUM(field_rr_limbs),
|
194
|
-
FIELD(.N =) STATIC_BIGNUM(field_limbs),
|
195
|
-
FIELD(.n0 =) {{ BN_MONT_CTX_N0(0x{q_n1:x}, 0x{q_n0:x}) }},
|
196
|
-
}},
|
197
|
-
FIELD(.one =) STATIC_BIGNUM(one_limbs),
|
198
|
-
}};
|
199
|
-
return &group;
|
200
|
-
}}",
|
201
|
-
ec_group_fn_name = curve.name.replace("CURVE", "EC_GROUP"),
|
202
|
-
name = curve.name,
|
203
|
-
nid = curve.nid,
|
204
|
-
|
205
|
-
q = bn_limbs(&q.p),
|
206
|
-
q_rr = bn_limbs(&q.rr),
|
207
|
-
q_n0 = (q.k % (1u64 << 32)) as usize,
|
208
|
-
q_n1 = (q.k / (1u64 << 32)) as usize,
|
209
|
-
|
210
|
-
n = bn_limbs(&n.p),
|
211
|
-
n_minus_2 = bn_limbs(&n_minus_2),
|
212
|
-
n_rr = bn_limbs(&n.rr),
|
213
|
-
n_n0 = (n.k % (1u64 << 32)) as usize,
|
214
|
-
n_n1 = (n.k / (1u64 << 32)) as usize,
|
215
|
-
|
216
|
-
one = bn_limbs(&one),
|
217
|
-
x = bn_limbs(&generator_x),
|
218
|
-
y = bn_limbs(&generator_y),
|
219
|
-
a = bn_limbs(&a),
|
220
|
-
b = bn_limbs(&b),
|
221
|
-
|
222
|
-
one_mont = bn_limbs(&one_mont),
|
223
|
-
x_mont = bn_limbs(&generator_x_mont),
|
224
|
-
y_mont = bn_limbs(&generator_y_mont),
|
225
|
-
a_mont = bn_limbs(&a_mont),
|
226
|
-
b_mont = bn_limbs(&b_mont))
|
227
|
-
.replace("\n ", "\n")
|
228
|
-
}
|
229
|
-
|
230
|
-
fn bn_limbs(value: &Integer) -> String {
|
231
|
-
const INDENT: &'static str = " ";
|
232
|
-
|
233
|
-
let limbs =
|
234
|
-
value
|
235
|
-
.to_bytes_le()
|
236
|
-
.1
|
237
|
-
.chunks(4)
|
238
|
-
.map(|bytes| {
|
239
|
-
let mut place = 0;
|
240
|
-
let mut value = 0;
|
241
|
-
for b in bytes {
|
242
|
-
value |= (*b as u32) << place;
|
243
|
-
place += 8;
|
244
|
-
}
|
245
|
-
value
|
246
|
-
})
|
247
|
-
.collect::<Vec<_>>()
|
248
|
-
.chunks(2)
|
249
|
-
.map(|limbs_32x2| {
|
250
|
-
match limbs_32x2.len() {
|
251
|
-
2 => format!("{}TOBN(0x{:08x}, 0x{:08x}),\n", INDENT,
|
252
|
-
limbs_32x2[1], limbs_32x2[0]),
|
253
|
-
1 => format!("{}0x{:08x},\n", INDENT,
|
254
|
-
limbs_32x2[0]),
|
255
|
-
_ => unreachable!()
|
256
|
-
}
|
257
|
-
})
|
258
|
-
.collect::<String>();
|
259
|
-
|
260
|
-
format!("{{\n{} }}", limbs)
|
261
|
-
}
|
262
|
-
|
263
|
-
const EC_GROUPS_BOILERPLATE: &'static str = r##"/* Copyright 2015 Brian Smith.
|
264
|
-
*
|
265
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
266
|
-
* purpose with or without fee is hereby granted, provided that the above
|
267
|
-
* copyright notice and this permission notice appear in all copies.
|
268
|
-
*
|
269
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
270
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
271
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
272
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
273
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
274
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
275
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
276
|
-
|
277
|
-
/* This entire file was generated by ecc_build.rs from
|
278
|
-
* https://github.com/briansmith/ring. */
|
279
|
-
"##;
|
@@ -1,117 +0,0 @@
|
|
1
|
-
// Copyright 2015 Brian Smith.
|
2
|
-
//
|
3
|
-
// Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
// purpose with or without fee is hereby granted, provided that the above
|
5
|
-
// copyright notice and this permission notice appear in all copies.
|
6
|
-
//
|
7
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
|
8
|
-
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
10
|
-
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
-
|
15
|
-
//! Data defining the supported elliptic curves.
|
16
|
-
|
17
|
-
pub struct NISTCurve {
|
18
|
-
pub name: &'static str,
|
19
|
-
pub nid: &'static str,
|
20
|
-
pub q: &'static str,
|
21
|
-
pub n: &'static str,
|
22
|
-
pub generator: (&'static str, &'static str),
|
23
|
-
pub a: i8, // Must always be -3.
|
24
|
-
pub b: &'static str,
|
25
|
-
pub cofactor: i8, // Must always be 1.
|
26
|
-
}
|
27
|
-
|
28
|
-
// The curve parameters are from
|
29
|
-
// http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf.
|
30
|
-
|
31
|
-
pub static SUPPORTED_CURVES: [NISTCurve; 4] = [
|
32
|
-
NISTCurve {
|
33
|
-
name: "CURVE_P224",
|
34
|
-
|
35
|
-
// 2^224 − 2^96 + 1
|
36
|
-
q: "ffffffffffffffffffffffffffffffff000000000000000000000001",
|
37
|
-
|
38
|
-
n: "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
|
39
|
-
|
40
|
-
generator:
|
41
|
-
("b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
|
42
|
-
"bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),
|
43
|
-
|
44
|
-
a: -3,
|
45
|
-
b: "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
|
46
|
-
cofactor: 1,
|
47
|
-
|
48
|
-
nid: "NID_secp224r1",
|
49
|
-
},
|
50
|
-
NISTCurve {
|
51
|
-
name: "CURVE_P256",
|
52
|
-
|
53
|
-
// 2**256 - 2**224 + 2**192 + 2**96 - 1
|
54
|
-
q: "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
|
55
|
-
|
56
|
-
// 2**256 - 2**224 + 2**192 - 2**128 +
|
57
|
-
// 0xbce6faada7179e84f3b9cac2fc632551
|
58
|
-
n: "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
|
59
|
-
|
60
|
-
generator:
|
61
|
-
("6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
|
62
|
-
"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),
|
63
|
-
|
64
|
-
a: -3,
|
65
|
-
b: "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
|
66
|
-
cofactor: 1,
|
67
|
-
|
68
|
-
nid: "NID_X9_62_prime256v1",
|
69
|
-
},
|
70
|
-
NISTCurve {
|
71
|
-
name: "CURVE_P384",
|
72
|
-
|
73
|
-
// 2^384 − 2^128 − 2^96 + 2^32 − 1
|
74
|
-
q: "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\
|
75
|
-
ffffffff0000000000000000ffffffff",
|
76
|
-
|
77
|
-
// 2^384 - 2^192 + 0xc7634d81f4372ddf581a0db248b0a77aecec196accc52973
|
78
|
-
n: "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf\
|
79
|
-
581a0db248b0a77aecec196accc52973",
|
80
|
-
|
81
|
-
generator:
|
82
|
-
("aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a38\
|
83
|
-
5502f25dbf55296c3a545e3872760ab7",
|
84
|
-
"3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c0\
|
85
|
-
0a60b1ce1d7e819d7a431d7c90ea0e5f"),
|
86
|
-
|
87
|
-
a: -3,
|
88
|
-
b: "b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875a\
|
89
|
-
c656398d8a2ed19d2a85c8edd3ec2aef",
|
90
|
-
cofactor: 1,
|
91
|
-
|
92
|
-
nid: "NID_secp384r1",
|
93
|
-
},
|
94
|
-
NISTCurve {
|
95
|
-
name: "CURVE_P521",
|
96
|
-
|
97
|
-
// 2^521 − 1
|
98
|
-
q: "01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\
|
99
|
-
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
100
|
-
|
101
|
-
n: "01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\
|
102
|
-
fa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409",
|
103
|
-
|
104
|
-
generator:
|
105
|
-
("00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3d\
|
106
|
-
baa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66",
|
107
|
-
"011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e66\
|
108
|
-
2c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),
|
109
|
-
|
110
|
-
a: -3,
|
111
|
-
b: "0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109\
|
112
|
-
e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00",
|
113
|
-
cofactor: 1,
|
114
|
-
|
115
|
-
nid: "NID_secp521r1",
|
116
|
-
},
|
117
|
-
];
|