Exemplo n.º 1
0
 internal static unsafe int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput)
 {
     fixed(byte *pbOutputPtr = &pbOutput.DangerousGetPinnableReference())
     {
         return(HmacFinal(ctx, pbOutputPtr, cbOutput));
     }
 }
Exemplo n.º 2
0
 internal static unsafe int HmacInit(SafeHmacHandle ctx, ReadOnlySpan <byte> key)
 {
     fixed(byte *pKey = &MemoryMarshal.GetReference(key))
     {
         return(HmacInit(ctx, pKey, key.Length));
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 internal static unsafe int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData)
 {
     fixed(byte *pbDataPtr = &pbData.DangerousGetPinnableReference())
     {
         return(HmacUpdate(ctx, pbDataPtr, cbData));
     }
 }
Exemplo n.º 5
0
            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;
            }
Exemplo n.º 6
0
 private static extern int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData);
Exemplo n.º 7
0
 internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput) =>
 HmacFinal(ctx, ref MemoryMarshal.GetReference(pbOutput), cbOutput);
Exemplo n.º 8
0
 internal static extern unsafe int HmacInit(SafeHmacHandle ctx, [In] byte[] pbKey, int cbKey);
Exemplo n.º 9
0
 internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData) =>
 HmacUpdate(ctx, ref MemoryMarshal.GetReference(pbData), cbData);
Exemplo n.º 10
0
 private static extern int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
Exemplo n.º 11
0
 internal static partial int HmacInit(SafeHmacHandle ctx, byte[] pbKey, int cbKey);
Exemplo n.º 12
0
 internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> data) =>
 HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), data.Length);
Exemplo n.º 13
0
 internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan <byte> pbOutput, int cbOutput) =>
 HmacFinal(ctx, ref pbOutput.DangerousGetPinnableReference(), cbOutput);
Exemplo n.º 14
0
 private static partial int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
Exemplo n.º 15
0
 internal static extern unsafe int HmacUpdate(SafeHmacHandle ctx, byte *pbData, int cbData);
Exemplo n.º 16
0
 private static partial int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData);
Exemplo n.º 17
0
 internal static extern unsafe int HmacFinal(SafeHmacHandle ctx, byte *pbOutput, int cbOutput);
Exemplo n.º 18
0
 private static unsafe partial int HmacInit(SafeHmacHandle ctx, byte *pbKey, int cbKey);
Exemplo n.º 19
0
 private static extern unsafe int HmacFinal(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
Exemplo n.º 20
0
 internal static int HmacCurrent(SafeHmacHandle ctx, ReadOnlySpan <byte> output) =>
 HmacCurrent(ctx, ref MemoryMarshal.GetReference(output), output.Length);
Exemplo n.º 21
0
 private static partial int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);
Exemplo n.º 22
0
 internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan <byte> pbData, int cbData) =>
 HmacUpdate(ctx, ref pbData.DangerousGetPinnableReference(), cbData);