Latest 1.1.3
Homepage https://github.com/indisoluble/AesKeyWrap
License MIT
Platforms ios 8.0
Authors

CI Status
codecov.io
Version
Docs
License

ObjC implementation of the AES Key Wrap (RFC 3394) and
AES Key Wrap with Padding (RFC 5649) algorithms.

Notice

CommonCrypto already offers a couple of functions that implement RFC 3394:

  • CCSymmetricKeyWrap
  • CCSymmetricKeyUnwrap

However, it does not offer any functions to wrap with padding (RFC 5649) … yet.

Installation

AesKeyWrap is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "AesKeyWrap"

Usage

#import <CommonCrypto/CommonCryptor.h>

#import "AKWAesKeyWrap.h"

u_char keyBytes[kCCKeySizeAES192] = {...};
NSData *keyEncryptionKey = [NSData dataWithBytes:keyBytes length:kCCKeySizeAES192];

// AES Key Wrap

u_char plainBytes[2 * sizeof(uint64_t)] = {...};
NSData *expectedPlainData = [NSData dataWithBytes:plainBytes length:sizeof(plainBytes)];

NSData *cipheredData = [AKWAesKeyWrap cipheredDataByWrappingPlainData:expectedPlainData
                                                 withKeyEncryptionKey:keyEncryptionKey
                                                                error:nil];
NSData *plainData = [AKWAesKeyWrap plainDataByUnwrappingCipheredData:cipheredData
                                                withKeyEncryptionKey:keyEncryptionKey
                                                               error:nil];

XCTAssertEqualObjects(expectedPlainData, plainData);

// AES Key Wrap with Padding

u_char plainBytesWithPadding[1] = {...};
expectedPlainData = [NSData dataWithBytes:plainBytesWithPadding length:sizeof(plainBytesWithPadding)];

cipheredData = [AKWAesKeyWrap cipheredDataByWrappingWithPaddingPlainData:expectedPlainData
                                                   usingKeyEncryptionKey:keyEncryptionKey
                                                                   error:nil];
plainData = [AKWAesKeyWrap plainDataByUnwrappingWithPaddingCipheredData:cipheredData
                                                  usingKeyEncryptionKey:keyEncryptionKey
                                                                  error:nil];

XCTAssertEqualObjects(expectedPlainData, plainData);

License

AesKeyWrap is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "AesKeyWrap",
    "version": "1.1.3",
    "summary": "AES Key Wrap and AES Key Wrap with Padding algorithms (RFC 3394 & RFC 5649).",
    "description": "ObjC implementation of the AES Key Wrap and AES Key Wrap with Padding algorithms (RFC 3394 & RFC 5649).",
    "homepage": "https://github.com/indisoluble/AesKeyWrap",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Enrique de la Torre": "[email protected]"
    },
    "source": {
        "git": "https://github.com/indisoluble/AesKeyWrap.git",
        "tag": "1.1.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AesKeyWrap/Classes/**/*"
}

Pin It on Pinterest

Share This