Skip to main content
net10.0-ios26.2net10.0-maccatalyst26.2net10.0-macos26.2net10.0-tvos26.2

Native Swift interop bindings for Apple CryptoKit

Published
May 3, 2026
5mo ago
Total Downloads
1.6K
1,575

Install

dotnet add package SwiftBindings.Apple.CryptoKit --version 26.2.1
ProductVersions
.NET
net10.0-ios26.2net10.0-maccatalyst26.2net10.0-macos26.2net10.0-tvos26.2

README

SwiftBindings.Apple.CryptoKit

Native .NET bindings for Apple's CryptoKit framework — hashing, symmetric and authenticated encryption, key agreement, and signatures. These are not Objective-C proxy wrappers; they use .NET 10's native Swift interop for direct, high-performance calls into Swift APIs from C#.

Installation

dotnet add package SwiftBindings.Apple.CryptoKit

Requirements

  • .NET 10.0+
  • iOS 26.2+, macOS 26.2+, Mac Catalyst 26.2+, tvOS 26.2+
  • macOS host for development

Usage

Hashing

using System.Text;
using CryptoKit;

var data = Encoding.UTF8.GetBytes("hello");
var digest = SHA256.Hash(data);

Authenticated encryption (AES-GCM)

using System.Text;
using CryptoKit;

var key = new SymmetricKey(SymmetricKeySize.Bits256);
var plaintext = Encoding.UTF8.GetBytes("secret message");

var sealedBox = AES.GCM.Seal(plaintext, key);
var recovered = AES.GCM.Open(sealedBox, key);

ChaChaPoly

var key = new SymmetricKey(SymmetricKeySize.Bits256);
var sealedBox = ChaChaPoly.Seal(plaintext, key);
var recovered = ChaChaPoly.Open(sealedBox, key);

Authenticated encryption with associated data

var aad = Encoding.UTF8.GetBytes("authenticated-header");
var sealedBox = AES.GCM.Seal(plaintext, key, aad);
// sealedBox.Ciphertext / sealedBox.Tag are exposed as byte[]

Documentation

Caveats

The primary AEAD round-trip (AES.GCM and ChaChaPoly Seal/Open) is verified end-to-end on both Mono JIT (simulator) and NativeAOT (device).

A residual cluster of ancillary CryptoKit APIs are emitted as [Obsolete("SB0001")] stubs and are not callable from C# in this release:

  • HMAC constructor
  • Signature generation (P-256/P-384/P-521 ECDSA signature(for:))
  • HPKE Unwrap / Decapsulate / ExportSecret
  • AES.GCM.Open<TAD> (the generic overload that takes authenticated-data of an arbitrary DataProtocol type)
  • The 3-argument IsValidSignature(_:for:) overload

Tamper detection is exercised via wrong-key Open (which throws authenticationFailure) rather than the SealedBox(nonce:ciphertext:tag:) constructor (a Swift generic init the binding generator does not yet emit).

How It Works

These bindings are auto-generated by Swift Dotnet Bindings using .NET 10's native Swift interop via the SwiftBindings SDK.

License

The bindings are MIT licensed. CryptoKit is part of the Apple SDK; refer to Apple's licensing for the underlying framework.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.