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,28 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Memory
|
3
|
-
*
|
4
|
-
* A class with a few memory-management methods, as much as
|
5
|
-
* such a thing exists in a Flash player.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.util
|
11
|
-
{
|
12
|
-
import flash.net.LocalConnection;
|
13
|
-
import flash.system.System;
|
14
|
-
|
15
|
-
public class Memory
|
16
|
-
{
|
17
|
-
public static function gc():void {
|
18
|
-
// force a GC
|
19
|
-
try {
|
20
|
-
new LocalConnection().connect('foo');
|
21
|
-
new LocalConnection().connect('foo');
|
22
|
-
} catch (e:*) {}
|
23
|
-
}
|
24
|
-
public static function get used():uint {
|
25
|
-
return System.totalMemory;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* ByteString
|
3
|
-
*
|
4
|
-
* An ASN1 type for a ByteString, represented with a ByteArray
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.util.der
|
10
|
-
{
|
11
|
-
import flash.utils.ByteArray;
|
12
|
-
import com.hurlant.util.Hex;
|
13
|
-
|
14
|
-
public class ByteString extends ByteArray implements IAsn1Type
|
15
|
-
{
|
16
|
-
private var type:uint;
|
17
|
-
private var len:uint;
|
18
|
-
|
19
|
-
public function ByteString(type:uint = 0x04, length:uint = 0x00) {
|
20
|
-
this.type = type;
|
21
|
-
this.len = length;
|
22
|
-
}
|
23
|
-
|
24
|
-
public function getLength():uint
|
25
|
-
{
|
26
|
-
return len;
|
27
|
-
}
|
28
|
-
|
29
|
-
public function getType():uint
|
30
|
-
{
|
31
|
-
return type;
|
32
|
-
}
|
33
|
-
|
34
|
-
public function toDER():ByteArray {
|
35
|
-
return DER.wrapDER(type, this);
|
36
|
-
}
|
37
|
-
|
38
|
-
override public function toString():String {
|
39
|
-
return DER.indent+"ByteString["+type+"]["+len+"]["+Hex.fromArray(this)+"]";
|
40
|
-
}
|
41
|
-
|
42
|
-
}
|
43
|
-
}
|
@@ -1,210 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* DER
|
3
|
-
*
|
4
|
-
* A basic class to parse DER structures.
|
5
|
-
* It is very incomplete, but sufficient to extract whatever data we need so far.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.util.der
|
11
|
-
{
|
12
|
-
import com.hurlant.math.BigInteger;
|
13
|
-
|
14
|
-
import flash.utils.ByteArray;
|
15
|
-
import com.hurlant.util.der.Sequence;
|
16
|
-
import com.hurlant.util.Hex;
|
17
|
-
|
18
|
-
// goal 1: to be able to parse an RSA Private Key PEM file.
|
19
|
-
// goal 2: to parse an X509v3 cert. kinda.
|
20
|
-
|
21
|
-
/**
|
22
|
-
* DER for dummies:
|
23
|
-
* http://luca.ntop.org/Teaching/Appunti/asn1.html
|
24
|
-
*
|
25
|
-
* This class does the bare minimum to get by. if that.
|
26
|
-
*/
|
27
|
-
public class DER
|
28
|
-
{
|
29
|
-
public static var indent:String = "";
|
30
|
-
|
31
|
-
public static function parse(der:ByteArray, structure:*=null):IAsn1Type {
|
32
|
-
/* if (der.position==0) {
|
33
|
-
trace("DER.parse: "+Hex.fromArray(der));
|
34
|
-
}
|
35
|
-
*/ // type
|
36
|
-
var type:int = der.readUnsignedByte();
|
37
|
-
var constructed:Boolean = (type&0x20)!=0;
|
38
|
-
type &=0x1F;
|
39
|
-
// length
|
40
|
-
var len:int = der.readUnsignedByte();
|
41
|
-
if (len>=0x80) {
|
42
|
-
// long form of length
|
43
|
-
var count:int = len & 0x7f;
|
44
|
-
len = 0;
|
45
|
-
while (count>0) {
|
46
|
-
len = (len<<8) | der.readUnsignedByte();
|
47
|
-
count--;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
// data
|
51
|
-
var b:ByteArray
|
52
|
-
switch (type) {
|
53
|
-
case 0x00: // WHAT IS THIS THINGY? (seen as 0xa0)
|
54
|
-
// (note to self: read a spec someday.)
|
55
|
-
// for now, treat as a sequence.
|
56
|
-
case 0x10: // SEQUENCE/SEQUENCE OF. whatever
|
57
|
-
// treat as an array
|
58
|
-
var p:int = der.position;
|
59
|
-
var o:Sequence = new Sequence(type, len);
|
60
|
-
var arrayStruct:Array = structure as Array;
|
61
|
-
if (arrayStruct!=null) {
|
62
|
-
// copy the array, as we destroy it later.
|
63
|
-
arrayStruct = arrayStruct.concat();
|
64
|
-
}
|
65
|
-
while (der.position < p+len) {
|
66
|
-
var tmpStruct:Object = null
|
67
|
-
if (arrayStruct!=null) {
|
68
|
-
tmpStruct = arrayStruct.shift();
|
69
|
-
}
|
70
|
-
if (tmpStruct!=null) {
|
71
|
-
while (tmpStruct && tmpStruct.optional) {
|
72
|
-
// make sure we have something that looks reasonable. XXX I'm winging it here..
|
73
|
-
var wantConstructed:Boolean = (tmpStruct.value is Array);
|
74
|
-
var isConstructed:Boolean = isConstructedType(der);
|
75
|
-
if (wantConstructed!=isConstructed) {
|
76
|
-
// not found. put default stuff, or null
|
77
|
-
o.push(tmpStruct.defaultValue);
|
78
|
-
o[tmpStruct.name] = tmpStruct.defaultValue;
|
79
|
-
// try the next thing
|
80
|
-
tmpStruct = arrayStruct.shift();
|
81
|
-
} else {
|
82
|
-
break;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
if (tmpStruct!=null) {
|
87
|
-
var name:String = tmpStruct.name;
|
88
|
-
var value:* = tmpStruct.value;
|
89
|
-
if (tmpStruct.extract) {
|
90
|
-
// we need to keep a binary copy of this element
|
91
|
-
var size:int = getLengthOfNextElement(der);
|
92
|
-
var ba:ByteArray = new ByteArray;
|
93
|
-
ba.writeBytes(der, der.position, size);
|
94
|
-
o[name+"_bin"] = ba;
|
95
|
-
}
|
96
|
-
var obj:IAsn1Type = DER.parse(der, value);
|
97
|
-
o.push(obj);
|
98
|
-
o[name] = obj;
|
99
|
-
} else {
|
100
|
-
o.push(DER.parse(der));
|
101
|
-
}
|
102
|
-
}
|
103
|
-
return o;
|
104
|
-
case 0x11: // SET/SET OF
|
105
|
-
p = der.position;
|
106
|
-
var s:Set = new Set(type, len);
|
107
|
-
while (der.position < p+len) {
|
108
|
-
s.push(DER.parse(der));
|
109
|
-
}
|
110
|
-
return s;
|
111
|
-
case 0x02: // INTEGER
|
112
|
-
// put in a BigInteger
|
113
|
-
b = new ByteArray;
|
114
|
-
der.readBytes(b,0,len);
|
115
|
-
b.position=0;
|
116
|
-
return new Integer(type, len, b);
|
117
|
-
case 0x06: // OBJECT IDENTIFIER:
|
118
|
-
b = new ByteArray;
|
119
|
-
der.readBytes(b,0,len);
|
120
|
-
b.position=0;
|
121
|
-
return new ObjectIdentifier(type, len, b);
|
122
|
-
default:
|
123
|
-
trace("I DONT KNOW HOW TO HANDLE DER stuff of TYPE "+type);
|
124
|
-
// fall through
|
125
|
-
case 0x03: // BIT STRING
|
126
|
-
if (der[der.position]==0) {
|
127
|
-
//trace("Horrible Bit String pre-padding removal hack."); // I wish I had the patience to find a spec for this.
|
128
|
-
der.position++;
|
129
|
-
len--;
|
130
|
-
}
|
131
|
-
case 0x04: // OCTET STRING
|
132
|
-
// stuff in a ByteArray for now.
|
133
|
-
var bs:ByteString = new ByteString(type, len);
|
134
|
-
der.readBytes(bs,0,len);
|
135
|
-
return bs;
|
136
|
-
case 0x05: // NULL
|
137
|
-
// if len!=0, something's horribly wrong.
|
138
|
-
// should I check?
|
139
|
-
return null;
|
140
|
-
case 0x13: // PrintableString
|
141
|
-
var ps:PrintableString = new PrintableString(type, len);
|
142
|
-
ps.setString(der.readMultiByte(len, "US-ASCII"));
|
143
|
-
return ps;
|
144
|
-
case 0x22: // XXX look up what this is. openssl uses this to store my email.
|
145
|
-
case 0x14: // T61String - an horrible format we don't even pretend to support correctly
|
146
|
-
ps = new PrintableString(type, len);
|
147
|
-
ps.setString(der.readMultiByte(len, "latin1"));
|
148
|
-
return ps;
|
149
|
-
case 0x17: // UTCTime
|
150
|
-
var ut:UTCTime = new UTCTime(type, len);
|
151
|
-
ut.setUTCTime(der.readMultiByte(len, "US-ASCII"));
|
152
|
-
return ut;
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
private static function getLengthOfNextElement(b:ByteArray):int {
|
157
|
-
var p:uint = b.position;
|
158
|
-
// length
|
159
|
-
b.position++;
|
160
|
-
var len:int = b.readUnsignedByte();
|
161
|
-
if (len>=0x80) {
|
162
|
-
// long form of length
|
163
|
-
var count:int = len & 0x7f;
|
164
|
-
len = 0;
|
165
|
-
while (count>0) {
|
166
|
-
len = (len<<8) | b.readUnsignedByte();
|
167
|
-
count--;
|
168
|
-
}
|
169
|
-
}
|
170
|
-
len += b.position-p; // length of length
|
171
|
-
b.position = p;
|
172
|
-
return len;
|
173
|
-
}
|
174
|
-
private static function isConstructedType(b:ByteArray):Boolean {
|
175
|
-
var type:int = b[b.position];
|
176
|
-
return (type&0x20)!=0;
|
177
|
-
}
|
178
|
-
|
179
|
-
public static function wrapDER(type:int, data:ByteArray):ByteArray {
|
180
|
-
var d:ByteArray = new ByteArray;
|
181
|
-
d.writeByte(type);
|
182
|
-
var len:int = data.length;
|
183
|
-
if (len<128) {
|
184
|
-
d.writeByte(len);
|
185
|
-
} else if (len<256) {
|
186
|
-
d.writeByte(1 | 0x80);
|
187
|
-
d.writeByte(len);
|
188
|
-
} else if (len<65536) {
|
189
|
-
d.writeByte(2 | 0x80);
|
190
|
-
d.writeByte(len>>8);
|
191
|
-
d.writeByte(len);
|
192
|
-
} else if (len<65536*256) {
|
193
|
-
d.writeByte(3 | 0x80);
|
194
|
-
d.writeByte(len>>16);
|
195
|
-
d.writeByte(len>>8);
|
196
|
-
d.writeByte(len);
|
197
|
-
} else {
|
198
|
-
d.writeByte(4 | 0x80);
|
199
|
-
d.writeByte(len>>24);
|
200
|
-
d.writeByte(len>>16);
|
201
|
-
d.writeByte(len>>8);
|
202
|
-
d.writeByte(len);
|
203
|
-
}
|
204
|
-
d.writeBytes(data);
|
205
|
-
d.position=0;
|
206
|
-
return d;
|
207
|
-
|
208
|
-
}
|
209
|
-
}
|
210
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* IAsn1Type
|
3
|
-
*
|
4
|
-
* An interface for Asn-1 types.
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.util.der
|
10
|
-
{
|
11
|
-
import flash.utils.ByteArray;
|
12
|
-
|
13
|
-
public interface IAsn1Type
|
14
|
-
{
|
15
|
-
function getType():uint;
|
16
|
-
function getLength():uint;
|
17
|
-
|
18
|
-
function toDER():ByteArray;
|
19
|
-
|
20
|
-
}
|
21
|
-
}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Integer
|
3
|
-
*
|
4
|
-
* An ASN1 type for an Integer, represented with a BigInteger
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.util.der
|
10
|
-
{
|
11
|
-
import com.hurlant.math.BigInteger;
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
|
14
|
-
public class Integer extends BigInteger implements IAsn1Type
|
15
|
-
{
|
16
|
-
private var type:uint;
|
17
|
-
private var len:uint;
|
18
|
-
|
19
|
-
public function Integer(type:uint, length:uint, b:ByteArray) {
|
20
|
-
this.type = type;
|
21
|
-
this.len = length;
|
22
|
-
super(b);
|
23
|
-
}
|
24
|
-
|
25
|
-
public function getLength():uint
|
26
|
-
{
|
27
|
-
return len;
|
28
|
-
}
|
29
|
-
|
30
|
-
public function getType():uint
|
31
|
-
{
|
32
|
-
return type;
|
33
|
-
}
|
34
|
-
|
35
|
-
override public function toString(radix:Number=0):String {
|
36
|
-
return DER.indent+"Integer["+type+"]["+len+"]["+super.toString(16)+"]";
|
37
|
-
}
|
38
|
-
|
39
|
-
public function toDER():ByteArray {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
|
43
|
-
}
|
44
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* OID
|
3
|
-
*
|
4
|
-
* A list of various ObjectIdentifiers.
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.util.der
|
10
|
-
{
|
11
|
-
public class OID
|
12
|
-
{
|
13
|
-
|
14
|
-
public static const RSA_ENCRYPTION:String = "1.2.840.113549.1.1.1";
|
15
|
-
public static const MD2_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.2";
|
16
|
-
public static const MD5_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.4";
|
17
|
-
public static const SHA1_WITH_RSA_ENCRYPTION:String = "1.2.840.113549.1.1.5";
|
18
|
-
public static const MD2_ALGORITHM:String = "1.2.840.113549.2.2";
|
19
|
-
public static const MD5_ALGORITHM:String = "1.2.840.113549.2.5";
|
20
|
-
public static const DSA:String = "1.2.840.10040.4.1";
|
21
|
-
public static const DSA_WITH_SHA1:String = "1.2.840.10040.4.3";
|
22
|
-
public static const DH_PUBLIC_NUMBER:String = "1.2.840.10046.2.1";
|
23
|
-
public static const SHA1_ALGORITHM:String = "1.3.14.3.2.26";
|
24
|
-
|
25
|
-
public static const COMMON_NAME:String = "2.5.4.3";
|
26
|
-
public static const SURNAME:String = "2.5.4.4";
|
27
|
-
public static const COUNTRY_NAME:String = "2.5.4.6";
|
28
|
-
public static const LOCALITY_NAME:String = "2.5.4.7";
|
29
|
-
public static const STATE_NAME:String = "2.5.4.8";
|
30
|
-
public static const ORGANIZATION_NAME:String = "2.5.4.10";
|
31
|
-
public static const ORG_UNIT_NAME:String = "2.5.4.11";
|
32
|
-
public static const TITLE:String = "2.5.4.12";
|
33
|
-
|
34
|
-
}
|
35
|
-
}
|
@@ -1,112 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* ObjectIdentifier
|
3
|
-
*
|
4
|
-
* An ASN1 type for an ObjectIdentifier
|
5
|
-
* We store the oid in an Array.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.util.der
|
11
|
-
{
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
|
14
|
-
public class ObjectIdentifier implements IAsn1Type
|
15
|
-
{
|
16
|
-
private var type:uint;
|
17
|
-
private var len:uint;
|
18
|
-
private var oid:Array;
|
19
|
-
|
20
|
-
public function ObjectIdentifier(type:uint, length:uint, b:*) {
|
21
|
-
this.type = type;
|
22
|
-
this.len = length;
|
23
|
-
if (b is ByteArray) {
|
24
|
-
parse(b as ByteArray);
|
25
|
-
} else if (b is String) {
|
26
|
-
generate(b as String);
|
27
|
-
} else {
|
28
|
-
throw new Error("Invalid call to new ObjectIdentifier");
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
private function generate(s:String):void {
|
33
|
-
oid = s.split(".");
|
34
|
-
}
|
35
|
-
|
36
|
-
private function parse(b:ByteArray):void {
|
37
|
-
// parse stuff
|
38
|
-
// first byte = 40*value1 + value2
|
39
|
-
var o:uint = b.readUnsignedByte();
|
40
|
-
var a:Array = []
|
41
|
-
a.push(uint(o/40));
|
42
|
-
a.push(uint(o%40));
|
43
|
-
var v:uint = 0;
|
44
|
-
while (b.bytesAvailable>0) {
|
45
|
-
o = b.readUnsignedByte();
|
46
|
-
var last:Boolean = (o&0x80)==0;
|
47
|
-
o &= 0x7f;
|
48
|
-
v = v*128 + o;
|
49
|
-
if (last) {
|
50
|
-
a.push(v);
|
51
|
-
v = 0;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
oid = a;
|
55
|
-
}
|
56
|
-
|
57
|
-
public function getLength():uint
|
58
|
-
{
|
59
|
-
return len;
|
60
|
-
}
|
61
|
-
|
62
|
-
public function getType():uint
|
63
|
-
{
|
64
|
-
return type;
|
65
|
-
}
|
66
|
-
|
67
|
-
public function toDER():ByteArray {
|
68
|
-
var tmp:Array = [];
|
69
|
-
tmp[0] = oid[0]*40 + oid[1];
|
70
|
-
for (var i:int=2;i<oid.length;i++) {
|
71
|
-
var v:int = parseInt(oid[i]);
|
72
|
-
if (v<128) {
|
73
|
-
tmp.push(v);
|
74
|
-
} else if (v<128*128) {
|
75
|
-
tmp.push( (v>>7)|0x80 );
|
76
|
-
tmp.push( v&0x7f );
|
77
|
-
} else if (v<128*128*128) {
|
78
|
-
tmp.push( (v>>14)|0x80 );
|
79
|
-
tmp.push( (v>>7)&0x7f | 0x80 );
|
80
|
-
tmp.push( v&0x7f);
|
81
|
-
} else if (v<128*128*128*128) {
|
82
|
-
tmp.push( (v>>21)|0x80 );
|
83
|
-
tmp.push( (v>>14) & 0x7f | 0x80 );
|
84
|
-
tmp.push( (v>>7) & 0x7f | 0x80 );
|
85
|
-
tmp.push( v & 0x7f );
|
86
|
-
} else {
|
87
|
-
throw new Error("OID element bigger than we thought. :(");
|
88
|
-
}
|
89
|
-
}
|
90
|
-
len = tmp.length;
|
91
|
-
if (type==0) {
|
92
|
-
type = 6;
|
93
|
-
}
|
94
|
-
tmp.unshift(len); // assume length is small enough to fit here.
|
95
|
-
tmp.unshift(type);
|
96
|
-
var b:ByteArray = new ByteArray;
|
97
|
-
for (i=0;i<tmp.length;i++) {
|
98
|
-
b[i] = tmp[i];
|
99
|
-
}
|
100
|
-
return b;
|
101
|
-
}
|
102
|
-
|
103
|
-
public function toString():String {
|
104
|
-
return DER.indent+oid.join(".");
|
105
|
-
}
|
106
|
-
|
107
|
-
public function dump():String {
|
108
|
-
return "OID["+type+"]["+len+"]["+toString()+"]";
|
109
|
-
}
|
110
|
-
|
111
|
-
}
|
112
|
-
}
|