Sha256: b0b1178dfa263b6e869a2428587328182c049df926fe68215e7bf0131066466f

Contents?: true

Size: 1.8 KB

Versions: 19

Compression:

Stored size: 1.8 KB

Contents

/**
 * XTeaKeyTest
 * 
 * A test class for XTeaKey
 * Copyright (c) 2007 Henri Torgemane
 * 
 * See LICENSE.txt for full license information.
 */
package com.hurlant.crypto.tests
{
	import com.hurlant.crypto.prng.Random;
	import com.hurlant.crypto.symmetric.ECBMode;
	import com.hurlant.crypto.symmetric.XTeaKey;
	import com.hurlant.util.Hex;
	
	import flash.utils.ByteArray;
	import flash.utils.getTimer;
	
	public class XTeaKeyTest extends TestCase
	{
		public function XTeaKeyTest(h:ITestHarness) {
			super(h, "XTeaKey Test");
			runTest(testGetBlockSize, "XTea Block Size");
			runTest(testVectors, "XTea Test Vectors");
			
			h.endTestCase();
		}
		
		public function testGetBlockSize():void {
			var tea:XTeaKey = new XTeaKey(Hex.toArray("deadbabecafebeefdeadbabecafebeef"));
			assert("tea blocksize", tea.getBlockSize()==8);
		}
		
		public function testVectors():void {
			// blah.
			// can't find working test vectors.
			// algorithms should not get published without vectors :(
			var keys:Array=[
			"00000000000000000000000000000000",
			"2b02056806144976775d0e266c287843"];
			var pts:Array=[
			"0000000000000000",
			"74657374206d652e"];
			var cts:Array=[
			"2dc7e8d3695b0538",
			"7909582138198783"];
			// self-fullfilling vectors.
			// oh well, at least I can decrypt what I produce. :(
			
			for (var i:uint=0;i<keys.length;i++) {
				var key:ByteArray = Hex.toArray(keys[i]);
				var pt:ByteArray = Hex.toArray(pts[i]);
				var tea:XTeaKey = new XTeaKey(key);
				tea.encrypt(pt);
				var out:String = Hex.fromArray(pt);
				assert("comparing "+cts[i]+" to "+out, cts[i]==out);
				// now go back to plaintext.
				pt.position=0;
				tea.decrypt(pt);
				out = Hex.fromArray(pt);
				assert("comparing "+pts[i]+" to "+out, pts[i]==out);
			}
		}

	}
}

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
coffeecake-0.0.1 node_modules/jasmine-runner/node_modules/socket.io/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as
rocket-js-0.0.2 src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as