rocket-js 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +0 -11
  2. data/Rakefile +33 -47
  3. data/lib/rocket/js.rb +0 -2
  4. data/lib/rocket/js/builder.rb +2 -2
  5. data/lib/rocket/js/cli.rb +1 -1
  6. data/rocket-js.gemspec +23 -80
  7. data/src/vendor/web-socket-js/FABridge.js +604 -0
  8. data/src/vendor/web-socket-js/README.txt +109 -0
  9. data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
  10. data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
  11. data/src/vendor/web-socket-js/flash-src/WebSocket.as +473 -0
  12. data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +88 -0
  13. data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +19 -0
  14. data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +32 -0
  15. data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +943 -0
  16. data/src/vendor/web-socket-js/flash-src/build.sh +10 -0
  17. data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +204 -0
  18. data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +375 -0
  19. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +287 -0
  20. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +3235 -0
  21. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +218 -0
  22. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +57 -0
  23. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +82 -0
  24. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +27 -0
  25. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +21 -0
  26. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +137 -0
  27. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +124 -0
  28. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +204 -0
  29. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +106 -0
  30. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +28 -0
  31. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +115 -0
  32. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +71 -0
  33. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +90 -0
  34. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +20 -0
  35. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +119 -0
  36. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +142 -0
  37. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +339 -0
  38. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +2797 -0
  39. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +375 -0
  40. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +55 -0
  41. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +61 -0
  42. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +64 -0
  43. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +58 -0
  44. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +365 -0
  45. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +86 -0
  46. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +21 -0
  47. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +15 -0
  48. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +32 -0
  49. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +21 -0
  50. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +35 -0
  51. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +110 -0
  52. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +34 -0
  53. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +52 -0
  54. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +44 -0
  55. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +44 -0
  56. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +60 -0
  57. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +42 -0
  58. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +88 -0
  59. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +94 -0
  60. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +29 -0
  61. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +2304 -0
  62. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +1220 -0
  63. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +58 -0
  64. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +39 -0
  65. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +148 -0
  66. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +160 -0
  67. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +71 -0
  68. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +98 -0
  69. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +109 -0
  70. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +112 -0
  71. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +151 -0
  72. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +184 -0
  73. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +20 -0
  74. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +56 -0
  75. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +58 -0
  76. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +101 -0
  77. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +92 -0
  78. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +198 -0
  79. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +58 -0
  80. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +60 -0
  81. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +51 -0
  82. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +42 -0
  83. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +59 -0
  84. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +66 -0
  85. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +102 -0
  86. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +117 -0
  87. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +14 -0
  88. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +29 -0
  89. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +24 -0
  90. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +38 -0
  91. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +171 -0
  92. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +26 -0
  93. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +340 -0
  94. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +70 -0
  95. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +151 -0
  96. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +895 -0
  97. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +39 -0
  98. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +27 -0
  99. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +197 -0
  100. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +370 -0
  101. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +26 -0
  102. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +180 -0
  103. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +90 -0
  104. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +1543 -0
  105. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +35 -0
  106. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +11 -0
  107. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +85 -0
  108. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +34 -0
  109. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +11 -0
  110. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +25 -0
  111. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +189 -0
  112. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +66 -0
  113. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +28 -0
  114. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +43 -0
  115. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +210 -0
  116. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +21 -0
  117. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +44 -0
  118. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +35 -0
  119. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +112 -0
  120. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +118 -0
  121. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +49 -0
  122. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +90 -0
  123. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +27 -0
  124. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +94 -0
  125. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +60 -0
  126. data/src/vendor/web-socket-js/sample.html +76 -0
  127. data/src/vendor/web-socket-js/swfobject.js +4 -0
  128. data/src/vendor/web-socket-js/web_socket.js +388 -0
  129. metadata +163 -30
  130. data/lib/rocket/js/version.rb +0 -14
  131. data/rocket-0.0.1.min.js +0 -45
@@ -0,0 +1,124 @@
1
+ /**
2
+ * MD2
3
+ *
4
+ * An ActionScript 3 implementation of the RSA Data Security, Inc MD2 Message
5
+ * Digest Algorithm, as defined in RFC 1319
6
+ * Copyright (c) 2007 Henri Torgemane
7
+ *
8
+ * See LICENSE.txt for full license information.
9
+ *
10
+ * Excerpt from http://en.wikipedia.org/wiki/MD2:
11
+ * >
12
+ * > Rogier and Chauvaud (1997) described collisions of MD2's compression function,
13
+ * > although they were unable to extend the attack to the full MD2.
14
+ * >
15
+ * > In 2004, MD2 was shown to be vulnerable to a preimage attack with time
16
+ * > complexity equivalent to 2104 applications of the compression function
17
+ * > (Muller, 2004).
18
+ * > The author concludes, "MD2 can no longer be considered a secure one-way
19
+ * > hash function".
20
+ *
21
+ * also, this implementaton is quite slow.
22
+ */
23
+
24
+ package com.hurlant.crypto.hash
25
+ {
26
+ import flash.utils.ByteArray;
27
+
28
+ public class MD2 implements IHash
29
+ {
30
+ public static const HASH_SIZE:int = 16;
31
+ public var pad_size:int = 48; // probably will never get used, only here for SSL 3.0 support
32
+
33
+ private static const S:Array = [ // PI Digits
34
+ 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19,
35
+ 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202,
36
+ 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18,
37
+ 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122,
38
+ 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33,
39
+ 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3,
40
+ 255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198,
41
+ 79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241,
42
+ 69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2,
43
+ 27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
44
+ 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38,
45
+ 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82,
46
+ 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74,
47
+ 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57,
48
+ 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10,
49
+ 49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 ];
50
+
51
+
52
+ public function MD2() { }
53
+
54
+ public function getInputSize():uint
55
+ {
56
+ return 16;
57
+ }
58
+
59
+ public function getPadSize():int {
60
+ return pad_size;
61
+ }
62
+
63
+ public function getHashSize():uint
64
+ {
65
+ return HASH_SIZE;
66
+ }
67
+
68
+ public function hash(src:ByteArray):ByteArray
69
+ {
70
+ var savedLength:uint = src.length;
71
+
72
+ // 3.1 Step 1. Padding
73
+ var i:uint = (16-src.length%16) || 16;
74
+ do {
75
+ src[src.length]=i;
76
+ } while (src.length%16!=0);
77
+
78
+ // 3.2 Step 2. Checksum
79
+ var len:uint = src.length;
80
+ var checksum:ByteArray = new ByteArray;
81
+ var L:uint = 0;
82
+ for (i = 0;i<len;i+=16) {
83
+ for (var j:uint=0;j<16;j++) {
84
+ L = checksum[j] ^= S[src[i+j] ^ L];
85
+ }
86
+ }
87
+ src.position = src.length;
88
+ src.writeBytes(checksum);
89
+ len += 16;
90
+
91
+ // 3.3 Step 3. MD Buffer
92
+ var X:ByteArray = new ByteArray;
93
+
94
+ // 3.4 Process Message
95
+ for (i=0;i<len;i+=16) {
96
+
97
+ /* Copy block i into X */
98
+ for (j=0;j<16;j++) {
99
+ X[32+j] = (X[16+j] = src[i+j])^X[j];
100
+ }
101
+ var t:uint=0;
102
+ /* Do 18 rounds */
103
+ for (j=0;j<18;j++) {
104
+ /* Round j. */
105
+ for (var k:uint=0;k<48;k++) {
106
+ X[k] = t = X[k]^S[t];
107
+ }
108
+ t = (t+j)&0xff;
109
+ }
110
+ }
111
+ // 3.5 Step 5. Output
112
+ X.length = 16;
113
+ // restore original length;
114
+ src.length = savedLength;
115
+ return X;
116
+ }
117
+
118
+ public function toString():String
119
+ {
120
+ return "md2";
121
+ }
122
+
123
+ }
124
+ }
@@ -0,0 +1,204 @@
1
+ /**
2
+ * MD5
3
+ *
4
+ * An ActionScript 3 implementation of the RSA Data Security, Inc. MD5 Message
5
+ * Digest Algorithm, as defined in RFC 1321.
6
+ * Copyright (c) 2007 Henri Torgemane
7
+ *
8
+ * Derived from
9
+ * A JavaScript implementation of the same.
10
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
11
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
12
+ *
13
+ * Note:
14
+ * This algorithm should not be your first choice for new developements, but is
15
+ * included to allow interoperability with existing codes and protocols.
16
+ *
17
+ * See LICENSE.txt for full license information.
18
+ */
19
+ package com.hurlant.crypto.hash
20
+ {
21
+ import flash.utils.ByteArray;
22
+ import flash.utils.Endian;
23
+
24
+ public class MD5 implements IHash
25
+ {
26
+ public static const HASH_SIZE:int = 16;
27
+ public var pad_size:int = 48;
28
+
29
+ public function MD5() { }
30
+
31
+ public function getInputSize():uint
32
+ {
33
+ return 64;
34
+ }
35
+
36
+ public function getHashSize():uint
37
+ {
38
+ return HASH_SIZE;
39
+ }
40
+
41
+ public function getPadSize():int
42
+ {
43
+ return pad_size;
44
+ }
45
+
46
+ public function hash(src:ByteArray):ByteArray
47
+ {
48
+ var len:uint = src.length *8;
49
+ var savedEndian:String = src.endian;
50
+ // pad to nearest int.
51
+ while (src.length%4!=0) {
52
+ src[src.length]=0;
53
+ }
54
+ // convert ByteArray to an array of uint
55
+ src.position=0;
56
+ var a:Array = [];
57
+ src.endian=Endian.LITTLE_ENDIAN
58
+ for (var i:uint=0;i<src.length;i+=4) {
59
+ a.push(src.readUnsignedInt());
60
+ }
61
+ var h:Array = core_md5(a, len);
62
+ var out:ByteArray = new ByteArray;
63
+ out.endian=Endian.LITTLE_ENDIAN;
64
+ for (i=0;i<4;i++) {
65
+ out.writeUnsignedInt(h[i]);
66
+ }
67
+ // restore length!
68
+ src.length = len/8;
69
+ src.endian = savedEndian;
70
+
71
+ return out;
72
+ }
73
+
74
+ private function core_md5(x:Array, len:uint):Array {
75
+ /* append padding */
76
+ x[len >> 5] |= 0x80 << ((len) % 32);
77
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
78
+
79
+ var a:uint = 0x67452301; // 1732584193;
80
+ var b:uint = 0xEFCDAB89; //-271733879;
81
+ var c:uint = 0x98BADCFE; //-1732584194;
82
+ var d:uint = 0x10325476; // 271733878;
83
+
84
+ for(var i:uint = 0; i < x.length; i += 16)
85
+ {
86
+ x[i]||=0; x[i+1]||=0; x[i+2]||=0; x[i+3]||=0;
87
+ x[i+4]||=0; x[i+5]||=0; x[i+6]||=0; x[i+7]||=0;
88
+ x[i+8]||=0; x[i+9]||=0; x[i+10]||=0; x[i+11]||=0;
89
+ x[i+12]||=0; x[i+13]||=0; x[i+14]||=0; x[i+15]||=0;
90
+
91
+ var olda:uint = a;
92
+ var oldb:uint = b;
93
+ var oldc:uint = c;
94
+ var oldd:uint = d;
95
+
96
+ a = ff(a, b, c, d, x[i+ 0], 7 , 0xD76AA478);
97
+ d = ff(d, a, b, c, x[i+ 1], 12, 0xE8C7B756);
98
+ c = ff(c, d, a, b, x[i+ 2], 17, 0x242070DB);
99
+ b = ff(b, c, d, a, x[i+ 3], 22, 0xC1BDCEEE);
100
+ a = ff(a, b, c, d, x[i+ 4], 7 , 0xF57C0FAF);
101
+ d = ff(d, a, b, c, x[i+ 5], 12, 0x4787C62A);
102
+ c = ff(c, d, a, b, x[i+ 6], 17, 0xA8304613);
103
+ b = ff(b, c, d, a, x[i+ 7], 22, 0xFD469501);
104
+ a = ff(a, b, c, d, x[i+ 8], 7 , 0x698098D8);
105
+ d = ff(d, a, b, c, x[i+ 9], 12, 0x8B44F7AF);
106
+ c = ff(c, d, a, b, x[i+10], 17, 0xFFFF5BB1);
107
+ b = ff(b, c, d, a, x[i+11], 22, 0x895CD7BE);
108
+ a = ff(a, b, c, d, x[i+12], 7 , 0x6B901122);
109
+ d = ff(d, a, b, c, x[i+13], 12, 0xFD987193);
110
+ c = ff(c, d, a, b, x[i+14], 17, 0xA679438E);
111
+ b = ff(b, c, d, a, x[i+15], 22, 0x49B40821);
112
+
113
+ a = gg(a, b, c, d, x[i+ 1], 5 , 0xf61e2562);
114
+ d = gg(d, a, b, c, x[i+ 6], 9 , 0xc040b340);
115
+ c = gg(c, d, a, b, x[i+11], 14, 0x265e5a51);
116
+ b = gg(b, c, d, a, x[i+ 0], 20, 0xe9b6c7aa);
117
+ a = gg(a, b, c, d, x[i+ 5], 5 , 0xd62f105d);
118
+ d = gg(d, a, b, c, x[i+10], 9 , 0x2441453);
119
+ c = gg(c, d, a, b, x[i+15], 14, 0xd8a1e681);
120
+ b = gg(b, c, d, a, x[i+ 4], 20, 0xe7d3fbc8);
121
+ a = gg(a, b, c, d, x[i+ 9], 5 , 0x21e1cde6);
122
+ d = gg(d, a, b, c, x[i+14], 9 , 0xc33707d6);
123
+ c = gg(c, d, a, b, x[i+ 3], 14, 0xf4d50d87);
124
+ b = gg(b, c, d, a, x[i+ 8], 20, 0x455a14ed);
125
+ a = gg(a, b, c, d, x[i+13], 5 , 0xa9e3e905);
126
+ d = gg(d, a, b, c, x[i+ 2], 9 , 0xfcefa3f8);
127
+ c = gg(c, d, a, b, x[i+ 7], 14, 0x676f02d9);
128
+ b = gg(b, c, d, a, x[i+12], 20, 0x8d2a4c8a);
129
+
130
+ a = hh(a, b, c, d, x[i+ 5], 4 , 0xfffa3942);
131
+ d = hh(d, a, b, c, x[i+ 8], 11, 0x8771f681);
132
+ c = hh(c, d, a, b, x[i+11], 16, 0x6d9d6122);
133
+ b = hh(b, c, d, a, x[i+14], 23, 0xfde5380c);
134
+ a = hh(a, b, c, d, x[i+ 1], 4 , 0xa4beea44);
135
+ d = hh(d, a, b, c, x[i+ 4], 11, 0x4bdecfa9);
136
+ c = hh(c, d, a, b, x[i+ 7], 16, 0xf6bb4b60);
137
+ b = hh(b, c, d, a, x[i+10], 23, 0xbebfbc70);
138
+ a = hh(a, b, c, d, x[i+13], 4 , 0x289b7ec6);
139
+ d = hh(d, a, b, c, x[i+ 0], 11, 0xeaa127fa);
140
+ c = hh(c, d, a, b, x[i+ 3], 16, 0xd4ef3085);
141
+ b = hh(b, c, d, a, x[i+ 6], 23, 0x4881d05);
142
+ a = hh(a, b, c, d, x[i+ 9], 4 , 0xd9d4d039);
143
+ d = hh(d, a, b, c, x[i+12], 11, 0xe6db99e5);
144
+ c = hh(c, d, a, b, x[i+15], 16, 0x1fa27cf8);
145
+ b = hh(b, c, d, a, x[i+ 2], 23, 0xc4ac5665);
146
+
147
+ a = ii(a, b, c, d, x[i+ 0], 6 , 0xf4292244);
148
+ d = ii(d, a, b, c, x[i+ 7], 10, 0x432aff97);
149
+ c = ii(c, d, a, b, x[i+14], 15, 0xab9423a7);
150
+ b = ii(b, c, d, a, x[i+ 5], 21, 0xfc93a039);
151
+ a = ii(a, b, c, d, x[i+12], 6 , 0x655b59c3);
152
+ d = ii(d, a, b, c, x[i+ 3], 10, 0x8f0ccc92);
153
+ c = ii(c, d, a, b, x[i+10], 15, 0xffeff47d);
154
+ b = ii(b, c, d, a, x[i+ 1], 21, 0x85845dd1);
155
+ a = ii(a, b, c, d, x[i+ 8], 6 , 0x6fa87e4f);
156
+ d = ii(d, a, b, c, x[i+15], 10, 0xfe2ce6e0);
157
+ c = ii(c, d, a, b, x[i+ 6], 15, 0xa3014314);
158
+ b = ii(b, c, d, a, x[i+13], 21, 0x4e0811a1);
159
+ a = ii(a, b, c, d, x[i+ 4], 6 , 0xf7537e82);
160
+ d = ii(d, a, b, c, x[i+11], 10, 0xbd3af235);
161
+ c = ii(c, d, a, b, x[i+ 2], 15, 0x2ad7d2bb);
162
+ b = ii(b, c, d, a, x[i+ 9], 21, 0xeb86d391);
163
+
164
+ a += olda;
165
+ b += oldb;
166
+ c += oldc;
167
+ d += oldd;
168
+
169
+ }
170
+ return [ a, b, c, d ];
171
+ }
172
+
173
+ /*
174
+ * Bitwise rotate a 32-bit number to the left.
175
+ */
176
+ private function rol(num:uint, cnt:uint):uint
177
+ {
178
+ return (num << cnt) | (num >>> (32 - cnt));
179
+ }
180
+
181
+ /*
182
+ * These functions implement the four basic operations the algorithm uses.
183
+ */
184
+ private function cmn(q:uint, a:uint, b:uint, x:uint, s:uint, t:uint):uint {
185
+ return rol(a + q + x + t, s) + b;
186
+ }
187
+ private function ff(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint {
188
+ return cmn((b & c) | ((~b) & d), a, b, x, s, t);
189
+ }
190
+ private function gg(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint {
191
+ return cmn((b & d) | (c & (~d)), a, b, x, s, t);
192
+ }
193
+ private function hh(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint {
194
+ return cmn(b ^ c ^ d, a, b, x, s, t);
195
+ }
196
+ private function ii(a:uint, b:uint, c:uint, d:uint, x:uint, s:uint, t:uint):uint {
197
+ return cmn(c ^ (b | (~d)), a, b, x, s, t);
198
+ }
199
+
200
+ public function toString():String {
201
+ return "md5";
202
+ }
203
+ }
204
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * SHA1
3
+ *
4
+ * An ActionScript 3 implementation of Secure Hash Algorithm, SHA-1, as defined
5
+ * in FIPS PUB 180-1
6
+ * Copyright (c) 2007 Henri Torgemane
7
+ *
8
+ * Derived from:
9
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
10
+ * in FIPS PUB 180-1
11
+ * Version 2.1a Copyright Paul Johnston 2000 - 2002.
12
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
13
+ *
14
+ * See LICENSE.txt for full license information.
15
+ */
16
+ package com.hurlant.crypto.hash
17
+ {
18
+
19
+
20
+ public class SHA1 extends SHABase implements IHash
21
+ {
22
+ public static const HASH_SIZE:int = 20;
23
+
24
+ public override function getHashSize():uint {
25
+ return HASH_SIZE;
26
+ }
27
+
28
+ protected override function core(x:Array, len:uint):Array
29
+ {
30
+ /* append padding */
31
+ x[len >> 5] |= 0x80 << (24 - len % 32);
32
+ x[((len + 64 >> 9) << 4) + 15] = len;
33
+
34
+ var w:Array = [];
35
+ var a:uint = 0x67452301; //1732584193;
36
+ var b:uint = 0xEFCDAB89; //-271733879;
37
+ var c:uint = 0x98BADCFE; //-1732584194;
38
+ var d:uint = 0x10325476; //271733878;
39
+ var e:uint = 0xC3D2E1F0; //-1009589776;
40
+
41
+ for(var i:uint = 0; i < x.length; i += 16)
42
+ {
43
+
44
+ var olda:uint = a;
45
+ var oldb:uint = b;
46
+ var oldc:uint = c;
47
+ var oldd:uint = d;
48
+ var olde:uint = e;
49
+
50
+ for(var j:uint = 0; j < 80; j++)
51
+ {
52
+ if (j < 16) {
53
+ w[j] = x[i + j] || 0;
54
+ } else {
55
+ w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
56
+ }
57
+ var t:uint = rol(a,5) + ft(j,b,c,d) + e + w[j] + kt(j);
58
+ e = d;
59
+ d = c;
60
+ c = rol(b, 30);
61
+ b = a;
62
+ a = t;
63
+ }
64
+ a += olda;
65
+ b += oldb;
66
+ c += oldc;
67
+ d += oldd;
68
+ e += olde;
69
+ }
70
+ return [ a, b, c, d, e ];
71
+
72
+ }
73
+
74
+ /*
75
+ * Bitwise rotate a 32-bit number to the left.
76
+ */
77
+ private function rol(num:uint, cnt:uint):uint
78
+ {
79
+ return (num << cnt) | (num >>> (32 - cnt));
80
+ }
81
+
82
+ /*
83
+ * Perform the appropriate triplet combination function for the current
84
+ * iteration
85
+ */
86
+ private function ft(t:uint, b:uint, c:uint, d:uint):uint
87
+ {
88
+ if(t < 20) return (b & c) | ((~b) & d);
89
+ if(t < 40) return b ^ c ^ d;
90
+ if(t < 60) return (b & c) | (b & d) | (c & d);
91
+ return b ^ c ^ d;
92
+ }
93
+
94
+ /*
95
+ * Determine the appropriate additive constant for the current iteration
96
+ */
97
+ private function kt(t:uint):uint
98
+ {
99
+ return (t < 20) ? 0x5A827999 : (t < 40) ? 0x6ED9EBA1 :
100
+ (t < 60) ? 0x8F1BBCDC : 0xCA62C1D6;
101
+ }
102
+ public override function toString():String {
103
+ return "sha1";
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * SHA224
3
+ *
4
+ * An ActionScript 3 implementation of Secure Hash Algorithm, SHA-224, as defined
5
+ * in FIPS PUB 180-2
6
+ * Copyright (c) 2007 Henri Torgemane
7
+ *
8
+ * See LICENSE.txt for full license information.
9
+ */
10
+ package com.hurlant.crypto.hash
11
+ {
12
+ public class SHA224 extends SHA256
13
+ {
14
+ function SHA224() {
15
+ h = [
16
+ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
17
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
18
+ ];
19
+ }
20
+
21
+ public override function getHashSize():uint {
22
+ return 28;
23
+ }
24
+ public override function toString():String {
25
+ return "sha224";
26
+ }
27
+ }
28
+ }