DulocCastle is a general cryptographic library written in Swift.

Swift Version License

I was looking for a nice cryptographic library that easily interfaces with Apple CommonCrypto and Keychain. I couldn’t find anything that really got the job done so I’ve decided to take a crack at it myself.

The intention of this library is that it will not depend on any other libraries and will be fully self contained. It will be a fully loaded PKI library that will support the most common cryptpgraphic structures and functions.

A lot of inspiration for the creation of this library was BouncyCastle in Java and it’s lack of existence in Swift.


PKI Features

ASN.1 Decoder (0.1.0)

  • Reading ASN.1 BER/DER/CER format
  • Conversion of ASN.1 data to Swift types
  • Ease of use functionality for ASN.1 traversal (probably with dictionaries)

ASN.1 Encoder (0.2.0)

  • Encoding bytes using the ASN.1 BER/DER encoding format
  • Easy insertion of new bytes to already written structure
  • Composition of structured and nested types
  • Wrapping of existing structures

General PKI Structures (0.4.0)

  • PEM to DER Conversion (0.3.1)
  • DER to PEM Conversion (0.3.1)
  • RSA and ECC key generation (Apple SecKey/Secure Enclave) (0.3.2)
    • Biometric usage
    • Saving to KeyChain
    • Encryption with keys
    • Signing with keys
    • ASN.1 representation
  • Distinguished Name (0.4.1)
    • Swift
    • ASN.1
  • X509 Certificate (0.4.2)
    • Swift
    • ASN.1
    • Saved as Apple SecCertificate
    • Store the the Key Chain
  • Certificate Revocation List (0.4.3)
    • Swift
    • ASN.1
  • PKCS#10 Certificate Signing Request (0.4.4)
    • Swift
    • ASN.1
  • PKCS#7 (0.4.5)
    • Swift
    • ASN.1


There isn't really anything to use at the moment but keep checking back!



View Github