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.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGES.md +7 -0
  4. data/Makefile +5 -0
  5. data/README.md +12 -5
  6. data/Rakefile +4 -0
  7. data/ext/ring/extconf.rb +4 -5
  8. data/lib/ring/native.rb +3 -1
  9. data/lib/ring/native/version.rb +5 -1
  10. data/ring-native.gemspec +6 -6
  11. data/vendor/ring-ffi/Cargo.lock +26 -0
  12. data/vendor/ring-ffi/Cargo.toml +45 -0
  13. data/vendor/ring-ffi/LICENSE +16 -0
  14. data/vendor/ring-ffi/README.md +59 -0
  15. data/vendor/ring-ffi/src/lib.rs +79 -0
  16. metadata +10 -255
  17. data/vendor/ring/BUILDING.md +0 -40
  18. data/vendor/ring/Cargo.toml +0 -43
  19. data/vendor/ring/LICENSE +0 -185
  20. data/vendor/ring/Makefile +0 -35
  21. data/vendor/ring/PORTING.md +0 -163
  22. data/vendor/ring/README.md +0 -113
  23. data/vendor/ring/STYLE.md +0 -197
  24. data/vendor/ring/appveyor.yml +0 -27
  25. data/vendor/ring/build.rs +0 -108
  26. data/vendor/ring/crypto/aes/aes.c +0 -1142
  27. data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +0 -25
  28. data/vendor/ring/crypto/aes/aes_test.cc +0 -93
  29. data/vendor/ring/crypto/aes/asm/aes-586.pl +0 -2368
  30. data/vendor/ring/crypto/aes/asm/aes-armv4.pl +0 -1249
  31. data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +0 -2246
  32. data/vendor/ring/crypto/aes/asm/aesni-x86.pl +0 -1318
  33. data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +0 -2084
  34. data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +0 -675
  35. data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +0 -1364
  36. data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +0 -1565
  37. data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +0 -841
  38. data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +0 -1116
  39. data/vendor/ring/crypto/aes/internal.h +0 -87
  40. data/vendor/ring/crypto/aes/mode_wrappers.c +0 -61
  41. data/vendor/ring/crypto/bn/add.c +0 -394
  42. data/vendor/ring/crypto/bn/asm/armv4-mont.pl +0 -694
  43. data/vendor/ring/crypto/bn/asm/armv8-mont.pl +0 -1503
  44. data/vendor/ring/crypto/bn/asm/bn-586.pl +0 -774
  45. data/vendor/ring/crypto/bn/asm/co-586.pl +0 -287
  46. data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +0 -1882
  47. data/vendor/ring/crypto/bn/asm/x86-mont.pl +0 -592
  48. data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +0 -599
  49. data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +0 -1393
  50. data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +0 -3507
  51. data/vendor/ring/crypto/bn/bn.c +0 -352
  52. data/vendor/ring/crypto/bn/bn_asn1.c +0 -74
  53. data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +0 -25
  54. data/vendor/ring/crypto/bn/bn_test.cc +0 -1696
  55. data/vendor/ring/crypto/bn/cmp.c +0 -200
  56. data/vendor/ring/crypto/bn/convert.c +0 -433
  57. data/vendor/ring/crypto/bn/ctx.c +0 -311
  58. data/vendor/ring/crypto/bn/div.c +0 -594
  59. data/vendor/ring/crypto/bn/exponentiation.c +0 -1335
  60. data/vendor/ring/crypto/bn/gcd.c +0 -711
  61. data/vendor/ring/crypto/bn/generic.c +0 -1019
  62. data/vendor/ring/crypto/bn/internal.h +0 -316
  63. data/vendor/ring/crypto/bn/montgomery.c +0 -516
  64. data/vendor/ring/crypto/bn/mul.c +0 -888
  65. data/vendor/ring/crypto/bn/prime.c +0 -829
  66. data/vendor/ring/crypto/bn/random.c +0 -334
  67. data/vendor/ring/crypto/bn/rsaz_exp.c +0 -262
  68. data/vendor/ring/crypto/bn/rsaz_exp.h +0 -53
  69. data/vendor/ring/crypto/bn/shift.c +0 -276
  70. data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +0 -25
  71. data/vendor/ring/crypto/bytestring/bytestring_test.cc +0 -421
  72. data/vendor/ring/crypto/bytestring/cbb.c +0 -399
  73. data/vendor/ring/crypto/bytestring/cbs.c +0 -227
  74. data/vendor/ring/crypto/bytestring/internal.h +0 -46
  75. data/vendor/ring/crypto/chacha/chacha_generic.c +0 -140
  76. data/vendor/ring/crypto/chacha/chacha_vec.c +0 -323
  77. data/vendor/ring/crypto/chacha/chacha_vec_arm.S +0 -1447
  78. data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +0 -153
  79. data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +0 -25
  80. data/vendor/ring/crypto/cipher/e_aes.c +0 -390
  81. data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +0 -208
  82. data/vendor/ring/crypto/cipher/internal.h +0 -173
  83. data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +0 -543
  84. data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +0 -9
  85. data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +0 -475
  86. data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +0 -23
  87. data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +0 -422
  88. data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +0 -484
  89. data/vendor/ring/crypto/cipher/test/cipher_test.txt +0 -100
  90. data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +0 -25
  91. data/vendor/ring/crypto/constant_time_test.c +0 -304
  92. data/vendor/ring/crypto/cpu-arm-asm.S +0 -32
  93. data/vendor/ring/crypto/cpu-arm.c +0 -199
  94. data/vendor/ring/crypto/cpu-intel.c +0 -261
  95. data/vendor/ring/crypto/crypto.c +0 -151
  96. data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +0 -2118
  97. data/vendor/ring/crypto/curve25519/curve25519.c +0 -4888
  98. data/vendor/ring/crypto/curve25519/x25519_test.cc +0 -128
  99. data/vendor/ring/crypto/digest/md32_common.h +0 -181
  100. data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +0 -2725
  101. data/vendor/ring/crypto/ec/ec.c +0 -193
  102. data/vendor/ring/crypto/ec/ec_curves.c +0 -61
  103. data/vendor/ring/crypto/ec/ec_key.c +0 -228
  104. data/vendor/ring/crypto/ec/ec_montgomery.c +0 -114
  105. data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +0 -25
  106. data/vendor/ring/crypto/ec/internal.h +0 -243
  107. data/vendor/ring/crypto/ec/oct.c +0 -253
  108. data/vendor/ring/crypto/ec/p256-64.c +0 -1794
  109. data/vendor/ring/crypto/ec/p256-x86_64-table.h +0 -9548
  110. data/vendor/ring/crypto/ec/p256-x86_64.c +0 -509
  111. data/vendor/ring/crypto/ec/simple.c +0 -1007
  112. data/vendor/ring/crypto/ec/util-64.c +0 -183
  113. data/vendor/ring/crypto/ec/wnaf.c +0 -508
  114. data/vendor/ring/crypto/ecdh/ecdh.c +0 -155
  115. data/vendor/ring/crypto/ecdsa/ecdsa.c +0 -304
  116. data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +0 -193
  117. data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +0 -25
  118. data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +0 -327
  119. data/vendor/ring/crypto/header_removed.h +0 -17
  120. data/vendor/ring/crypto/internal.h +0 -495
  121. data/vendor/ring/crypto/libring.Windows.vcxproj +0 -101
  122. data/vendor/ring/crypto/mem.c +0 -98
  123. data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +0 -1045
  124. data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +0 -517
  125. data/vendor/ring/crypto/modes/asm/ghash-x86.pl +0 -1393
  126. data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +0 -1741
  127. data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +0 -422
  128. data/vendor/ring/crypto/modes/ctr.c +0 -226
  129. data/vendor/ring/crypto/modes/gcm.c +0 -1206
  130. data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +0 -25
  131. data/vendor/ring/crypto/modes/gcm_test.c +0 -348
  132. data/vendor/ring/crypto/modes/internal.h +0 -299
  133. data/vendor/ring/crypto/perlasm/arm-xlate.pl +0 -170
  134. data/vendor/ring/crypto/perlasm/readme +0 -100
  135. data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +0 -1164
  136. data/vendor/ring/crypto/perlasm/x86asm.pl +0 -292
  137. data/vendor/ring/crypto/perlasm/x86gas.pl +0 -263
  138. data/vendor/ring/crypto/perlasm/x86masm.pl +0 -200
  139. data/vendor/ring/crypto/perlasm/x86nasm.pl +0 -187
  140. data/vendor/ring/crypto/poly1305/poly1305.c +0 -331
  141. data/vendor/ring/crypto/poly1305/poly1305_arm.c +0 -301
  142. data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +0 -2015
  143. data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +0 -25
  144. data/vendor/ring/crypto/poly1305/poly1305_test.cc +0 -80
  145. data/vendor/ring/crypto/poly1305/poly1305_test.txt +0 -52
  146. data/vendor/ring/crypto/poly1305/poly1305_vec.c +0 -892
  147. data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +0 -75
  148. data/vendor/ring/crypto/rand/internal.h +0 -32
  149. data/vendor/ring/crypto/rand/rand.c +0 -189
  150. data/vendor/ring/crypto/rand/urandom.c +0 -219
  151. data/vendor/ring/crypto/rand/windows.c +0 -56
  152. data/vendor/ring/crypto/refcount_c11.c +0 -66
  153. data/vendor/ring/crypto/refcount_lock.c +0 -53
  154. data/vendor/ring/crypto/refcount_test.Windows.vcxproj +0 -25
  155. data/vendor/ring/crypto/refcount_test.c +0 -58
  156. data/vendor/ring/crypto/rsa/blinding.c +0 -462
  157. data/vendor/ring/crypto/rsa/internal.h +0 -108
  158. data/vendor/ring/crypto/rsa/padding.c +0 -300
  159. data/vendor/ring/crypto/rsa/rsa.c +0 -450
  160. data/vendor/ring/crypto/rsa/rsa_asn1.c +0 -261
  161. data/vendor/ring/crypto/rsa/rsa_impl.c +0 -944
  162. data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +0 -25
  163. data/vendor/ring/crypto/rsa/rsa_test.cc +0 -437
  164. data/vendor/ring/crypto/sha/asm/sha-armv8.pl +0 -436
  165. data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +0 -2390
  166. data/vendor/ring/crypto/sha/asm/sha256-586.pl +0 -1275
  167. data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +0 -735
  168. data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +0 -14
  169. data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +0 -14
  170. data/vendor/ring/crypto/sha/asm/sha512-586.pl +0 -911
  171. data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +0 -666
  172. data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +0 -14
  173. data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +0 -14
  174. data/vendor/ring/crypto/sha/sha1.c +0 -271
  175. data/vendor/ring/crypto/sha/sha256.c +0 -204
  176. data/vendor/ring/crypto/sha/sha512.c +0 -355
  177. data/vendor/ring/crypto/test/file_test.cc +0 -326
  178. data/vendor/ring/crypto/test/file_test.h +0 -181
  179. data/vendor/ring/crypto/test/malloc.cc +0 -150
  180. data/vendor/ring/crypto/test/scoped_types.h +0 -95
  181. data/vendor/ring/crypto/test/test.Windows.vcxproj +0 -35
  182. data/vendor/ring/crypto/test/test_util.cc +0 -46
  183. data/vendor/ring/crypto/test/test_util.h +0 -41
  184. data/vendor/ring/crypto/thread_none.c +0 -55
  185. data/vendor/ring/crypto/thread_pthread.c +0 -165
  186. data/vendor/ring/crypto/thread_test.Windows.vcxproj +0 -25
  187. data/vendor/ring/crypto/thread_test.c +0 -200
  188. data/vendor/ring/crypto/thread_win.c +0 -282
  189. data/vendor/ring/examples/checkdigest.rs +0 -103
  190. data/vendor/ring/include/openssl/aes.h +0 -121
  191. data/vendor/ring/include/openssl/arm_arch.h +0 -129
  192. data/vendor/ring/include/openssl/base.h +0 -156
  193. data/vendor/ring/include/openssl/bn.h +0 -794
  194. data/vendor/ring/include/openssl/buffer.h +0 -18
  195. data/vendor/ring/include/openssl/bytestring.h +0 -235
  196. data/vendor/ring/include/openssl/chacha.h +0 -37
  197. data/vendor/ring/include/openssl/cmac.h +0 -76
  198. data/vendor/ring/include/openssl/cpu.h +0 -184
  199. data/vendor/ring/include/openssl/crypto.h +0 -43
  200. data/vendor/ring/include/openssl/curve25519.h +0 -88
  201. data/vendor/ring/include/openssl/ec.h +0 -225
  202. data/vendor/ring/include/openssl/ec_key.h +0 -129
  203. data/vendor/ring/include/openssl/ecdh.h +0 -110
  204. data/vendor/ring/include/openssl/ecdsa.h +0 -156
  205. data/vendor/ring/include/openssl/err.h +0 -201
  206. data/vendor/ring/include/openssl/mem.h +0 -101
  207. data/vendor/ring/include/openssl/obj_mac.h +0 -71
  208. data/vendor/ring/include/openssl/opensslfeatures.h +0 -68
  209. data/vendor/ring/include/openssl/opensslv.h +0 -18
  210. data/vendor/ring/include/openssl/ossl_typ.h +0 -18
  211. data/vendor/ring/include/openssl/poly1305.h +0 -51
  212. data/vendor/ring/include/openssl/rand.h +0 -70
  213. data/vendor/ring/include/openssl/rsa.h +0 -399
  214. data/vendor/ring/include/openssl/thread.h +0 -133
  215. data/vendor/ring/include/openssl/type_check.h +0 -71
  216. data/vendor/ring/mk/Common.props +0 -63
  217. data/vendor/ring/mk/Windows.props +0 -42
  218. data/vendor/ring/mk/WindowsTest.props +0 -18
  219. data/vendor/ring/mk/appveyor.bat +0 -62
  220. data/vendor/ring/mk/bottom_of_makefile.mk +0 -54
  221. data/vendor/ring/mk/ring.mk +0 -266
  222. data/vendor/ring/mk/top_of_makefile.mk +0 -214
  223. data/vendor/ring/mk/travis.sh +0 -40
  224. data/vendor/ring/mk/update-travis-yml.py +0 -229
  225. data/vendor/ring/ring.sln +0 -153
  226. data/vendor/ring/src/aead.rs +0 -682
  227. data/vendor/ring/src/agreement.rs +0 -248
  228. data/vendor/ring/src/c.rs +0 -129
  229. data/vendor/ring/src/constant_time.rs +0 -37
  230. data/vendor/ring/src/der.rs +0 -96
  231. data/vendor/ring/src/digest.rs +0 -690
  232. data/vendor/ring/src/digest_tests.txt +0 -57
  233. data/vendor/ring/src/ecc.rs +0 -28
  234. data/vendor/ring/src/ecc_build.rs +0 -279
  235. data/vendor/ring/src/ecc_curves.rs +0 -117
  236. data/vendor/ring/src/ed25519_tests.txt +0 -2579
  237. data/vendor/ring/src/exe_tests.rs +0 -46
  238. data/vendor/ring/src/ffi.rs +0 -29
  239. data/vendor/ring/src/file_test.rs +0 -187
  240. data/vendor/ring/src/hkdf.rs +0 -153
  241. data/vendor/ring/src/hkdf_tests.txt +0 -59
  242. data/vendor/ring/src/hmac.rs +0 -414
  243. data/vendor/ring/src/hmac_tests.txt +0 -97
  244. data/vendor/ring/src/input.rs +0 -312
  245. data/vendor/ring/src/lib.rs +0 -41
  246. data/vendor/ring/src/pbkdf2.rs +0 -265
  247. data/vendor/ring/src/pbkdf2_tests.txt +0 -113
  248. data/vendor/ring/src/polyfill.rs +0 -57
  249. data/vendor/ring/src/rand.rs +0 -28
  250. data/vendor/ring/src/signature.rs +0 -314
  251. data/vendor/ring/third-party/NIST/README.md +0 -9
  252. data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +0 -263
  253. data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +0 -309
  254. data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +0 -267
  255. data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +0 -263
  256. data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +0 -309
  257. data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +0 -267
  258. data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +0 -263
  259. data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +0 -309
  260. data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +0 -267
  261. data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +0 -519
  262. data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +0 -309
  263. data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +0 -523
  264. data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +0 -519
  265. data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +0 -309
  266. data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +0 -523
  267. data/vendor/ring/third-party/NIST/sha256sums.txt +0 -1
@@ -1,153 +0,0 @@
1
- // Copyright (c) 2014, Google Inc.
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 AUTHOR DISCLAIMS ALL WARRANTIES
8
- // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
- // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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
- // This package generates chacha_vec_arm.S from chacha_vec.c. Install the
16
- // arm-linux-gnueabihf-gcc compiler as described in BUILDING.md. Then:
17
- // `(cd crypto/chacha && go run chacha_vec_arm_generate.go)`.
18
-
19
- package main
20
-
21
- import (
22
- "bufio"
23
- "bytes"
24
- "os"
25
- "os/exec"
26
- "strings"
27
- )
28
-
29
- const defaultCompiler = "/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"
30
-
31
- func main() {
32
- compiler := defaultCompiler
33
- if len(os.Args) > 1 {
34
- compiler = os.Args[1]
35
- }
36
-
37
- args := []string{
38
- "-O3",
39
- "-mcpu=cortex-a8",
40
- "-mfpu=neon",
41
- "-fpic",
42
- "-DASM_GEN",
43
- "-I", "../../include",
44
- "-S", "chacha_vec.c",
45
- "-o", "-",
46
- }
47
-
48
- output, err := os.OpenFile("chacha_vec_arm.S", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
49
- if err != nil {
50
- panic(err)
51
- }
52
- defer output.Close()
53
-
54
- output.WriteString(preamble)
55
- output.WriteString(compiler)
56
- output.WriteString(" ")
57
- output.WriteString(strings.Join(args, " "))
58
- output.WriteString("\n\n#if !defined(OPENSSL_NO_ASM)\n")
59
- output.WriteString("#if defined(__arm__)\n\n")
60
-
61
- cmd := exec.Command(compiler, args...)
62
- cmd.Stderr = os.Stderr
63
- asm, err := cmd.StdoutPipe()
64
- if err != nil {
65
- panic(err)
66
- }
67
- if err := cmd.Start(); err != nil {
68
- panic(err)
69
- }
70
-
71
- attr28 := []byte(".eabi_attribute 28,")
72
- globalDirective := []byte(".global\t")
73
- newLine := []byte("\n")
74
- attr28Handled := false
75
-
76
- scanner := bufio.NewScanner(asm)
77
- for scanner.Scan() {
78
- line := scanner.Bytes()
79
-
80
- if bytes.Contains(line, attr28) {
81
- output.WriteString(attr28Block)
82
- attr28Handled = true
83
- continue
84
- }
85
-
86
- output.Write(line)
87
- output.Write(newLine)
88
-
89
- if i := bytes.Index(line, globalDirective); i >= 0 {
90
- output.Write(line[:i])
91
- output.WriteString(".hidden\t")
92
- output.Write(line[i+len(globalDirective):])
93
- output.Write(newLine)
94
- }
95
- }
96
-
97
- if err := scanner.Err(); err != nil {
98
- panic(err)
99
- }
100
-
101
- if !attr28Handled {
102
- panic("EABI attribute 28 not seen in processing")
103
- }
104
-
105
- if err := cmd.Wait(); err != nil {
106
- panic(err)
107
- }
108
-
109
- output.WriteString(trailer)
110
- }
111
-
112
- const preamble = `# Copyright (c) 2014, Google Inc.
113
- #
114
- # Permission to use, copy, modify, and/or distribute this software for any
115
- # purpose with or without fee is hereby granted, provided that the above
116
- # copyright notice and this permission notice appear in all copies.
117
- #
118
- # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
119
- # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
120
- # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
121
- # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
122
- # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
123
- # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
124
- # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
125
-
126
- # This file contains a pre-compiled version of chacha_vec.c for ARM. This is
127
- # needed to support switching on NEON code at runtime. If the whole of OpenSSL
128
- # were to be compiled with the needed flags to build chacha_vec.c, then it
129
- # wouldn't be possible to run on non-NEON systems.
130
- #
131
- # This file was generated by chacha_vec_arm_generate.go using the following
132
- # compiler command:
133
- #
134
- # `
135
-
136
- const attr28Block = `
137
- # EABI attribute 28 sets whether VFP register arguments were used to build this
138
- # file. If object files are inconsistent on this point, the linker will refuse
139
- # to link them. Thus we report whatever the compiler expects since we don't use
140
- # VFP arguments.
141
-
142
- #if defined(__ARM_PCS_VFP)
143
- .eabi_attribute 28, 1
144
- #else
145
- .eabi_attribute 28, 0
146
- #endif
147
-
148
- `
149
-
150
- const trailer = `
151
- #endif /* __arm__ */
152
- #endif /* !OPENSSL_NO_ASM */
153
- `
@@ -1,25 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <PropertyGroup Label="Globals">
4
- <ProjectGuid>{E9BBE9B6-8361-4007-B523-E59FDB775D01}</ProjectGuid>
5
- <TargetName>cipher_test</TargetName>
6
- </PropertyGroup>
7
- <ImportGroup Label="PropertySheets">
8
- <Import Project="..\..\mk\WindowsTest.props" />
9
- </ImportGroup>
10
- <PropertyGroup Label="Configuration">
11
- <OutDir>$(OutRootDir)test\ring\crypto\cipher\</OutDir>
12
- </PropertyGroup>
13
- <ItemGroup>
14
- <ClCompile Include="cipher_test.cc" />
15
- </ItemGroup>
16
- <ItemGroup>
17
- <ProjectReference Include="..\libring.Windows.vcxproj">
18
- <Project>{f4c0a1b6-5e09-41c8-8242-3e1f6762fb18}</Project>
19
- </ProjectReference>
20
- <ProjectReference Include="..\test\test.Windows.vcxproj">
21
- <Project>{1dace503-6498-492d-b1ff-f9ee18624443}</Project>
22
- </ProjectReference>
23
- </ItemGroup>
24
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
25
- </Project>
@@ -1,390 +0,0 @@
1
- /* ====================================================================
2
- * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
3
- *
4
- * Redistribution and use in source and binary forms, with or without
5
- * modification, are permitted provided that the following conditions
6
- * are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright
9
- * notice, this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above copyright
12
- * notice, this list of conditions and the following disclaimer in
13
- * the documentation and/or other materials provided with the
14
- * distribution.
15
- *
16
- * 3. All advertising materials mentioning features or use of this
17
- * software must display the following acknowledgment:
18
- * "This product includes software developed by the OpenSSL Project
19
- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20
- *
21
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22
- * endorse or promote products derived from this software without
23
- * prior written permission. For written permission, please contact
24
- * openssl-core@openssl.org.
25
- *
26
- * 5. Products derived from this software may not be called "OpenSSL"
27
- * nor may "OpenSSL" appear in their names without prior written
28
- * permission of the OpenSSL Project.
29
- *
30
- * 6. Redistributions of any form whatsoever must retain the following
31
- * acknowledgment:
32
- * "This product includes software developed by the OpenSSL Project
33
- * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34
- *
35
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46
- * OF THE POSSIBILITY OF SUCH DAMAGE.
47
- * ==================================================================== */
48
-
49
- #include <string.h>
50
-
51
- #include <openssl/aes.h>
52
- #include <openssl/cpu.h>
53
- #include <openssl/err.h>
54
- #include <openssl/mem.h>
55
- #include <openssl/obj_mac.h>
56
- #include <openssl/rand.h>
57
-
58
- #include "internal.h"
59
- #include "../internal.h"
60
- #include "../modes/internal.h"
61
-
62
- #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
63
- #include <openssl/arm_arch.h>
64
- #endif
65
-
66
-
67
- #define EVP_AEAD_AES_GCM_NONCE_LEN 12
68
- #define EVP_AEAD_AES_GCM_TAG_LEN 16
69
-
70
- #if !defined(OPENSSL_NO_ASM) && \
71
- (defined(OPENSSL_X86_64) || defined(OPENSSL_X86))
72
- #define VPAES
73
- static char vpaes_capable(void) {
74
- return (OPENSSL_ia32cap_P[1] & (1 << (41 - 32))) != 0;
75
- }
76
-
77
- #if defined(OPENSSL_X86_64)
78
- #define BSAES
79
- static char bsaes_capable(void) {
80
- return vpaes_capable();
81
- }
82
- #endif
83
-
84
- #elif !defined(OPENSSL_NO_ASM) && \
85
- (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
86
-
87
- #if defined(OPENSSL_ARM) && __ARM_MAX_ARCH__ >= 7
88
- #define BSAES
89
- static char bsaes_capable(void) {
90
- return CRYPTO_is_NEON_capable();
91
- }
92
- #endif
93
-
94
- #define HWAES
95
- static int hwaes_capable(void) {
96
- return CRYPTO_is_ARMv8_AES_capable();
97
- }
98
-
99
- int aes_v8_set_encrypt_key(const uint8_t *user_key, const int bits,
100
- AES_KEY *key);
101
- void aes_v8_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
102
- void aes_v8_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
103
- const AES_KEY *key, const uint8_t ivec[16]);
104
-
105
- #endif /* OPENSSL_ARM */
106
-
107
- #if defined(BSAES)
108
- /* On platforms where BSAES gets defined (just above), then these functions are
109
- * provided by asm. */
110
- void bsaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
111
- const AES_KEY *key, const uint8_t ivec[16]);
112
- #else
113
- static char bsaes_capable(void) {
114
- return 0;
115
- }
116
-
117
- /* On other platforms, bsaes_capable() will always return false and so the
118
- * following will never be called. */
119
- void bsaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
120
- const AES_KEY *key, const uint8_t ivec[16]) {
121
- abort();
122
- }
123
- #endif
124
-
125
- #if defined(VPAES)
126
- /* On platforms where VPAES gets defined (just above), then these functions are
127
- * provided by asm. */
128
- int vpaes_set_encrypt_key(const uint8_t *userKey, int bits, AES_KEY *key);
129
-
130
- void vpaes_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
131
- #else
132
- static char vpaes_capable(void) {
133
- return 0;
134
- }
135
-
136
- /* On other platforms, vpaes_capable() will always return false and so the
137
- * following will never be called. */
138
- static int vpaes_set_encrypt_key(const uint8_t *userKey, int bits,
139
- AES_KEY *key) {
140
- abort();
141
- }
142
- static void vpaes_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key) {
143
- abort();
144
- }
145
- #endif
146
-
147
- #if !defined(HWAES)
148
- /* If HWAES isn't defined then we provide dummy functions for each of the hwaes
149
- * functions. */
150
- static int hwaes_capable(void) {
151
- return 0;
152
- }
153
-
154
- static int aes_v8_set_encrypt_key(const uint8_t *user_key, int bits,
155
- AES_KEY *key) {
156
- abort();
157
- }
158
-
159
- static void aes_v8_encrypt(const uint8_t *in, uint8_t *out,
160
- const AES_KEY *key) {
161
- abort();
162
- }
163
-
164
- static void aes_v8_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
165
- size_t len, const AES_KEY *key,
166
- const uint8_t ivec[16]) {
167
- abort();
168
- }
169
- #endif
170
-
171
- #if !defined(OPENSSL_NO_ASM) && \
172
- (defined(OPENSSL_X86_64) || defined(OPENSSL_X86))
173
- int aesni_set_encrypt_key(const uint8_t *userKey, int bits, AES_KEY *key);
174
-
175
- void aesni_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
176
-
177
- void aesni_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t blocks,
178
- const void *key, const uint8_t *ivec);
179
-
180
- #else
181
-
182
- /* On other platforms, aesni_capable() will always return false and so the
183
- * following will never be called. */
184
- static void aesni_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key) {
185
- abort();
186
- }
187
- static int aesni_set_encrypt_key(const uint8_t *userKey, int bits,
188
- AES_KEY *key) {
189
- abort();
190
- }
191
- static void aesni_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
192
- size_t blocks, const void *key,
193
- const uint8_t *ivec) {
194
- abort();
195
- }
196
-
197
- #endif
198
-
199
- static char aesni_capable(void);
200
-
201
- static ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_CONTEXT *gcm_ctx,
202
- block128_f *out_block, const uint8_t *key,
203
- size_t key_len)
204
- OPENSSL_SUPPRESS_UNREACHABLE_CODE_WARNINGS {
205
- #if !defined(OPENSSL_NO_ASM)
206
- if (aesni_capable()) {
207
- aesni_set_encrypt_key(key, key_len * 8, aes_key);
208
- if (gcm_ctx != NULL) {
209
- CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)aesni_encrypt);
210
- }
211
- if (out_block) {
212
- *out_block = (block128_f) aesni_encrypt;
213
- }
214
- return (ctr128_f)aesni_ctr32_encrypt_blocks;
215
- }
216
-
217
- if (hwaes_capable()) {
218
- aes_v8_set_encrypt_key(key, key_len * 8, aes_key);
219
- if (gcm_ctx != NULL) {
220
- CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)aes_v8_encrypt);
221
- }
222
- if (out_block) {
223
- *out_block = (block128_f) aes_v8_encrypt;
224
- }
225
- return (ctr128_f)aes_v8_ctr32_encrypt_blocks;
226
- }
227
-
228
- if (bsaes_capable()) {
229
- AES_set_encrypt_key(key, key_len * 8, aes_key);
230
- if (gcm_ctx != NULL) {
231
- CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)AES_encrypt);
232
- }
233
- if (out_block) {
234
- *out_block = (block128_f) AES_encrypt;
235
- }
236
- return (ctr128_f)bsaes_ctr32_encrypt_blocks;
237
- }
238
-
239
- if (vpaes_capable()) {
240
- vpaes_set_encrypt_key(key, key_len * 8, aes_key);
241
- if (out_block) {
242
- *out_block = (block128_f) vpaes_encrypt;
243
- }
244
- if (gcm_ctx != NULL) {
245
- CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)vpaes_encrypt);
246
- }
247
- return NULL;
248
- }
249
- #endif
250
-
251
- AES_set_encrypt_key(key, key_len * 8, aes_key);
252
- if (gcm_ctx != NULL) {
253
- CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)AES_encrypt);
254
- }
255
- if (out_block) {
256
- *out_block = (block128_f) AES_encrypt;
257
- }
258
- return NULL;
259
- }
260
-
261
- static char aesni_capable(void) {
262
- return (OPENSSL_ia32cap_P[1] & (1 << (57 - 32))) != 0;
263
- }
264
-
265
-
266
- struct aead_aes_gcm_ctx {
267
- union {
268
- double align;
269
- AES_KEY ks;
270
- } ks;
271
- GCM128_CONTEXT gcm;
272
- ctr128_f ctr;
273
- };
274
-
275
- int evp_aead_aes_gcm_init(void *ctx_buf, size_t ctx_buf_len, const uint8_t *key,
276
- size_t key_len) {
277
- aead_assert_init_preconditions(alignof(struct aead_aes_gcm_ctx),
278
- sizeof(struct aead_aes_gcm_ctx), ctx_buf,
279
- ctx_buf_len, key);
280
-
281
- struct aead_aes_gcm_ctx *gcm_ctx = ctx_buf;
282
- gcm_ctx->ctr =
283
- aes_ctr_set_key(&gcm_ctx->ks.ks, &gcm_ctx->gcm, NULL, key, key_len);
284
- return 1;
285
- }
286
-
287
- int evp_aead_aes_gcm_seal(const void *ctx_buf, uint8_t *out, size_t *out_len,
288
- size_t max_out_len, const uint8_t *nonce,
289
- const uint8_t *in, size_t in_len, const uint8_t *ad,
290
- size_t ad_len) {
291
- aead_assert_open_seal_preconditions(alignof(struct aead_aes_gcm_ctx), ctx_buf,
292
- out, out_len, nonce, in, in_len, ad,
293
- ad_len);
294
-
295
- const struct aead_aes_gcm_ctx *gcm_ctx = ctx_buf;
296
-
297
- if (!aead_seal_out_max_out_in_tag_len(out_len, max_out_len, in_len,
298
- EVP_AEAD_AES_GCM_TAG_LEN)) {
299
- /* |aead_seal_out_max_out_in_tag_len| already called |OPENSSL_PUT_ERROR|. */
300
- return 0;
301
- }
302
-
303
- GCM128_CONTEXT gcm;
304
-
305
- const AES_KEY *key = &gcm_ctx->ks.ks;
306
-
307
- memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm));
308
- CRYPTO_gcm128_set_96_bit_iv(&gcm, key, nonce);
309
-
310
- if (ad_len > 0 && !CRYPTO_gcm128_aad(&gcm, ad, ad_len)) {
311
- return 0;
312
- }
313
-
314
- if (gcm_ctx->ctr) {
315
- if (!CRYPTO_gcm128_encrypt_ctr32(&gcm, key, in, out, in_len, gcm_ctx->ctr)) {
316
- return 0;
317
- }
318
- } else {
319
- if (!CRYPTO_gcm128_encrypt(&gcm, key, in, out, in_len)) {
320
- return 0;
321
- }
322
- }
323
-
324
- CRYPTO_gcm128_tag(&gcm, out + in_len, EVP_AEAD_AES_GCM_TAG_LEN);
325
- return 1;
326
- }
327
-
328
- int evp_aead_aes_gcm_open(const void *ctx_buf, uint8_t *out, size_t *out_len,
329
- size_t max_out_len, const uint8_t *nonce,
330
- const uint8_t *in, size_t in_len, const uint8_t *ad,
331
- size_t ad_len) {
332
- aead_assert_open_seal_preconditions(alignof(struct aead_aes_gcm_ctx), ctx_buf,
333
- out, out_len, nonce, in, in_len, ad,
334
- ad_len);
335
-
336
- const struct aead_aes_gcm_ctx *gcm_ctx = ctx_buf;
337
-
338
- if (!aead_open_out_max_out_in_tag_len(out_len, max_out_len, in_len,
339
- EVP_AEAD_AES_GCM_TAG_LEN)) {
340
- /* |aead_open_out_max_out_in_tag_len| already called |OPENSSL_PUT_ERROR|. */
341
- return 0;
342
- }
343
-
344
- uint8_t tag[EVP_AEAD_AES_GCM_TAG_LEN];
345
- size_t plaintext_len;
346
- GCM128_CONTEXT gcm;
347
-
348
- plaintext_len = in_len - EVP_AEAD_AES_GCM_TAG_LEN;
349
-
350
- const AES_KEY *key = &gcm_ctx->ks.ks;
351
-
352
- memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm));
353
- CRYPTO_gcm128_set_96_bit_iv(&gcm, key, nonce);
354
-
355
- if (!CRYPTO_gcm128_aad(&gcm, ad, ad_len)) {
356
- return 0;
357
- }
358
-
359
- if (gcm_ctx->ctr) {
360
- if (!CRYPTO_gcm128_decrypt_ctr32(&gcm, key, in, out,
361
- in_len - EVP_AEAD_AES_GCM_TAG_LEN,
362
- gcm_ctx->ctr)) {
363
- return 0;
364
- }
365
- } else {
366
- if (!CRYPTO_gcm128_decrypt(&gcm, key, in, out,
367
- in_len - EVP_AEAD_AES_GCM_TAG_LEN)) {
368
- return 0;
369
- }
370
- }
371
-
372
- CRYPTO_gcm128_tag(&gcm, tag, EVP_AEAD_AES_GCM_TAG_LEN);
373
- if (CRYPTO_memcmp(tag, in + plaintext_len, EVP_AEAD_AES_GCM_TAG_LEN) != 0) {
374
- OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
375
- return 0;
376
- }
377
-
378
- return 1;
379
- }
380
-
381
-
382
- int EVP_has_aes_hardware(void) {
383
- #if defined(OPENSSL_X86) || defined(OPENSSL_X86_64)
384
- return aesni_capable() && crypto_gcm_clmul_enabled();
385
- #elif defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
386
- return hwaes_capable() && CRYPTO_is_ARMv8_PMULL_capable();
387
- #else
388
- return 0;
389
- #endif
390
- }