CommonCryptoSymECB.c [plain text]
#include <stdio.h>
#include "CCCryptorTestFuncs.h"
#include "testbyteBuffer.h"
#include "testmore.h"
#include "capabilities.h"
#if (CCSYMECB == 0)
entryPoint(CommonCryptoSymECB,"CommonCrypto Symmetric ECB Testing")
#else
static int kTestTestCount = 4;
int CommonCryptoSymECB(int argc, char *const *argv) {
char *keyStr;
char *iv;
char *plainText;
char *cipherText;
CCAlgorithm alg;
CCOptions options;
int retval;
int accum = 0;
keyStr = "000102030405060708090a0b0c0d0e0f";
alg = kCCAlgorithmAES128;
options = kCCOptionECBMode;
plan_tests(kTestTestCount);
accum = (int) genRandomSize(1,10);
iv = NULL;
plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a";
cipherText = "d307b25d3abaf87c0053e8188152992a";
retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText);
ok(retval == 0, "ECB with Padding 16 byte CCCrypt NULL IV");
retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText);
ok(retval == 0, "ECB with Padding 16 byte Multiple Updates NULL IV");
accum |= retval;
plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a";
cipherText = "d307b25d3abaf87c0053e8188152992ad307b25d3abaf87c0053e8188152992a";
retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText);
ok(retval == 0, "ECB 32 byte CCCrypt NULL IV");
accum |= retval;
retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText);
ok(retval == 0, "ECB 32 byte Multiple Updates NULL IV");
accum |= retval;
return accum != 0;
}
#endif