public static unsafe int HashData(string hashAlgorithmId, ReadOnlySpan <byte> source, Span <byte> destination) { Interop.AppleCrypto.PAL_HashAlgorithm algorithm = HashAlgorithmNames.HashAlgorithmToPal(hashAlgorithmId); fixed(byte *pSource = source) fixed(byte *pDestination = destination) { int digestSize; int ret = Interop.AppleCrypto.DigestOneShot( algorithm, pSource, source.Length, pDestination, destination.Length, &digestSize); if (ret != 1) { Debug.Fail($"HashData return value {ret} was not 1"); throw new CryptographicException(); } Debug.Assert(digestSize <= destination.Length); return(digestSize); } }
public AppleHmacProvider(string hashAlgorithmId, ReadOnlySpan <byte> key) { PAL_HashAlgorithm algorithm = HashAlgorithmNames.HashAlgorithmToPal(hashAlgorithmId); _liteHmac = new LiteHmac(algorithm, key, preinitialize: false); _key = key.ToArray(); }
public byte[] SignHash(byte[] rgbHash, string str) { if (rgbHash == null) throw new ArgumentNullException(nameof(rgbHash)); if (PublicOnly) throw new CryptographicException(SR.Cryptography_CSP_NoPrivateKey); HashAlgorithmName algName = HashAlgorithmNames.NameOrOidToHashAlgorithmName(str); return _impl.SignHash(rgbHash, algName, RSASignaturePadding.Pkcs1); }
public bool VerifyHash(byte[] rgbHash, string str, byte[] rgbSignature) { if (rgbHash == null) throw new ArgumentNullException(nameof(rgbHash)); if (rgbSignature == null) throw new ArgumentNullException(nameof(rgbSignature)); // _impl does remaining parameter validation HashAlgorithmName algName = HashAlgorithmNames.NameOrOidToHashAlgorithmName(str); return _impl.VerifyHash(rgbHash, rgbSignature, algName, RSASignaturePadding.Pkcs1); }
public override void SetHashAlgorithm(string strName) { // Verify the name if (CryptoConfig.MapNameToOID(strName) != null) { // Uppercase known names as required for BCrypt _algName = HashAlgorithmNames.ToUpper(strName); } else { // For .NET Framework compat, exception is deferred until VerifySignature _algName = null; } }
public override void SetHashAlgorithm(string strName) { try { // Verify the name Oid.FromFriendlyName(strName, OidGroup.HashAlgorithm); // Uppercase known names as required for BCrypt _algName = HashAlgorithmNames.ToUpper(strName); } catch (CryptographicException) { // For desktop compat, exception is deferred until VerifySignature _algName = null; } }
internal static LiteHmac CreateHmac(string hashAlgorithmId, ReadOnlySpan <byte> key) { PAL_HashAlgorithm algorithm = HashAlgorithmNames.HashAlgorithmToPal(hashAlgorithmId); return(new LiteHmac(algorithm, key, preinitialize: true)); }
internal static LiteHash CreateHash(string hashAlgorithmId) { PAL_HashAlgorithm algorithm = HashAlgorithmNames.HashAlgorithmToPal(hashAlgorithmId); return(new LiteHash(algorithm)); }
public bool VerifyData(byte[] buffer, object halg, byte[] signature) => _impl.VerifyData(buffer, signature, HashAlgorithmNames.ObjToHashAlgorithmName(halg), RSASignaturePadding.Pkcs1);
public byte[] SignData(Stream inputStream, object halg) => _impl.SignData(inputStream, HashAlgorithmNames.ObjToHashAlgorithmName(halg), RSASignaturePadding.Pkcs1);
public byte[] SignData(byte[] buffer, object halg) => _impl.SignData(buffer, HashAlgorithmNames.ObjToHashAlgorithmName(halg), RSASignaturePadding.Pkcs1);