Sha256: 873c4562610e3af62e5b95cea98ad9e55fcf51998c61eb62a65efa95b30f6acd

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

/**
 * CTRMode
 * 
 * An ActionScript 3 implementation of the counter confidentiality mode
 * Copyright (c) 2007 Henri Torgemane
 * 
 * See LICENSE.txt for full license information.
 */
package com.hurlant.crypto.symmetric
{
	import flash.utils.ByteArray;

	public class CTRMode extends IVMode implements IMode
	{

		public function CTRMode(key:ISymmetricKey, padding:IPad = null) {
			super(key, padding);
		}
		
		public function encrypt(src:ByteArray):void
		{
			padding.pad(src);
			var vector:ByteArray = getIV4e();
			core(src, vector);
		}
		
		public function decrypt(src:ByteArray):void
		{
			var vector:ByteArray = getIV4d();
			core(src, vector);
			padding.unpad(src);
		}
		
		private function core(src:ByteArray, iv:ByteArray):void {
			var X:ByteArray = new ByteArray;
			var Xenc:ByteArray = new ByteArray;
			X.writeBytes(iv);
			for (var i:uint=0;i<src.length;i+=blockSize) {
				Xenc.position=0;
				Xenc.writeBytes(X);
				key.encrypt(Xenc);
				for (var j:uint=0;j<blockSize;j++) {
					src[i+j] ^= Xenc[j];
				}
				
 				for (j=blockSize-1;j>=0;--j) {
					X[j]++;
					if (X[j]!=0)
						break;
				}
			}
		}
		public function toString():String {
			return key.toString()+"-ctr";
		}
		
	}
}

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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.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/symmetric/CTRMode.as
rocket-js-0.0.2 src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as