Swiftpack.co - dracoon/dracoon-swift-crypto-sdk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dracoon.
dracoon/dracoon-swift-crypto-sdk v2.2.1
Official DRACOON Crypto SDK for Swift
⭐️ 0
🕓 1 year ago
.package(url: "https://github.com/dracoon/dracoon-swift-crypto-sdk.git", from: "v2.2.1")

DRACOON Swift Crypto SDK

A library which implements the client-side encryption of DRACOON.


A detailed description of client-side encryption of DRACOON can be found here:



Minimum Requirements

Xcode 13

Swift Package Manager

Add this line to the dependencies section of your Package.swift:

.package(name: "crypto_sdk", url: "https://github.com/dracoon/dracoon-swift-crypto-sdk", .upToNextMajor(from: "2.2.1"))


Add the SDK to your Cartfile:

github "dracoon/dracoon-swift-crypto-sdk.git" ~> 2.2.1

Then run

carthage update --platform iOS

to create a framework or

carthage update --use-xcframeworks --platform iOS

to create an xcframework.


Add to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'

target '<Your Target Name>' do
pod 'DRACOON-Crypto-SDK', '~> v2.2.1'

Then run

pod install


An example playground can be found here: Example/CryptoSDK.playground

The example shows the complete encryption workflow, i.e. generate user keypair, validate user keypair, generate file key, encrypt file key, and finally encrypt and decrypt a file.

    // --- INITIALIZATION ---
    let crypto = Crypto()
    // Generate key pair
    let userKeyPair = try crypto.generateUserKeyPair(password: USER_PASSWORD)
    // Check key pair
    if !crypto.checkUserKeyPair(keyPair: userKeyPair, password: USER_PASSWORD) {

    let plainData = plainText.data(using: .utf8)


    // --- ENCRYPTION ---
    // Generate plain file key
    let plainFileKey = try crypto.generateFileKey()
    // Encrypt blocks
    let encryptionCipher = try crypto.createEncryptionCipher(fileKey: fileKey)
    let encData = try encryptionCipher.processBlock(fileData: plainData)
    try encryptionCipher.doFinal()
    // Encrypt file key
    let encryptedKey = try crypto.encryptFileKey(fileKey: plainFileKey, publicKey: userKeyPair.publicKeyContainer)


    // --- DECRYPTION ---
    // Decrypt file key
    let decryptedKey = try crypto.decryptFileKey(fileKey: encryptedKey, privateKey: userKeyPair.privateKeyContainer,
    // Decrypt blocks
    let decryptionCipher = try crypto.createDecryptionCipher(fileKey: fileKey)
    let decData = try decryptionCipher.processBlock(fileData: encData)
    try decryptionCipher.doFinal()


Build boringSSL

If you want to update the crypto library, please adjust and run


Then copy the content from output dir to the 'OpenSSL' directory.

Copyright and License



Stars: 0
Last commit: 4 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 year ago

Fixed an encoding issue that prevented decryption of some private keys.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics