AesKeyWrap
(DEPRECATED) AES Key Wrap (RFC 3394) and AES Key Wrap with Padding (RFC 5649) algorithms.
Install / Use
/learn @indisoluble/AesKeyWrapREADME
AesKeyWrap
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.
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
