Latest 1.0.2
Homepage https://github.com/dracoon/dracoon-swift-crypto-sdk
License Apache 2.0
Platforms ios 9.3
Authors

DRACOON Swift Crypto SDK

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

Introduction

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

https://support.dracoon.com/hc/en-us/articles/360000986345

Setup

Minimum Requirements

Xcode 7.3.1 or newer

Build boringSSL

./build-boringssl.sh

Carthage

Add the SDK to your Cartfile:

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

Then run

carthage update --platform iOS

To add the framework to your project, open it in Xcode, choose the "General" tab in targets settings and add it to "Linked Frameworks and Libraries".

CocoaPods

Add to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
use_frameworks!

target '<Your Target Name>' do
pod 'DRACOON-Crypto-SDK', '~> v1.0.2'
end

Then run

pod install

Build examples

There is an example app in build_examples.

Run sh setupCarthage.sh and sh setupCocoaPods.sh.
The run sh regenerateProjects to generate both the example projects.

To run the Carthage project open CryptoSDKCarthageExample.xcodeproj
To run the CocoaPods project open CryptoSDKCocoaPodsExample.xcworkspace

Example

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,
      USER_PASSWORD)
    // Decrypt blocks
    let decryptionCipher = try crypto.createDecryptionCipher(fileKey: fileKey)
    let decData = try decryptionCipher.processBlock(fileData: encData)
    try decryptionCipher.doFinal()

    ...

Copyright and License

See LICENSE

Latest podspec

{
    "name": "DRACOON-Crypto-SDK",
    "version": "1.0.2",
    "summary": "Official DRACOON Crypto SDK",
    "description": "This SDK implements client-side encryption for DRACOON.",
    "homepage": "https://github.com/dracoon/dracoon-swift-crypto-sdk",
    "license": {
        "type": "Apache 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Mathias Schreiner": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dracoon/dracoon-swift-crypto-sdk.git",
        "tag": "v1.0.2"
    },
    "module_name": "crypto_sdk",
    "platforms": {
        "ios": "9.3"
    },
    "swift_version": "4.2",
    "source_files": "crypto-sdk/**/*",
    "vendored_frameworks": "OpenSSL/openssl.framework"
}

Pin It on Pinterest

Share This