1//
2//  CommonCryptorWithData.c
3//  CommonCrypto
4//
5//  Created by Richard Murphy on 8/8/12.
6//  Copyright (c) 2012 Platform Security. All rights reserved.
7//
8
9#include <stdio.h>
10#include <CommonCrypto/CommonCryptor.h>
11#include "testbyteBuffer.h"
12#include "testmore.h"
13#include "capabilities.h"
14
15#if (CCWITHDATA == 0)
16entryPoint(CommonCryptoWithData,"CommonCrypto With Data Testing")
17#else
18#define AES_KEYST_SIZE    (kCCContextSizeAES128 + 8)
19
20static int kTestTestCount = 1;
21
22int CommonCryptoWithData(int argc, char *const *argv)
23{
24    CCCryptorStatus retval;
25    CCCryptorRef cryptor;
26    unsigned char data[AES_KEYST_SIZE];
27
28
29	plan_tests(kTestTestCount);
30
31    byteBuffer key = hexStringToBytes("2b7e151628aed2a6abf7158809cf4f3c");
32    retval = CCCryptorCreateFromData(kCCEncrypt, kCCAlgorithmAES128,
33                                     kCCOptionECBMode, key->bytes, key->len, NULL,
34                                     data, AES_KEYST_SIZE, &cryptor, NULL);
35
36    ok(retval == kCCSuccess, "Cryptor was created");
37
38    return 0;
39}
40#endif
41