From b60df56157ee1fd0bd4938799bac05a62fda91a1 Mon Sep 17 00:00:00 2001 From: lookshe Date: Sat, 14 Mar 2015 20:45:20 +0100 Subject: initial commit from working version --- .../com/hurlant/crypto/symmetric/SimpleIVMode.as | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as (limited to 'signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as') diff --git a/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as new file mode 100644 index 0000000..590f0df --- /dev/null +++ b/signaling-server/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as @@ -0,0 +1,60 @@ +/** + * SimpleIVMode + * + * A convenience class that automatically places the IV + * at the beginning of the encrypted stream, so it doesn't have to + * be handled explicitely. + * Copyright (c) 2007 Henri Torgemane + * + * See LICENSE.txt for full license information. + */ +package com.hurlant.crypto.symmetric +{ + import flash.utils.ByteArray; + import com.hurlant.util.Memory; + + public class SimpleIVMode implements IMode, ICipher + { + protected var mode:IVMode; + protected var cipher:ICipher; + + public function SimpleIVMode(mode:IVMode) { + this.mode = mode; + cipher = mode as ICipher; + } + + public function getBlockSize():uint { + return mode.getBlockSize(); + } + + public function dispose():void { + mode.dispose(); + mode = null; + cipher = null; + Memory.gc(); + } + + public function encrypt(src:ByteArray):void { + cipher.encrypt(src); + var tmp:ByteArray = new ByteArray; + tmp.writeBytes(mode.IV); + tmp.writeBytes(src); + src.position=0; + src.writeBytes(tmp); + } + + public function decrypt(src:ByteArray):void { + var tmp:ByteArray = new ByteArray; + tmp.writeBytes(src, 0, getBlockSize()); + mode.IV = tmp; + tmp = new ByteArray; + tmp.writeBytes(src, getBlockSize()); + cipher.decrypt(tmp); + src.length=0; + src.writeBytes(tmp); + } + public function toString():String { + return "simple-"+cipher.toString(); + } + } +} \ No newline at end of file -- cgit v1.2.3