/// <inheritdoc /> protected internal override byte[] Sign(byte[] data) { using (var algorithm = MacAlgorithmProvider.GetAlgorithm(this.algorithm)) { #if Android algorithm.Init(MacAlgorithmProvider.GetSecretKey(this.algorithm, this.key)); return(algorithm.DoFinal(data)); #else algorithm.Key = this.key; return(algorithm.ComputeHash(data)); #endif } }
/// <inheritdoc /> protected internal override byte[] Sign(byte[] data) { using (var algorithm = MacAlgorithmProvider.GetAlgorithm(this.algorithm)) { #if __ANDROID__ using Javax.Crypto.Spec.SecretKeySpec key = MacAlgorithmProvider.GetSecretKey(this.algorithm, this.key); algorithm.Init(key); return(algorithm.DoFinal(data) !); #else algorithm.Key = this.key; return(algorithm.ComputeHash(data)); #endif } }
/// <inheritdoc /> protected internal override bool VerifySignature(byte[] data, byte[] signature) { using (var algorithm = MacAlgorithmProvider.GetAlgorithm(this.algorithm)) { byte[] computedMac; #if Android algorithm.Init(MacAlgorithmProvider.GetSecretKey(this.algorithm, this.key)); computedMac = algorithm.DoFinal(data); #else algorithm.Key = this.key; computedMac = algorithm.ComputeHash(data); #endif return(CryptoUtilities.BufferEquals(computedMac, signature)); } }