internal static unsafe int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput) { fixed(byte *pbOutputPtr = &pbOutput.DangerousGetPinnableReference()) { return(HmacFinal(ctx, pbOutputPtr, cbOutput)); } }
internal static unsafe int HmacInit(SafeHmacHandle ctx, ReadOnlySpan <byte> key) { fixed(byte *pKey = &MemoryMarshal.GetReference(key)) { return(HmacInit(ctx, pKey, key.Length)); } }
internal LiteHmac(PAL_HashAlgorithm algorithm, ReadOnlySpan <byte> key, bool preinitialize) { int hashSizeInBytes = 0; _ctx = Interop.AppleCrypto.HmacCreate(algorithm, ref hashSizeInBytes); if (hashSizeInBytes < 0) { _ctx.Dispose(); throw new PlatformNotSupportedException( SR.Format( SR.Cryptography_UnknownHashAlgorithm, Enum.GetName(typeof(Interop.AppleCrypto.PAL_HashAlgorithm), algorithm))); } if (_ctx.IsInvalid) { _ctx.Dispose(); throw new CryptographicException(); } if (preinitialize) { if (Interop.AppleCrypto.HmacInit(_ctx, key) != Success) { _ctx.Dispose(); throw new CryptographicException(); } } _hashSizeInBytes = hashSizeInBytes; }
internal static unsafe int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData) { fixed(byte *pbDataPtr = &pbData.DangerousGetPinnableReference()) { return(HmacUpdate(ctx, pbDataPtr, cbData)); } }
internal AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm algorithm, byte[] key) { _key = key.CloneByteArray(); int hashSizeInBytes = 0; _ctx = Interop.AppleCrypto.HmacCreate(algorithm, ref hashSizeInBytes); if (hashSizeInBytes < 0) { _ctx.Dispose(); throw new PlatformNotSupportedException( SR.Format( SR.Cryptography_UnknownHashAlgorithm, Enum.GetName(typeof(Interop.AppleCrypto.PAL_HashAlgorithm), algorithm))); } if (_ctx.IsInvalid) { _ctx.Dispose(); throw new CryptographicException(); } HashSizeInBytes = hashSizeInBytes; }
private static extern int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData);
internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput) => HmacFinal(ctx, ref MemoryMarshal.GetReference(pbOutput), cbOutput);
internal static extern unsafe int HmacInit(SafeHmacHandle ctx, [In] byte[] pbKey, int cbKey);
internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData) => HmacUpdate(ctx, ref MemoryMarshal.GetReference(pbData), cbData);
private static extern int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
internal static partial int HmacInit(SafeHmacHandle ctx, byte[] pbKey, int cbKey);
internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> data) => HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), data.Length);
internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput) => HmacFinal(ctx, ref pbOutput.DangerousGetPinnableReference(), cbOutput);
private static partial int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
internal static extern unsafe int HmacUpdate(SafeHmacHandle ctx, byte *pbData, int cbData);
private static partial int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData);
internal static extern unsafe int HmacFinal(SafeHmacHandle ctx, byte *pbOutput, int cbOutput);
private static unsafe partial int HmacInit(SafeHmacHandle ctx, byte *pbKey, int cbKey);
private static extern unsafe int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
internal static int HmacCurrent(SafeHmacHandle ctx, ReadOnlySpan <byte> output) => HmacCurrent(ctx, ref MemoryMarshal.GetReference(output), output.Length);
private static partial int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData) => HmacUpdate(ctx, ref pbData.DangerousGetPinnableReference(), cbData);