diff options
author | Hiroshi Ichikawa <gimite@gmail.com> | 2011-08-28 22:14:15 +0900 |
---|---|---|
committer | Hiroshi Ichikawa <gimite@gmail.com> | 2011-08-28 22:14:15 +0900 |
commit | 80c91d84bc3e84f684f53172e8eb7cad81795fb1 (patch) | |
tree | 70d3a71d8020902ed246fc7b908ebf9c3478f653 /flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as | |
parent | ed0622a890de811eb6d766d5c5a9a62d726f0593 (diff) | |
download | web-socket-js-80c91d84bc3e84f684f53172e8eb7cad81795fb1.tar.gz |
Moving our own .as files into flash-src/src and third-party .as files into flash-src/third-party.
Adding build rule for WebSocketWithoutDependencies.swc.
Diffstat (limited to 'flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as')
-rwxr-xr-x | flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as b/flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as new file mode 100755 index 0000000..8dd1324 --- /dev/null +++ b/flash-src/third-party/com/hurlant/crypto/symmetric/SSLPad.as @@ -0,0 +1,44 @@ +/** + * TLSPad + * + * A padding implementation used by TLS + * 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.Hex; + import com.hurlant.crypto.tls.TLSError; + + public class SSLPad implements IPad { + private var blockSize:uint; + + public function SSLPad(blockSize:uint=0) { + this.blockSize = blockSize; + } + public function pad(a:ByteArray):void { + var c:uint = blockSize - (a.length+1)%blockSize; + for (var i:uint=0;i<=c;i++) { + a[a.length] = c; + } + + } + public function unpad(a:ByteArray):void { + var c:uint = a.length%blockSize; + if (c!=0) throw new TLSError("SSLPad::unpad: ByteArray.length isn't a multiple of the blockSize", TLSError.bad_record_mac); + c = a[a.length-1]; + for (var i:uint=c;i>0;i--) { + var v:uint = a[a.length-1]; + a.length--; + // But LOOK! SSL 3.0 doesn't care about this, bytes are arbitrary! + // if (c!=v) throw new TLSError("SSLPad:unpad: Invalid padding value. expected ["+c+"], found ["+v+"]", TLSError.bad_record_mac); + } + a.length--; + + } + public function setBlockSize(bs:uint):void { + blockSize = bs; + } + } +}
\ No newline at end of file |