/// <summary> /// Returns the secret key to use for initializing the Mac. /// </summary> /// <param name="algorithm">The algorithm.</param> /// <param name="keyMaterial">The key material.</param> /// <returns>The secret key.</returns> internal static SecretKeySpec GetSecretKey(MacAlgorithm algorithm, byte[] keyMaterial) { string algorithmName = MacAlgorithmProviderFactory.GetAlgorithmName(algorithm); var signingKey = new SecretKeySpec(keyMaterial, algorithmName); return(signingKey); }
/// <summary>Returns the keyed hash algorithm from the platform.</summary> /// <param name="algorithm">The algorithm desired.</param> /// <returns>The platform-specific algorithm.</returns> internal static Platform.KeyedHashAlgorithm GetAlgorithm(MacAlgorithm algorithm) { #if SILVERLIGHT switch (algorithm) { case MacAlgorithm.HmacSha1: return(new Platform.HMACSHA1()); case MacAlgorithm.HmacSha256: return(new Platform.HMACSHA256()); default: throw new NotSupportedException(); } #else string algorithmName = MacAlgorithmProviderFactory.GetAlgorithmName(algorithm); var result = Platform.KeyedHashAlgorithm.Create(algorithmName); if (result == null) { throw new NotSupportedException(); } return(result); #endif }
/// <summary> /// Returns the keyed hash algorithm from the platform. /// </summary> /// <param name="algorithm">The algorithm desired.</param> /// <returns>The platform-specific algorithm.</returns> internal static Platform.KeyedHashAlgorithm GetAlgorithm(MacAlgorithm algorithm) { string algorithmName = MacAlgorithmProviderFactory.GetAlgorithmName(algorithm); var result = Platform.KeyedHashAlgorithm.Create(algorithmName); if (result == null) { throw new NotSupportedException(); } return(result); }
/// <summary> /// Returns the keyed hash algorithm from the platform. /// </summary> /// <param name="algorithm">The algorithm desired.</param> /// <returns>The platform-specific algorithm.</returns> internal static Mac GetAlgorithm(MacAlgorithm algorithm) { string algorithmName = MacAlgorithmProviderFactory.GetAlgorithmName(algorithm); try { return(Mac.GetInstance(algorithmName)); } catch (Java.Security.NoSuchAlgorithmException ex) { throw new NotSupportedException(ex.Message, ex); } }
/// <summary> /// Returns the keyed hash algorithm from the platform. /// </summary> /// <param name="algorithm">The algorithm desired.</param> /// <returns>The platform-specific algorithm.</returns> internal static Mac GetAlgorithm(MacAlgorithm algorithm) { string algorithmName = MacAlgorithmProviderFactory.GetAlgorithmName(algorithm); return(Mac.GetInstance(algorithmName)); }