~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to third_party/websockify/include/web-socket-js/src/flash-src/third-party/com/hurlant/crypto/tests/TripleDESKeyTest.as

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * TripleDESKeyTest
 
3
 * 
 
4
 * A test class for TripleDESKey
 
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.symmetric.TripleDESKey;
 
12
        import com.hurlant.util.Hex;
 
13
        import flash.utils.ByteArray;
 
14
        import com.hurlant.crypto.symmetric.ICipher;
 
15
        import com.hurlant.crypto.symmetric.ECBMode;
 
16
        
 
17
        public class TripleDESKeyTest extends TestCase
 
18
        {
 
19
                public function TripleDESKeyTest(h:ITestHarness)
 
20
                {
 
21
                        super(h, "Triped Des Test");
 
22
                        runTest(testECB,"Triple DES ECB Test Vectors");
 
23
                        h.endTestCase();
 
24
                }
 
25
                
 
26
                /**
 
27
                 * Lots of vectors at http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf
 
28
                 * XXX move them in here.
 
29
                 */
 
30
                public function testECB():void {
 
31
                        var keys:Array = [
 
32
                        "010101010101010101010101010101010101010101010101",
 
33
                        "dd24b3aafcc69278d650dad234956b01e371384619492ac4",
 
34
                        ];
 
35
                        var pts:Array = [
 
36
                        "8000000000000000",
 
37
                        "F36B21045A030303",
 
38
                        ];
 
39
                        var cts:Array = [
 
40
                        "95F8A5E5DD31D900",
 
41
                        "E823A43DEEA4D0A4",
 
42
                        ];
 
43
                        
 
44
                        for (var i:uint=0;i<keys.length;i++) {
 
45
                                var key:ByteArray = Hex.toArray(keys[i]);
 
46
                                var pt:ByteArray = Hex.toArray(pts[i]);
 
47
                                var ede:TripleDESKey = new TripleDESKey(key);
 
48
                                ede.encrypt(pt);
 
49
                                var out:String = Hex.fromArray(pt).toUpperCase();
 
50
                                assert("comparing "+cts[i]+" to "+out, cts[i]==out);
 
51
                                // now go back to plaintext
 
52
                                ede.decrypt(pt);
 
53
                                out = Hex.fromArray(pt).toUpperCase();
 
54
                                assert("comparing "+pts[i]+" to "+out, pts[i]==out);
 
55
                        }
 
56
                }
 
57
                
 
58
        }
 
59
}
 
 
b'\\ No newline at end of file'