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,98 +0,0 @@
1
- /**
2
- * CFBModeTest
3
- *
4
- * A test class for CFBMode
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.CFBMode;
13
- import com.hurlant.crypto.symmetric.NullPad;
14
- import com.hurlant.util.Hex;
15
-
16
- import flash.utils.ByteArray;
17
-
18
- public class CFBModeTest extends TestCase
19
- {
20
- public function CFBModeTest(h:ITestHarness)
21
- {
22
- super(h, "CFBMode Test");
23
- runTest(testCFB_AES128, "CFB AES-128 Test Vectors");
24
- runTest(testCFB_AES192, "CFB AES-192 Test Vectors");
25
- runTest(testCFB_AES256, "CFB AES-256 Test Vectors");
26
- h.endTestCase();
27
- }
28
-
29
- /**
30
- * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
31
- */
32
- public function testCFB_AES128():void {
33
- var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
34
- var pt:ByteArray = Hex.toArray(
35
- "6bc1bee22e409f96e93d7e117393172a" +
36
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
37
- "30c81c46a35ce411e5fbc1191a0a52ef" +
38
- "f69f2445df4f9b17ad2b417be66c3710");
39
- var ct:ByteArray = Hex.toArray(
40
- "3b3fd92eb72dad20333449f8e83cfb4a" +
41
- "c8a64537a0b3a93fcde3cdad9f1ce58b" +
42
- "26751f67a3cbb140b1808cf187a4f4df" +
43
- "c04b05357c5d1c0eeac4c66f9ff7f2e6");
44
- var cfb:CFBMode = new CFBMode(new AESKey(key), new NullPad);
45
- cfb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
46
- var src:ByteArray = new ByteArray;
47
- src.writeBytes(pt);
48
- cfb.encrypt(src);
49
- assert("CFB_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
50
- cfb.decrypt(src);
51
- assert("CFB_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
52
- }
53
- public function testCFB_AES192():void {
54
- var key:ByteArray = Hex.toArray("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
55
- var pt:ByteArray = Hex.toArray(
56
- "6bc1bee22e409f96e93d7e117393172a" +
57
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
58
- "30c81c46a35ce411e5fbc1191a0a52ef" +
59
- "f69f2445df4f9b17ad2b417be66c3710");
60
- var ct:ByteArray = Hex.toArray(
61
- "cdc80d6fddf18cab34c25909c99a4174" +
62
- "67ce7f7f81173621961a2b70171d3d7a" +
63
- "2e1e8a1dd59b88b1c8e60fed1efac4c9" +
64
- "c05f9f9ca9834fa042ae8fba584b09ff");
65
- var cfb:CFBMode = new CFBMode(new AESKey(key), new NullPad);
66
- cfb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
67
- var src:ByteArray = new ByteArray;
68
- src.writeBytes(pt);
69
- cfb.encrypt(src);
70
- assert("CFB_AES192 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
71
- cfb.decrypt(src);
72
- assert("CFB_AES192 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
73
- }
74
- public function testCFB_AES256():void {
75
- var key:ByteArray = Hex.toArray(
76
- "603deb1015ca71be2b73aef0857d7781" +
77
- "1f352c073b6108d72d9810a30914dff4");
78
- var pt:ByteArray = Hex.toArray(
79
- "6bc1bee22e409f96e93d7e117393172a" +
80
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
81
- "30c81c46a35ce411e5fbc1191a0a52ef" +
82
- "f69f2445df4f9b17ad2b417be66c3710");
83
- var ct:ByteArray = Hex.toArray(
84
- "dc7e84bfda79164b7ecd8486985d3860" +
85
- "39ffed143b28b1c832113c6331e5407b" +
86
- "df10132415e54b92a13ed0a8267ae2f9" +
87
- "75a385741ab9cef82031623d55b1e471");
88
- var cfb:CFBMode = new CFBMode(new AESKey(key), new NullPad);
89
- cfb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
90
- var src:ByteArray = new ByteArray;
91
- src.writeBytes(pt);
92
- cfb.encrypt(src);
93
- assert("CFB_AES256 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
94
- cfb.decrypt(src);
95
- assert("CFB_AES256 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
96
- }
97
- }
98
- }
@@ -1,109 +0,0 @@
1
- /**
2
- * CTRModeTest
3
- *
4
- * A test class for CTRMode
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.CTRMode;
14
- import com.hurlant.crypto.symmetric.AESKey;
15
- import com.hurlant.crypto.symmetric.NullPad;
16
-
17
- public class CTRModeTest extends TestCase
18
- {
19
- public function CTRModeTest(h:ITestHarness)
20
- {
21
- super(h, "CTRMode Test");
22
- runTest(testCTR_AES128, "CTR AES-128 Test Vectors");
23
- runTest(testCTR_AES192, "CTR AES-192 Test Vectors");
24
- runTest(testCTR_AES256, "CTR AES-256 Test Vectors");
25
- h.endTestCase();
26
- }
27
-
28
- /**
29
- * Vectors from http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38A.pdf
30
- * Section F.5.1 and below.
31
- */
32
- public function testCTR_AES128():void {
33
- var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
34
- var pt:ByteArray = Hex.toArray(
35
- "6bc1bee22e409f96e93d7e117393172a" +
36
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
37
- "30c81c46a35ce411e5fbc1191a0a52ef" +
38
- "f69f2445df4f9b17ad2b417be66c3710");
39
- var ct:ByteArray = Hex.toArray(
40
- "874d6191b620e3261bef6864990db6ce" +
41
- "9806f66b7970fdff8617187bb9fffdff" +
42
- "5ae4df3edbd5d35e5b4f09020db03eab" +
43
- "1e031dda2fbe03d1792170a0f3009cee");
44
- var ctr:CTRMode = new CTRMode(new AESKey(key), new NullPad);
45
- ctr.IV = Hex.toArray("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
46
- var src:ByteArray = new ByteArray;
47
- src.writeBytes(pt);
48
- ctr.encrypt(src);
49
- var hsrc:String = Hex.fromArray(src);
50
- var hct:String = Hex.fromArray(ct);
51
- assert("CTR_AES128 test 1: "+hsrc+" != "+hct, hsrc==hct);
52
- ctr.decrypt(src);
53
- hsrc = Hex.fromArray(src);
54
- var hpt:String = Hex.fromArray(pt);
55
- assert("CTR_AES128 test 2: "+hsrc+" != "+hpt, hsrc==hpt);
56
- }
57
- public function testCTR_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
- "1abc932417521ca24f2b0459fe7e6e0b" +
66
- "090339ec0aa6faefd5ccc2c6f4ce8e94" +
67
- "1e36b26bd1ebc670d1bd1d665620abf7" +
68
- "4f78a7f6d29809585a97daec58c6b050");
69
- var ctr:CTRMode = new CTRMode(new AESKey(key), new NullPad);
70
- ctr.IV = Hex.toArray("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
71
- var src:ByteArray = new ByteArray;
72
- src.writeBytes(pt);
73
- ctr.encrypt(src);
74
- var hsrc:String = Hex.fromArray(src);
75
- var hct:String = Hex.fromArray(ct);
76
- assert("CTR_AES192 test 1: "+hsrc+" != "+hct, hsrc==hct);
77
- ctr.decrypt(src);
78
- hsrc = Hex.fromArray(src);
79
- var hpt:String = Hex.fromArray(pt);
80
- assert("CTR_AES192 test 2: "+hsrc+" != "+hpt, hsrc==hpt);
81
- }
82
- public function testCTR_AES256():void {
83
- var key:ByteArray = Hex.toArray("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");
84
- var pt:ByteArray = Hex.toArray(
85
- "6bc1bee22e409f96e93d7e117393172a" +
86
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
87
- "30c81c46a35ce411e5fbc1191a0a52ef" +
88
- "f69f2445df4f9b17ad2b417be66c3710");
89
- var ct:ByteArray = Hex.toArray(
90
- "601ec313775789a5b7a7f504bbf3d228" +
91
- "f443e3ca4d62b59aca84e990cacaf5c5" +
92
- "2b0930daa23de94ce87017ba2d84988d" +
93
- "dfc9c58db67aada613c2dd08457941a6");
94
- var ctr:CTRMode = new CTRMode(new AESKey(key), new NullPad);
95
- ctr.IV = Hex.toArray("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
96
- var src:ByteArray = new ByteArray;
97
- src.writeBytes(pt);
98
- ctr.encrypt(src);
99
- var hsrc:String = Hex.fromArray(src);
100
- var hct:String = Hex.fromArray(ct);
101
- assert("CTR_AES256 test 1: "+hsrc+" != "+hct, hsrc==hct);
102
- ctr.decrypt(src);
103
- hsrc = Hex.fromArray(src);
104
- var hpt:String = Hex.fromArray(pt);
105
- assert("CTR_AES256 test 2: "+hsrc+" != "+hpt, hsrc==hpt);
106
- }
107
-
108
- }
109
- }
@@ -1,112 +0,0 @@
1
- /**
2
- * DesKeyTest
3
- *
4
- * A test class for DesKey
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.DESKey;
12
- import com.hurlant.util.Hex;
13
- import flash.utils.ByteArray;
14
-
15
- public class DESKeyTest extends TestCase
16
- {
17
- public function DESKeyTest(h:ITestHarness)
18
- {
19
- super(h, "DESKey Test");
20
- runTest(testECB,"DES ECB Test Vectors");
21
- h.endTestCase();
22
- }
23
-
24
- /**
25
- * Test vectors mostly grabbed from
26
- * http://csrc.nist.gov/publications/nistpubs/800-17/800-17.pdf
27
- * (Appendix A and B)
28
- * incomplete.
29
- */
30
- public function testECB():void {
31
- var keys:Array = [
32
- "3b3898371520f75e", // grabbed from the output of some js implementation out there
33
- "10316E028C8F3B4A", // appendix A vector
34
- "0101010101010101", // appendix B Table 1, round 0
35
- "0101010101010101", // round 1
36
- "0101010101010101", // 2
37
- "0101010101010101",
38
- "0101010101010101",
39
- "0101010101010101",
40
- "0101010101010101",
41
- "0101010101010101",
42
- "0101010101010101", // round 8
43
- "8001010101010101", // app B, tbl 2, round 0
44
- "4001010101010101",
45
- "2001010101010101",
46
- "1001010101010101",
47
- "0801010101010101",
48
- "0401010101010101",
49
- "0201010101010101",
50
- "0180010101010101",
51
- "0140010101010101", // round 8
52
- ];
53
- var pts:Array = [
54
- "0000000000000000", // js
55
- "0000000000000000", // App A
56
- "8000000000000000", // App B, tbl 1, rnd0
57
- "4000000000000000",
58
- "2000000000000000",
59
- "1000000000000000",
60
- "0800000000000000", // rnd 4
61
- "0400000000000000",
62
- "0200000000000000",
63
- "0100000000000000",
64
- "0080000000000000", // round 8
65
- "0000000000000000", // App B, tbl2, rnd0
66
- "0000000000000000",
67
- "0000000000000000",
68
- "0000000000000000",
69
- "0000000000000000",
70
- "0000000000000000",
71
- "0000000000000000",
72
- "0000000000000000",
73
- "0000000000000000", // rnd 8
74
- ];
75
- var cts:Array = [
76
- "83A1E814889253E0", // js
77
- "82DCBAFBDEAB6602", // App A
78
- "95F8A5E5DD31D900", // App b, tbl 1, rnd 0
79
- "DD7F121CA5015619",
80
- "2E8653104F3834EA",
81
- "4BD388FF6CD81D4F",
82
- "20B9E767B2FB1456",
83
- "55579380D77138EF",
84
- "6CC5DEFAAF04512F",
85
- "0D9F279BA5D87260",
86
- "D9031B0271BD5A0A", // rnd 8
87
- "95A8D72813DAA94D", // App B, tbl 2, rnd 0
88
- "0EEC1487DD8C26D5",
89
- "7AD16FFB79C45926",
90
- "D3746294CA6A6CF3",
91
- "809F5F873C1FD761",
92
- "C02FAFFEC989D1FC",
93
- "4615AA1D33E72F10",
94
- "2055123350C00858",
95
- "DF3B99D6577397C8", // rnd 8
96
- ];
97
-
98
- for (var i:uint=0;i<keys.length;i++) {
99
- var key:ByteArray = Hex.toArray(keys[i]);
100
- var pt:ByteArray = Hex.toArray(pts[i]);
101
- var des:DESKey = new DESKey(key);
102
- des.encrypt(pt);
103
- var out:String = Hex.fromArray(pt).toUpperCase();
104
- assert("comparing "+cts[i]+" to "+out, cts[i]==out);
105
- // now go back to plaintext
106
- des.decrypt(pt);
107
- out = Hex.fromArray(pt).toUpperCase();
108
- assert("comparing "+pts[i]+" to "+out, pts[i]==out);
109
- }
110
- }
111
- }
112
- }
@@ -1,151 +0,0 @@
1
- /**
2
- * ECBModeTest
3
- *
4
- * A test class for ECBMode
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.ECBMode;
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 ECBModeTest extends TestCase
20
- {
21
- public function ECBModeTest(h:ITestHarness) {
22
- super(h, "ECBMode Test");
23
- runTest(testAES,"ECB AES Test Vectors");
24
- runTest(testXTea,"ECB XTea Test Vectors");
25
- runTest(testECB_AES128,"ECB AES-128 Test Vectors");
26
- runTest(testECB_AES192,"ECB AES-192 Test Vectors");
27
- runTest(testECB_AES256,"ECB AES-256 Test Vectors");
28
- h.endTestCase();
29
- }
30
- /**
31
- * For now the main goal is to show we can decrypt what we encrypt in this mode.
32
- * Eventually, this should get correlated with some well known vectors.
33
- * yay. found hawt test vectors: http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
34
- */
35
- public function testECB_AES128():void {
36
- var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
37
- var pt:ByteArray = Hex.toArray(
38
- "6bc1bee22e409f96e93d7e117393172a" +
39
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
40
- "30c81c46a35ce411e5fbc1191a0a52ef" +
41
- "f69f2445df4f9b17ad2b417be66c3710");
42
- var ct:ByteArray = Hex.toArray(
43
- "3ad77bb40d7a3660a89ecaf32466ef97" +
44
- "f5d3d58503b9699de785895a96fdbaaf" +
45
- "43b1cd7f598ece23881b00e3ed030688" +
46
- "7b0c785e27e8ad3f8223207104725dd4");
47
- var ecb:ECBMode = new ECBMode(new AESKey(key), new NullPad);
48
- var src:ByteArray = new ByteArray;
49
- src.writeBytes(pt);
50
- ecb.encrypt(src);
51
- assert("ECB_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
52
- ecb.decrypt(src);
53
- assert("ECB_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
54
- }
55
- public function testECB_AES192():void {
56
- var key:ByteArray = Hex.toArray("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
57
- var pt:ByteArray = Hex.toArray(
58
- "6bc1bee22e409f96e93d7e117393172a" +
59
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
60
- "30c81c46a35ce411e5fbc1191a0a52ef" +
61
- "f69f2445df4f9b17ad2b417be66c3710");
62
- var ct:ByteArray = Hex.toArray(
63
- "bd334f1d6e45f25ff712a214571fa5cc" +
64
- "974104846d0ad3ad7734ecb3ecee4eef" +
65
- "ef7afd2270e2e60adce0ba2face6444e" +
66
- "9a4b41ba738d6c72fb16691603c18e0e");
67
- var ecb:ECBMode = new ECBMode(new AESKey(key), new NullPad);
68
- var src:ByteArray = new ByteArray;
69
- src.writeBytes(pt);
70
- ecb.encrypt(src);
71
- assert("ECB_AES192 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
72
- ecb.decrypt(src);
73
- assert("ECB_AES192 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
74
- }
75
- public function testECB_AES256():void {
76
- var key:ByteArray = Hex.toArray(
77
- "603deb1015ca71be2b73aef0857d7781" +
78
- "1f352c073b6108d72d9810a30914dff4");
79
- var pt:ByteArray = Hex.toArray(
80
- "6bc1bee22e409f96e93d7e117393172a" +
81
- "ae2d8a571e03ac9c9eb76fac45af8e51" +
82
- "30c81c46a35ce411e5fbc1191a0a52ef" +
83
- "f69f2445df4f9b17ad2b417be66c3710");
84
- var ct:ByteArray = Hex.toArray(
85
- "f3eed1bdb5d2a03c064b5a7e3db181f8" +
86
- "591ccb10d410ed26dc5ba74a31362870" +
87
- "b6ed21b99ca6f4f9f153e7b1beafed1d" +
88
- "23304b7a39f9f3ff067d8d8f9e24ecc7");
89
- var ecb:ECBMode = new ECBMode(new AESKey(key), new NullPad);
90
- var src:ByteArray = new ByteArray;
91
- src.writeBytes(pt);
92
- ecb.encrypt(src);
93
- assert("ECB_AES256 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
94
- ecb.decrypt(src);
95
- assert("ECB_AES256 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
96
- }
97
- // crappier, older testing. keeping around for no good reason.
98
- public function testAES():void {
99
- var keys:Array = [
100
- "00010203050607080A0B0C0D0F101112",
101
- "14151617191A1B1C1E1F202123242526"];
102
- var pts:Array = [
103
- "506812A45F08C889B97F5980038B8359506812A45F08C889B97F5980038B8359506812A45F08C889B97F5980038B8359",
104
- "5C6D71CA30DE8B8B00549984D2EC7D4B5C6D71CA30DE8B8B00549984D2EC7D4B5C6D71CA30DE8B8B00549984D2EC7D4B"];
105
- var cts:Array = [
106
- "D8F532538289EF7D06B506A4FD5BE9C9D8F532538289EF7D06B506A4FD5BE9C9D8F532538289EF7D06B506A4FD5BE9C96DE5F607AB7EB8202F3957703B04E8B5",
107
- "59AB30F4D4EE6E4FF9907EF65B1FB68C59AB30F4D4EE6E4FF9907EF65B1FB68C59AB30F4D4EE6E4FF9907EF65B1FB68C2993487785CB1CFDA6BB4F0F345F76C7"];
108
-
109
- for (var i:uint=0;i<keys.length;i++) {
110
- var key:ByteArray = Hex.toArray(keys[i]);
111
- var pt:ByteArray = Hex.toArray(pts[i]);
112
- var aes:AESKey = new AESKey(key);
113
- var ecb:ECBMode = new ECBMode(aes);
114
- ecb.encrypt(pt);
115
- var str:String = Hex.fromArray(pt).toUpperCase();
116
- assert("comparing "+cts[i]+" to "+str, cts[i]==str);
117
- // back to pt
118
- ecb.decrypt(pt);
119
- str = Hex.fromArray(pt).toUpperCase();
120
- assert("comparing "+pts[i]+" to "+str, pts[i]==str);
121
- }
122
- }
123
- public function testXTea():void {
124
- var keys:Array=[
125
- "00000000000000000000000000000000",
126
- "2b02056806144976775d0e266c287843"];
127
- var pts:Array=[
128
- "0000000000000000000000000000000000000000000000000000000000000000",
129
- "74657374206d652e74657374206d652e74657374206d652e74657374206d652e"];
130
- var cts:Array=[
131
- "2dc7e8d3695b05382dc7e8d3695b05382dc7e8d3695b05382dc7e8d3695b053820578a874233632d",
132
- "79095821381987837909582138198783790958213819878379095821381987830e4dc3c48b2edf32"];
133
- // self-fullfilling vectors.
134
- // oh well, at least I can decrypt what I produce. :(
135
-
136
- for (var i:uint=0;i<keys.length;i++) {
137
- var key:ByteArray = Hex.toArray(keys[i]);
138
- var pt:ByteArray = Hex.toArray(pts[i]);
139
- var tea:XTeaKey = new XTeaKey(key);
140
- var ecb:ECBMode = new ECBMode(tea);
141
- ecb.encrypt(pt);
142
- var str:String = Hex.fromArray(pt);
143
- assert("comparing "+cts[i]+" to "+str, cts[i]==str);
144
- // now go back to plaintext.
145
- ecb.decrypt(pt);
146
- str = Hex.fromArray(pt);
147
- assert("comparing "+pts[i]+" to "+str, pts[i]==str);
148
- }
149
- }
150
- }
151
- }