Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Swift;
using System.Security.Cryptography.Apple;

#pragma warning disable CS3016 // Arrays as attribute arguments are not CLS Compliant

internal static partial class Interop
{
internal static partial class AppleCrypto
{
[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFree")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
internal static partial void HmacFree(IntPtr handle);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCreate")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
internal static partial SafeHmacHandle HmacCreate(PAL_HashAlgorithm algorithm, ref int cbDigest);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacInit")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
private static unsafe partial int HmacInit(SafeHmacHandle ctx, byte* pbKey, int cbKey);

internal static unsafe int HmacInit(SafeHmacHandle ctx, ReadOnlySpan<byte> key)
Expand All @@ -30,21 +37,25 @@ internal static int HmacUpdate(SafeHmacHandle ctx, ReadOnlySpan<byte> data) =>
HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), data.Length);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacUpdate")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
private static partial int HmacUpdate(SafeHmacHandle ctx, ref byte pbData, int cbData);

internal static int HmacFinal(SafeHmacHandle ctx, ReadOnlySpan<byte> output) =>
HmacFinal(ctx, ref MemoryMarshal.GetReference(output), output.Length);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFinal")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
private static partial 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);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCurrent")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
private static partial int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacOneShot")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
internal static unsafe partial int HmacOneShot(
PAL_HashAlgorithm algorithm,
byte* pKey,
Expand All @@ -56,6 +67,7 @@ internal static unsafe partial int HmacOneShot(
int* cbDigest);

[LibraryImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacClone")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvSwift) ])]
internal static partial SafeHmacHandle HmacClone(SafeHmacHandle ctx);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ append_extra_cryptography_apple_libs(NATIVE_LIBS_EXTRA)

set(NATIVECRYPTO_SOURCES
pal_ecc.c
pal_hmac.c
pal_keyagree.c
pal_keyderivation.c
pal_random.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Include System.Security.Cryptography.Native.Apple headers
#include "pal_digest.h"
#include "pal_ecc.h"
#include "pal_hmac.h"
#include "pal_keyagree.h"
#include "pal_keychain_macos.h"
#include "pal_keyderivation.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ enum
};
typedef uint32_t PAL_HashAlgorithm;

typedef struct digest_ctx_st DigestCtx;
163 changes: 0 additions & 163 deletions src/native/libs/System.Security.Cryptography.Native.Apple/pal_hmac.c

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ EXTERN_C void* AppleCryptoNative_DigestCurrent;
EXTERN_C void* AppleCryptoNative_DigestOneShot;
EXTERN_C void* AppleCryptoNative_DigestReset;
EXTERN_C void* AppleCryptoNative_DigestClone;

EXTERN_C void* AppleCryptoNative_HmacFree;
EXTERN_C void* AppleCryptoNative_HmacCreate;
EXTERN_C void* AppleCryptoNative_HmacInit;
EXTERN_C void* AppleCryptoNative_HmacUpdate;
EXTERN_C void* AppleCryptoNative_HmacFinal;
EXTERN_C void* AppleCryptoNative_HmacCurrent;
EXTERN_C void* AppleCryptoNative_HmacOneShot;
EXTERN_C void* AppleCryptoNative_HmacClone;

Loading
Loading