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,184 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* HMACTest
|
3
|
-
*
|
4
|
-
* A test class for HMAC
|
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.hash.HMAC;
|
12
|
-
import com.hurlant.crypto.hash.MD5;
|
13
|
-
import com.hurlant.crypto.hash.SHA1;
|
14
|
-
import com.hurlant.crypto.hash.SHA224;
|
15
|
-
import com.hurlant.crypto.hash.SHA256;
|
16
|
-
import com.hurlant.util.Hex;
|
17
|
-
|
18
|
-
import flash.utils.ByteArray;
|
19
|
-
|
20
|
-
public class HMACTest extends TestCase
|
21
|
-
{
|
22
|
-
public function HMACTest(h:ITestHarness)
|
23
|
-
{
|
24
|
-
super(h, "HMAC Test");
|
25
|
-
runTest(testHMAC_MD5,"HMAC MD5 Test Vectors");
|
26
|
-
runTest(testHMAC_SHA_1,"HMAC SHA-1 Test Vectors");
|
27
|
-
runTest(testHMAC_SHA_2,"HMAC SHA-224/SHA-256 Test Vectors");
|
28
|
-
runTest(testHMAC96_MD5,"HMAC-96 MD5 Test Vectors");
|
29
|
-
runTest(testHMAC96_SHA_1,"HMAC-96 SHA-1 Test Vectors");
|
30
|
-
runTest(testHMAC128_SHA_2,"HMAC-128 SHA-224/SHA-256 Test Vectors");
|
31
|
-
h.endTestCase();
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* Test vectors taking from RFC2202
|
35
|
-
* http://tools.ietf.org/html/rfc2202
|
36
|
-
* Yes, it's from an RFC, jefe! Now waddayawant?
|
37
|
-
*/
|
38
|
-
public function testHMAC_SHA_1():void {
|
39
|
-
var keys:Array = [
|
40
|
-
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
|
41
|
-
Hex.fromString("Jefe"),
|
42
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
43
|
-
"0102030405060708090a0b0c0d0e0f10111213141516171819",
|
44
|
-
"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
|
45
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
46
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"];
|
47
|
-
var pts:Array = [
|
48
|
-
Hex.fromString("Hi There"),
|
49
|
-
Hex.fromString("what do ya want for nothing?"),
|
50
|
-
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
51
|
-
"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
|
52
|
-
Hex.fromString("Test With Truncation"),
|
53
|
-
Hex.fromString("Test Using Larger Than Block-Size Key - Hash Key First"),
|
54
|
-
Hex.fromString("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data")];
|
55
|
-
var cts:Array = [
|
56
|
-
"b617318655057264e28bc0b6fb378c8ef146be00",
|
57
|
-
"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79",
|
58
|
-
"125d7342b9ac11cd91a39af48aa17b4f63f175d3",
|
59
|
-
"4c9007f4026250c6bc8414f9bf50c86c2d7235da",
|
60
|
-
"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04",
|
61
|
-
"aa4ae5e15272d00e95705637ce8a3b55ed402112",
|
62
|
-
"e8e99d0f45237d786d6bbaa7965c7808bbff1a91"];
|
63
|
-
|
64
|
-
var hmac:HMAC = new HMAC(new SHA1());
|
65
|
-
for (var i:uint=0;i<keys.length;i++) {
|
66
|
-
var key:ByteArray = Hex.toArray(keys[i]);
|
67
|
-
var pt:ByteArray = Hex.toArray(pts[i]);
|
68
|
-
var digest:ByteArray = hmac.compute(key, pt);
|
69
|
-
assert("HMAC-SHA-1 test "+i, Hex.fromArray(digest) == cts[i]);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
public function testHMAC96_SHA_1():void {
|
73
|
-
var hmac:HMAC = new HMAC(new SHA1, 96);
|
74
|
-
var key:ByteArray = Hex.toArray("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c");
|
75
|
-
var pt:ByteArray = Hex.toArray(Hex.fromString("Test With Truncation"));
|
76
|
-
var ct:String = "4c1a03424b55e07fe7f27be1";
|
77
|
-
var digest:ByteArray = hmac.compute(key, pt);
|
78
|
-
assert("HMAC96-SHA-1 test", Hex.fromArray(digest) == ct);
|
79
|
-
}
|
80
|
-
|
81
|
-
public function testHMAC_MD5():void {
|
82
|
-
var keys:Array = [
|
83
|
-
Hex.fromString("Jefe"),
|
84
|
-
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
|
85
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
86
|
-
"0102030405060708090a0b0c0d0e0f10111213141516171819",
|
87
|
-
"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
|
88
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
89
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"];
|
90
|
-
var pts:Array = [
|
91
|
-
Hex.fromString("what do ya want for nothing?"),
|
92
|
-
Hex.fromString("Hi There"),
|
93
|
-
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
94
|
-
"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
|
95
|
-
Hex.fromString("Test With Truncation"),
|
96
|
-
Hex.fromString("Test Using Larger Than Block-Size Key - Hash Key First"),
|
97
|
-
Hex.fromString("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data")];
|
98
|
-
var cts:Array = [
|
99
|
-
"750c783e6ab0b503eaa86e310a5db738",
|
100
|
-
"9294727a3638bb1c13f48ef8158bfc9d",
|
101
|
-
"56be34521d144c88dbb8c733f0e8b3f6",
|
102
|
-
"697eaf0aca3a3aea3a75164746ffaa79",
|
103
|
-
"56461ef2342edc00f9bab995690efd4c",
|
104
|
-
"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd",
|
105
|
-
"6f630fad67cda0ee1fb1f562db3aa53e"];
|
106
|
-
|
107
|
-
var hmac:HMAC = new HMAC(new MD5());
|
108
|
-
for (var i:uint=0;i<keys.length;i++) {
|
109
|
-
var key:ByteArray = Hex.toArray(keys[i]);
|
110
|
-
var pt:ByteArray = Hex.toArray(pts[i]);
|
111
|
-
var digest:ByteArray = hmac.compute(key, pt);
|
112
|
-
assert("HMAC-MD5 test "+i, Hex.fromArray(digest) == cts[i]);
|
113
|
-
}
|
114
|
-
}
|
115
|
-
public function testHMAC96_MD5():void {
|
116
|
-
var hmac:HMAC = new HMAC(new MD5, 96);
|
117
|
-
var key:ByteArray = Hex.toArray("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c");
|
118
|
-
var pt:ByteArray = Hex.toArray(Hex.fromString("Test With Truncation"));
|
119
|
-
var ct:String = "56461ef2342edc00f9bab995";
|
120
|
-
var digest:ByteArray = hmac.compute(key, pt);
|
121
|
-
assert("HMAC96-MD5 test", Hex.fromArray(digest) == ct);
|
122
|
-
}
|
123
|
-
|
124
|
-
/**
|
125
|
-
* Test vectors for HMAC-SHA-2 taken from RFC4231
|
126
|
-
* http://www.ietf.org/rfc/rfc4231.txt
|
127
|
-
* Still the same lame strings, but hidden in hex. why not.
|
128
|
-
*/
|
129
|
-
public function testHMAC_SHA_2():void {
|
130
|
-
var keys:Array = [
|
131
|
-
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
|
132
|
-
"4a656665",
|
133
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
134
|
-
"0102030405060708090a0b0c0d0e0f10111213141516171819",
|
135
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
136
|
-
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"];
|
137
|
-
var pts:Array = [
|
138
|
-
"4869205468657265",
|
139
|
-
"7768617420646f2079612077616e7420666f72206e6f7468696e673f",
|
140
|
-
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
141
|
-
"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
|
142
|
-
"54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374",
|
143
|
-
"5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"];
|
144
|
-
var cts224:Array = [
|
145
|
-
"896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22",
|
146
|
-
"a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44",
|
147
|
-
"7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea",
|
148
|
-
"6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a",
|
149
|
-
"95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e",
|
150
|
-
"3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1"];
|
151
|
-
var cts256:Array = [
|
152
|
-
"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7",
|
153
|
-
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843",
|
154
|
-
"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe",
|
155
|
-
"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b",
|
156
|
-
"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54",
|
157
|
-
"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2"];
|
158
|
-
// 384 and 512 will be added. someday. if I ever figure how to do 64bit computations half efficiently in as3
|
159
|
-
|
160
|
-
var hmac224:HMAC = new HMAC(new SHA224);
|
161
|
-
var hmac256:HMAC = new HMAC(new SHA256);
|
162
|
-
for (var i:uint=0;i<keys.length;i++) {
|
163
|
-
var key:ByteArray = Hex.toArray(keys[i]);
|
164
|
-
var pt:ByteArray = Hex.toArray(pts[i]);
|
165
|
-
var digest224:ByteArray = hmac224.compute(key, pt);
|
166
|
-
assert("HMAC-SHA-224 test "+i, Hex.fromArray(digest224) == cts224[i]);
|
167
|
-
var digest256:ByteArray = hmac256.compute(key, pt);
|
168
|
-
assert("HMAC-SHA-256 test "+i, Hex.fromArray(digest256) == cts256[i]);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
public function testHMAC128_SHA_2():void {
|
172
|
-
var hmac224:HMAC = new HMAC(new SHA224,128);
|
173
|
-
var hmac256:HMAC = new HMAC(new SHA256,128);
|
174
|
-
var key:ByteArray = Hex.toArray("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c");
|
175
|
-
var pt:ByteArray = Hex.toArray("546573742057697468205472756e636174696f6e");
|
176
|
-
var ct224:String = "0e2aea68a90c8d37c988bcdb9fca6fa8";
|
177
|
-
var ct256:String = "a3b6167473100ee06e0c796c2955552b";
|
178
|
-
var digest224:ByteArray = hmac224.compute(key, pt);
|
179
|
-
assert("HMAC128-SHA-224 test", Hex.fromArray(digest224) == ct224);
|
180
|
-
var digest256:ByteArray = hmac256.compute(key, pt);
|
181
|
-
assert("HMAC128-SHA-256 test", Hex.fromArray(digest256) == ct256);
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* ITestHarness
|
3
|
-
*
|
4
|
-
* An interface to specify what's available for test cases to use.
|
5
|
-
* Copyright (c) 2007 Henri Torgemane
|
6
|
-
*
|
7
|
-
* See LICENSE.txt for full license information.
|
8
|
-
*/
|
9
|
-
package com.hurlant.crypto.tests
|
10
|
-
{
|
11
|
-
public interface ITestHarness
|
12
|
-
{
|
13
|
-
function beginTestCase(name:String):void;
|
14
|
-
function endTestCase():void;
|
15
|
-
|
16
|
-
function beginTest(name:String):void;
|
17
|
-
function passTest():void;
|
18
|
-
function failTest(msg:String):void;
|
19
|
-
}
|
20
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* MD2Test
|
3
|
-
*
|
4
|
-
* A test class for MD2
|
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.hash.MD2;
|
12
|
-
import com.hurlant.util.Hex;
|
13
|
-
|
14
|
-
import flash.utils.ByteArray;
|
15
|
-
|
16
|
-
public class MD2Test extends TestCase
|
17
|
-
{
|
18
|
-
public function MD2Test(h:ITestHarness)
|
19
|
-
{
|
20
|
-
super(h, "MD2 Test");
|
21
|
-
runTest(testMd2, "MD2 Test Vectors");
|
22
|
-
h.endTestCase();
|
23
|
-
}
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Test Vectors grabbed from
|
27
|
-
* http://www.faqs.org/rfcs/rfc1319.html
|
28
|
-
*/
|
29
|
-
public function testMd2():void {
|
30
|
-
var srcs:Array = [
|
31
|
-
"",
|
32
|
-
Hex.fromString("a"),
|
33
|
-
Hex.fromString("abc"),
|
34
|
-
Hex.fromString("message digest"),
|
35
|
-
Hex.fromString("abcdefghijklmnopqrstuvwxyz"),
|
36
|
-
Hex.fromString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
|
37
|
-
Hex.fromString("12345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
38
|
-
];
|
39
|
-
var hashes:Array = [
|
40
|
-
"8350e5a3e24c153df2275c9f80692773",
|
41
|
-
"32ec01ec4a6dac72c0ab96fb34c0b5d1",
|
42
|
-
"da853b0d3f88d99b30283a69e6ded6bb",
|
43
|
-
"ab4f496bfb2a530b219ff33031fe06b0",
|
44
|
-
"4e8ddff3650292ab5a4108c3aa47940b",
|
45
|
-
"da33def2a42df13975352846c30338cd",
|
46
|
-
"d5976f79d83d3a0dc9806c3c66f3efd8"
|
47
|
-
];
|
48
|
-
var md2:MD2 = new MD2;
|
49
|
-
for (var i:uint=0;i<srcs.length;i++) {
|
50
|
-
var src:ByteArray = Hex.toArray(srcs[i]);
|
51
|
-
var digest:ByteArray = md2.hash(src);
|
52
|
-
assert("MD2 Test "+i, Hex.fromArray(digest) == hashes[i]);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* MD5Test
|
3
|
-
*
|
4
|
-
* A test class for MD5
|
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.hash.MD5;
|
12
|
-
import com.hurlant.util.Hex;
|
13
|
-
|
14
|
-
import flash.utils.ByteArray;
|
15
|
-
|
16
|
-
public class MD5Test extends TestCase
|
17
|
-
{
|
18
|
-
public function MD5Test(h:ITestHarness)
|
19
|
-
{
|
20
|
-
super(h, "MD5 Test");
|
21
|
-
runTest(testMd5,"MD5 Test Vectors");
|
22
|
-
h.endTestCase();
|
23
|
-
}
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Test Vectors grabbed from
|
27
|
-
* http://www.faqs.org/rfcs/rfc1321.html
|
28
|
-
*/
|
29
|
-
public function testMd5():void {
|
30
|
-
var srcs:Array = [
|
31
|
-
"",
|
32
|
-
Hex.fromString("a"),
|
33
|
-
Hex.fromString("abc"),
|
34
|
-
Hex.fromString("message digest"),
|
35
|
-
Hex.fromString("abcdefghijklmnopqrstuvwxyz"),
|
36
|
-
Hex.fromString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
|
37
|
-
Hex.fromString("12345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
38
|
-
];
|
39
|
-
var hashes:Array = [
|
40
|
-
"d41d8cd98f00b204e9800998ecf8427e",
|
41
|
-
"0cc175b9c0f1b6a831c399e269772661",
|
42
|
-
"900150983cd24fb0d6963f7d28e17f72",
|
43
|
-
"f96b697d7cb7938d525a2f31aaf161d0",
|
44
|
-
"c3fcd3d76192e4007dfb496cca67e13b",
|
45
|
-
"d174ab98d277d9f5a5611c2c9f419d9f",
|
46
|
-
"57edf4a22be3c955ac49da2e2107b67a"
|
47
|
-
];
|
48
|
-
var md5:MD5 = new MD5;
|
49
|
-
for (var i:uint=0;i<srcs.length;i++) {
|
50
|
-
var src:ByteArray = Hex.toArray(srcs[i]);
|
51
|
-
var digest:ByteArray = md5.hash(src);
|
52
|
-
assert("MD5 Test "+i, Hex.fromArray(digest) == hashes[i]);
|
53
|
-
}
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
}
|
58
|
-
}
|
@@ -1,101 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* OFBModeTest
|
3
|
-
*
|
4
|
-
* A test class for OFBMode
|
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 flash.utils.ByteArray;
|
12
|
-
import com.hurlant.util.Hex;
|
13
|
-
import com.hurlant.crypto.symmetric.OFBMode;
|
14
|
-
import com.hurlant.crypto.symmetric.AESKey;
|
15
|
-
import com.hurlant.crypto.symmetric.NullPad;
|
16
|
-
|
17
|
-
public class OFBModeTest extends TestCase
|
18
|
-
{
|
19
|
-
public function OFBModeTest(h:ITestHarness)
|
20
|
-
{
|
21
|
-
super(h, "OFBMode Test");
|
22
|
-
runTest(testOFB_AES128,"OFB AES-128 Test Vectors");
|
23
|
-
runTest(testOFB_AES192,"OFB AES-192 Test Vectors");
|
24
|
-
runTest(testOFB_AES256,"OFB AES-256 Test Vectors");
|
25
|
-
h.endTestCase();
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Nist Vectors: http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
|
30
|
-
* Section F.4.1 and below.
|
31
|
-
*/
|
32
|
-
public function testOFB_AES128():void {
|
33
|
-
var key:ByteArray = Hex.toArray("2b7e151628aed2a6abf7158809cf4f3c");
|
34
|
-
var pt:ByteArray = Hex.toArray(
|
35
|
-
"6bc1bee22e409f96e93d7e117393172a" +
|
36
|
-
"ae2d8a571e03ac9c9eb76fac45af8e51" +
|
37
|
-
"30c81c46a35ce411e5fbc1191a0a52ef" +
|
38
|
-
"f69f2445df4f9b17ad2b417be66c3710");
|
39
|
-
var ct:ByteArray = Hex.toArray(
|
40
|
-
"3b3fd92eb72dad20333449f8e83cfb4a" +
|
41
|
-
"7789508d16918f03f53c52dac54ed825" +
|
42
|
-
"9740051e9c5fecf64344f7a82260edcc" +
|
43
|
-
"304c6528f659c77866a510d9c1d6ae5e");
|
44
|
-
var ofb:OFBMode = new OFBMode(new AESKey(key), new NullPad);
|
45
|
-
ofb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
|
46
|
-
var src:ByteArray = new ByteArray;
|
47
|
-
src.writeBytes(pt);
|
48
|
-
ofb.encrypt(src);
|
49
|
-
assert("OFB_AES128 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
|
50
|
-
ofb.decrypt(src);
|
51
|
-
assert("OFB_AES128 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
|
52
|
-
}
|
53
|
-
|
54
|
-
public function testOFB_AES192():void {
|
55
|
-
var key:ByteArray = Hex.toArray("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
|
56
|
-
var pt:ByteArray = Hex.toArray(
|
57
|
-
"6bc1bee22e409f96e93d7e117393172a" +
|
58
|
-
"ae2d8a571e03ac9c9eb76fac45af8e51" +
|
59
|
-
"30c81c46a35ce411e5fbc1191a0a52ef" +
|
60
|
-
"f69f2445df4f9b17ad2b417be66c3710");
|
61
|
-
var ct:ByteArray = Hex.toArray(
|
62
|
-
"cdc80d6fddf18cab34c25909c99a4174" +
|
63
|
-
"fcc28b8d4c63837c09e81700c1100401" +
|
64
|
-
"8d9a9aeac0f6596f559c6d4daf59a5f2" +
|
65
|
-
"6d9f200857ca6c3e9cac524bd9acc92a");
|
66
|
-
var ofb:OFBMode = new OFBMode(new AESKey(key), new NullPad);
|
67
|
-
ofb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
|
68
|
-
var src:ByteArray = new ByteArray;
|
69
|
-
src.writeBytes(pt);
|
70
|
-
ofb.encrypt(src);
|
71
|
-
assert("OFB_AES192 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
|
72
|
-
ofb.decrypt(src);
|
73
|
-
assert("OFB_AES192 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
|
74
|
-
}
|
75
|
-
|
76
|
-
public function testOFB_AES256():void {
|
77
|
-
var key:ByteArray = Hex.toArray(
|
78
|
-
"603deb1015ca71be2b73aef0857d7781" +
|
79
|
-
"1f352c073b6108d72d9810a30914dff4");
|
80
|
-
var pt:ByteArray = Hex.toArray(
|
81
|
-
"6bc1bee22e409f96e93d7e117393172a" +
|
82
|
-
"ae2d8a571e03ac9c9eb76fac45af8e51" +
|
83
|
-
"30c81c46a35ce411e5fbc1191a0a52ef" +
|
84
|
-
"f69f2445df4f9b17ad2b417be66c3710");
|
85
|
-
var ct:ByteArray = Hex.toArray(
|
86
|
-
"dc7e84bfda79164b7ecd8486985d3860" +
|
87
|
-
"4febdc6740d20b3ac88f6ad82a4fb08d" +
|
88
|
-
"71ab47a086e86eedf39d1c5bba97c408" +
|
89
|
-
"0126141d67f37be8538f5a8be740e484");
|
90
|
-
var ofb:OFBMode = new OFBMode(new AESKey(key), new NullPad);
|
91
|
-
ofb.IV = Hex.toArray("000102030405060708090a0b0c0d0e0f");
|
92
|
-
var src:ByteArray = new ByteArray;
|
93
|
-
src.writeBytes(pt);
|
94
|
-
ofb.encrypt(src);
|
95
|
-
assert("OFB_AES256 test 1", Hex.fromArray(src)==Hex.fromArray(ct));
|
96
|
-
ofb.decrypt(src);
|
97
|
-
assert("OFB_AES256 test 2", Hex.fromArray(src)==Hex.fromArray(pt));
|
98
|
-
}
|
99
|
-
|
100
|
-
}
|
101
|
-
}
|
@@ -1,92 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RSAKeyTest
|
3
|
-
*
|
4
|
-
* A test class for RSAKey
|
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.rsa.RSAKey;
|
12
|
-
import flash.utils.ByteArray;
|
13
|
-
import com.hurlant.util.Hex;
|
14
|
-
import com.hurlant.util.der.PEM;
|
15
|
-
|
16
|
-
public class RSAKeyTest extends TestCase
|
17
|
-
{
|
18
|
-
public function RSAKeyTest(h:ITestHarness)
|
19
|
-
{
|
20
|
-
super(h, "RSA Testing");
|
21
|
-
|
22
|
-
runTest(testSmoke,"RSA smoke test");
|
23
|
-
runTest(testGenerate, "RSA Key Generation test");
|
24
|
-
runTest(testPEM, "RSA Private Key PEM parsing");
|
25
|
-
runTest(testPEM2, "RSA Public Key PEM parsing");
|
26
|
-
h.endTestCase();
|
27
|
-
}
|
28
|
-
|
29
|
-
public function testSmoke():void {
|
30
|
-
var N:String ="C4E3F7212602E1E396C0B6623CF11D26204ACE3E7D26685E037AD2507DCE82FC" +
|
31
|
-
"28F2D5F8A67FC3AFAB89A6D818D1F4C28CFA548418BD9F8E7426789A67E73E41";
|
32
|
-
var E:String = "10001";
|
33
|
-
var D:String = "7cd1745aec69096129b1f42da52ac9eae0afebbe0bc2ec89253598dcf454960e" +
|
34
|
-
"3e5e4ec9f8c87202b986601dd167253ee3fb3fa047e14f1dfd5ccd37e931b29d";
|
35
|
-
var P:String = "f0e4dd1eac5622bd3932860fc749bbc48662edabdf3d2826059acc0251ac0d3b";
|
36
|
-
var Q:String = "d13cb38fbcd06ee9bca330b4000b3dae5dae12b27e5173e4d888c325cda61ab3";
|
37
|
-
var DMP1:String = "b3d5571197fc31b0eb6b4153b425e24c033b054d22b9c8282254fe69d8c8c593";
|
38
|
-
var DMQ1:String = "968ffe89e50d7b72585a79b65cfdb9c1da0963cceb56c3759e57334de5a0ac3f";
|
39
|
-
var IQMP:String = "d9bc4f420e93adad9f007d0e5744c2fe051c9ed9d3c9b65f439a18e13d6e3908";
|
40
|
-
// create a key.
|
41
|
-
var rsa:RSAKey = RSAKey.parsePrivateKey(N,E,D, P,Q,DMP1,DMQ1,IQMP);
|
42
|
-
var txt:String = "hello";
|
43
|
-
var src:ByteArray = Hex.toArray(Hex.fromString(txt));
|
44
|
-
var dst:ByteArray = new ByteArray;
|
45
|
-
var dst2:ByteArray = new ByteArray;
|
46
|
-
rsa.encrypt(src, dst, src.length);
|
47
|
-
rsa.decrypt(dst, dst2, dst.length);
|
48
|
-
var txt2:String = Hex.toString(Hex.fromArray(dst2));
|
49
|
-
assert("rsa encrypt+decrypt", txt==txt2);
|
50
|
-
}
|
51
|
-
|
52
|
-
public function testGenerate():void {
|
53
|
-
var rsa:RSAKey = RSAKey.generate(256, "10001");
|
54
|
-
// same lame smoke test here.
|
55
|
-
var txt:String = "hello";
|
56
|
-
var src:ByteArray = Hex.toArray(Hex.fromString(txt));
|
57
|
-
var dst:ByteArray = new ByteArray;
|
58
|
-
var dst2:ByteArray = new ByteArray;
|
59
|
-
rsa.encrypt(src, dst, src.length);
|
60
|
-
rsa.decrypt(dst, dst2, dst.length);
|
61
|
-
var txt2:String = Hex.toString(Hex.fromArray(dst2));
|
62
|
-
assert("rsa encrypt+decrypt", txt==txt2);
|
63
|
-
}
|
64
|
-
|
65
|
-
public function testPEM():void {
|
66
|
-
var pem:String = "-----BEGIN RSA PRIVATE KEY-----\n" +
|
67
|
-
"MGQCAQACEQDJG3bkuB9Ie7jOldQTVdzPAgMBAAECEQCOGqcPhP8t8mX8cb4cQEaR\n" +
|
68
|
-
"AgkA5WTYuAGmH0cCCQDgbrto0i7qOQIINYr5btGrtccCCQCYy4qX4JDEMQIJAJll\n" +
|
69
|
-
"OnLVtCWk\n" +
|
70
|
-
"-----END RSA PRIVATE KEY-----";
|
71
|
-
var rsa:RSAKey = PEM.readRSAPrivateKey(pem);
|
72
|
-
//trace(rsa.dump());
|
73
|
-
|
74
|
-
// obligatory use
|
75
|
-
var txt:String = "hello";
|
76
|
-
var src:ByteArray = Hex.toArray(Hex.fromString(txt));
|
77
|
-
var dst:ByteArray = new ByteArray;
|
78
|
-
var dst2:ByteArray = new ByteArray;
|
79
|
-
rsa.encrypt(src, dst, src.length);
|
80
|
-
rsa.decrypt(dst, dst2, dst.length);
|
81
|
-
var txt2:String = Hex.toString(Hex.fromArray(dst2));
|
82
|
-
assert("rsa encrypt+decrypt", txt==txt2);
|
83
|
-
}
|
84
|
-
public function testPEM2():void {
|
85
|
-
var pem:String = "-----BEGIN PUBLIC KEY-----\n" +
|
86
|
-
"MCwwDQYJKoZIhvcNAQEBBQADGwAwGAIRAMkbduS4H0h7uM6V1BNV3M8CAwEAAQ==\n" +
|
87
|
-
"-----END PUBLIC KEY-----";
|
88
|
-
var rsa:RSAKey = PEM.readRSAPublicKey(pem);
|
89
|
-
//trace(rsa.dump());
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|