PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/flash-src/third-party/com/hurlant/crypto/tls/MACs.as

http://github.com/gimite/web-socket-js
ActionScript | 38 lines | 23 code | 7 blank | 8 comment | 1 complexity | 62c9883a26d68969193b6e0ea77e1e3f MD5 | raw file
 1/**
 2 * MACs
 3 * 
 4 * An enumeration of MACs implemented for TLS 1.0/SSL 3.0
 5 * Copyright (c) 2007 Henri Torgemane
 6 * 
 7 * See LICENSE.txt for full license information.
 8 */
 9package com.hurlant.crypto.tls {
10	import com.hurlant.crypto.Crypto;
11	import com.hurlant.crypto.hash.HMAC;
12	import com.hurlant.crypto.hash.MAC;
13	
14	public class MACs {
15		public static const NULL:uint = 0;
16		public static const MD5:uint = 1;
17		public static const SHA1:uint = 2;
18		
19		public static function getHashSize(hash:uint):uint {
20			return [0,16,20][hash];
21		}	
22		
23		public static function getPadSize(hash:uint):int {
24			return [0, 48, 40][hash];
25		}	
26		
27		public static function getHMAC(hash:uint):HMAC {
28			if (hash==NULL) return null;
29			return Crypto.getHMAC(['',"md5","sha1"][hash]);
30		}
31	
32		public static function getMAC(hash:uint):MAC {
33			return Crypto.getMAC(['', "md5", "sha1"][hash]);
34		} 
35		
36		
37	}
38}