rocket-js 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/Rakefile +5 -52
  2. data/spec/ruby/spec_helper.rb +2 -1
  3. metadata +7 -129
  4. data/src/vendor/web-socket-js/FABridge.js +0 -604
  5. data/src/vendor/web-socket-js/README.txt +0 -109
  6. data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
  7. data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
  8. data/src/vendor/web-socket-js/flash-src/WebSocket.as +0 -473
  9. data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +0 -88
  10. data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +0 -19
  11. data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +0 -32
  12. data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +0 -943
  13. data/src/vendor/web-socket-js/flash-src/build.sh +0 -10
  14. data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +0 -204
  15. data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +0 -375
  16. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +0 -287
  17. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +0 -3235
  18. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +0 -218
  19. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +0 -57
  20. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +0 -82
  21. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +0 -27
  22. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +0 -21
  23. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +0 -137
  24. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +0 -124
  25. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +0 -204
  26. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +0 -106
  27. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +0 -28
  28. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +0 -115
  29. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +0 -71
  30. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +0 -90
  31. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +0 -20
  32. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +0 -119
  33. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +0 -142
  34. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +0 -339
  35. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +0 -2797
  36. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +0 -375
  37. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +0 -55
  38. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +0 -61
  39. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +0 -64
  40. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +0 -58
  41. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +0 -365
  42. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +0 -86
  43. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +0 -21
  44. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +0 -15
  45. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +0 -32
  46. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +0 -21
  47. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +0 -35
  48. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +0 -110
  49. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +0 -34
  50. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +0 -52
  51. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +0 -44
  52. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +0 -44
  53. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +0 -60
  54. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +0 -42
  55. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +0 -88
  56. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +0 -94
  57. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +0 -29
  58. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +0 -2304
  59. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +0 -1220
  60. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +0 -58
  61. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +0 -39
  62. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +0 -148
  63. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +0 -160
  64. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +0 -71
  65. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +0 -98
  66. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +0 -109
  67. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +0 -112
  68. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +0 -151
  69. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +0 -184
  70. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +0 -20
  71. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +0 -56
  72. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +0 -58
  73. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +0 -101
  74. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +0 -92
  75. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +0 -198
  76. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +0 -58
  77. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +0 -60
  78. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +0 -51
  79. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +0 -42
  80. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +0 -59
  81. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +0 -66
  82. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +0 -102
  83. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +0 -117
  84. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +0 -14
  85. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +0 -29
  86. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +0 -24
  87. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +0 -38
  88. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +0 -171
  89. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +0 -26
  90. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +0 -340
  91. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +0 -70
  92. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +0 -151
  93. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +0 -895
  94. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +0 -39
  95. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +0 -27
  96. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +0 -197
  97. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +0 -370
  98. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +0 -26
  99. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +0 -180
  100. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +0 -90
  101. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +0 -1543
  102. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +0 -35
  103. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +0 -11
  104. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +0 -85
  105. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +0 -34
  106. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +0 -11
  107. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +0 -25
  108. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +0 -189
  109. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +0 -66
  110. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +0 -28
  111. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +0 -43
  112. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +0 -210
  113. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +0 -21
  114. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +0 -44
  115. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +0 -35
  116. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +0 -112
  117. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +0 -118
  118. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +0 -49
  119. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +0 -90
  120. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +0 -27
  121. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +0 -94
  122. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +0 -60
  123. data/src/vendor/web-socket-js/sample.html +0 -76
  124. data/src/vendor/web-socket-js/swfobject.js +0 -4
  125. data/src/vendor/web-socket-js/web_socket.js +0 -388
@@ -1,58 +0,0 @@
1
- /**
2
- * ARC4Test
3
- *
4
- * A test class for ARC4
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.tests
10
- {
11
- import com.hurlant.util.Hex;
12
- import flash.utils.ByteArray;
13
- import com.hurlant.crypto.prng.ARC4;
14
-
15
- public class ARC4Test extends TestCase
16
- {
17
- public function ARC4Test(h:ITestHarness)
18
- {
19
- super(h, "ARC4 Test");
20
- runTest(testLameVectors,"ARC4 Test Vectors");
21
- h.endTestCase();
22
- }
23
-
24
- /**
25
- * Sad test vectors pilfered from
26
- * http://en.wikipedia.org/wiki/RC4
27
- */
28
- public function testLameVectors():void {
29
- var keys:Array = [
30
- Hex.fromString("Key"),
31
- Hex.fromString("Wiki"),
32
- Hex.fromString("Secret")];
33
- var pts:Array = [
34
- Hex.fromString("Plaintext"),
35
- Hex.fromString("pedia"),
36
- Hex.fromString("Attack at dawn")];
37
- var cts:Array = [
38
- "BBF316E8D940AF0AD3",
39
- "1021BF0420",
40
- "45A01F645FC35B383552544B9BF5"];
41
-
42
- for (var i:uint=0;i<keys.length;i++) {
43
- var key:ByteArray = Hex.toArray(keys[i]);
44
- var pt:ByteArray = Hex.toArray(pts[i]);
45
- var rc4:ARC4 = new ARC4(key);
46
- rc4.encrypt(pt);
47
- var out:String = Hex.fromArray(pt).toUpperCase();
48
- assert("comparing "+cts[i]+" to "+out, cts[i]==out);
49
- // now go back to plaintext
50
- rc4.init(key);
51
- rc4.decrypt(pt);
52
- out = Hex.fromArray(pt);
53
- assert("comparing "+pts[i]+" to "+out, pts[i]==out);
54
- }
55
- }
56
-
57
- }
58
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * BigIntegerTest
3
- *
4
- * A test class for BigInteger
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.tests
10
- {
11
- import com.hurlant.math.BigInteger;
12
- import com.hurlant.util.Hex;
13
-
14
- public class BigIntegerTest extends TestCase
15
- {
16
- public function BigIntegerTest(h:ITestHarness)
17
- {
18
- super(h, "BigInteger Tests");
19
- runTest(testAdd, "BigInteger Addition");
20
- h.endTestCase();
21
- }
22
-
23
- public function testAdd():void {
24
- var n1:BigInteger = BigInteger.nbv(25);
25
- var n2:BigInteger = BigInteger.nbv(1002);
26
- var n3:BigInteger = n1.add(n2);
27
- var v:int = n3.valueOf();
28
- assert("25+1002 = "+v, 25+1002==v);
29
-
30
- var p:BigInteger = new BigInteger(Hex.toArray("e564d8b801a61f47"));
31
- var xp:BigInteger = new BigInteger(Hex.toArray("99246db2a3507fa"));
32
-
33
- xp = xp.add(p);
34
-
35
- assert("xp==eef71f932bdb2741", xp.toString(16)=="eef71f932bdb2741");
36
- }
37
-
38
- }
39
- }
@@ -1,148 +0,0 @@
1
- /**
2
- * BlowFishKeyTest
3
- *
4
- * A test class for BlowFishKey
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.tests
10
- {
11
- import com.hurlant.crypto.symmetric.BlowFishKey;
12
- import com.hurlant.util.Hex;
13
- import flash.utils.ByteArray;
14
-
15
- public class BlowFishKeyTest extends TestCase
16
- {
17
- public function BlowFishKeyTest(h:ITestHarness)
18
- {
19
- super(h, "BlowFishKey Test");
20
- runTest(testECB,"BlowFish ECB Test Vectors");
21
- h.endTestCase();
22
- }
23
-
24
- /**
25
- * Test vectors from http://www.schneier.com/code/vectors.txt
26
- */
27
- public function testECB():void {
28
- var keys:Array = [
29
- "0000000000000000",
30
- "FFFFFFFFFFFFFFFF",
31
- "3000000000000000",
32
- "1111111111111111",
33
- "0123456789ABCDEF",
34
- "1111111111111111",
35
- "0000000000000000",
36
- "FEDCBA9876543210",
37
- "7CA110454A1A6E57",
38
- "0131D9619DC1376E",
39
- "07A1133E4A0B2686",
40
- "3849674C2602319E",
41
- "04B915BA43FEB5B6",
42
- "0113B970FD34F2CE",
43
- "0170F175468FB5E6",
44
- "43297FAD38E373FE",
45
- "07A7137045DA2A16",
46
- "04689104C2FD3B2F",
47
- "37D06BB516CB7546",
48
- "1F08260D1AC2465E",
49
- "584023641ABA6176",
50
- "025816164629B007",
51
- "49793EBC79B3258F",
52
- "4FB05E1515AB73A7",
53
- "49E95D6D4CA229BF",
54
- "018310DC409B26D6",
55
- "1C587F1C13924FEF",
56
- "0101010101010101",
57
- "1F1F1F1F0E0E0E0E",
58
- "E0FEE0FEF1FEF1FE",
59
- "0000000000000000",
60
- "FFFFFFFFFFFFFFFF",
61
- "0123456789ABCDEF",
62
- "FEDCBA9876543210" ];
63
- var pts:Array = [
64
- "0000000000000000",
65
- "FFFFFFFFFFFFFFFF",
66
- "1000000000000001",
67
- "1111111111111111",
68
- "1111111111111111",
69
- "0123456789ABCDEF",
70
- "0000000000000000",
71
- "0123456789ABCDEF",
72
- "01A1D6D039776742",
73
- "5CD54CA83DEF57DA",
74
- "0248D43806F67172",
75
- "51454B582DDF440A",
76
- "42FD443059577FA2",
77
- "059B5E0851CF143A",
78
- "0756D8E0774761D2",
79
- "762514B829BF486A",
80
- "3BDD119049372802",
81
- "26955F6835AF609A",
82
- "164D5E404F275232",
83
- "6B056E18759F5CCA",
84
- "004BD6EF09176062",
85
- "480D39006EE762F2",
86
- "437540C8698F3CFA",
87
- "072D43A077075292",
88
- "02FE55778117F12A",
89
- "1D9D5C5018F728C2",
90
- "305532286D6F295A",
91
- "0123456789ABCDEF",
92
- "0123456789ABCDEF",
93
- "0123456789ABCDEF",
94
- "FFFFFFFFFFFFFFFF",
95
- "0000000000000000",
96
- "0000000000000000",
97
- "FFFFFFFFFFFFFFFF" ];
98
- var cts:Array = [
99
- "4EF997456198DD78",
100
- "51866FD5B85ECB8A",
101
- "7D856F9A613063F2",
102
- "2466DD878B963C9D",
103
- "61F9C3802281B096",
104
- "7D0CC630AFDA1EC7",
105
- "4EF997456198DD78",
106
- "0ACEAB0FC6A0A28D",
107
- "59C68245EB05282B",
108
- "B1B8CC0B250F09A0",
109
- "1730E5778BEA1DA4",
110
- "A25E7856CF2651EB",
111
- "353882B109CE8F1A",
112
- "48F4D0884C379918",
113
- "432193B78951FC98",
114
- "13F04154D69D1AE5",
115
- "2EEDDA93FFD39C79",
116
- "D887E0393C2DA6E3",
117
- "5F99D04F5B163969",
118
- "4A057A3B24D3977B",
119
- "452031C1E4FADA8E",
120
- "7555AE39F59B87BD",
121
- "53C55F9CB49FC019",
122
- "7A8E7BFA937E89A3",
123
- "CF9C5D7A4986ADB5",
124
- "D1ABB290658BC778",
125
- "55CB3774D13EF201",
126
- "FA34EC4847B268B2",
127
- "A790795108EA3CAE",
128
- "C39E072D9FAC631D",
129
- "014933E0CDAFF6E4",
130
- "F21E9A77B71C49BC",
131
- "245946885754369A",
132
- "6B5C5A9C5D9E0A5A" ];
133
-
134
- for (var i:uint=0;i<keys.length;i++) {
135
- var key:ByteArray = Hex.toArray(keys[i]);
136
- var pt:ByteArray = Hex.toArray(pts[i]);
137
- var bf:BlowFishKey = new BlowFishKey(key);
138
- bf.encrypt(pt);
139
- var out:String = Hex.fromArray(pt).toUpperCase();
140
- assert("comparing "+cts[i]+" to "+out, cts[i]==out);
141
- // now go back to plaintext
142
- bf.decrypt(pt);
143
- out = Hex.fromArray(pt).toUpperCase();
144
- assert("comparing "+pts[i]+" to "+out, pts[i]==out);
145
- }
146
- }
147
- }
148
- }
@@ -1,160 +0,0 @@
1
- /**
2
- * CBCModeTest
3
- *
4
- * A test class for CBCMode
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.tests
10
- {
11
- import com.hurlant.crypto.symmetric.AESKey;
12
- import com.hurlant.crypto.symmetric.CBCMode;
13
- import com.hurlant.crypto.symmetric.NullPad;
14
- import com.hurlant.crypto.symmetric.XTeaKey;
15
- import com.hurlant.util.Hex;
16
-
17
- import flash.utils.ByteArray;
18
-
19
- public class CBCModeTest extends TestCase
20
- {
21
- public function CBCModeTest(h:ITestHarness) {
22
- super(h, "CBCMode Test");
23
- runTest(testAES,"CBC AES Test Vectors");
24
- runTest(testXTea,"CBC XTea Test Vectors");
25
- //
26
- runTest(testCBC_AES128, "CBC AES-128 Test Vectors");
27
- runTest(testCBC_AES192, "CBC AES-192 Test Vectors");
28
- runTest(testCBC_AES256, "CBC AES-256 Test Vectors");
29
- h.endTestCase();
30
- }
31
-
32
- /**
33
- * Hawt NIST Vectors: http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
34
- * Section F.2.1 and below.
35
- */
36
- public function testCBC_AES128():void {
37
- var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
38
- var pt:ByteArray = Hex.toArray(
39
- "6bc1bee22e409f96e93d7e117393172a" +
40
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
41
- "30c81c46a35ce411e5fbc1191a0a52ef" +
42
- "f69f2445df4f9b17ad2b417be66c3710");
43
- var ct:ByteArray = Hex.toArray(
44
- "7649abac8119b246cee98e9b12e9197d" +
45
- "5086cb9b507219ee95db113a917678b2" +
46
- "73bed6b8e3c1743b7116e69e22229516" +
47
- "3ff1caa1681fac09120eca307586e1a7");
48
- var cbc:CBCMode = new CBCMode(new AESKey(key), new NullPad);
49
- cbc.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
50
- var src:ByteArray = new ByteArray;
51
- src.writeBytes(pt);
52
- cbc.encrypt(src);
53
- assert("CBC_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
54
- cbc.decrypt(src);
55
- assert("CBC_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
56
- }
57
- public function testCBC_AES192():void {
58
- var key:ByteArray = Hex.toArray("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
59
- var pt:ByteArray = Hex.toArray(
60
- "6bc1bee22e409f96e93d7e117393172a" +
61
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
62
- "30c81c46a35ce411e5fbc1191a0a52ef" +
63
- "f69f2445df4f9b17ad2b417be66c3710");
64
- var ct:ByteArray = Hex.toArray(
65
- "4f021db243bc633d7178183a9fa071e8" +
66
- "b4d9ada9ad7dedf4e5e738763f69145a" +
67
- "571b242012fb7ae07fa9baac3df102e0" +
68
- "08b0e27988598881d920a9e64f5615cd");
69
- var cbc:CBCMode = new CBCMode(new AESKey(key), new NullPad);
70
- cbc.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
71
- var src:ByteArray = new ByteArray;
72
- src.writeBytes(pt);
73
- cbc.encrypt(src);
74
- assert("CBC_AES192 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
75
- cbc.decrypt(src);
76
- assert("CBC_AES192 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
77
- }
78
- public function testCBC_AES256():void {
79
- var key:ByteArray = Hex.toArray(
80
- "603deb1015ca71be2b73aef0857d7781" +
81
- "1f352c073b6108d72d9810a30914dff4");
82
- var pt:ByteArray = Hex.toArray(
83
- "6bc1bee22e409f96e93d7e117393172a" +
84
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
85
- "30c81c46a35ce411e5fbc1191a0a52ef" +
86
- "f69f2445df4f9b17ad2b417be66c3710");
87
- var ct:ByteArray = Hex.toArray(
88
- "f58c4c04d6e5f1ba779eabfb5f7bfbd6" +
89
- "9cfc4e967edb808d679f777bc6702c7d" +
90
- "39f23369a9d9bacfa530e26304231461" +
91
- "b2eb05e2c39be9fcda6c19078c6a9d1b");
92
- var cbc:CBCMode = new CBCMode(new AESKey(key), new NullPad);
93
- cbc.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
94
- var src:ByteArray = new ByteArray;
95
- src.writeBytes(pt);
96
- cbc.encrypt(src);
97
- assert("CBC_AES256 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
98
- cbc.decrypt(src);
99
- assert("CBC_AES256 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
100
- }
101
-
102
-
103
- /**
104
- * For now the main goal is to show we can decrypt what we encrypt in this mode.
105
- * Eventually, this should get correlated with some well known vectors.
106
- */
107
- public function testAES():void {
108
- var keys:Array = [
109
- "00010203050607080A0B0C0D0F101112",
110
- "14151617191A1B1C1E1F202123242526"];
111
- var cts:Array = [
112
- "D8F532538289EF7D06B506A4FD5BE9C94894C5508A8D8E29AB600DB0261F0555A8FA287B89E65C0973F1F8283E70C72863FE1C8F1F782084CE05626E961A67B3",
113
- "59AB30F4D4EE6E4FF9907EF65B1FB68C96890CE217689B1BE0C93ED51CF21BB5A0101A8C30714EC4F52DBC9C6F4126067D363F67ABE58463005E679B68F0B496"];
114
- var pts:Array = [
115
- "506812A45F08C889B97F5980038B8359506812A45F08C889B97F5980038B8359506812A45F08C889B97F5980038B8359",
116
- "5C6D71CA30DE8B8B00549984D2EC7D4B5C6D71CA30DE8B8B00549984D2EC7D4B5C6D71CA30DE8B8B00549984D2EC7D4B"];
117
-
118
- for (var i:uint=0;i<keys.length;i++) {
119
- var key:ByteArray = Hex.toArray(keys[i]);
120
- var pt:ByteArray = Hex.toArray(pts[i]);
121
- var aes:AESKey = new AESKey(key);
122
- var cbc:CBCMode = new CBCMode(aes);
123
- cbc.IV = Hex.toArray("00000000000000000000000000000000");
124
- cbc.encrypt(pt);
125
- var str:String = Hex.fromArray(pt).toUpperCase();
126
- assert("comparing "+cts[i]+" to "+str, cts[i]==str);
127
- // back to pt
128
- cbc.decrypt(pt);
129
- str = Hex.fromArray(pt).toUpperCase();
130
- assert("comparing "+pts[i]+" to "+str, pts[i]==str);
131
- }
132
- }
133
- public function testXTea():void {
134
- var keys:Array=[
135
- "00000000000000000000000000000000",
136
- "2b02056806144976775d0e266c287843"];
137
- var cts:Array = [
138
- "2dc7e8d3695b0538d8f1640d46dca717790af2ab545e11f3b08e798eb3f17b1744299d4d20b534aa",
139
- "790958213819878370eb8251ffdac371081c5a457fc42502c63910306fea150be8674c3b8e675516"];
140
- var pts:Array=[
141
- "0000000000000000000000000000000000000000000000000000000000000000",
142
- "74657374206d652e74657374206d652e74657374206d652e74657374206d652e"];
143
-
144
- for (var i:uint=0;i<keys.length;i++) {
145
- var key:ByteArray = Hex.toArray(keys[i]);
146
- var pt:ByteArray = Hex.toArray(pts[i]);
147
- var tea:XTeaKey = new XTeaKey(key);
148
- var cbc:CBCMode = new CBCMode(tea);
149
- cbc.IV = Hex.toArray("0000000000000000");
150
- cbc.encrypt(pt);
151
- var str:String = Hex.fromArray(pt);
152
- assert("comparing "+cts[i]+" to "+str, cts[i]==str);
153
- // now go back to plaintext.
154
- cbc.decrypt(pt);
155
- str = Hex.fromArray(pt);
156
- assert("comparing "+pts[i]+" to "+str, pts[i]==str);
157
- }
158
- }
159
- }
160
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * CFB8ModeTest
3
- *
4
- * A test class for CFB8Mode
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.tests
10
- {
11
- import flash.utils.ByteArray;
12
- import com.hurlant.util.Hex;
13
- import com.hurlant.crypto.symmetric.CFB8Mode;
14
- import com.hurlant.crypto.symmetric.AESKey;
15
- import com.hurlant.crypto.symmetric.NullPad;
16
-
17
- public class CFB8ModeTest extends TestCase
18
- {
19
- public function CFB8ModeTest(h:ITestHarness) {
20
- super(h,"CBF8Mode Test");
21
- runTest(testCFB8_AES128, "CFB-8 AES-128 Test Vectors");
22
- runTest(testCFB8_AES192, "CFB-8 AES-192 Test Vectors");
23
- runTest(testCFB8_AES256, "CFB-8 AES-192 Test Vectors");
24
- h.endTestCase();
25
- }
26
-
27
- /**
28
- * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
29
- */
30
- public function testCFB8_AES128():void {
31
- var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
32
- var pt:ByteArray = Hex.toArray("6bc1bee22e409f96e93d7e117393172aae2d");
33
- var ct:ByteArray = Hex.toArray("3b79424c9c0dd436bace9e0ed4586a4f32b9");
34
- var cfb8:CFB8Mode = new CFB8Mode(new AESKey(key), new NullPad);
35
- cfb8.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
36
- var src:ByteArray = new ByteArray;
37
- src.writeBytes(pt);
38
- cfb8.encrypt(src);
39
- assert("CFB8_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
40
- cfb8.decrypt(src);
41
- assert("CFB8_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
42
- }
43
- public function testCFB8_AES192():void {
44
- var key:ByteArray = Hex.toArray("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
45
- var pt:ByteArray = Hex.toArray("6bc1bee22e409f96e93d7e117393172aae2d");
46
- var ct:ByteArray = Hex.toArray("cda2521ef0a905ca44cd057cbf0d47a0678a");
47
- var cfb8:CFB8Mode = new CFB8Mode(new AESKey(key), new NullPad);
48
- cfb8.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
49
- var src:ByteArray = new ByteArray;
50
- src.writeBytes(pt);
51
- cfb8.encrypt(src);
52
- assert("CFB8_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
53
- cfb8.decrypt(src);
54
- assert("CFB8_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
55
- }
56
- public function testCFB8_AES256():void {
57
- var key:ByteArray = Hex.toArray("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");
58
- var pt:ByteArray = Hex.toArray("6bc1bee22e409f96e93d7e117393172aae2d");
59
- var ct:ByteArray = Hex.toArray("dc1f1a8520a64db55fcc8ac554844e889700");
60
- var cfb8:CFB8Mode = new CFB8Mode(new AESKey(key), new NullPad);
61
- cfb8.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
62
- var src:ByteArray = new ByteArray;
63
- src.writeBytes(pt);
64
- cfb8.encrypt(src);
65
- assert("CFB8_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
66
- cfb8.decrypt(src);
67
- assert("CFB8_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
68
- }
69
-
70
- }
71
- }