public byte[] TestDigest(HandshakeHashType algorithm, byte[] data) { var hash = CreateHash(algorithm); hash.TransformFinalBlock(data, 0, data.Length); return(hash.Hash); }
public byte[] TestPRF (HandshakeHashType algorithm, byte[] secret, string seed, byte[] data, int length) { var prf = new PseudoRandomFunctionTls12 (algorithm); var result = prf.PRF (SecureBuffer.CreateCopy (secret), seed, SecureBuffer.CreateCopy (data), length); return result.StealBuffer (); }
public byte[] TestPRF(HandshakeHashType algorithm, byte[] secret, string seed, byte[] data, int length) { var prf = new PseudoRandomFunctionTls12(algorithm); var result = prf.PRF(SecureBuffer.CreateCopy(secret), seed, SecureBuffer.CreateCopy(data), length); return(result.StealBuffer()); }
HashAlgorithm CreateHash (HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return SHA256.Create (); case HandshakeHashType.SHA384: return SHA384.Create (); default: throw new NotSupportedException (); } }
NativeCryptoHashType GetAlgorithm (HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return NativeCryptoHashType.SHA256; case HandshakeHashType.SHA384: return NativeCryptoHashType.SHA384; default: throw new NotSupportedException (); } }
IHashAlgorithm GetAlgorithm (HandshakeHashType type) { switch (type) { case HandshakeHashType.MD5SHA1: return hashes [0]; case HandshakeHashType.SHA256: return hashes [3]; case HandshakeHashType.SHA384: return hashes [4]; default: throw new InvalidOperationException (); } }
public byte[] TestHMac(HandshakeHashType algorithm, byte[] key, byte[] data) { var hmac = HMac.Create(algorithm, SecureBuffer.CreateCopy(key)); hmac.Reset(); hmac.TransformBlock(data, 0, data.Length); var output = new byte [hmac.MacSize]; hmac.TransformFinalBlock(output, 0, output.Length); return(output); }
int GetMacSize(HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return(32); case HandshakeHashType.SHA384: return(48); default: throw new NotSupportedException(); } }
int GetAlgorithm(HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return(native_crypto_test_get_prf_algorithm_sha256()); case HandshakeHashType.SHA384: return(native_crypto_test_get_prf_algorithm_sha384()); default: throw new NotSupportedException(); } }
HashAlgorithm CreateHash(HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return(SHA256.Create()); case HandshakeHashType.SHA384: return(SHA384.Create()); default: throw new NotSupportedException(); } }
public static HMac Create(HandshakeHashType type, SecureBuffer key) { switch (type) { case HandshakeHashType.SHA256: return(new HMac(SHA256.Create(), 64, key)); case HandshakeHashType.SHA384: return(new HMac(SHA384.Create(), 128, key)); default: throw new NotSupportedException(); } }
NativeCryptoHashType GetAlgorithm(HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return(NativeCryptoHashType.SHA256); case HandshakeHashType.SHA384: return(NativeCryptoHashType.SHA384); default: throw new NotSupportedException(); } }
public byte[] TestHMac(HandshakeHashType algorithm, byte[] key, byte[] data) { var type = GetAlgorithm(algorithm); int macSize = GetMacSize(algorithm); var output = new byte [macSize]; int ret = native_crypto_test_HMac(type, data, data.Length, null, 0, null, 0, null, 0, null, 0, key, key.Length, output, macSize); if (ret != 1) { throw new InvalidOperationException(); } return(output); }
public byte[] TestPRF(HandshakeHashType algorithm, byte[] secret, string seed, byte[] data, int length) { var digest_mask = GetAlgorithm(algorithm); var output = new byte [length]; var temp = new byte [length]; var seedBytes = Encoding.ASCII.GetBytes(seed); int ret = native_crypto_test_PRF(digest_mask, seedBytes, seedBytes.Length, data, data.Length, null, 0, null, 0, null, 0, secret, secret.Length, output, temp, length); if (ret != 1) { throw new InvalidOperationException(); } return(output); }
public byte[] TestDigest(HandshakeHashType algorithm, byte[] data) { var type = GetAlgorithm(algorithm); var output = new byte [200]; var ret = native_crypto_test_digest(type, data, data.Length, output, output.Length); if (ret <= 0) { throw new InvalidOperationException(); } var buffer = new byte [ret]; Buffer.BlockCopy(output, 0, buffer, 0, ret); return(buffer); }
IHashAlgorithm GetAlgorithm(HandshakeHashType type) { switch (type) { case HandshakeHashType.MD5SHA1: return(hashes [0]); case HandshakeHashType.SHA256: return(hashes [3]); case HandshakeHashType.SHA384: return(hashes [4]); default: throw new InvalidOperationException(); } }
public byte[] TestDigest (HandshakeHashType algorithm, byte[] data) { var hash = CreateHash (algorithm); hash.TransformFinalBlock (data, 0, data.Length); return hash.Hash; }
public byte[] TestPRF (HandshakeHashType algorithm, byte[] secret, string seed, byte[] data, int length) { var digest_mask = GetAlgorithm (algorithm); var output = new byte [length]; var temp = new byte [length]; var seedBytes = Encoding.ASCII.GetBytes (seed); int ret = native_crypto_test_PRF (digest_mask, seedBytes, seedBytes.Length, data, data.Length, null, 0, null, 0, null, 0, secret, secret.Length, output, temp, length); if (ret != 1) throw new InvalidOperationException (); return output; }
public byte[] TestHMac (HandshakeHashType algorithm, byte[] key, byte[] data) { var type = GetAlgorithm (algorithm); int macSize = GetMacSize (algorithm); var output = new byte [macSize]; int ret = native_crypto_test_HMac (type, data, data.Length, null, 0, null, 0, null, 0, null, 0, key, key.Length, output, macSize); if (ret != 1) throw new InvalidOperationException (); return output; }
public byte[] TestDigest (HandshakeHashType algorithm, byte[] data) { var type = GetAlgorithm (algorithm); var output = new byte [200]; var ret = native_crypto_test_digest (type, data, data.Length, output, output.Length); if (ret <= 0) throw new InvalidOperationException (); var buffer = new byte [ret]; Buffer.BlockCopy (output, 0, buffer, 0, ret); return buffer; }
public PseudoRandomFunctionTls12 (HandshakeHashType hashType) { HandshakeHashType = hashType; }
public static HMac Create (HandshakeHashType type, SecureBuffer key) { switch (type) { case HandshakeHashType.SHA256: return new HMac (SHA256.Create (), 64, key); case HandshakeHashType.SHA384: return new HMac (SHA384.Create (), 128, key); default: throw new NotSupportedException (); } }
public SecureBuffer GetHash(HandshakeHashType type) { return(new SecureBuffer(GetAlgorithm(type).GetRunningHash())); }
public SecureBuffer GetHash (HandshakeHashType type) { return new SecureBuffer (GetAlgorithm (type).GetRunningHash ()); }
int GetMacSize (HandshakeHashType algorithm) { switch (algorithm) { case HandshakeHashType.SHA256: return 32; case HandshakeHashType.SHA384: return 48; default: throw new NotSupportedException(); } }
public PseudoRandomFunctionTls12(HandshakeHashType hashType) { HandshakeHashType = hashType; }
public byte[] TestHMac (HandshakeHashType algorithm, byte[] key, byte[] data) { var hmac = HMac.Create (algorithm, SecureBuffer.CreateCopy (key)); hmac.Reset (); hmac.TransformBlock (data, 0, data.Length); var output = new byte [hmac.MacSize]; hmac.TransformFinalBlock (output, 0, output.Length); return output; }