Latest 1.0.0
Homepage https://github.com/aerogear/aerogear-ios-crypto
License Apache License, Version 2.0
Platforms ios 9.0, requires ARC
Dependencies libsodium

aerogear-ios-crypto

Maintenance
circle-ci
License
GitHub release
CocoaPods
Platform

Cryptographic services library

Project Info
License: Apache License, Version 2.0
Build: CocoaPods
Languague: Objective-C
Documentation: http://aerogear.org/ios/
Issue tracker: https://issues.jboss.org/browse/AGIOS
Mailing lists: aerogear-users (subscribe)
aerogear-dev (subscribe)

Table of Content

Features

Installation

CocoaPods

In your Podfile add:

pod 'AeroGearCrypto'

and then:

pod install

to install your dependencies

Usage

Password based key derivation

AGPBKDF2 *pbkdf2 = [[AGPBKDF2 alloc] init];
NSData *rawKey = [pbkdf2 deriveKey:@"passphrase"];

Symmetric encryption

//Generate the key
AGPBKDF2 *pbkdf2 = [[AGPBKDF2 alloc] init];
NSData *privateKey = [pbkdf2 deriveKey:@"passphrase"];

//Initializes the secret box
AGSecretBox *secretBox = [[AGSecretBox alloc] initWithKey:privateKey];

//Encryption
NSData *nonce = [AGRandomGenerator randomBytes:32];
NSData *dataToEncrypt = [@"My bonnie lies over the ocean" dataUsingEncoding:NSUTF8StringEncoding];

NSData *cipherData = [secretBox encrypt:dataToEncrypt nonce:nonce];

//Decryption
AGSecretBox *pandora = [[AGSecretBox alloc] initWithKey:privateKey];
NSData *message = [secretBox decrypt:cipherData nonce:nonce];

Asymmetric encryption

//Create a new key pair
AGKeyPair *keyPairBob = [[AGKeyPair alloc] init];
AGKeyPair *keyPairAlice = [[AGKeyPair alloc] init];

//Initializes the crypto box
AGCryptoBox *cryptoBox = [[AGCryptoBox alloc] initWithKey:keyPairAlice.publicKey privateKey:keyPairBob.privateKey];

NSData *nonce = [AGRandomGenerator randomBytes:32];
NSData *dataToEncrypt = [@"My bonnie lies over the ocean" dataUsingEncoding:NSUTF8StringEncoding];

NSData *cipherData = [cryptoBox encrypt:dataToEncrypt nonce:nonce];

//Create a new box to test end to end asymmetric encryption
AGCryptoBox *pandora = [[AGCryptoBox alloc] initWithKey:keyPairBob.publicKey privateKey:keyPairAlice.privateKey];

NSData *message = [pandora decrypt:cipherData nonce:nonce];

Hashing functions

// create an SHA256 hash
AGHash *agHash = [[AGHash alloc] init:CC_SHA256_DIGEST_LENGTH];
NSData *rawPassword = [agHash digest:@"My bonnie lies over the ocean"];

// create an SHA512 hash
AGHash *agHash = [[AGHash alloc] init:CC_SHA512_DIGEST_LENGTH];
NSData *rawPassword = [agHash digest:@"My bonnie lies over the ocean"];

Digital Signatures

NSData *message = [@"My bonnie lies over the ocean" dataUsingEncoding:NSUTF8StringEncoding];

AGSigningKey *signingKey = [[AGSigningKey alloc] init];
AGVerifyKey *verifyKey = [[AGVerifyKey alloc] initWithKey:signingKey.publicKey];
// sign the message
NSData *signedMessage = [signingKey sign:message];

// should detect corrupted signature
NSMutableData *corruptedSignature = [NSMutableData dataWithLength:64];
BOOL isValid = [verifyKey verify:message signature:signedMessage];

// isValid should be YES
BOOL isValid = [verifyKey verify:message signature:corruptedSignature];
// isValid should be NO

Generation of Cryptographically secure Random Numbers

NSData *random = [AGRandomGenerator randomBytes:<length>];

Documentation

For more details about that please consult our documentation.

Demo apps

Take a look in our demo apps:

Development

If you would like to help develop AeroGear you can join our developer’s mailing list, join #aerogear on Freenode, or shout at us on Twitter @aerogears.

Also takes some time and skim the contributor guide

Questions?

Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear!

Found a bug?

If you found a bug please create a ticket for us on Jira with some steps to reproduce it.

Latest podspec

{
    "name": "AeroGearCrypto",
    "version": "1.0.0",
    "summary": "Provides encryption utilities.",
    "homepage": "https://github.com/aerogear/aerogear-ios-crypto",
    "license": "Apache License, Version 2.0",
    "authors": "Red Hat, Inc.",
    "source": {
        "git": "https://github.com/aerogear/aerogear-ios-crypto.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "AeroGearCrypto/**/*.{h,m}",
    "public_header_files": [
        "AeroGearCrypto/AeroGearCrypto.h",
        "AeroGearCrypto/AGPBKDF2.h",
        "AeroGearCrypto/AGRandomGenerator.h",
        "AeroGearCrypto/AGSecretBox.h",
        "AeroGearCrypto/AGCryptoBox.h",
        "AeroGearCrypto/AGHash.h",
        "AeroGearCrypto/AGSigningKey.h",
        "AeroGearCrypto/AGVerifyKey.h",
        "AeroGearCrypto/AGVerifyKey.h",
        "AeroGearCrypto/AGKeyPair.h",
        "AeroGearCrypto/AGUtil.h"
    ],
    "requires_arc": true,
    "dependencies": {
        "libsodium": [
            "~> 1.0"
        ]
    }
}

Pin It on Pinterest

Share This