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,86 +0,0 @@
1
- /**
2
- * ECBMode
3
- *
4
- * An ActionScript 3 implementation of the ECB confidentiality mode
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
- import com.hurlant.util.Memory;
13
- import com.hurlant.util.Hex;
14
-
15
- /**
16
- * ECB mode.
17
- * This uses a padding and a symmetric key.
18
- * If no padding is given, PKCS#5 is used.
19
- */
20
- public class ECBMode implements IMode, ICipher
21
- {
22
- private var key:ISymmetricKey;
23
- private var padding:IPad;
24
-
25
- public function ECBMode(key:ISymmetricKey, padding:IPad = null) {
26
- this.key = key;
27
- if (padding == null) {
28
- padding = new PKCS5(key.getBlockSize());
29
- } else {
30
- padding.setBlockSize(key.getBlockSize());
31
- }
32
- this.padding = padding;
33
- }
34
-
35
- public function getBlockSize():uint {
36
- return key.getBlockSize();
37
- }
38
-
39
- public function encrypt(src:ByteArray):void {
40
- padding.pad(src);
41
- src.position = 0;
42
- var blockSize:uint = key.getBlockSize();
43
- var tmp:ByteArray = new ByteArray;
44
- var dst:ByteArray = new ByteArray;
45
- for (var i:uint=0;i<src.length;i+=blockSize) {
46
- tmp.length=0;
47
- src.readBytes(tmp, 0, blockSize);
48
- key.encrypt(tmp);
49
- dst.writeBytes(tmp);
50
- }
51
- src.length=0;
52
- src.writeBytes(dst);
53
- }
54
- public function decrypt(src:ByteArray):void {
55
- src.position = 0;
56
- var blockSize:uint = key.getBlockSize();
57
-
58
- // sanity check.
59
- if (src.length%blockSize!=0) {
60
- throw new Error("ECB mode cipher length must be a multiple of blocksize "+blockSize);
61
- }
62
-
63
- var tmp:ByteArray = new ByteArray;
64
- var dst:ByteArray = new ByteArray;
65
- for (var i:uint=0;i<src.length;i+=blockSize) {
66
- tmp.length=0;
67
- src.readBytes(tmp, 0, blockSize);
68
-
69
- key.decrypt(tmp);
70
- dst.writeBytes(tmp);
71
- }
72
- padding.unpad(dst);
73
- src.length=0;
74
- src.writeBytes(dst);
75
- }
76
- public function dispose():void {
77
- key.dispose();
78
- key = null;
79
- padding = null;
80
- Memory.gc();
81
- }
82
- public function toString():String {
83
- return key.toString()+"-ecb";
84
- }
85
- }
86
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * ICipher
3
- *
4
- * A generic interface to use symmetric ciphers
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- public interface ICipher
14
- {
15
- function getBlockSize():uint;
16
- function encrypt(src:ByteArray):void;
17
- function decrypt(src:ByteArray):void;
18
- function dispose():void;
19
- function toString():String;
20
- }
21
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * IMode
3
- *
4
- * An interface for confidentiality modes to implement
5
- * This could become deprecated at some point.
6
- * Copyright (c) 2007 Henri Torgemane
7
- *
8
- * See LICENSE.txt for full license information.
9
- */
10
- package com.hurlant.crypto.symmetric
11
- {
12
- public interface IMode extends ICipher
13
- {
14
- }
15
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * IPad
3
- *
4
- * An interface for padding mechanisms to implement.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- /**
14
- * Tiny interface that represents a padding mechanism.
15
- */
16
- public interface IPad
17
- {
18
- /**
19
- * Add padding to the array
20
- */
21
- function pad(a:ByteArray):void;
22
- /**
23
- * Remove padding from the array.
24
- * @throws Error if the padding is invalid.
25
- */
26
- function unpad(a:ByteArray):void;
27
- /**
28
- * Set the blockSize to work on
29
- */
30
- function setBlockSize(bs:uint):void;
31
- }
32
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * IStreamCipher
3
- *
4
- * A "marker" interface for stream ciphers.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric {
10
-
11
- /**
12
- * A marker to indicate how this cipher works.
13
- * A stream cipher:
14
- * - does not use initialization vector
15
- * - keeps some internal state between calls to encrypt() and decrypt()
16
- *
17
- */
18
- public interface IStreamCipher extends ICipher {
19
-
20
- }
21
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * ISymmetricKey
3
- *
4
- * An interface for symmetric encryption keys to implement.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- public interface ISymmetricKey
14
- {
15
- /**
16
- * Returns the block size used by this particular encryption algorithm
17
- */
18
- function getBlockSize():uint;
19
- /**
20
- * Encrypt one block of data in "block", starting at "index", of length "getBlockSize()"
21
- */
22
- function encrypt(block:ByteArray, index:uint=0):void;
23
- /**
24
- * Decrypt one block of data in "block", starting at "index", of length "getBlockSize()"
25
- */
26
- function decrypt(block:ByteArray, index:uint=0):void;
27
- /**
28
- * Attempts to destroy sensitive information from memory, such as encryption keys.
29
- * Note: This is not guaranteed to work given the Flash sandbox model.
30
- */
31
- function dispose():void;
32
-
33
- function toString():String;
34
- }
35
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * IVMode
3
- *
4
- * An abstract class for confidentialy modes that rely on an initialization vector.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import com.hurlant.crypto.prng.Random;
12
- import com.hurlant.crypto.tests.TestCase;
13
- import com.hurlant.util.Memory;
14
-
15
- import flash.utils.ByteArray;
16
-
17
- /**
18
- * An "abtract" class to avoid redundant code in subclasses
19
- */
20
- public class IVMode
21
- {
22
- protected var key:ISymmetricKey;
23
- protected var padding:IPad;
24
- // random generator used to generate IVs
25
- protected var prng:Random;
26
- // optional static IV. used for testing only.
27
- protected var iv:ByteArray;
28
- // generated IV is stored here.
29
- protected var lastIV:ByteArray;
30
- protected var blockSize:uint;
31
-
32
-
33
- public function IVMode(key:ISymmetricKey, padding:IPad = null) {
34
- this.key = key;
35
- blockSize = key.getBlockSize();
36
- if (padding == null) {
37
- padding = new PKCS5(blockSize);
38
- } else {
39
- padding.setBlockSize(blockSize);
40
- }
41
- this.padding = padding;
42
-
43
- prng = new Random;
44
- iv = null;
45
- lastIV = new ByteArray;
46
- }
47
-
48
- public function getBlockSize():uint {
49
- return key.getBlockSize();
50
- }
51
- public function dispose():void {
52
- var i:uint;
53
- if (iv != null) {
54
- for (i=0;i<iv.length;i++) {
55
- iv[i] = prng.nextByte();
56
- }
57
- iv.length=0;
58
- iv = null;
59
- }
60
- if (lastIV != null) {
61
- for (i=0;i<iv.length;i++) {
62
- lastIV[i] = prng.nextByte();
63
- }
64
- lastIV.length=0;
65
- lastIV=null;
66
- }
67
- key.dispose();
68
- key = null;
69
- padding = null;
70
- prng.dispose();
71
- prng = null;
72
- Memory.gc();
73
- }
74
- /**
75
- * Optional function to force the IV value.
76
- * Normally, an IV gets generated randomly at every encrypt() call.
77
- * Also, use this to set the IV before calling decrypt()
78
- * (if not set before decrypt(), the IV is read from the beginning of the stream.)
79
- */
80
- public function set IV(value:ByteArray):void {
81
- iv = value;
82
- lastIV.length=0;
83
- lastIV.writeBytes(iv);
84
- }
85
- public function get IV():ByteArray {
86
- return lastIV;
87
- }
88
-
89
- protected function getIV4e():ByteArray {
90
- var vec:ByteArray = new ByteArray;
91
- if (iv) {
92
- vec.writeBytes(iv);
93
- } else {
94
- prng.nextBytes(vec, blockSize);
95
- }
96
- lastIV.length=0;
97
- lastIV.writeBytes(vec);
98
- return vec;
99
- }
100
- protected function getIV4d():ByteArray {
101
- var vec:ByteArray = new ByteArray;
102
- if (iv) {
103
- vec.writeBytes(iv);
104
- } else {
105
- throw new Error("an IV must be set before calling decrypt()");
106
- }
107
- return vec;
108
- }
109
- }
110
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * NullPad
3
- *
4
- * A padding class that doesn't pad.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- /**
14
- * A pad that does nothing.
15
- * Useful when you don't want padding in your Mode.
16
- */
17
- public class NullPad implements IPad
18
- {
19
- public function unpad(a:ByteArray):void
20
- {
21
- return;
22
- }
23
-
24
- public function pad(a:ByteArray):void
25
- {
26
- return;
27
- }
28
-
29
- public function setBlockSize(bs:uint):void {
30
- return;
31
- }
32
-
33
- }
34
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * OFBMode
3
- *
4
- * An ActionScript 3 implementation of the OFB confidentiality mode
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- public class OFBMode extends IVMode implements IMode
14
- {
15
- public function OFBMode(key:ISymmetricKey, padding:IPad=null)
16
- {
17
- super(key, null);
18
- }
19
-
20
- public function encrypt(src:ByteArray):void
21
- {
22
- var vector:ByteArray = getIV4e();
23
- core(src, vector);
24
- }
25
-
26
- public function decrypt(src:ByteArray):void
27
- {
28
- var vector:ByteArray = getIV4d();
29
- core(src, vector);
30
- }
31
-
32
- private function core(src:ByteArray, iv:ByteArray):void {
33
- var l:uint = src.length;
34
- var tmp:ByteArray = new ByteArray;
35
- for (var i:uint=0;i<src.length;i+=blockSize) {
36
- key.encrypt(iv);
37
- tmp.position=0;
38
- tmp.writeBytes(iv);
39
- var chunk:uint = (i+blockSize<l)?blockSize:l-i;
40
- for (var j:uint=0;j<chunk;j++) {
41
- src[i+j] ^= iv[j];
42
- }
43
- iv.position=0;
44
- iv.writeBytes(tmp);
45
- }
46
- }
47
- public function toString():String {
48
- return key.toString()+"-ofb";
49
- }
50
-
51
- }
52
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * PKCS5
3
- *
4
- * A padding implementation of PKCS5.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.crypto.symmetric
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- public class PKCS5 implements IPad
14
- {
15
- private var blockSize:uint;
16
-
17
- public function PKCS5(blockSize:uint=0) {
18
- this.blockSize = blockSize;
19
- }
20
-
21
- public function pad(a:ByteArray):void {
22
- var c:uint = blockSize-a.length%blockSize;
23
- for (var i:uint=0;i<c;i++){
24
- a[a.length] = c;
25
- }
26
- }
27
- public function unpad(a:ByteArray):void {
28
- var c:uint = a.length%blockSize;
29
- if (c!=0) throw new Error("PKCS#5::unpad: ByteArray.length isn't a multiple of the blockSize");
30
- c = a[a.length-1];
31
- for (var i:uint=c;i>0;i--) {
32
- var v:uint = a[a.length-1];
33
- a.length--;
34
- if (c!=v) throw new Error("PKCS#5:unpad: Invalid padding value. expected ["+c+"], found ["+v+"]");
35
- }
36
- // that is all.
37
- }
38
-
39
- public function setBlockSize(bs:uint):void {
40
- blockSize = bs;
41
- }
42
-
43
- }
44
- }