ring-native 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +3 -0
  4. data/README.md +22 -0
  5. data/Rakefile +1 -0
  6. data/ext/ring/extconf.rb +29 -0
  7. data/lib/ring/native.rb +8 -0
  8. data/lib/ring/native/version.rb +5 -0
  9. data/ring-native.gemspec +25 -0
  10. data/vendor/ring/BUILDING.md +40 -0
  11. data/vendor/ring/Cargo.toml +43 -0
  12. data/vendor/ring/LICENSE +185 -0
  13. data/vendor/ring/Makefile +35 -0
  14. data/vendor/ring/PORTING.md +163 -0
  15. data/vendor/ring/README.md +113 -0
  16. data/vendor/ring/STYLE.md +197 -0
  17. data/vendor/ring/appveyor.yml +27 -0
  18. data/vendor/ring/build.rs +108 -0
  19. data/vendor/ring/crypto/aes/aes.c +1142 -0
  20. data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +25 -0
  21. data/vendor/ring/crypto/aes/aes_test.cc +93 -0
  22. data/vendor/ring/crypto/aes/asm/aes-586.pl +2368 -0
  23. data/vendor/ring/crypto/aes/asm/aes-armv4.pl +1249 -0
  24. data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +2246 -0
  25. data/vendor/ring/crypto/aes/asm/aesni-x86.pl +1318 -0
  26. data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +2084 -0
  27. data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +675 -0
  28. data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +1364 -0
  29. data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +1565 -0
  30. data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +841 -0
  31. data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +1116 -0
  32. data/vendor/ring/crypto/aes/internal.h +87 -0
  33. data/vendor/ring/crypto/aes/mode_wrappers.c +61 -0
  34. data/vendor/ring/crypto/bn/add.c +394 -0
  35. data/vendor/ring/crypto/bn/asm/armv4-mont.pl +694 -0
  36. data/vendor/ring/crypto/bn/asm/armv8-mont.pl +1503 -0
  37. data/vendor/ring/crypto/bn/asm/bn-586.pl +774 -0
  38. data/vendor/ring/crypto/bn/asm/co-586.pl +287 -0
  39. data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +1882 -0
  40. data/vendor/ring/crypto/bn/asm/x86-mont.pl +592 -0
  41. data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +599 -0
  42. data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +1393 -0
  43. data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +3507 -0
  44. data/vendor/ring/crypto/bn/bn.c +352 -0
  45. data/vendor/ring/crypto/bn/bn_asn1.c +74 -0
  46. data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +25 -0
  47. data/vendor/ring/crypto/bn/bn_test.cc +1696 -0
  48. data/vendor/ring/crypto/bn/cmp.c +200 -0
  49. data/vendor/ring/crypto/bn/convert.c +433 -0
  50. data/vendor/ring/crypto/bn/ctx.c +311 -0
  51. data/vendor/ring/crypto/bn/div.c +594 -0
  52. data/vendor/ring/crypto/bn/exponentiation.c +1335 -0
  53. data/vendor/ring/crypto/bn/gcd.c +711 -0
  54. data/vendor/ring/crypto/bn/generic.c +1019 -0
  55. data/vendor/ring/crypto/bn/internal.h +316 -0
  56. data/vendor/ring/crypto/bn/montgomery.c +516 -0
  57. data/vendor/ring/crypto/bn/mul.c +888 -0
  58. data/vendor/ring/crypto/bn/prime.c +829 -0
  59. data/vendor/ring/crypto/bn/random.c +334 -0
  60. data/vendor/ring/crypto/bn/rsaz_exp.c +262 -0
  61. data/vendor/ring/crypto/bn/rsaz_exp.h +53 -0
  62. data/vendor/ring/crypto/bn/shift.c +276 -0
  63. data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +25 -0
  64. data/vendor/ring/crypto/bytestring/bytestring_test.cc +421 -0
  65. data/vendor/ring/crypto/bytestring/cbb.c +399 -0
  66. data/vendor/ring/crypto/bytestring/cbs.c +227 -0
  67. data/vendor/ring/crypto/bytestring/internal.h +46 -0
  68. data/vendor/ring/crypto/chacha/chacha_generic.c +140 -0
  69. data/vendor/ring/crypto/chacha/chacha_vec.c +323 -0
  70. data/vendor/ring/crypto/chacha/chacha_vec_arm.S +1447 -0
  71. data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +153 -0
  72. data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +25 -0
  73. data/vendor/ring/crypto/cipher/e_aes.c +390 -0
  74. data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +208 -0
  75. data/vendor/ring/crypto/cipher/internal.h +173 -0
  76. data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +543 -0
  77. data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +9 -0
  78. data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +475 -0
  79. data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +23 -0
  80. data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +422 -0
  81. data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +484 -0
  82. data/vendor/ring/crypto/cipher/test/cipher_test.txt +100 -0
  83. data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +25 -0
  84. data/vendor/ring/crypto/constant_time_test.c +304 -0
  85. data/vendor/ring/crypto/cpu-arm-asm.S +32 -0
  86. data/vendor/ring/crypto/cpu-arm.c +199 -0
  87. data/vendor/ring/crypto/cpu-intel.c +261 -0
  88. data/vendor/ring/crypto/crypto.c +151 -0
  89. data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +2118 -0
  90. data/vendor/ring/crypto/curve25519/curve25519.c +4888 -0
  91. data/vendor/ring/crypto/curve25519/x25519_test.cc +128 -0
  92. data/vendor/ring/crypto/digest/md32_common.h +181 -0
  93. data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +2725 -0
  94. data/vendor/ring/crypto/ec/ec.c +193 -0
  95. data/vendor/ring/crypto/ec/ec_curves.c +61 -0
  96. data/vendor/ring/crypto/ec/ec_key.c +228 -0
  97. data/vendor/ring/crypto/ec/ec_montgomery.c +114 -0
  98. data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +25 -0
  99. data/vendor/ring/crypto/ec/internal.h +243 -0
  100. data/vendor/ring/crypto/ec/oct.c +253 -0
  101. data/vendor/ring/crypto/ec/p256-64.c +1794 -0
  102. data/vendor/ring/crypto/ec/p256-x86_64-table.h +9548 -0
  103. data/vendor/ring/crypto/ec/p256-x86_64.c +509 -0
  104. data/vendor/ring/crypto/ec/simple.c +1007 -0
  105. data/vendor/ring/crypto/ec/util-64.c +183 -0
  106. data/vendor/ring/crypto/ec/wnaf.c +508 -0
  107. data/vendor/ring/crypto/ecdh/ecdh.c +155 -0
  108. data/vendor/ring/crypto/ecdsa/ecdsa.c +304 -0
  109. data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +193 -0
  110. data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +25 -0
  111. data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +327 -0
  112. data/vendor/ring/crypto/header_removed.h +17 -0
  113. data/vendor/ring/crypto/internal.h +495 -0
  114. data/vendor/ring/crypto/libring.Windows.vcxproj +101 -0
  115. data/vendor/ring/crypto/mem.c +98 -0
  116. data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +1045 -0
  117. data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +517 -0
  118. data/vendor/ring/crypto/modes/asm/ghash-x86.pl +1393 -0
  119. data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +1741 -0
  120. data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +422 -0
  121. data/vendor/ring/crypto/modes/ctr.c +226 -0
  122. data/vendor/ring/crypto/modes/gcm.c +1206 -0
  123. data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +25 -0
  124. data/vendor/ring/crypto/modes/gcm_test.c +348 -0
  125. data/vendor/ring/crypto/modes/internal.h +299 -0
  126. data/vendor/ring/crypto/perlasm/arm-xlate.pl +170 -0
  127. data/vendor/ring/crypto/perlasm/readme +100 -0
  128. data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +1164 -0
  129. data/vendor/ring/crypto/perlasm/x86asm.pl +292 -0
  130. data/vendor/ring/crypto/perlasm/x86gas.pl +263 -0
  131. data/vendor/ring/crypto/perlasm/x86masm.pl +200 -0
  132. data/vendor/ring/crypto/perlasm/x86nasm.pl +187 -0
  133. data/vendor/ring/crypto/poly1305/poly1305.c +331 -0
  134. data/vendor/ring/crypto/poly1305/poly1305_arm.c +301 -0
  135. data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +2015 -0
  136. data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +25 -0
  137. data/vendor/ring/crypto/poly1305/poly1305_test.cc +80 -0
  138. data/vendor/ring/crypto/poly1305/poly1305_test.txt +52 -0
  139. data/vendor/ring/crypto/poly1305/poly1305_vec.c +892 -0
  140. data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +75 -0
  141. data/vendor/ring/crypto/rand/internal.h +32 -0
  142. data/vendor/ring/crypto/rand/rand.c +189 -0
  143. data/vendor/ring/crypto/rand/urandom.c +219 -0
  144. data/vendor/ring/crypto/rand/windows.c +56 -0
  145. data/vendor/ring/crypto/refcount_c11.c +66 -0
  146. data/vendor/ring/crypto/refcount_lock.c +53 -0
  147. data/vendor/ring/crypto/refcount_test.Windows.vcxproj +25 -0
  148. data/vendor/ring/crypto/refcount_test.c +58 -0
  149. data/vendor/ring/crypto/rsa/blinding.c +462 -0
  150. data/vendor/ring/crypto/rsa/internal.h +108 -0
  151. data/vendor/ring/crypto/rsa/padding.c +300 -0
  152. data/vendor/ring/crypto/rsa/rsa.c +450 -0
  153. data/vendor/ring/crypto/rsa/rsa_asn1.c +261 -0
  154. data/vendor/ring/crypto/rsa/rsa_impl.c +944 -0
  155. data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +25 -0
  156. data/vendor/ring/crypto/rsa/rsa_test.cc +437 -0
  157. data/vendor/ring/crypto/sha/asm/sha-armv8.pl +436 -0
  158. data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +2390 -0
  159. data/vendor/ring/crypto/sha/asm/sha256-586.pl +1275 -0
  160. data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +735 -0
  161. data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +14 -0
  162. data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +14 -0
  163. data/vendor/ring/crypto/sha/asm/sha512-586.pl +911 -0
  164. data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +666 -0
  165. data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +14 -0
  166. data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +14 -0
  167. data/vendor/ring/crypto/sha/sha1.c +271 -0
  168. data/vendor/ring/crypto/sha/sha256.c +204 -0
  169. data/vendor/ring/crypto/sha/sha512.c +355 -0
  170. data/vendor/ring/crypto/test/file_test.cc +326 -0
  171. data/vendor/ring/crypto/test/file_test.h +181 -0
  172. data/vendor/ring/crypto/test/malloc.cc +150 -0
  173. data/vendor/ring/crypto/test/scoped_types.h +95 -0
  174. data/vendor/ring/crypto/test/test.Windows.vcxproj +35 -0
  175. data/vendor/ring/crypto/test/test_util.cc +46 -0
  176. data/vendor/ring/crypto/test/test_util.h +41 -0
  177. data/vendor/ring/crypto/thread_none.c +55 -0
  178. data/vendor/ring/crypto/thread_pthread.c +165 -0
  179. data/vendor/ring/crypto/thread_test.Windows.vcxproj +25 -0
  180. data/vendor/ring/crypto/thread_test.c +200 -0
  181. data/vendor/ring/crypto/thread_win.c +282 -0
  182. data/vendor/ring/examples/checkdigest.rs +103 -0
  183. data/vendor/ring/include/openssl/aes.h +121 -0
  184. data/vendor/ring/include/openssl/arm_arch.h +129 -0
  185. data/vendor/ring/include/openssl/base.h +156 -0
  186. data/vendor/ring/include/openssl/bn.h +794 -0
  187. data/vendor/ring/include/openssl/buffer.h +18 -0
  188. data/vendor/ring/include/openssl/bytestring.h +235 -0
  189. data/vendor/ring/include/openssl/chacha.h +37 -0
  190. data/vendor/ring/include/openssl/cmac.h +76 -0
  191. data/vendor/ring/include/openssl/cpu.h +184 -0
  192. data/vendor/ring/include/openssl/crypto.h +43 -0
  193. data/vendor/ring/include/openssl/curve25519.h +88 -0
  194. data/vendor/ring/include/openssl/ec.h +225 -0
  195. data/vendor/ring/include/openssl/ec_key.h +129 -0
  196. data/vendor/ring/include/openssl/ecdh.h +110 -0
  197. data/vendor/ring/include/openssl/ecdsa.h +156 -0
  198. data/vendor/ring/include/openssl/err.h +201 -0
  199. data/vendor/ring/include/openssl/mem.h +101 -0
  200. data/vendor/ring/include/openssl/obj_mac.h +71 -0
  201. data/vendor/ring/include/openssl/opensslfeatures.h +68 -0
  202. data/vendor/ring/include/openssl/opensslv.h +18 -0
  203. data/vendor/ring/include/openssl/ossl_typ.h +18 -0
  204. data/vendor/ring/include/openssl/poly1305.h +51 -0
  205. data/vendor/ring/include/openssl/rand.h +70 -0
  206. data/vendor/ring/include/openssl/rsa.h +399 -0
  207. data/vendor/ring/include/openssl/thread.h +133 -0
  208. data/vendor/ring/include/openssl/type_check.h +71 -0
  209. data/vendor/ring/mk/Common.props +63 -0
  210. data/vendor/ring/mk/Windows.props +42 -0
  211. data/vendor/ring/mk/WindowsTest.props +18 -0
  212. data/vendor/ring/mk/appveyor.bat +62 -0
  213. data/vendor/ring/mk/bottom_of_makefile.mk +54 -0
  214. data/vendor/ring/mk/ring.mk +266 -0
  215. data/vendor/ring/mk/top_of_makefile.mk +214 -0
  216. data/vendor/ring/mk/travis.sh +40 -0
  217. data/vendor/ring/mk/update-travis-yml.py +229 -0
  218. data/vendor/ring/ring.sln +153 -0
  219. data/vendor/ring/src/aead.rs +682 -0
  220. data/vendor/ring/src/agreement.rs +248 -0
  221. data/vendor/ring/src/c.rs +129 -0
  222. data/vendor/ring/src/constant_time.rs +37 -0
  223. data/vendor/ring/src/der.rs +96 -0
  224. data/vendor/ring/src/digest.rs +690 -0
  225. data/vendor/ring/src/digest_tests.txt +57 -0
  226. data/vendor/ring/src/ecc.rs +28 -0
  227. data/vendor/ring/src/ecc_build.rs +279 -0
  228. data/vendor/ring/src/ecc_curves.rs +117 -0
  229. data/vendor/ring/src/ed25519_tests.txt +2579 -0
  230. data/vendor/ring/src/exe_tests.rs +46 -0
  231. data/vendor/ring/src/ffi.rs +29 -0
  232. data/vendor/ring/src/file_test.rs +187 -0
  233. data/vendor/ring/src/hkdf.rs +153 -0
  234. data/vendor/ring/src/hkdf_tests.txt +59 -0
  235. data/vendor/ring/src/hmac.rs +414 -0
  236. data/vendor/ring/src/hmac_tests.txt +97 -0
  237. data/vendor/ring/src/input.rs +312 -0
  238. data/vendor/ring/src/lib.rs +41 -0
  239. data/vendor/ring/src/pbkdf2.rs +265 -0
  240. data/vendor/ring/src/pbkdf2_tests.txt +113 -0
  241. data/vendor/ring/src/polyfill.rs +57 -0
  242. data/vendor/ring/src/rand.rs +28 -0
  243. data/vendor/ring/src/signature.rs +314 -0
  244. data/vendor/ring/third-party/NIST/README.md +9 -0
  245. data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +263 -0
  246. data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +309 -0
  247. data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +267 -0
  248. data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +263 -0
  249. data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +309 -0
  250. data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +267 -0
  251. data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +263 -0
  252. data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +309 -0
  253. data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +267 -0
  254. data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +519 -0
  255. data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +309 -0
  256. data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +523 -0
  257. data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +519 -0
  258. data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +309 -0
  259. data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +523 -0
  260. data/vendor/ring/third-party/NIST/sha256sums.txt +1 -0
  261. metadata +333 -0
@@ -0,0 +1,675 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # ====================================================================
4
+ # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
5
+ # project. The module is, however, dual licensed under OpenSSL and
6
+ # CRYPTOGAMS licenses depending on where you obtain it. For further
7
+ # details see http://www.openssl.org/~appro/cryptogams/.
8
+ # ====================================================================
9
+ #
10
+ # This module implements support for ARMv8 AES instructions. The
11
+ # module is endian-agnostic in sense that it supports both big- and
12
+ # little-endian cases. As does it support both 32- and 64-bit modes
13
+ # of operation. Latter is achieved by limiting amount of utilized
14
+ # registers to 16, which implies additional NEON load and integer
15
+ # instructions. This has no effect on mighty Apple A7, where results
16
+ # are literally equal to the theoretical estimates based on AES
17
+ # instruction latencies and issue rates. On Cortex-A53, an in-order
18
+ # execution core, this costs up to 10-15%, which is partially
19
+ # compensated by implementing dedicated code path for 128-bit
20
+ # CBC encrypt case. On Cortex-A57 parallelizable mode performance
21
+ # seems to be limited by sheer amount of NEON instructions...
22
+ #
23
+ # Performance in cycles per byte processed with 128-bit key:
24
+ #
25
+ # CBC enc CBC dec CTR
26
+ # Apple A7 2.39 1.20 1.20
27
+ # Cortex-A53 1.32 1.29 1.46
28
+ # Cortex-A57(*) 1.95 0.85 0.93
29
+ # Denver 1.96 0.86 0.80
30
+ #
31
+ # (*) original 3.64/1.34/1.32 results were for r0p0 revision
32
+ # and are still same even for updated module;
33
+
34
+ $flavour = shift;
35
+ $output = shift;
36
+
37
+ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
38
+ ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
39
+ ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
40
+ die "can't locate arm-xlate.pl";
41
+
42
+ open OUT,"| \"$^X\" $xlate $flavour $output";
43
+ *STDOUT=*OUT;
44
+
45
+ $prefix="aes_v8";
46
+
47
+ $code=<<___;
48
+ #include <openssl/arm_arch.h>
49
+
50
+ #if __ARM_MAX_ARCH__>=7
51
+ .text
52
+ ___
53
+ $code.=<<___ if ($flavour =~ /64/);
54
+ #if !defined(__clang__)
55
+ .arch armv8-a+crypto
56
+ #endif
57
+ ___
58
+ $code.=".arch armv7-a\n.fpu neon\n.code 32\n" if ($flavour !~ /64/);
59
+ #^^^^^^ this is done to simplify adoption by not depending
60
+ # on latest binutils.
61
+
62
+ # Assembler mnemonics are an eclectic mix of 32- and 64-bit syntax,
63
+ # NEON is mostly 32-bit mnemonics, integer - mostly 64. Goal is to
64
+ # maintain both 32- and 64-bit codes within single module and
65
+ # transliterate common code to either flavour with regex vodoo.
66
+ #
67
+ {{{
68
+ my ($inp,$bits,$out,$ptr,$rounds)=("x0","w1","x2","x3","w12");
69
+ my ($zero,$rcon,$mask,$in0,$in1,$tmp,$key)=
70
+ $flavour=~/64/? map("q$_",(0..6)) : map("q$_",(0..3,8..10));
71
+
72
+
73
+ $code.=<<___;
74
+ .align 5
75
+ .Lrcon:
76
+ .long 0x01,0x01,0x01,0x01
77
+ .long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat
78
+ .long 0x1b,0x1b,0x1b,0x1b
79
+
80
+ .globl ${prefix}_set_encrypt_key
81
+ .type ${prefix}_set_encrypt_key,%function
82
+ .align 5
83
+ ${prefix}_set_encrypt_key:
84
+ .Lenc_key:
85
+ ___
86
+ $code.=<<___ if ($flavour =~ /64/);
87
+ stp x29,x30,[sp,#-16]!
88
+ add x29,sp,#0
89
+ ___
90
+ $code.=<<___;
91
+ mov $ptr,#-1
92
+ cmp $inp,#0
93
+ b.eq .Lenc_key_abort
94
+ cmp $out,#0
95
+ b.eq .Lenc_key_abort
96
+ mov $ptr,#-2
97
+ cmp $bits,#128
98
+ b.lt .Lenc_key_abort
99
+ cmp $bits,#256
100
+ b.gt .Lenc_key_abort
101
+ tst $bits,#0x3f
102
+ b.ne .Lenc_key_abort
103
+
104
+ adr $ptr,.Lrcon
105
+ cmp $bits,#192
106
+
107
+ veor $zero,$zero,$zero
108
+ vld1.8 {$in0},[$inp],#16
109
+ mov $bits,#8 // reuse $bits
110
+ vld1.32 {$rcon,$mask},[$ptr],#32
111
+
112
+ b.lt .Loop128
113
+ b.eq .L192
114
+ b .L256
115
+
116
+ .align 4
117
+ .Loop128:
118
+ vtbl.8 $key,{$in0},$mask
119
+ vext.8 $tmp,$zero,$in0,#12
120
+ vst1.32 {$in0},[$out],#16
121
+ aese $key,$zero
122
+ subs $bits,$bits,#1
123
+
124
+ veor $in0,$in0,$tmp
125
+ vext.8 $tmp,$zero,$tmp,#12
126
+ veor $in0,$in0,$tmp
127
+ vext.8 $tmp,$zero,$tmp,#12
128
+ veor $key,$key,$rcon
129
+ veor $in0,$in0,$tmp
130
+ vshl.u8 $rcon,$rcon,#1
131
+ veor $in0,$in0,$key
132
+ b.ne .Loop128
133
+
134
+ vld1.32 {$rcon},[$ptr]
135
+
136
+ vtbl.8 $key,{$in0},$mask
137
+ vext.8 $tmp,$zero,$in0,#12
138
+ vst1.32 {$in0},[$out],#16
139
+ aese $key,$zero
140
+
141
+ veor $in0,$in0,$tmp
142
+ vext.8 $tmp,$zero,$tmp,#12
143
+ veor $in0,$in0,$tmp
144
+ vext.8 $tmp,$zero,$tmp,#12
145
+ veor $key,$key,$rcon
146
+ veor $in0,$in0,$tmp
147
+ vshl.u8 $rcon,$rcon,#1
148
+ veor $in0,$in0,$key
149
+
150
+ vtbl.8 $key,{$in0},$mask
151
+ vext.8 $tmp,$zero,$in0,#12
152
+ vst1.32 {$in0},[$out],#16
153
+ aese $key,$zero
154
+
155
+ veor $in0,$in0,$tmp
156
+ vext.8 $tmp,$zero,$tmp,#12
157
+ veor $in0,$in0,$tmp
158
+ vext.8 $tmp,$zero,$tmp,#12
159
+ veor $key,$key,$rcon
160
+ veor $in0,$in0,$tmp
161
+ veor $in0,$in0,$key
162
+ vst1.32 {$in0},[$out]
163
+ add $out,$out,#0x50
164
+
165
+ mov $rounds,#10
166
+ b .Ldone
167
+
168
+ .align 4
169
+ .L192:
170
+ vld1.8 {$in1},[$inp],#8
171
+ vmov.i8 $key,#8 // borrow $key
172
+ vst1.32 {$in0},[$out],#16
173
+ vsub.i8 $mask,$mask,$key // adjust the mask
174
+
175
+ .Loop192:
176
+ vtbl.8 $key,{$in1},$mask
177
+ vext.8 $tmp,$zero,$in0,#12
178
+ vst1.32 {$in1},[$out],#8
179
+ aese $key,$zero
180
+ subs $bits,$bits,#1
181
+
182
+ veor $in0,$in0,$tmp
183
+ vext.8 $tmp,$zero,$tmp,#12
184
+ veor $in0,$in0,$tmp
185
+ vext.8 $tmp,$zero,$tmp,#12
186
+ veor $in0,$in0,$tmp
187
+
188
+ vdup.32 $tmp,${in0}[3]
189
+ veor $tmp,$tmp,$in1
190
+ veor $key,$key,$rcon
191
+ vext.8 $in1,$zero,$in1,#12
192
+ vshl.u8 $rcon,$rcon,#1
193
+ veor $in1,$in1,$tmp
194
+ veor $in0,$in0,$key
195
+ veor $in1,$in1,$key
196
+ vst1.32 {$in0},[$out],#16
197
+ b.ne .Loop192
198
+
199
+ mov $rounds,#12
200
+ add $out,$out,#0x20
201
+ b .Ldone
202
+
203
+ .align 4
204
+ .L256:
205
+ vld1.8 {$in1},[$inp]
206
+ mov $bits,#7
207
+ mov $rounds,#14
208
+ vst1.32 {$in0},[$out],#16
209
+
210
+ .Loop256:
211
+ vtbl.8 $key,{$in1},$mask
212
+ vext.8 $tmp,$zero,$in0,#12
213
+ vst1.32 {$in1},[$out],#16
214
+ aese $key,$zero
215
+ subs $bits,$bits,#1
216
+
217
+ veor $in0,$in0,$tmp
218
+ vext.8 $tmp,$zero,$tmp,#12
219
+ veor $in0,$in0,$tmp
220
+ vext.8 $tmp,$zero,$tmp,#12
221
+ veor $key,$key,$rcon
222
+ veor $in0,$in0,$tmp
223
+ vshl.u8 $rcon,$rcon,#1
224
+ veor $in0,$in0,$key
225
+ vst1.32 {$in0},[$out],#16
226
+ b.eq .Ldone
227
+
228
+ vdup.32 $key,${in0}[3] // just splat
229
+ vext.8 $tmp,$zero,$in1,#12
230
+ aese $key,$zero
231
+
232
+ veor $in1,$in1,$tmp
233
+ vext.8 $tmp,$zero,$tmp,#12
234
+ veor $in1,$in1,$tmp
235
+ vext.8 $tmp,$zero,$tmp,#12
236
+ veor $in1,$in1,$tmp
237
+
238
+ veor $in1,$in1,$key
239
+ b .Loop256
240
+
241
+ .Ldone:
242
+ str $rounds,[$out]
243
+ mov $ptr,#0
244
+
245
+ .Lenc_key_abort:
246
+ mov x0,$ptr // return value
247
+ `"ldr x29,[sp],#16" if ($flavour =~ /64/)`
248
+ ret
249
+ .size ${prefix}_set_encrypt_key,.-${prefix}_set_encrypt_key
250
+
251
+ .globl ${prefix}_set_decrypt_key
252
+ .type ${prefix}_set_decrypt_key,%function
253
+ .align 5
254
+ ${prefix}_set_decrypt_key:
255
+ ___
256
+ $code.=<<___ if ($flavour =~ /64/);
257
+ stp x29,x30,[sp,#-16]!
258
+ add x29,sp,#0
259
+ ___
260
+ $code.=<<___ if ($flavour !~ /64/);
261
+ stmdb sp!,{r4,lr}
262
+ ___
263
+ $code.=<<___;
264
+ bl .Lenc_key
265
+
266
+ cmp x0,#0
267
+ b.ne .Ldec_key_abort
268
+
269
+ sub $out,$out,#240 // restore original $out
270
+ mov x4,#-16
271
+ add $inp,$out,x12,lsl#4 // end of key schedule
272
+
273
+ vld1.32 {v0.16b},[$out]
274
+ vld1.32 {v1.16b},[$inp]
275
+ vst1.32 {v0.16b},[$inp],x4
276
+ vst1.32 {v1.16b},[$out],#16
277
+
278
+ .Loop_imc:
279
+ vld1.32 {v0.16b},[$out]
280
+ vld1.32 {v1.16b},[$inp]
281
+ aesimc v0.16b,v0.16b
282
+ aesimc v1.16b,v1.16b
283
+ vst1.32 {v0.16b},[$inp],x4
284
+ vst1.32 {v1.16b},[$out],#16
285
+ cmp $inp,$out
286
+ b.hi .Loop_imc
287
+
288
+ vld1.32 {v0.16b},[$out]
289
+ aesimc v0.16b,v0.16b
290
+ vst1.32 {v0.16b},[$inp]
291
+
292
+ eor x0,x0,x0 // return value
293
+ .Ldec_key_abort:
294
+ ___
295
+ $code.=<<___ if ($flavour !~ /64/);
296
+ ldmia sp!,{r4,pc}
297
+ ___
298
+ $code.=<<___ if ($flavour =~ /64/);
299
+ ldp x29,x30,[sp],#16
300
+ ret
301
+ ___
302
+ $code.=<<___;
303
+ .size ${prefix}_set_decrypt_key,.-${prefix}_set_decrypt_key
304
+ ___
305
+ }}}
306
+ {{{
307
+ sub gen_block () {
308
+ my $dir = shift;
309
+ my ($e,$mc) = $dir eq "en" ? ("e","mc") : ("d","imc");
310
+ my ($inp,$out,$key)=map("x$_",(0..2));
311
+ my $rounds="w3";
312
+ my ($rndkey0,$rndkey1,$inout)=map("q$_",(0..3));
313
+
314
+ $code.=<<___;
315
+ .globl ${prefix}_${dir}crypt
316
+ .type ${prefix}_${dir}crypt,%function
317
+ .align 5
318
+ ${prefix}_${dir}crypt:
319
+ ldr $rounds,[$key,#240]
320
+ vld1.32 {$rndkey0},[$key],#16
321
+ vld1.8 {$inout},[$inp]
322
+ sub $rounds,$rounds,#2
323
+ vld1.32 {$rndkey1},[$key],#16
324
+
325
+ .Loop_${dir}c:
326
+ aes$e $inout,$rndkey0
327
+ aes$mc $inout,$inout
328
+ vld1.32 {$rndkey0},[$key],#16
329
+ subs $rounds,$rounds,#2
330
+ aes$e $inout,$rndkey1
331
+ aes$mc $inout,$inout
332
+ vld1.32 {$rndkey1},[$key],#16
333
+ b.gt .Loop_${dir}c
334
+
335
+ aes$e $inout,$rndkey0
336
+ aes$mc $inout,$inout
337
+ vld1.32 {$rndkey0},[$key]
338
+ aes$e $inout,$rndkey1
339
+ veor $inout,$inout,$rndkey0
340
+
341
+ vst1.8 {$inout},[$out]
342
+ ret
343
+ .size ${prefix}_${dir}crypt,.-${prefix}_${dir}crypt
344
+ ___
345
+ }
346
+ &gen_block("en");
347
+ &gen_block("de");
348
+ }}}
349
+ {{{
350
+ my ($inp,$out,$len,$key,$ivp)=map("x$_",(0..4));
351
+ my ($rounds,$cnt,$key_)=("w5","w6","x7");
352
+ my ($ctr,$tctr0,$tctr1,$tctr2)=map("w$_",(8..10,12));
353
+ my $step="x12"; # aliases with $tctr2
354
+
355
+ my ($dat0,$dat1,$in0,$in1,$tmp0,$tmp1,$ivec,$rndlast)=map("q$_",(0..7));
356
+ my ($dat2,$in2,$tmp2)=map("q$_",(10,11,9));
357
+
358
+ my ($dat,$tmp)=($dat0,$tmp0);
359
+
360
+ ### q8-q15 preloaded key schedule
361
+
362
+ $code.=<<___;
363
+ .globl ${prefix}_ctr32_encrypt_blocks
364
+ .type ${prefix}_ctr32_encrypt_blocks,%function
365
+ .align 5
366
+ ${prefix}_ctr32_encrypt_blocks:
367
+ ___
368
+ $code.=<<___ if ($flavour =~ /64/);
369
+ stp x29,x30,[sp,#-16]!
370
+ add x29,sp,#0
371
+ ___
372
+ $code.=<<___ if ($flavour !~ /64/);
373
+ mov ip,sp
374
+ stmdb sp!,{r4-r10,lr}
375
+ vstmdb sp!,{d8-d15} @ ABI specification says so
376
+ ldr r4, [ip] @ load remaining arg
377
+ ___
378
+ $code.=<<___;
379
+ ldr $rounds,[$key,#240]
380
+
381
+ ldr $ctr, [$ivp, #12]
382
+ vld1.32 {$dat0},[$ivp]
383
+
384
+ vld1.32 {q8-q9},[$key] // load key schedule...
385
+ sub $rounds,$rounds,#4
386
+ mov $step,#16
387
+ cmp $len,#2
388
+ add $key_,$key,x5,lsl#4 // pointer to last 5 round keys
389
+ sub $rounds,$rounds,#2
390
+ vld1.32 {q12-q13},[$key_],#32
391
+ vld1.32 {q14-q15},[$key_],#32
392
+ vld1.32 {$rndlast},[$key_]
393
+ add $key_,$key,#32
394
+ mov $cnt,$rounds
395
+ cclr $step,lo
396
+ #ifndef __ARMEB__
397
+ rev $ctr, $ctr
398
+ #endif
399
+ vorr $dat1,$dat0,$dat0
400
+ add $tctr1, $ctr, #1
401
+ vorr $dat2,$dat0,$dat0
402
+ add $ctr, $ctr, #2
403
+ vorr $ivec,$dat0,$dat0
404
+ rev $tctr1, $tctr1
405
+ vmov.32 ${dat1}[3],$tctr1
406
+ b.ls .Lctr32_tail
407
+ rev $tctr2, $ctr
408
+ sub $len,$len,#3 // bias
409
+ vmov.32 ${dat2}[3],$tctr2
410
+ b .Loop3x_ctr32
411
+
412
+ .align 4
413
+ .Loop3x_ctr32:
414
+ aese $dat0,q8
415
+ aesmc $dat0,$dat0
416
+ aese $dat1,q8
417
+ aesmc $dat1,$dat1
418
+ aese $dat2,q8
419
+ aesmc $dat2,$dat2
420
+ vld1.32 {q8},[$key_],#16
421
+ subs $cnt,$cnt,#2
422
+ aese $dat0,q9
423
+ aesmc $dat0,$dat0
424
+ aese $dat1,q9
425
+ aesmc $dat1,$dat1
426
+ aese $dat2,q9
427
+ aesmc $dat2,$dat2
428
+ vld1.32 {q9},[$key_],#16
429
+ b.gt .Loop3x_ctr32
430
+
431
+ aese $dat0,q8
432
+ aesmc $tmp0,$dat0
433
+ aese $dat1,q8
434
+ aesmc $tmp1,$dat1
435
+ vld1.8 {$in0},[$inp],#16
436
+ vorr $dat0,$ivec,$ivec
437
+ aese $dat2,q8
438
+ aesmc $dat2,$dat2
439
+ vld1.8 {$in1},[$inp],#16
440
+ vorr $dat1,$ivec,$ivec
441
+ aese $tmp0,q9
442
+ aesmc $tmp0,$tmp0
443
+ aese $tmp1,q9
444
+ aesmc $tmp1,$tmp1
445
+ vld1.8 {$in2},[$inp],#16
446
+ mov $key_,$key
447
+ aese $dat2,q9
448
+ aesmc $tmp2,$dat2
449
+ vorr $dat2,$ivec,$ivec
450
+ add $tctr0,$ctr,#1
451
+ aese $tmp0,q12
452
+ aesmc $tmp0,$tmp0
453
+ aese $tmp1,q12
454
+ aesmc $tmp1,$tmp1
455
+ veor $in0,$in0,$rndlast
456
+ add $tctr1,$ctr,#2
457
+ aese $tmp2,q12
458
+ aesmc $tmp2,$tmp2
459
+ veor $in1,$in1,$rndlast
460
+ add $ctr,$ctr,#3
461
+ aese $tmp0,q13
462
+ aesmc $tmp0,$tmp0
463
+ aese $tmp1,q13
464
+ aesmc $tmp1,$tmp1
465
+ veor $in2,$in2,$rndlast
466
+ rev $tctr0,$tctr0
467
+ aese $tmp2,q13
468
+ aesmc $tmp2,$tmp2
469
+ vmov.32 ${dat0}[3], $tctr0
470
+ rev $tctr1,$tctr1
471
+ aese $tmp0,q14
472
+ aesmc $tmp0,$tmp0
473
+ aese $tmp1,q14
474
+ aesmc $tmp1,$tmp1
475
+ vmov.32 ${dat1}[3], $tctr1
476
+ rev $tctr2,$ctr
477
+ aese $tmp2,q14
478
+ aesmc $tmp2,$tmp2
479
+ vmov.32 ${dat2}[3], $tctr2
480
+ subs $len,$len,#3
481
+ aese $tmp0,q15
482
+ aese $tmp1,q15
483
+ aese $tmp2,q15
484
+
485
+ veor $in0,$in0,$tmp0
486
+ vld1.32 {q8},[$key_],#16 // re-pre-load rndkey[0]
487
+ vst1.8 {$in0},[$out],#16
488
+ veor $in1,$in1,$tmp1
489
+ mov $cnt,$rounds
490
+ vst1.8 {$in1},[$out],#16
491
+ veor $in2,$in2,$tmp2
492
+ vld1.32 {q9},[$key_],#16 // re-pre-load rndkey[1]
493
+ vst1.8 {$in2},[$out],#16
494
+ b.hs .Loop3x_ctr32
495
+
496
+ adds $len,$len,#3
497
+ b.eq .Lctr32_done
498
+ cmp $len,#1
499
+ mov $step,#16
500
+ cclr $step,eq
501
+
502
+ .Lctr32_tail:
503
+ aese $dat0,q8
504
+ aesmc $dat0,$dat0
505
+ aese $dat1,q8
506
+ aesmc $dat1,$dat1
507
+ vld1.32 {q8},[$key_],#16
508
+ subs $cnt,$cnt,#2
509
+ aese $dat0,q9
510
+ aesmc $dat0,$dat0
511
+ aese $dat1,q9
512
+ aesmc $dat1,$dat1
513
+ vld1.32 {q9},[$key_],#16
514
+ b.gt .Lctr32_tail
515
+
516
+ aese $dat0,q8
517
+ aesmc $dat0,$dat0
518
+ aese $dat1,q8
519
+ aesmc $dat1,$dat1
520
+ aese $dat0,q9
521
+ aesmc $dat0,$dat0
522
+ aese $dat1,q9
523
+ aesmc $dat1,$dat1
524
+ vld1.8 {$in0},[$inp],$step
525
+ aese $dat0,q12
526
+ aesmc $dat0,$dat0
527
+ aese $dat1,q12
528
+ aesmc $dat1,$dat1
529
+ vld1.8 {$in1},[$inp]
530
+ aese $dat0,q13
531
+ aesmc $dat0,$dat0
532
+ aese $dat1,q13
533
+ aesmc $dat1,$dat1
534
+ veor $in0,$in0,$rndlast
535
+ aese $dat0,q14
536
+ aesmc $dat0,$dat0
537
+ aese $dat1,q14
538
+ aesmc $dat1,$dat1
539
+ veor $in1,$in1,$rndlast
540
+ aese $dat0,q15
541
+ aese $dat1,q15
542
+
543
+ cmp $len,#1
544
+ veor $in0,$in0,$dat0
545
+ veor $in1,$in1,$dat1
546
+ vst1.8 {$in0},[$out],#16
547
+ b.eq .Lctr32_done
548
+ vst1.8 {$in1},[$out]
549
+
550
+ .Lctr32_done:
551
+ ___
552
+ $code.=<<___ if ($flavour !~ /64/);
553
+ vldmia sp!,{d8-d15}
554
+ ldmia sp!,{r4-r10,pc}
555
+ ___
556
+ $code.=<<___ if ($flavour =~ /64/);
557
+ ldr x29,[sp],#16
558
+ ret
559
+ ___
560
+ $code.=<<___;
561
+ .size ${prefix}_ctr32_encrypt_blocks,.-${prefix}_ctr32_encrypt_blocks
562
+ ___
563
+ }}}
564
+ $code.=<<___;
565
+ #endif
566
+ ___
567
+ ########################################
568
+ if ($flavour =~ /64/) { ######## 64-bit code
569
+ my %opcode = (
570
+ "aesd" => 0x4e285800, "aese" => 0x4e284800,
571
+ "aesimc"=> 0x4e287800, "aesmc" => 0x4e286800 );
572
+
573
+ local *unaes = sub {
574
+ my ($mnemonic,$arg)=@_;
575
+
576
+ $arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o &&
577
+ sprintf ".inst\t0x%08x\t//%s %s",
578
+ $opcode{$mnemonic}|$1|($2<<5),
579
+ $mnemonic,$arg;
580
+ };
581
+
582
+ foreach(split("\n",$code)) {
583
+ s/\`([^\`]*)\`/eval($1)/geo;
584
+
585
+ s/\bq([0-9]+)\b/"v".($1<8?$1:$1+8).".16b"/geo; # old->new registers
586
+ s/@\s/\/\//o; # old->new style commentary
587
+
588
+ #s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or
589
+ s/cclr\s+([wx])([^,]+),\s*([a-z]+)/csel $1$2,$1zr,$1$2,$3/o or
590
+ s/mov\.([a-z]+)\s+([wx][0-9]+),\s*([wx][0-9]+)/csel $2,$3,$2,$1/o or
591
+ s/vmov\.i8/movi/o or # fix up legacy mnemonics
592
+ s/vext\.8/ext/o or
593
+ s/vrev32\.8/rev32/o or
594
+ s/vtst\.8/cmtst/o or
595
+ s/vshr/ushr/o or
596
+ s/^(\s+)v/$1/o or # strip off v prefix
597
+ s/\bbx\s+lr\b/ret/o;
598
+
599
+ # fix up remainig legacy suffixes
600
+ s/\.[ui]?8//o;
601
+ m/\],#8/o and s/\.16b/\.8b/go;
602
+ s/\.[ui]?32//o and s/\.16b/\.4s/go;
603
+ s/\.[ui]?64//o and s/\.16b/\.2d/go;
604
+ s/\.[42]([sd])\[([0-3])\]/\.$1\[$2\]/o;
605
+
606
+ print $_,"\n";
607
+ }
608
+ } else { ######## 32-bit code
609
+ my %opcode = (
610
+ "aesd" => 0xf3b00340, "aese" => 0xf3b00300,
611
+ "aesimc"=> 0xf3b003c0, "aesmc" => 0xf3b00380 );
612
+
613
+ local *unaes = sub {
614
+ my ($mnemonic,$arg)=@_;
615
+
616
+ if ($arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o) {
617
+ my $word = $opcode{$mnemonic}|(($1&7)<<13)|(($1&8)<<19)
618
+ |(($2&7)<<1) |(($2&8)<<2);
619
+ # since ARMv7 instructions are always encoded little-endian.
620
+ # correct solution is to use .inst directive, but older
621
+ # assemblers don't implement it:-(
622
+ sprintf ".byte\t0x%02x,0x%02x,0x%02x,0x%02x\t@ %s %s",
623
+ $word&0xff,($word>>8)&0xff,
624
+ ($word>>16)&0xff,($word>>24)&0xff,
625
+ $mnemonic,$arg;
626
+ }
627
+ };
628
+
629
+ sub unvtbl {
630
+ my $arg=shift;
631
+
632
+ $arg =~ m/q([0-9]+),\s*\{q([0-9]+)\},\s*q([0-9]+)/o &&
633
+ sprintf "vtbl.8 d%d,{q%d},d%d\n\t".
634
+ "vtbl.8 d%d,{q%d},d%d", 2*$1,$2,2*$3, 2*$1+1,$2,2*$3+1;
635
+ }
636
+
637
+ sub unvdup32 {
638
+ my $arg=shift;
639
+
640
+ $arg =~ m/q([0-9]+),\s*q([0-9]+)\[([0-3])\]/o &&
641
+ sprintf "vdup.32 q%d,d%d[%d]",$1,2*$2+($3>>1),$3&1;
642
+ }
643
+
644
+ sub unvmov32 {
645
+ my $arg=shift;
646
+
647
+ $arg =~ m/q([0-9]+)\[([0-3])\],(.*)/o &&
648
+ sprintf "vmov.32 d%d[%d],%s",2*$1+($2>>1),$2&1,$3;
649
+ }
650
+
651
+ foreach(split("\n",$code)) {
652
+ s/\`([^\`]*)\`/eval($1)/geo;
653
+
654
+ s/\b[wx]([0-9]+)\b/r$1/go; # new->old registers
655
+ s/\bv([0-9])\.[12468]+[bsd]\b/q$1/go; # new->old registers
656
+ s/\/\/\s?/@ /o; # new->old style commentary
657
+
658
+ # fix up remainig new-style suffixes
659
+ s/\{q([0-9]+)\},\s*\[(.+)\],#8/sprintf "{d%d},[$2]!",2*$1/eo or
660
+ s/\],#[0-9]+/]!/o;
661
+
662
+ s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or
663
+ s/cclr\s+([^,]+),\s*([a-z]+)/mov$2 $1,#0/o or
664
+ s/vtbl\.8\s+(.*)/unvtbl($1)/geo or
665
+ s/vdup\.32\s+(.*)/unvdup32($1)/geo or
666
+ s/vmov\.32\s+(.*)/unvmov32($1)/geo or
667
+ s/^(\s+)b\./$1b/o or
668
+ s/^(\s+)mov\./$1mov/o or
669
+ s/^(\s+)ret/$1bx\tlr/o;
670
+
671
+ print $_,"\n";
672
+ }
673
+ }
674
+
675
+ close STDOUT;