rocket-js 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +0 -11
  2. data/Rakefile +33 -47
  3. data/lib/rocket/js.rb +0 -2
  4. data/lib/rocket/js/builder.rb +2 -2
  5. data/lib/rocket/js/cli.rb +1 -1
  6. data/rocket-js.gemspec +23 -80
  7. data/src/vendor/web-socket-js/FABridge.js +604 -0
  8. data/src/vendor/web-socket-js/README.txt +109 -0
  9. data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
  10. data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
  11. data/src/vendor/web-socket-js/flash-src/WebSocket.as +473 -0
  12. data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +88 -0
  13. data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +19 -0
  14. data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +32 -0
  15. data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +943 -0
  16. data/src/vendor/web-socket-js/flash-src/build.sh +10 -0
  17. data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +204 -0
  18. data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +375 -0
  19. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +287 -0
  20. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +3235 -0
  21. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +218 -0
  22. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +57 -0
  23. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +82 -0
  24. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +27 -0
  25. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +21 -0
  26. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +137 -0
  27. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +124 -0
  28. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +204 -0
  29. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +106 -0
  30. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +28 -0
  31. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +115 -0
  32. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +71 -0
  33. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +90 -0
  34. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +20 -0
  35. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +119 -0
  36. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +142 -0
  37. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +339 -0
  38. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +2797 -0
  39. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +375 -0
  40. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +55 -0
  41. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +61 -0
  42. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +64 -0
  43. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +58 -0
  44. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +365 -0
  45. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +86 -0
  46. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +21 -0
  47. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +15 -0
  48. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +32 -0
  49. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +21 -0
  50. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +35 -0
  51. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +110 -0
  52. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +34 -0
  53. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +52 -0
  54. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +44 -0
  55. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +44 -0
  56. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +60 -0
  57. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +42 -0
  58. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +88 -0
  59. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +94 -0
  60. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +29 -0
  61. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +2304 -0
  62. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +1220 -0
  63. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +58 -0
  64. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +39 -0
  65. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +148 -0
  66. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +160 -0
  67. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +71 -0
  68. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +98 -0
  69. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +109 -0
  70. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +112 -0
  71. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +151 -0
  72. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +184 -0
  73. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +20 -0
  74. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +56 -0
  75. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +58 -0
  76. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +101 -0
  77. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +92 -0
  78. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +198 -0
  79. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +58 -0
  80. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +60 -0
  81. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +51 -0
  82. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +42 -0
  83. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +59 -0
  84. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +66 -0
  85. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +102 -0
  86. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +117 -0
  87. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +14 -0
  88. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +29 -0
  89. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +24 -0
  90. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +38 -0
  91. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +171 -0
  92. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +26 -0
  93. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +340 -0
  94. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +70 -0
  95. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +151 -0
  96. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +895 -0
  97. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +39 -0
  98. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +27 -0
  99. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +197 -0
  100. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +370 -0
  101. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +26 -0
  102. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +180 -0
  103. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +90 -0
  104. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +1543 -0
  105. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +35 -0
  106. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +11 -0
  107. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +85 -0
  108. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +34 -0
  109. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +11 -0
  110. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +25 -0
  111. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +189 -0
  112. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +66 -0
  113. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +28 -0
  114. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +43 -0
  115. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +210 -0
  116. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +21 -0
  117. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +44 -0
  118. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +35 -0
  119. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +112 -0
  120. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +118 -0
  121. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +49 -0
  122. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +90 -0
  123. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +27 -0
  124. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +94 -0
  125. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +60 -0
  126. data/src/vendor/web-socket-js/sample.html +76 -0
  127. data/src/vendor/web-socket-js/swfobject.js +4 -0
  128. data/src/vendor/web-socket-js/web_socket.js +388 -0
  129. metadata +163 -30
  130. data/lib/rocket/js/version.rb +0 -14
  131. data/rocket-0.0.1.min.js +0 -45
@@ -0,0 +1,118 @@
1
+ /**
2
+ * PEM
3
+ *
4
+ * A class to parse some PEM stuff.
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.crypto.rsa.RSAKey;
12
+ import com.hurlant.math.BigInteger;
13
+ import com.hurlant.util.Base64;
14
+
15
+ import flash.utils.ByteArray;
16
+ import com.hurlant.util.Hex;
17
+
18
+ public class PEM
19
+ {
20
+ private static const RSA_PRIVATE_KEY_HEADER:String = "-----BEGIN RSA PRIVATE KEY-----";
21
+ private static const RSA_PRIVATE_KEY_FOOTER:String = "-----END RSA PRIVATE KEY-----";
22
+ private static const RSA_PUBLIC_KEY_HEADER:String = "-----BEGIN PUBLIC KEY-----";
23
+ private static const RSA_PUBLIC_KEY_FOOTER:String = "-----END PUBLIC KEY-----";
24
+ private static const CERTIFICATE_HEADER:String = "-----BEGIN CERTIFICATE-----";
25
+ private static const CERTIFICATE_FOOTER:String = "-----END CERTIFICATE-----";
26
+
27
+
28
+
29
+ /**
30
+ *
31
+ * Read a structure encoded according to
32
+ * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc
33
+ * section 11.1.2
34
+ *
35
+ * @param str
36
+ * @return
37
+ *
38
+ */
39
+ public static function readRSAPrivateKey(str:String):RSAKey {
40
+ var der:ByteArray = extractBinary(RSA_PRIVATE_KEY_HEADER, RSA_PRIVATE_KEY_FOOTER, str);
41
+ if (der==null) return null;
42
+ var obj:* = DER.parse(der);
43
+ if (obj is Array) {
44
+ var arr:Array = obj as Array;
45
+ // arr[0] is Version. should be 0. should be checked. shoulda woulda coulda.
46
+ return new RSAKey(
47
+ arr[1], // N
48
+ arr[2].valueOf(), // E
49
+ arr[3], // D
50
+ arr[4], // P
51
+ arr[5], // Q
52
+ arr[6], // DMP1
53
+ arr[7], // DMQ1
54
+ arr[8]); // IQMP
55
+ } else {
56
+ // dunno
57
+ return null;
58
+ }
59
+ }
60
+
61
+
62
+ /**
63
+ * Read a structure encoded according to some spec somewhere
64
+ * Also, follows some chunk from
65
+ * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc
66
+ * section 11.1
67
+ *
68
+ * @param str
69
+ * @return
70
+ *
71
+ */
72
+ public static function readRSAPublicKey(str:String):RSAKey {
73
+ var der:ByteArray = extractBinary(RSA_PUBLIC_KEY_HEADER, RSA_PUBLIC_KEY_FOOTER, str);
74
+ if (der==null) return null;
75
+ var obj:* = DER.parse(der);
76
+ if (obj is Array) {
77
+ var arr:Array = obj as Array;
78
+ // arr[0] = [ <some crap that means "rsaEncryption">, null ]; ( apparently, that's an X-509 Algorithm Identifier.
79
+ if (arr[0][0].toString()!=OID.RSA_ENCRYPTION) {
80
+ return null;
81
+ }
82
+ // arr[1] is a ByteArray begging to be parsed as DER
83
+ arr[1].position = 1; // there's a 0x00 byte up front. find out why later. like, read a spec.
84
+ obj = DER.parse(arr[1]);
85
+ if (obj is Array) {
86
+ arr = obj as Array;
87
+ // arr[0] = modulus
88
+ // arr[1] = public expt.
89
+ return new RSAKey(arr[0], arr[1]);
90
+ } else {
91
+ return null;
92
+ }
93
+ } else {
94
+ // dunno
95
+ return null;
96
+ }
97
+ }
98
+
99
+ public static function readCertIntoArray(str:String):ByteArray {
100
+ var tmp:ByteArray = extractBinary(CERTIFICATE_HEADER, CERTIFICATE_FOOTER, str);
101
+ return tmp;
102
+ }
103
+
104
+ private static function extractBinary(header:String, footer:String, str:String):ByteArray {
105
+ var i:int = str.indexOf(header);
106
+ if (i==-1) return null;
107
+ i += header.length;
108
+ var j:int = str.indexOf(footer);
109
+ if (j==-1) return null;
110
+ var b64:String = str.substring(i, j);
111
+ // remove whitesapces.
112
+ b64 = b64.replace(/\s/mg, '');
113
+ // decode
114
+ return Base64.decodeToByteArray(b64);
115
+ }
116
+
117
+ }
118
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * PrintableString
3
+ *
4
+ * An ASN1 type for a PrintableString, held within a String
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 class PrintableString implements IAsn1Type
14
+ {
15
+ protected var type:uint;
16
+ protected var len:uint;
17
+ protected var str:String;
18
+
19
+ public function PrintableString(type:uint, length:uint) {
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 setString(s:String):void {
35
+ str = s;
36
+ }
37
+ public function getString():String {
38
+ return str;
39
+ }
40
+
41
+ public function toString():String {
42
+ return DER.indent+str;
43
+ }
44
+
45
+ public function toDER():ByteArray {
46
+ return null; // XXX not implemented
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Sequence
3
+ *
4
+ * An ASN1 type for a Sequence, implemented as an Array
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 dynamic class Sequence extends Array implements IAsn1Type
14
+ {
15
+ protected var type:uint;
16
+ protected var len:uint;
17
+
18
+ public function Sequence(type:uint = 0x30, length:uint = 0x00) {
19
+ this.type = type;
20
+ this.len = length;
21
+ }
22
+
23
+ public function getLength():uint
24
+ {
25
+ return len;
26
+ }
27
+
28
+ public function getType():uint
29
+ {
30
+ return type;
31
+ }
32
+
33
+ public function toDER():ByteArray {
34
+ var tmp:ByteArray = new ByteArray;
35
+ for (var i:int=0;i<length;i++) {
36
+ var e:IAsn1Type = this[i];
37
+ if (e == null) { // XXX Arguably, I could have a der.Null class instead
38
+ tmp.writeByte(0x05);
39
+ tmp.writeByte(0x00);
40
+ } else {
41
+ tmp.writeBytes(e.toDER());
42
+ }
43
+ }
44
+ return DER.wrapDER(type, tmp);
45
+ }
46
+
47
+ public function toString():String {
48
+ var s:String = DER.indent;
49
+ DER.indent += " ";
50
+ var t:String = "";
51
+ for (var i:int=0;i<length;i++) {
52
+ if (this[i]==null) continue;
53
+ var found:Boolean = false;
54
+ for (var key:String in this) {
55
+ if ( (i.toString()!=key) && this[i]==this[key]) {
56
+ t += key+": "+this[i]+"\n";
57
+ found = true;
58
+ break;
59
+ }
60
+ }
61
+ if (!found) t+=this[i]+"\n";
62
+ }
63
+ // var t:String = join("\n");
64
+ DER.indent= s;
65
+ return DER.indent+"Sequence["+type+"]["+len+"][\n"+t+"\n"+s+"]";
66
+ }
67
+
68
+ /////////
69
+
70
+ public function findAttributeValue(oid:String):IAsn1Type {
71
+ for each (var set:* in this) {
72
+ if (set is Set) {
73
+ var child:* = set[0];
74
+ if (child is Sequence) {
75
+ var tmp:* = child[0];
76
+ if (tmp is ObjectIdentifier) {
77
+ var id:ObjectIdentifier = tmp as ObjectIdentifier;
78
+ if (id.toString()==oid) {
79
+ return child[1] as IAsn1Type;
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ return null;
86
+ }
87
+
88
+
89
+ }
90
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Set
3
+ *
4
+ * An ASN1 type for an Set, that extends a Sequence
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 dynamic class Set extends Sequence implements IAsn1Type
12
+ {
13
+ public function Set(type:uint = 0x31, length:uint = 0x00) {
14
+ super(type, length);
15
+ }
16
+
17
+
18
+ public override function toString():String {
19
+ var s:String = DER.indent;
20
+ DER.indent += " ";
21
+ var t:String = join("\n");
22
+ DER.indent= s;
23
+ return DER.indent+"Set["+type+"]["+len+"][\n"+t+"\n"+s+"]";
24
+ }
25
+
26
+ }
27
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Type
3
+ *
4
+ * A few Asn-1 structures
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.util.Hex;
12
+
13
+ public class Type
14
+ {
15
+ public static const TLS_CERT:Array = [
16
+ {name:"signedCertificate", extract:true, value: [
17
+ {name:"versionHolder", optional:true, value: [
18
+ {name:"version"}
19
+ ], defaultValue: function():Sequence{
20
+ var s:Sequence = new Sequence(0, 0);
21
+ var v:Integer = new Integer(2,1, Hex.toArray("00"));
22
+ s.push(v);
23
+ s.version = v;
24
+ return s;
25
+ }()
26
+ },
27
+ {name:"serialNumber"},
28
+ {name:"signature", value: [
29
+ {name:"algorithmId"}
30
+ ]},
31
+ {name:"issuer", extract:true, value: [
32
+ {name:"type"},
33
+ {name:"value"}
34
+ ]},
35
+ {name:"validity", value: [
36
+ {name:"notBefore"},
37
+ {name:"notAfter"}
38
+ ]},
39
+ {name:"subject", extract:true, value: [
40
+ ]},
41
+ {name:"subjectPublicKeyInfo", value: [
42
+ {name:"algorithm", value: [
43
+ {name:"algorithmId"}
44
+ ]},
45
+ {name:"subjectPublicKey"}
46
+ ]},
47
+ {name:"extensions", value: [
48
+ ]}
49
+ ]},
50
+ {name:"algorithmIdentifier",value:[
51
+ {name:"algorithmId"}
52
+ ]},
53
+ {name:"encrypted", value:null}
54
+ ];
55
+ public static const CERTIFICATE:Array = [
56
+ {name:"tbsCertificate", value:[
57
+ {name:"tag0", value:[
58
+ {name:"version"}
59
+ ]},
60
+ {name:"serialNumber"},
61
+ {name:"signature"},
62
+ {name:"issuer", value:[
63
+ {name:"type"},
64
+ {name:"value"}
65
+ ]},
66
+ {name:"validity", value:[
67
+ {name:"notBefore"},
68
+ {name:"notAfter"}
69
+ ]},
70
+ {name:"subject"},
71
+ {name:"subjectPublicKeyInfo", value:[
72
+ {name:"algorithm"},
73
+ {name:"subjectPublicKey"}
74
+ ]},
75
+ {name:"issuerUniqueID"},
76
+ {name:"subjectUniqueID"},
77
+ {name:"extensions"}
78
+ ]},
79
+ {name:"signatureAlgorithm"},
80
+ {name:"signatureValue"}
81
+ ];
82
+ public static const RSA_PUBLIC_KEY:Array = [
83
+ {name:"modulus"},
84
+ {name:"publicExponent"}
85
+ ];
86
+ public static const RSA_SIGNATURE:Array = [
87
+ {name:"algorithm", value:[
88
+ {name:"algorithmId"}
89
+ ]},
90
+ {name:"hash"}
91
+ ];
92
+
93
+ }
94
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * UTCTime
3
+ *
4
+ * An ASN1 type for UTCTime, represented as a Date
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 class UTCTime implements IAsn1Type
14
+ {
15
+ protected var type:uint;
16
+ protected var len:uint;
17
+ public var date:Date;
18
+
19
+ public function UTCTime(type:uint, len:uint)
20
+ {
21
+ this.type = type;
22
+ this.len = len;
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
+ public function setUTCTime(str:String):void {
36
+
37
+ var year:uint = parseInt(str.substr(0, 2));
38
+ if (year<50) {
39
+ year+=2000;
40
+ } else {
41
+ year+=1900;
42
+ }
43
+ var month:uint = parseInt(str.substr(2,2));
44
+ var day:uint = parseInt(str.substr(4,2));
45
+ var hour:uint = parseInt(str.substr(6,2));
46
+ var minute:uint = parseInt(str.substr(8,2));
47
+ // XXX this could be off by up to a day. parse the rest. someday.
48
+ date = new Date(year, month-1, day, hour, minute);
49
+ }
50
+
51
+
52
+ public function toString():String {
53
+ return DER.indent+"UTCTime["+type+"]["+len+"]["+date+"]";
54
+ }
55
+
56
+ public function toDER():ByteArray {
57
+ return null // XXX not implemented
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,76 @@
1
+ <!--
2
+ Lincense: Public Domain
3
+ -->
4
+
5
+ <html><head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <title>Sample of web_socket.js</title>
8
+
9
+ <!-- Include these three JS files: -->
10
+ <script type="text/javascript" src="swfobject.js"></script>
11
+ <script type="text/javascript" src="FABridge.js"></script>
12
+ <script type="text/javascript" src="web_socket.js"></script>
13
+
14
+ <script type="text/javascript">
15
+
16
+ // Set URL of your WebSocketMain.swf here:
17
+ WEB_SOCKET_SWF_LOCATION = "WebSocketMain.swf";
18
+ // Set this to dump debug message from Flash to console.log:
19
+ WEB_SOCKET_DEBUG = true;
20
+
21
+ // Everything below is the same as using standard WebSocket.
22
+
23
+ var ws;
24
+
25
+ function init() {
26
+
27
+ // Connect to Web Socket.
28
+ // Change host/port here to your own Web Socket server.
29
+ ws = new WebSocket("ws://localhost:10081/");
30
+
31
+ // Set event handlers.
32
+ ws.onopen = function() {
33
+ output("onopen");
34
+ };
35
+ ws.onmessage = function(e) {
36
+ // e.data contains received string.
37
+ output("onmessage: " + e.data);
38
+ };
39
+ ws.onclose = function() {
40
+ output("onclose");
41
+ };
42
+ ws.onerror = function() {
43
+ output("onerror");
44
+ };
45
+
46
+ }
47
+
48
+ function onSubmit() {
49
+ var input = document.getElementById("input");
50
+ // You can send message to the Web Socket using ws.send.
51
+ ws.send(input.value);
52
+ output("send: " + input.value);
53
+ input.value = "";
54
+ input.focus();
55
+ }
56
+
57
+ function onCloseClick() {
58
+ ws.close();
59
+ }
60
+
61
+ function output(str) {
62
+ var log = document.getElementById("log");
63
+ var escaped = str.replace(/&/, "&amp;").replace(/</, "&lt;").
64
+ replace(/>/, "&gt;").replace(/"/, "&quot;"); // "
65
+ log.innerHTML = escaped + "<br>" + log.innerHTML;
66
+ }
67
+
68
+ </script>
69
+ </head><body onload="init();">
70
+ <form onsubmit="onSubmit(); return false;">
71
+ <input type="text" id="input">
72
+ <input type="submit" value="Send">
73
+ <button onclick="onCloseClick(); return false;">close</button>
74
+ </form>
75
+ <div id="log"></div>
76
+ </body></html>