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,218 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* X509Certificate
|
3
|
-
*
|
4
|
-
* A representation for a X509 Certificate, with
|
5
|
-
* methods to parse, verify and sign it.
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.cert {
|
11
|
-
import com.hurlant.crypto.hash.IHash;
|
12
|
-
import com.hurlant.crypto.hash.MD2;
|
13
|
-
import com.hurlant.crypto.hash.MD5;
|
14
|
-
import com.hurlant.crypto.hash.SHA1;
|
15
|
-
import com.hurlant.crypto.rsa.RSAKey;
|
16
|
-
import com.hurlant.util.ArrayUtil;
|
17
|
-
import com.hurlant.util.Base64;
|
18
|
-
import com.hurlant.util.der.ByteString;
|
19
|
-
import com.hurlant.util.der.DER;
|
20
|
-
import com.hurlant.util.der.OID;
|
21
|
-
import com.hurlant.util.der.ObjectIdentifier;
|
22
|
-
import com.hurlant.util.der.PEM;
|
23
|
-
import com.hurlant.util.der.PrintableString;
|
24
|
-
import com.hurlant.util.der.Sequence;
|
25
|
-
import com.hurlant.util.der.Type;
|
26
|
-
|
27
|
-
import flash.utils.ByteArray;
|
28
|
-
|
29
|
-
public class X509Certificate {
|
30
|
-
private var _loaded:Boolean;
|
31
|
-
private var _param:*;
|
32
|
-
private var _obj:Object;
|
33
|
-
public function X509Certificate(p:*) {
|
34
|
-
_loaded = false;
|
35
|
-
_param = p;
|
36
|
-
// lazy initialization, to avoid unnecessary parsing of every builtin CA at start-up.
|
37
|
-
}
|
38
|
-
private function load():void {
|
39
|
-
if (_loaded) return;
|
40
|
-
var p:* = _param;
|
41
|
-
var b:ByteArray;
|
42
|
-
if (p is String) {
|
43
|
-
b = PEM.readCertIntoArray(p as String);
|
44
|
-
} else if (p is ByteArray) {
|
45
|
-
b = p;
|
46
|
-
}
|
47
|
-
if (b!=null) {
|
48
|
-
_obj = DER.parse(b, Type.TLS_CERT);
|
49
|
-
_loaded = true;
|
50
|
-
} else {
|
51
|
-
throw new Error("Invalid x509 Certificate parameter: "+p);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
public function isSigned(store:X509CertificateCollection, CAs:X509CertificateCollection, time:Date=null):Boolean {
|
55
|
-
load();
|
56
|
-
// check timestamps first. cheapest.
|
57
|
-
if (time==null) {
|
58
|
-
time = new Date;
|
59
|
-
}
|
60
|
-
var notBefore:Date = getNotBefore();
|
61
|
-
var notAfter:Date = getNotAfter();
|
62
|
-
if (time.getTime()<notBefore.getTime()) return false; // cert isn't born yet.
|
63
|
-
if (time.getTime()>notAfter.getTime()) return false; // cert died of old age.
|
64
|
-
// check signature.
|
65
|
-
var subject:String = getIssuerPrincipal();
|
66
|
-
// try from CA first, since they're treated better.
|
67
|
-
var parent:X509Certificate = CAs.getCertificate(subject);
|
68
|
-
var parentIsAuthoritative:Boolean = false;
|
69
|
-
if (parent == null) {
|
70
|
-
parent = store.getCertificate(subject);
|
71
|
-
if (parent == null) {
|
72
|
-
return false; // issuer not found
|
73
|
-
}
|
74
|
-
} else {
|
75
|
-
parentIsAuthoritative = true;
|
76
|
-
}
|
77
|
-
if (parent == this) { // pathological case. avoid infinite loop
|
78
|
-
return false; // isSigned() returns false if we're self-signed.
|
79
|
-
}
|
80
|
-
if (!(parentIsAuthoritative&&parent.isSelfSigned(time)) &&
|
81
|
-
!parent.isSigned(store, CAs, time)) {
|
82
|
-
return false;
|
83
|
-
}
|
84
|
-
var key:RSAKey = parent.getPublicKey();
|
85
|
-
return verifyCertificate(key);
|
86
|
-
}
|
87
|
-
public function isSelfSigned(time:Date):Boolean {
|
88
|
-
load();
|
89
|
-
|
90
|
-
var key:RSAKey = getPublicKey();
|
91
|
-
return verifyCertificate(key);
|
92
|
-
}
|
93
|
-
private function verifyCertificate(key:RSAKey):Boolean {
|
94
|
-
var algo:String = getAlgorithmIdentifier();
|
95
|
-
var hash:IHash;
|
96
|
-
var oid:String;
|
97
|
-
switch (algo) {
|
98
|
-
case OID.SHA1_WITH_RSA_ENCRYPTION:
|
99
|
-
hash = new SHA1;
|
100
|
-
oid = OID.SHA1_ALGORITHM;
|
101
|
-
break;
|
102
|
-
case OID.MD2_WITH_RSA_ENCRYPTION:
|
103
|
-
hash = new MD2;
|
104
|
-
oid = OID.MD2_ALGORITHM;
|
105
|
-
break;
|
106
|
-
case OID.MD5_WITH_RSA_ENCRYPTION:
|
107
|
-
hash = new MD5;
|
108
|
-
oid = OID.MD5_ALGORITHM;
|
109
|
-
break;
|
110
|
-
default:
|
111
|
-
return false;
|
112
|
-
}
|
113
|
-
var data:ByteArray = _obj.signedCertificate_bin;
|
114
|
-
var buf:ByteArray = new ByteArray;
|
115
|
-
key.verify(_obj.encrypted, buf, _obj.encrypted.length);
|
116
|
-
buf.position=0;
|
117
|
-
data = hash.hash(data);
|
118
|
-
var obj:Object = DER.parse(buf, Type.RSA_SIGNATURE);
|
119
|
-
if (obj.algorithm.algorithmId.toString() != oid) {
|
120
|
-
return false; // wrong algorithm
|
121
|
-
}
|
122
|
-
if (!ArrayUtil.equals(obj.hash, data)) {
|
123
|
-
return false; // hashes don't match
|
124
|
-
}
|
125
|
-
return true;
|
126
|
-
}
|
127
|
-
|
128
|
-
/**
|
129
|
-
* This isn't used anywhere so far.
|
130
|
-
* It would become useful if we started to offer facilities
|
131
|
-
* to generate and sign X509 certificates.
|
132
|
-
*
|
133
|
-
* @param key
|
134
|
-
* @param algo
|
135
|
-
* @return
|
136
|
-
*
|
137
|
-
*/
|
138
|
-
private function signCertificate(key:RSAKey, algo:String):ByteArray {
|
139
|
-
var hash:IHash;
|
140
|
-
var oid:String;
|
141
|
-
switch (algo) {
|
142
|
-
case OID.SHA1_WITH_RSA_ENCRYPTION:
|
143
|
-
hash = new SHA1;
|
144
|
-
oid = OID.SHA1_ALGORITHM;
|
145
|
-
break;
|
146
|
-
case OID.MD2_WITH_RSA_ENCRYPTION:
|
147
|
-
hash = new MD2;
|
148
|
-
oid = OID.MD2_ALGORITHM;
|
149
|
-
break;
|
150
|
-
case OID.MD5_WITH_RSA_ENCRYPTION:
|
151
|
-
hash = new MD5;
|
152
|
-
oid = OID.MD5_ALGORITHM;
|
153
|
-
break;
|
154
|
-
default:
|
155
|
-
return null
|
156
|
-
}
|
157
|
-
var data:ByteArray = _obj.signedCertificate_bin;
|
158
|
-
data = hash.hash(data);
|
159
|
-
var seq1:Sequence = new Sequence;
|
160
|
-
seq1[0] = new Sequence;
|
161
|
-
seq1[0][0] = new ObjectIdentifier(0,0, oid);
|
162
|
-
seq1[0][1] = null;
|
163
|
-
seq1[1] = new ByteString;
|
164
|
-
seq1[1].writeBytes(data);
|
165
|
-
data = seq1.toDER();
|
166
|
-
var buf:ByteArray = new ByteArray;
|
167
|
-
key.sign(data, buf, data.length);
|
168
|
-
return buf;
|
169
|
-
}
|
170
|
-
|
171
|
-
public function getPublicKey():RSAKey {
|
172
|
-
load();
|
173
|
-
var pk:ByteArray = _obj.signedCertificate.subjectPublicKeyInfo.subjectPublicKey as ByteArray;
|
174
|
-
pk.position = 0;
|
175
|
-
var rsaKey:Object = DER.parse(pk, [{name:"N"},{name:"E"}]);
|
176
|
-
return new RSAKey(rsaKey.N, rsaKey.E.valueOf());
|
177
|
-
}
|
178
|
-
|
179
|
-
/**
|
180
|
-
* Returns a subject principal, as an opaque base64 string.
|
181
|
-
* This is only used as a hash key for known certificates.
|
182
|
-
*
|
183
|
-
* Note that this assumes X509 DER-encoded certificates are uniquely encoded,
|
184
|
-
* as we look for exact matches between Issuer and Subject fields.
|
185
|
-
*
|
186
|
-
*/
|
187
|
-
public function getSubjectPrincipal():String {
|
188
|
-
load();
|
189
|
-
return Base64.encodeByteArray(_obj.signedCertificate.subject_bin);
|
190
|
-
}
|
191
|
-
/**
|
192
|
-
* Returns an issuer principal, as an opaque base64 string.
|
193
|
-
* This is only used to quickly find matching parent certificates.
|
194
|
-
*
|
195
|
-
* Note that this assumes X509 DER-encoded certificates are uniquely encoded,
|
196
|
-
* as we look for exact matches between Issuer and Subject fields.
|
197
|
-
*
|
198
|
-
*/
|
199
|
-
public function getIssuerPrincipal():String {
|
200
|
-
load();
|
201
|
-
return Base64.encodeByteArray(_obj.signedCertificate.issuer_bin);
|
202
|
-
}
|
203
|
-
public function getAlgorithmIdentifier():String {
|
204
|
-
return _obj.algorithmIdentifier.algorithmId.toString();
|
205
|
-
}
|
206
|
-
public function getNotBefore():Date {
|
207
|
-
return _obj.signedCertificate.validity.notBefore.date;
|
208
|
-
}
|
209
|
-
public function getNotAfter():Date {
|
210
|
-
return _obj.signedCertificate.validity.notAfter.date;
|
211
|
-
}
|
212
|
-
|
213
|
-
public function getCommonName():String {
|
214
|
-
var subject:Sequence = _obj.signedCertificate.subject;
|
215
|
-
return (subject.findAttributeValue(OID.COMMON_NAME) as PrintableString).getString();
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* X509CertificateCollection
|
3
|
-
*
|
4
|
-
* A class to store and index X509 Certificates by Subject.
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.crypto.cert {
|
10
|
-
|
11
|
-
public class X509CertificateCollection {
|
12
|
-
|
13
|
-
private var _map:Object;
|
14
|
-
|
15
|
-
public function X509CertificateCollection() {
|
16
|
-
_map = {};
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Mostly meant for built-in CA loading.
|
21
|
-
* This entry-point allows to index CAs without parsing them.
|
22
|
-
*
|
23
|
-
* @param name A friendly name. not currently used
|
24
|
-
* @param subject base64 DER encoded Subject principal for the Cert
|
25
|
-
* @param pem PEM encoded certificate data
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
public function addPEMCertificate(name:String, subject:String, pem:String):void {
|
29
|
-
_map[subject] = new X509Certificate(pem);
|
30
|
-
}
|
31
|
-
|
32
|
-
/**
|
33
|
-
* Adds a X509 certificate to the collection.
|
34
|
-
* This call will force the certificate to be parsed.
|
35
|
-
*
|
36
|
-
* @param cert A X509 certificate
|
37
|
-
*
|
38
|
-
*/
|
39
|
-
public function addCertificate(cert:X509Certificate):void {
|
40
|
-
var subject:String = cert.getSubjectPrincipal();
|
41
|
-
_map[subject] = cert;
|
42
|
-
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Returns a X509 Certificate present in the collection, given
|
46
|
-
* a base64 DER encoded X500 Subject principal
|
47
|
-
*
|
48
|
-
* @param subject A Base64 DER-encoded Subject principal
|
49
|
-
* @return A matching certificate, or null.
|
50
|
-
*
|
51
|
-
*/
|
52
|
-
public function getCertificate(subject:String):X509Certificate {
|
53
|
-
return _map[subject];
|
54
|
-
}
|
55
|
-
|
56
|
-
}
|
57
|
-
}
|
@@ -1,82 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* HMAC
|
3
|
-
*
|
4
|
-
* An ActionScript 3 implementation of HMAC, Keyed-Hashing for Message
|
5
|
-
* Authentication, as defined by RFC-2104
|
6
|
-
* Copyright (c) 2007 Henri Torgemane
|
7
|
-
*
|
8
|
-
* See LICENSE.txt for full license information.
|
9
|
-
*/
|
10
|
-
package com.hurlant.crypto.hash
|
11
|
-
{
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
import com.hurlant.util.Hex;
|
14
|
-
|
15
|
-
public class HMAC implements IHMAC
|
16
|
-
{
|
17
|
-
private var hash:IHash;
|
18
|
-
private var bits:uint;
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Create a HMAC object, using a Hash function, and
|
22
|
-
* optionally a number of bits to return.
|
23
|
-
* The HMAC will be truncated to that size if needed.
|
24
|
-
*/
|
25
|
-
public function HMAC(hash:IHash, bits:uint=0) {
|
26
|
-
this.hash = hash;
|
27
|
-
this.bits = bits;
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
public function getHashSize():uint {
|
32
|
-
if (bits!=0) {
|
33
|
-
return bits/8;
|
34
|
-
} else {
|
35
|
-
return hash.getHashSize();
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Compute a HMAC using a key and some data.
|
41
|
-
* It doesn't modify either, and returns a new ByteArray with the HMAC value.
|
42
|
-
*/
|
43
|
-
public function compute(key:ByteArray, data:ByteArray):ByteArray {
|
44
|
-
var hashKey:ByteArray;
|
45
|
-
if (key.length>hash.getInputSize()) {
|
46
|
-
hashKey = hash.hash(key);
|
47
|
-
} else {
|
48
|
-
hashKey = new ByteArray;
|
49
|
-
hashKey.writeBytes(key);
|
50
|
-
}
|
51
|
-
while (hashKey.length<hash.getInputSize()) {
|
52
|
-
hashKey[hashKey.length]=0;
|
53
|
-
}
|
54
|
-
var innerKey:ByteArray = new ByteArray;
|
55
|
-
var outerKey:ByteArray = new ByteArray;
|
56
|
-
for (var i:uint=0;i<hashKey.length;i++) {
|
57
|
-
innerKey[i] = hashKey[i] ^ 0x36;
|
58
|
-
outerKey[i] = hashKey[i] ^ 0x5c;
|
59
|
-
}
|
60
|
-
// inner + data
|
61
|
-
innerKey.position = hashKey.length;
|
62
|
-
innerKey.writeBytes(data);
|
63
|
-
var innerHash:ByteArray = hash.hash(innerKey);
|
64
|
-
// outer + innerHash
|
65
|
-
outerKey.position = hashKey.length;
|
66
|
-
outerKey.writeBytes(innerHash);
|
67
|
-
var outerHash:ByteArray = hash.hash(outerKey);
|
68
|
-
if (bits>0 && bits<8*outerHash.length) {
|
69
|
-
outerHash.length = bits/8;
|
70
|
-
}
|
71
|
-
return outerHash;
|
72
|
-
}
|
73
|
-
public function dispose():void {
|
74
|
-
hash = null;
|
75
|
-
bits = 0;
|
76
|
-
}
|
77
|
-
public function toString():String {
|
78
|
-
return "hmac-"+(bits>0?bits+"-":"")+hash.toString();
|
79
|
-
}
|
80
|
-
|
81
|
-
}
|
82
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* HMAC
|
3
|
-
*
|
4
|
-
* An ActionScript 3 interface for HMAC & MAC
|
5
|
-
* implementations.
|
6
|
-
*
|
7
|
-
* Loosely copyrighted by Bobby Parker
|
8
|
-
*
|
9
|
-
* See LICENSE.txt for full license information.
|
10
|
-
*/
|
11
|
-
package com.hurlant.crypto.hash
|
12
|
-
{
|
13
|
-
import flash.utils.ByteArray;
|
14
|
-
|
15
|
-
public interface IHMAC
|
16
|
-
{
|
17
|
-
function getHashSize():uint;
|
18
|
-
/**
|
19
|
-
* Compute a HMAC using a key and some data.
|
20
|
-
* It doesn't modify either, and returns a new ByteArray with the HMAC value.
|
21
|
-
*/
|
22
|
-
function compute(key:ByteArray, data:ByteArray):ByteArray;
|
23
|
-
function dispose():void;
|
24
|
-
function toString():String;
|
25
|
-
|
26
|
-
}
|
27
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* IHash
|
3
|
-
*
|
4
|
-
* An interface for each hash function to implement
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.crypto.hash
|
10
|
-
{
|
11
|
-
import flash.utils.ByteArray;
|
12
|
-
|
13
|
-
public interface IHash
|
14
|
-
{
|
15
|
-
function getInputSize():uint;
|
16
|
-
function getHashSize():uint;
|
17
|
-
function hash(src:ByteArray):ByteArray;
|
18
|
-
function toString():String;
|
19
|
-
function getPadSize():int;
|
20
|
-
}
|
21
|
-
}
|
@@ -1,137 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* MAC
|
3
|
-
*
|
4
|
-
* An ActionScript 3 implementation of MAC, Message Authentication Code
|
5
|
-
* for use with SSL 3.0.
|
6
|
-
* Loosely copyrighted by Bobby Parker.
|
7
|
-
* As3crypto copyrighted by Henri Torgemane.
|
8
|
-
*
|
9
|
-
* See LICENSE.txt for full license information.
|
10
|
-
*/
|
11
|
-
package com.hurlant.crypto.hash
|
12
|
-
{
|
13
|
-
import flash.utils.ByteArray;
|
14
|
-
import com.hurlant.util.Hex;
|
15
|
-
|
16
|
-
public class MAC implements IHMAC
|
17
|
-
{
|
18
|
-
private var hash:IHash;
|
19
|
-
private var bits:uint;
|
20
|
-
private var pad_1:ByteArray;
|
21
|
-
private var pad_2:ByteArray;
|
22
|
-
private var innerHash:ByteArray;
|
23
|
-
private var outerHash:ByteArray;
|
24
|
-
private var outerKey:ByteArray;
|
25
|
-
private var innerKey:ByteArray;
|
26
|
-
/**
|
27
|
-
* Create a MAC object (for SSL 3.0 ) and
|
28
|
-
* optionally a number of bits to return.
|
29
|
-
* The MAC will be truncated to that size if needed.
|
30
|
-
*/
|
31
|
-
public function MAC(hash:IHash, bits:uint=0) {
|
32
|
-
this.hash = hash;
|
33
|
-
this.bits = bits;
|
34
|
-
innerHash = new ByteArray();
|
35
|
-
outerHash = new ByteArray();
|
36
|
-
innerKey = new ByteArray();
|
37
|
-
outerKey = new ByteArray();
|
38
|
-
|
39
|
-
|
40
|
-
if (hash != null) {
|
41
|
-
var pad_size:int = hash.getPadSize();
|
42
|
-
pad_1 = new ByteArray();
|
43
|
-
pad_2 = new ByteArray();
|
44
|
-
|
45
|
-
for (var x:int = 0; x < pad_size; x++) {
|
46
|
-
pad_1.writeByte(0x36);
|
47
|
-
pad_2.writeByte(0x5c);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
public function setPadSize(pad_size:int) : void { }
|
53
|
-
|
54
|
-
public function getHashSize():uint {
|
55
|
-
if (bits!=0) {
|
56
|
-
return bits/8;
|
57
|
-
} else {
|
58
|
-
return hash.getHashSize();
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Compute a MAC using a key and some data.
|
65
|
-
*
|
66
|
-
*/
|
67
|
-
public function compute(key:ByteArray, data:ByteArray):ByteArray {
|
68
|
-
// take that incoming key and do hash(key + pad_2 + hash(key + pad_1 + sequence + length + record)
|
69
|
-
// note that data = (sequence + type + length + record)
|
70
|
-
|
71
|
-
if (pad_1 == null) {
|
72
|
-
var pad_size:int = hash.getPadSize();
|
73
|
-
pad_1 = new ByteArray();
|
74
|
-
pad_2 = new ByteArray();
|
75
|
-
|
76
|
-
for (var x:int = 0; x < pad_size; x++) {
|
77
|
-
pad_1.writeByte(0x36);
|
78
|
-
pad_2.writeByte(0x5c);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
// Do some preliminary checking on stuff
|
83
|
-
/*
|
84
|
-
if (key.length > hash.getInputSize()) {
|
85
|
-
hashKey = hash.hash(key);
|
86
|
-
} else {
|
87
|
-
hashKey = new ByteArray;
|
88
|
-
hashKey.writeBytes(key);
|
89
|
-
}
|
90
|
-
|
91
|
-
while (hashKey.length < hash.getInputSize() ) {
|
92
|
-
hashKey[hashKey.length] = 0;
|
93
|
-
} */
|
94
|
-
// Henri's conventions work just fine here..
|
95
|
-
|
96
|
-
innerKey.length = 0;
|
97
|
-
outerKey.length = 0;
|
98
|
-
// trace("MAC Key: " + Hex.fromArray(key));
|
99
|
-
// trace("Key Length: " + key.length);
|
100
|
-
// trace("Pad_1 : " + Hex.fromArray(pad_1));
|
101
|
-
// inner hash calc
|
102
|
-
innerKey.writeBytes(key);
|
103
|
-
innerKey.writeBytes(pad_1);
|
104
|
-
innerKey.writeBytes(data);
|
105
|
-
// trace("MAC Inner Key: " + Hex.fromArray(innerKey));
|
106
|
-
|
107
|
-
innerHash = hash.hash(innerKey);
|
108
|
-
// trace("MAC Inner Hash: " + Hex.fromArray(innerHash));
|
109
|
-
|
110
|
-
// outer hash calc
|
111
|
-
outerKey.writeBytes(key);
|
112
|
-
outerKey.writeBytes(pad_2);
|
113
|
-
outerKey.writeBytes(innerHash);
|
114
|
-
|
115
|
-
// trace("MAC Outer Key: " + Hex.fromArray(outerKey));
|
116
|
-
outerHash = hash.hash(outerKey);
|
117
|
-
|
118
|
-
|
119
|
-
if (bits > 0 && bits < 8*outerHash.length) {
|
120
|
-
outerHash.length = bits/8;
|
121
|
-
}
|
122
|
-
|
123
|
-
// trace("MAC for record: " + Hex.fromArray(outerHash));
|
124
|
-
return outerHash;
|
125
|
-
|
126
|
-
}
|
127
|
-
|
128
|
-
public function dispose():void {
|
129
|
-
hash = null;
|
130
|
-
bits = 0;
|
131
|
-
}
|
132
|
-
public function toString():String {
|
133
|
-
return "mac-"+(bits>0?bits+"-":"")+hash.toString();
|
134
|
-
}
|
135
|
-
|
136
|
-
}
|
137
|
-
}
|