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.
- data/Rakefile +5 -52
- data/spec/ruby/spec_helper.rb +2 -1
- metadata +7 -129
- data/src/vendor/web-socket-js/FABridge.js +0 -604
- data/src/vendor/web-socket-js/README.txt +0 -109
- data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
- data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
- data/src/vendor/web-socket-js/flash-src/WebSocket.as +0 -473
- data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +0 -88
- data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +0 -19
- data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +0 -32
- data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +0 -943
- data/src/vendor/web-socket-js/flash-src/build.sh +0 -10
- data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +0 -204
- data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +0 -375
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +0 -287
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +0 -3235
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +0 -218
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +0 -57
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +0 -82
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +0 -27
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +0 -21
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +0 -137
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +0 -124
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +0 -204
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +0 -106
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +0 -28
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +0 -115
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +0 -71
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +0 -90
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +0 -20
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +0 -119
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +0 -142
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +0 -339
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +0 -2797
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +0 -375
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +0 -55
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +0 -61
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +0 -64
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +0 -58
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +0 -365
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +0 -86
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +0 -21
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +0 -15
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +0 -32
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +0 -21
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +0 -35
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +0 -110
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +0 -34
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +0 -52
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +0 -44
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +0 -44
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +0 -60
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +0 -42
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +0 -88
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +0 -94
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +0 -29
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +0 -2304
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +0 -1220
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +0 -58
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +0 -39
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +0 -148
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +0 -160
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +0 -71
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +0 -98
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +0 -109
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +0 -112
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +0 -151
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +0 -184
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +0 -20
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +0 -56
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +0 -58
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +0 -101
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +0 -92
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +0 -198
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +0 -58
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +0 -60
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +0 -51
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +0 -42
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +0 -59
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +0 -66
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +0 -102
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +0 -117
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +0 -14
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +0 -29
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +0 -24
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +0 -38
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +0 -171
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +0 -26
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +0 -340
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +0 -70
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +0 -151
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +0 -895
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +0 -39
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +0 -27
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +0 -197
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +0 -370
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +0 -26
- data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +0 -180
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +0 -90
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +0 -1543
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +0 -35
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +0 -11
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +0 -85
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +0 -34
- data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +0 -11
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +0 -25
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +0 -189
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +0 -66
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +0 -28
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +0 -43
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +0 -210
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +0 -21
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +0 -44
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +0 -35
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +0 -112
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +0 -118
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +0 -49
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +0 -90
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +0 -27
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +0 -94
- data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +0 -60
- data/src/vendor/web-socket-js/sample.html +0 -76
- data/src/vendor/web-socket-js/swfobject.js +0 -4
- data/src/vendor/web-socket-js/web_socket.js +0 -388
@@ -1,66 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* XTeaKeyTest
|
3
|
-
*
|
4
|
-
* A test class for XTeaKey
|
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.prng.Random;
|
12
|
-
import com.hurlant.crypto.symmetric.ECBMode;
|
13
|
-
import com.hurlant.crypto.symmetric.XTeaKey;
|
14
|
-
import com.hurlant.util.Hex;
|
15
|
-
|
16
|
-
import flash.utils.ByteArray;
|
17
|
-
import flash.utils.getTimer;
|
18
|
-
|
19
|
-
public class XTeaKeyTest extends TestCase
|
20
|
-
{
|
21
|
-
public function XTeaKeyTest(h:ITestHarness) {
|
22
|
-
super(h, "XTeaKey Test");
|
23
|
-
runTest(testGetBlockSize, "XTea Block Size");
|
24
|
-
runTest(testVectors, "XTea Test Vectors");
|
25
|
-
|
26
|
-
h.endTestCase();
|
27
|
-
}
|
28
|
-
|
29
|
-
public function testGetBlockSize():void {
|
30
|
-
var tea:XTeaKey = new XTeaKey(Hex.toArray("deadbabecafebeefdeadbabecafebeef"));
|
31
|
-
assert("tea blocksize", tea.getBlockSize()==8);
|
32
|
-
}
|
33
|
-
|
34
|
-
public function testVectors():void {
|
35
|
-
// blah.
|
36
|
-
// can't find working test vectors.
|
37
|
-
// algorithms should not get published without vectors :(
|
38
|
-
var keys:Array=[
|
39
|
-
"00000000000000000000000000000000",
|
40
|
-
"2b02056806144976775d0e266c287843"];
|
41
|
-
var pts:Array=[
|
42
|
-
"0000000000000000",
|
43
|
-
"74657374206d652e"];
|
44
|
-
var cts:Array=[
|
45
|
-
"2dc7e8d3695b0538",
|
46
|
-
"7909582138198783"];
|
47
|
-
// self-fullfilling vectors.
|
48
|
-
// oh well, at least I can decrypt what I produce. :(
|
49
|
-
|
50
|
-
for (var i:uint=0;i<keys.length;i++) {
|
51
|
-
var key:ByteArray = Hex.toArray(keys[i]);
|
52
|
-
var pt:ByteArray = Hex.toArray(pts[i]);
|
53
|
-
var tea:XTeaKey = new XTeaKey(key);
|
54
|
-
tea.encrypt(pt);
|
55
|
-
var out:String = Hex.fromArray(pt);
|
56
|
-
assert("comparing "+cts[i]+" to "+out, cts[i]==out);
|
57
|
-
// now go back to plaintext.
|
58
|
-
pt.position=0;
|
59
|
-
tea.decrypt(pt);
|
60
|
-
out = Hex.fromArray(pt);
|
61
|
-
assert("comparing "+pts[i]+" to "+out, pts[i]==out);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
}
|
66
|
-
}
|
@@ -1,102 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* BulkCiphers
|
3
|
-
*
|
4
|
-
* An enumeration of bulk ciphers available for TLS, along with their properties,
|
5
|
-
* with a few convenience methods to go with it.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.tls {
|
11
|
-
import com.hurlant.crypto.Crypto;
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
import com.hurlant.crypto.symmetric.ICipher;
|
14
|
-
import com.hurlant.crypto.symmetric.TLSPad;
|
15
|
-
import com.hurlant.crypto.symmetric.SSLPad;
|
16
|
-
|
17
|
-
public class BulkCiphers {
|
18
|
-
public static const STREAM_CIPHER:uint = 0;
|
19
|
-
public static const BLOCK_CIPHER:uint = 1;
|
20
|
-
|
21
|
-
public static const NULL:uint = 0;
|
22
|
-
public static const RC4_40:uint = 1;
|
23
|
-
public static const RC4_128:uint = 2
|
24
|
-
public static const RC2_CBC_40:uint = 3; // XXX I don't have that one.
|
25
|
-
public static const DES_CBC:uint = 4;
|
26
|
-
public static const DES3_EDE_CBC:uint = 5;
|
27
|
-
public static const DES40_CBC:uint = 6;
|
28
|
-
public static const IDEA_CBC:uint = 7; // XXX I don't have that one.
|
29
|
-
public static const AES_128:uint = 8;
|
30
|
-
public static const AES_256:uint = 9;
|
31
|
-
|
32
|
-
private static const algos:Array =
|
33
|
-
['', 'rc4', 'rc4', '', 'des-cbc', '3des-cbc', 'des-cbc', '', 'aes', 'aes'];
|
34
|
-
|
35
|
-
private static var _props:Array;
|
36
|
-
|
37
|
-
init();
|
38
|
-
private static function init():void {
|
39
|
-
_props = [];
|
40
|
-
_props[NULL] = new BulkCiphers(STREAM_CIPHER, 0, 0, 0, 0, 0);
|
41
|
-
_props[RC4_40] = new BulkCiphers(STREAM_CIPHER, 5, 16, 40, 0, 0);
|
42
|
-
_props[RC4_128] = new BulkCiphers(STREAM_CIPHER, 16, 16, 128, 0, 0);
|
43
|
-
_props[RC2_CBC_40] = new BulkCiphers( BLOCK_CIPHER, 5, 16, 40, 8, 8);
|
44
|
-
_props[DES_CBC] = new BulkCiphers( BLOCK_CIPHER, 8, 8, 56, 8, 8);
|
45
|
-
_props[DES3_EDE_CBC] = new BulkCiphers( BLOCK_CIPHER, 24, 24, 168, 8, 8);
|
46
|
-
_props[DES40_CBC] = new BulkCiphers( BLOCK_CIPHER, 5, 8, 40, 8, 8);
|
47
|
-
_props[IDEA_CBC] = new BulkCiphers( BLOCK_CIPHER, 16, 16, 128, 8, 8);
|
48
|
-
_props[AES_128] = new BulkCiphers( BLOCK_CIPHER, 16, 16, 128, 16, 16);
|
49
|
-
_props[AES_256] = new BulkCiphers( BLOCK_CIPHER, 32, 32, 256, 16, 16);
|
50
|
-
}
|
51
|
-
|
52
|
-
private static function getProp(cipher:uint):BulkCiphers {
|
53
|
-
var p:BulkCiphers = _props[cipher];
|
54
|
-
if (p==null) {
|
55
|
-
throw new Error("Unknown bulk cipher "+cipher.toString(16));
|
56
|
-
}
|
57
|
-
return p;
|
58
|
-
}
|
59
|
-
public static function getType(cipher:uint):uint {
|
60
|
-
return getProp(cipher).type;
|
61
|
-
}
|
62
|
-
public static function getKeyBytes(cipher:uint):uint {
|
63
|
-
return getProp(cipher).keyBytes;
|
64
|
-
}
|
65
|
-
public static function getExpandedKeyBytes(cipher:uint):uint {
|
66
|
-
return getProp(cipher).expandedKeyBytes;
|
67
|
-
}
|
68
|
-
public static function getEffectiveKeyBits(cipher:uint):uint {
|
69
|
-
return getProp(cipher).effectiveKeyBits;
|
70
|
-
}
|
71
|
-
public static function getIVSize(cipher:uint):uint {
|
72
|
-
return getProp(cipher).IVSize;
|
73
|
-
}
|
74
|
-
public static function getBlockSize(cipher:uint):uint {
|
75
|
-
return getProp(cipher).blockSize;
|
76
|
-
}
|
77
|
-
public static function getCipher(cipher:uint, key:ByteArray, proto:uint):ICipher {
|
78
|
-
if (proto == TLSSecurityParameters.PROTOCOL_VERSION) {
|
79
|
-
return Crypto.getCipher(algos[cipher], key, new TLSPad);
|
80
|
-
} else {
|
81
|
-
return Crypto.getCipher(algos[cipher], key, new SSLPad);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
private var type:uint;
|
87
|
-
private var keyBytes:uint;
|
88
|
-
private var expandedKeyBytes:uint;
|
89
|
-
private var effectiveKeyBits:uint;
|
90
|
-
private var IVSize:uint;
|
91
|
-
private var blockSize:uint;
|
92
|
-
|
93
|
-
public function BulkCiphers(t:uint, kb:uint, ekb:uint, fkb:uint, ivs:uint, bs:uint) {
|
94
|
-
type = t;
|
95
|
-
keyBytes = kb;
|
96
|
-
expandedKeyBytes = ekb;
|
97
|
-
effectiveKeyBits = fkb;
|
98
|
-
IVSize = ivs;
|
99
|
-
blockSize = bs;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
}
|
@@ -1,117 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* CipherSuites
|
3
|
-
*
|
4
|
-
* An enumeration of cipher-suites available for TLS to use, along with
|
5
|
-
* their properties, and some convenience methods
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.tls {
|
11
|
-
import com.hurlant.crypto.hash.MD5;
|
12
|
-
import com.hurlant.crypto.hash.SHA1;
|
13
|
-
|
14
|
-
public class CipherSuites {
|
15
|
-
|
16
|
-
|
17
|
-
// only the lines marked "ok" are currently implemented.
|
18
|
-
|
19
|
-
// rfc 2246
|
20
|
-
|
21
|
-
public static const TLS_NULL_WITH_NULL_NULL:uint = 0x0000; // ok
|
22
|
-
public static const TLS_RSA_WITH_NULL_MD5:uint = 0x0001; // ok
|
23
|
-
public static const TLS_RSA_WITH_NULL_SHA:uint = 0x0002; // ok
|
24
|
-
public static const TLS_RSA_WITH_RC4_128_MD5:uint = 0x0004; // ok
|
25
|
-
public static const TLS_RSA_WITH_RC4_128_SHA:uint = 0x0005; // ok
|
26
|
-
public static const TLS_RSA_WITH_IDEA_CBC_SHA:uint = 0x0007;
|
27
|
-
public static const TLS_RSA_WITH_DES_CBC_SHA:uint = 0x0009; // ok
|
28
|
-
public static const TLS_RSA_WITH_3DES_EDE_CBC_SHA:uint = 0x000A; // ok
|
29
|
-
|
30
|
-
public static const TLS_DH_DSS_WITH_DES_CBC_SHA:uint = 0x000C;
|
31
|
-
public static const TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:uint = 0x000D;
|
32
|
-
public static const TLS_DH_RSA_WITH_DES_CBC_SHA:uint = 0x000F;
|
33
|
-
public static const TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:uint = 0x0010;
|
34
|
-
public static const TLS_DHE_DSS_WITH_DES_CBC_SHA:uint = 0x0012;
|
35
|
-
public static const TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:uint = 0x0013;
|
36
|
-
public static const TLS_DHE_RSA_WITH_DES_CBC_SHA:uint = 0x0015;
|
37
|
-
public static const TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:uint = 0x0016;
|
38
|
-
|
39
|
-
public static const TLS_DH_anon_WITH_RC4_128_MD5:uint = 0x0018;
|
40
|
-
public static const TLS_DH_anon_WITH_DES_CBC_SHA:uint = 0x001A;
|
41
|
-
public static const TLS_DH_anon_WITH_3DES_EDE_CBC_SHA:uint = 0x001B;
|
42
|
-
|
43
|
-
// rfc3268
|
44
|
-
|
45
|
-
public static const TLS_RSA_WITH_AES_128_CBC_SHA:uint = 0x002F; // ok
|
46
|
-
public static const TLS_DH_DSS_WITH_AES_128_CBC_SHA:uint = 0x0030;
|
47
|
-
public static const TLS_DH_RSA_WITH_AES_128_CBC_SHA:uint = 0x0031;
|
48
|
-
public static const TLS_DHE_DSS_WITH_AES_128_CBC_SHA:uint = 0x0032;
|
49
|
-
public static const TLS_DHE_RSA_WITH_AES_128_CBC_SHA:uint = 0x0033;
|
50
|
-
public static const TLS_DH_anon_WITH_AES_128_CBC_SHA:uint = 0x0034;
|
51
|
-
|
52
|
-
public static const TLS_RSA_WITH_AES_256_CBC_SHA:uint = 0x0035; // ok
|
53
|
-
public static const TLS_DH_DSS_WITH_AES_256_CBC_SHA:uint = 0x0036;
|
54
|
-
public static const TLS_DH_RSA_WITH_AES_256_CBC_SHA:uint = 0x0037;
|
55
|
-
public static const TLS_DHE_DSS_WITH_AES_256_CBC_SHA:uint = 0x0038;
|
56
|
-
public static const TLS_DHE_RSA_WITH_AES_256_CBC_SHA:uint = 0x0039;
|
57
|
-
public static const TLS_DH_anon_WITH_AES_256_CBC_SHA:uint = 0x003A;
|
58
|
-
|
59
|
-
private static var _props:Array;
|
60
|
-
|
61
|
-
init();
|
62
|
-
private static function init():void {
|
63
|
-
_props = [];
|
64
|
-
_props[TLS_NULL_WITH_NULL_NULL] = new CipherSuites(BulkCiphers.NULL, MACs.NULL, KeyExchanges.NULL);
|
65
|
-
_props[TLS_RSA_WITH_NULL_MD5] = new CipherSuites(BulkCiphers.NULL, MACs.MD5, KeyExchanges.RSA);
|
66
|
-
_props[TLS_RSA_WITH_NULL_SHA] = new CipherSuites(BulkCiphers.NULL, MACs.SHA1, KeyExchanges.RSA);
|
67
|
-
_props[TLS_RSA_WITH_RC4_128_MD5] = new CipherSuites(BulkCiphers.RC4_128, MACs.MD5, KeyExchanges.RSA);
|
68
|
-
_props[TLS_RSA_WITH_RC4_128_SHA] = new CipherSuites(BulkCiphers.RC4_128, MACs.SHA1, KeyExchanges.RSA);
|
69
|
-
_props[TLS_RSA_WITH_DES_CBC_SHA] = new CipherSuites(BulkCiphers.DES_CBC, MACs.SHA1, KeyExchanges.RSA);
|
70
|
-
_props[TLS_RSA_WITH_3DES_EDE_CBC_SHA] = new CipherSuites(BulkCiphers.DES3_EDE_CBC, MACs.SHA1, KeyExchanges.RSA);
|
71
|
-
_props[TLS_RSA_WITH_AES_128_CBC_SHA] = new CipherSuites(BulkCiphers.AES_128, MACs.SHA1, KeyExchanges.RSA);
|
72
|
-
_props[TLS_RSA_WITH_AES_256_CBC_SHA] = new CipherSuites(BulkCiphers.AES_256, MACs.SHA1, KeyExchanges.RSA);
|
73
|
-
|
74
|
-
// ...
|
75
|
-
// more later
|
76
|
-
}
|
77
|
-
|
78
|
-
private static function getProp(cipher:uint):CipherSuites {
|
79
|
-
var p:CipherSuites = _props[cipher];
|
80
|
-
if (p==null) {
|
81
|
-
throw new Error("Unknown cipher "+cipher.toString(16));
|
82
|
-
}
|
83
|
-
return p;
|
84
|
-
}
|
85
|
-
public static function getBulkCipher(cipher:uint):uint {
|
86
|
-
return getProp(cipher).cipher;
|
87
|
-
}
|
88
|
-
public static function getMac(cipher:uint):uint {
|
89
|
-
return getProp(cipher).hash;
|
90
|
-
}
|
91
|
-
public static function getKeyExchange(cipher:uint):uint {
|
92
|
-
return getProp(cipher).key;
|
93
|
-
}
|
94
|
-
|
95
|
-
public static function getDefaultSuites():Array {
|
96
|
-
// a list of acceptable ciphers, sorted by preference.
|
97
|
-
return [
|
98
|
-
TLS_RSA_WITH_AES_256_CBC_SHA,
|
99
|
-
TLS_RSA_WITH_3DES_EDE_CBC_SHA,
|
100
|
-
TLS_RSA_WITH_AES_128_CBC_SHA,
|
101
|
-
TLS_RSA_WITH_RC4_128_SHA,
|
102
|
-
TLS_RSA_WITH_RC4_128_MD5,
|
103
|
-
TLS_RSA_WITH_DES_CBC_SHA
|
104
|
-
];
|
105
|
-
}
|
106
|
-
|
107
|
-
public var cipher:uint;
|
108
|
-
public var hash:uint;
|
109
|
-
public var key:uint;
|
110
|
-
|
111
|
-
public function CipherSuites(cipher:uint, hash:uint, key:uint) {
|
112
|
-
this.cipher = cipher;
|
113
|
-
this.hash = hash;
|
114
|
-
this.key = key;
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* IConnectionState
|
3
|
-
*
|
4
|
-
* Interface for TLS/SSL Connection states.
|
5
|
-
*
|
6
|
-
* See LICENSE.txt for full license information.
|
7
|
-
*/
|
8
|
-
package com.hurlant.crypto.tls {
|
9
|
-
import flash.utils.ByteArray;
|
10
|
-
public interface IConnectionState {
|
11
|
-
function decrypt(type:uint, length:uint, p:ByteArray) : ByteArray;
|
12
|
-
function encrypt(type:uint, p:ByteArray) : ByteArray;
|
13
|
-
}
|
14
|
-
}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* ISecurityParameters
|
3
|
-
*
|
4
|
-
* This class encapsulates all the security parameters that get negotiated
|
5
|
-
* during the TLS handshake. It also holds all the key derivation methods.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.tls {
|
11
|
-
import flash.utils.ByteArray;
|
12
|
-
|
13
|
-
public interface ISecurityParameters {
|
14
|
-
function get version() : uint;
|
15
|
-
function reset():void;
|
16
|
-
function getBulkCipher():uint;
|
17
|
-
function getCipherType():uint;
|
18
|
-
function getMacAlgorithm():uint;
|
19
|
-
function setCipher(cipher:uint):void;
|
20
|
-
function setCompression(algo:uint):void;
|
21
|
-
function setPreMasterSecret(secret:ByteArray):void;
|
22
|
-
function setClientRandom(secret:ByteArray):void;
|
23
|
-
function setServerRandom(secret:ByteArray):void;
|
24
|
-
function get useRSA():Boolean;
|
25
|
-
function computeVerifyData(side:uint, handshakeMessages:ByteArray):ByteArray;
|
26
|
-
function computeCertificateVerify( side:uint, handshakeRecords:ByteArray):ByteArray;
|
27
|
-
function getConnectionStates():Object;
|
28
|
-
}
|
29
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* KeyExchanges
|
3
|
-
*
|
4
|
-
* An enumeration of key exchange methods defined by TLS
|
5
|
-
* ( right now, only RSA is actually implemented )
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.tls {
|
11
|
-
public class KeyExchanges {
|
12
|
-
public static const NULL:uint = 0;
|
13
|
-
public static const RSA:uint = 1;
|
14
|
-
public static const DH_DSS:uint = 2;
|
15
|
-
public static const DH_RSA:uint = 3;
|
16
|
-
public static const DHE_DSS:uint = 4;
|
17
|
-
public static const DHE_RSA:uint = 5;
|
18
|
-
public static const DH_anon:uint = 6;
|
19
|
-
|
20
|
-
public static function useRSA(p:uint):Boolean {
|
21
|
-
return (p==RSA);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* MACs
|
3
|
-
*
|
4
|
-
* An enumeration of MACs implemented for TLS 1.0/SSL 3.0
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.crypto.tls {
|
10
|
-
import com.hurlant.crypto.Crypto;
|
11
|
-
import com.hurlant.crypto.hash.HMAC;
|
12
|
-
import com.hurlant.crypto.hash.MAC;
|
13
|
-
|
14
|
-
public class MACs {
|
15
|
-
public static const NULL:uint = 0;
|
16
|
-
public static const MD5:uint = 1;
|
17
|
-
public static const SHA1:uint = 2;
|
18
|
-
|
19
|
-
public static function getHashSize(hash:uint):uint {
|
20
|
-
return [0,16,20][hash];
|
21
|
-
}
|
22
|
-
|
23
|
-
public static function getPadSize(hash:uint):int {
|
24
|
-
return [0, 48, 40][hash];
|
25
|
-
}
|
26
|
-
|
27
|
-
public static function getHMAC(hash:uint):HMAC {
|
28
|
-
if (hash==NULL) return null;
|
29
|
-
return Crypto.getHMAC(['',"md5","sha1"][hash]);
|
30
|
-
}
|
31
|
-
|
32
|
-
public static function getMAC(hash:uint):MAC {
|
33
|
-
return Crypto.getMAC(['', "md5", "sha1"][hash]);
|
34
|
-
}
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
}
|
@@ -1,171 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* TLSConnectionState
|
3
|
-
*
|
4
|
-
* This class encapsulates the read or write state of a TLS connection,
|
5
|
-
* and implementes the encrypting and hashing of packets.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.tls {
|
11
|
-
import flash.utils.IDataInput;
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
import com.hurlant.crypto.hash.MD5;
|
14
|
-
import com.hurlant.crypto.hash.MAC;
|
15
|
-
import com.hurlant.crypto.hash.IHash;
|
16
|
-
import com.hurlant.crypto.symmetric.ICipher;
|
17
|
-
import com.hurlant.crypto.symmetric.IVMode;
|
18
|
-
import com.hurlant.util.Hex;
|
19
|
-
import com.hurlant.util.ArrayUtil;
|
20
|
-
|
21
|
-
public class SSLConnectionState implements IConnectionState {
|
22
|
-
|
23
|
-
// compression state
|
24
|
-
|
25
|
-
// cipher state
|
26
|
-
private var bulkCipher:uint;
|
27
|
-
private var cipherType:uint;
|
28
|
-
private var CIPHER_key:ByteArray;
|
29
|
-
private var CIPHER_IV:ByteArray;
|
30
|
-
private var cipher:ICipher;
|
31
|
-
private var ivmode:IVMode;
|
32
|
-
|
33
|
-
// mac secret
|
34
|
-
private var macAlgorithm:uint;
|
35
|
-
private var MAC_write_secret:ByteArray;
|
36
|
-
private var mac:MAC;
|
37
|
-
|
38
|
-
// sequence number. uint64
|
39
|
-
|
40
|
-
private var seq_lo:uint = 0x0;
|
41
|
-
private var seq_hi:uint = 0x0;
|
42
|
-
|
43
|
-
public function SSLConnectionState(
|
44
|
-
bulkCipher:uint=0, cipherType:uint=0, macAlgorithm:uint=0,
|
45
|
-
mac_enc:ByteArray=null, key:ByteArray=null, IV:ByteArray=null) {
|
46
|
-
this.bulkCipher = bulkCipher;
|
47
|
-
this.cipherType = cipherType;
|
48
|
-
this.macAlgorithm = macAlgorithm;
|
49
|
-
MAC_write_secret = mac_enc;
|
50
|
-
mac = MACs.getMAC(macAlgorithm);
|
51
|
-
|
52
|
-
CIPHER_key = key;
|
53
|
-
CIPHER_IV = IV;
|
54
|
-
cipher = BulkCiphers.getCipher(bulkCipher, key, 0x0300);
|
55
|
-
if (cipher is IVMode) {
|
56
|
-
ivmode = cipher as IVMode;
|
57
|
-
ivmode.IV = IV;
|
58
|
-
}
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
public function decrypt(type:uint, length:uint, p:ByteArray):ByteArray {
|
63
|
-
// decompression is a nop.
|
64
|
-
|
65
|
-
if (cipherType == BulkCiphers.STREAM_CIPHER) {
|
66
|
-
if (bulkCipher == BulkCiphers.NULL) {
|
67
|
-
// no-op
|
68
|
-
} else {
|
69
|
-
cipher.decrypt(p);
|
70
|
-
}
|
71
|
-
} else {
|
72
|
-
p.position = 0;
|
73
|
-
// block cipher
|
74
|
-
if (bulkCipher == BulkCiphers.NULL) {
|
75
|
-
|
76
|
-
} else {
|
77
|
-
var nextIV:ByteArray = new ByteArray;
|
78
|
-
nextIV.writeBytes(p, p.length-CIPHER_IV.length, CIPHER_IV.length);
|
79
|
-
p.position = 0;
|
80
|
-
cipher.decrypt(p);
|
81
|
-
|
82
|
-
CIPHER_IV = nextIV;
|
83
|
-
ivmode.IV = nextIV;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
if (macAlgorithm!=MACs.NULL) {
|
88
|
-
// there will be CTX delay here as well,
|
89
|
-
// I should probably optmize the hell out of it
|
90
|
-
var data:ByteArray = new ByteArray;
|
91
|
-
var len:uint = p.length - mac.getHashSize();
|
92
|
-
data.writeUnsignedInt(seq_hi);
|
93
|
-
data.writeUnsignedInt(seq_lo);
|
94
|
-
|
95
|
-
data.writeByte(type);
|
96
|
-
data.writeShort(len);
|
97
|
-
if (len!=0) {
|
98
|
-
data.writeBytes(p, 0, len);
|
99
|
-
}
|
100
|
-
var mac_enc:ByteArray = mac.compute(MAC_write_secret, data);
|
101
|
-
// compare "mac" with the last X bytes of p.
|
102
|
-
var mac_received:ByteArray = new ByteArray;
|
103
|
-
mac_received.writeBytes(p, len, mac.getHashSize());
|
104
|
-
if (ArrayUtil.equals(mac_enc, mac_received)) {
|
105
|
-
// happy happy joy joy
|
106
|
-
} else {
|
107
|
-
throw new TLSError("Bad Mac Data", TLSError.bad_record_mac);
|
108
|
-
}
|
109
|
-
p.length = len;
|
110
|
-
p.position = 0;
|
111
|
-
}
|
112
|
-
// increment seq
|
113
|
-
seq_lo++;
|
114
|
-
if (seq_lo==0) seq_hi++;
|
115
|
-
return p;
|
116
|
-
}
|
117
|
-
public function encrypt(type:uint, p:ByteArray):ByteArray {
|
118
|
-
var mac_enc:ByteArray = null;
|
119
|
-
if (macAlgorithm!=MACs.NULL) {
|
120
|
-
var data:ByteArray = new ByteArray;
|
121
|
-
// data.writeUnsignedInt(seq);
|
122
|
-
|
123
|
-
// Sequence
|
124
|
-
data.writeUnsignedInt(seq_hi);
|
125
|
-
data.writeUnsignedInt(seq_lo);
|
126
|
-
|
127
|
-
// Type
|
128
|
-
data.writeByte(type);
|
129
|
-
|
130
|
-
// Length
|
131
|
-
data.writeShort(p.length);
|
132
|
-
|
133
|
-
// The data
|
134
|
-
if (p.length!=0) {
|
135
|
-
data.writeBytes(p);
|
136
|
-
}
|
137
|
-
|
138
|
-
// trace("data for the MAC: " + Hex.fromArray(data));
|
139
|
-
mac_enc = mac.compute(MAC_write_secret, data);
|
140
|
-
// trace("MAC: " + Hex.fromArray( mac_enc ));
|
141
|
-
p.position = p.length;
|
142
|
-
p.writeBytes(mac_enc);
|
143
|
-
}
|
144
|
-
|
145
|
-
// trace("Record to encrypt: " + Hex.fromArray(p));
|
146
|
-
|
147
|
-
p.position = 0;
|
148
|
-
if (cipherType == BulkCiphers.STREAM_CIPHER) {
|
149
|
-
// stream cipher
|
150
|
-
if (bulkCipher == BulkCiphers.NULL) {
|
151
|
-
// no-op
|
152
|
-
} else {
|
153
|
-
cipher.encrypt(p);
|
154
|
-
}
|
155
|
-
} else {
|
156
|
-
// block cipher
|
157
|
-
cipher.encrypt(p);
|
158
|
-
// adjust IV
|
159
|
-
var nextIV:ByteArray = new ByteArray;
|
160
|
-
nextIV.writeBytes(p, p.length-CIPHER_IV.length, CIPHER_IV.length);
|
161
|
-
CIPHER_IV = nextIV;
|
162
|
-
ivmode.IV = nextIV;
|
163
|
-
}
|
164
|
-
// increment seq
|
165
|
-
seq_lo++;
|
166
|
-
if (seq_lo==0) seq_hi++;
|
167
|
-
return p;
|
168
|
-
}
|
169
|
-
|
170
|
-
}
|
171
|
-
}
|