Crypto
A cryptography library for Swift.
import Crypto
Module information
- Declarations
- 478
- Symbols
- 883
Overview
Swift Crypto provides a Swift library for common cryptographic operations. It is available as a Swift package and provides two main libraries:
Crypto
- an open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms. It enables cross-platform or server applications with the advantages of CryptoKit.CryptoExtras
- a collection of additional cryptographic primitives and utilities that are not part of CryptoKit but useful in a server environment.
Swift Crypto is built on top of BoringSSL, Google’s fork of OpenSSL. The current features of Swift Crypto cover key exchange, key derivation, encryption and decryption, hashing, message authentication, and more.
Cryptographically secure hashes
protocol HashFunction
A type that performs cryptographically secure hashing.
struct SHA512
An implementation of Secure Hashing Algorithm 2 (SHA-2) hashing with a 512-bit digest.
struct SHA384
An implementation of Secure Hashing Algorithm 2 (SHA-2) hashing with a 384-bit digest.
struct SHA256
An implementation of Secure Hashing Algorithm 2 (SHA-2) hashing with a 256-bit digest.
Message authentication codes
struct HMAC<H>
A hash-based message authentication algorithm.
struct SymmetricKey
A symmetric cryptographic key.
struct SymmetricKeySize
The sizes that a symmetric cryptographic key can take.
Ciphers
enum AES
A container for Advanced Encryption Standard (AES) ciphers.
enum ChaChaPoly
An implementation of the ChaCha20-Poly1305 cipher.
Public key cryptography
enum Curve25519
An elliptic curve that enables X25519 key agreement and Ed25519 signatures.
enum P521
An elliptic curve that enables NIST P-521 signatures and key agreement.
enum P384
An elliptic curve that enables NIST P-384 signatures and key agreement.
enum P256
An elliptic curve that enables NIST P-256 signatures and key agreement.
struct SharedSecret
A key agreement result from which you can derive a symmetric cryptographic key.
enum HPKE
A container for hybrid public key encryption (HPKE) operations.
Key derivation functions
struct HKDF<H>
A standards-based implementation of an HMAC-based Key Derivation Function (HKDF).
Errors
enum CryptoKitError
General cryptography errors used by CryptoKit.
enum CryptoKitASN1Error
Errors from decoding ASN.1 content.
Legacy algorithms
enum Insecure
A container for older, cryptographically insecure algorithms.