Latest 5.0.0-alpha1
Homepage https://github.com/VirgilSecurity/virgil-crypto-x
License BSD
Platforms ios 9.0, osx 10.10, tvos 9.0, watchos 2.0
Dependencies VirgilCryptoAPI, VirgilCryptoFoundation
Authors

Virgil Security Objective-C/Swift Crypto Library

Build Status
CocoaPods Compatible
Carthage compatible
Platform
GitHub license

Introduction | Library purposes | Usage examples | Installation | Docs | License | Contacts

Introduction

VirgilCrypto is a stack of security libraries (ECIES with Crypto Agility wrapped in Virgil Cryptogram) and an open-source high-level cryptographic library that allows you to perform all necessary operations for securely storing and transferring data in your digital solutions. Crypto Library is written in C++ and is suitable for mobile and server platforms.

Virgil Security, Inc., guides software developers into the forthcoming security world in which everything will be encrypted (and passwords will be eliminated). In this world, the days of developers having to raise millions of dollars to build a secure chat, secure email, secure file-sharing, or a secure anything have come to an end. Now developers can instead focus on building features that give them a competitive market advantage while end-users can enjoy the privacy and security they increasingly demand.

Library purposes

  • Asymmetric Key Generation
  • Encryption/Decryption of data and streams
  • Generation/Verification of digital signatures
  • PFS (Perfect Forward Secrecy)

Usage examples

Generate a key pair

Generate a Private Key with the default algorithm (EC_X25519):

import VirgilCryptoApiImpl

let crypto = VirgilCrypto()
let keyPair = try! crypto.generateKeyPair()

Generate and verify a signature

Generate signature and sign data with a private key:

import VirgilCryptoApiImpl

let crypto = VirgilCrypto()

// prepare a message
let messageToSign = "Hello, Bob!"
let dataToSign = messageToSign.data(using: .utf8)!

// generate a signature
let signature = try! crypto.generateSignature(of: dataToSign, using: senderPrivateKey)

Verify a signature with a public key:

import VirgilCryptoApiImpl

let crypto = VirgilCrypto()

// verify a signature
let verified = crypto.verifySignature(signature, of: dataToSign, with: senderPublicKey)

Encrypt and decrypt data

Encrypt Data on a Public Key:

import VirgilCryptoApiImpl

let crypto = VirgilCrypto()

// prepare a message
let messageToEncrypt = "Hello, Bob!"
let dataToEncrypt = messageToEncrypt.data(using: .utf8)!

// encrypt the message
let encryptedData = try! crypto.encrypt(dataToEncrypt, for: [receiverPublicKey])

Decrypt the encrypted data with a Private Key:

import VirgilCryptoApiImpl

let crypto = VirgilCrypto()

// prepare data to be decrypted
let decryptedData = try! crypto.decrypt(encryptedData, with: receiverPrivateKey)

// decrypt the encrypted data using a private key
let decryptedMessage = String(data: decryptedData, encoding: .utf8)!

Need more examples? Visit our developer documentation.

Installation

VirgilCrypto is provided as a set of frameworks. These frameworks are distributed via Carthage and CocoaPods.

All frameworks are available for:

  • iOS 9.0+
  • macOS 10.10+
  • tvOS 9.0+
  • watchOS 2.0+

COCOAPODS

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate VirgilCrypto into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target Name>' do
  use_frameworks!

  pod 'VirgilCryptoApiImpl', '~> 3.2'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate VirgilSDK into your Xcode project using Carthage, create an empty file with name Cartfile in your project’s root folder and add following lines to your Cartfile

github "VirgilSecurity/virgil-crypto-x" ~> 3.2

Linking against prebuilt binaries

To link prebuilt frameworks to your app, run following command:

$ carthage update --no-use-binaries

This will build each dependency or download a pre-compiled framework from github Releases.

Building for iOS/tvOS/watchOS

On your application target’s “General” settings tab, in the “Linked Frameworks and Libraries” section, add following frameworks from the Carthage/Build folder inside your project’s folder:

  • VirgilCryptoAPI
  • VirgilCryptoApiImpl
  • VirgilCrypto
  • VSCCrypto

On your application target’s “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

$(SRCROOT)/Carthage/Build/iOS/VirgilCryptoAPI.framework
$(SRCROOT)/Carthage/Build/iOS/VirgilCryptoAPIImpl.framework
$(SRCROOT)/Carthage/Build/iOS/VirgilCrypto.framework
$(SRCROOT)/Carthage/Build/iOS/VSCCrypto.framework
Building for macOS

On your application target’s “General” settings tab, in the “Embedded Binaries” section, drag and drop following frameworks from the Carthage/Build folder on disk:

  • VirgilCryptoAPI
  • VirgilCryptoApiImpl
  • VirgilCrypto
  • VSCCrypto

Additionally, you’ll need to copy debug symbols for debugging and crash reporting on macOS.

On your application target’s “Build Phases” settings tab, click the “+” icon and choose “New Copy Files Phase”.
Click the “Destination” drop-down menu and select “Products Directory”. For each framework, drag and drop the corresponding dSYM file.

Integrating as subproject

It is possible to use carthage just for fetching the right sources for further integration into your project.
Run following command:

$ carthage update --no-build

This will fetch dependencies into a Carthage/Checkouts folder inside your project’s folder. Then, drag and drop VirgilCrypto.xcodeproj and VirgilCryptoAPI.xcodeproj from corresponding folders inside Carthage/Checkouts folder to your Xcode Project Navigator sidebar.

Next, on your application target’s “General” settings tab, in the “Embedded Binaries” section add following frameworks from subprojects:

  • VirgilCryptoAPI
  • VirgilCryptoApiImpl
  • VirgilCrypto
  • VSCCrypto

Docs

License

This library is released under the 3-clause BSD License.

Support

Our developer support team is here to help you.

You can find us on Twitter or send us email [email protected]

Also, get extra help from our support team on Slack.

Latest podspec

{
    "name": "VirgilCryptoApiImpl",
    "version": "5.0.0-alpha1",
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "summary": "Contains implementation of VirgilCryptoAPI using VirgilCrypto library.",
    "homepage": "https://github.com/VirgilSecurity/virgil-crypto-x",
    "authors": {
        "Virgil Security": "https://virgilsecurity.com/"
    },
    "source": {
        "git": "https://github.com/VirgilSecurity/virgil-crypto-x.git",
        "tag": "5.0.0-alpha1"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source_files": "Source/**/*.swift",
    "dependencies": {
        "VirgilCryptoAPI": [
            "~> 1.0"
        ],
        "VirgilCryptoFoundation": [
            "~> 0.2.0-alpha"
        ]
    }
}

Pin It on Pinterest

Share This