CommonCryptoSymZeroLength.c [plain text]
#include <stdio.h>
#include <CommonCrypto/CommonCryptor.h>
#include "CCCryptorTestFuncs.h"
#include "testbyteBuffer.h"
#include "testmore.h"
#include "capabilities.h"
#if (CCSYMZEROLEN == 0)
entryPoint(CommonCryptoSymZeroLength,"CommonCrypto Symmetric Zero-Length Testing")
#else
static int kTestTestCount = 4;
int CommonCryptoSymZeroLength (int argc, char *const *argv)
{
char *keyStr;
char *iv;
char *plainText;
char *cipherText;
int retval, accum = 0;
plan_tests(kTestTestCount);
keyStr = "000102030405060708090a0b0c0d0e0f";
iv = "0f0e0d0c0b0a09080706050403020100";
plainText = "";
cipherText = "efddc425a6fa0c5f25e444092eb0f503";
retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText);
ok(retval == 0, "CBC Zero Length String, IV defined");
accum += retval;
plainText = NULL;
cipherText = "efddc425a6fa0c5f25e444092eb0f503";
retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText);
ok(retval == 0, "CBC NULL String, IV defined");
accum += retval;
keyStr = "000102030405060708090a0b0c0d0e0f";
iv = NULL;
plainText = "";
cipherText = "954f64f2e4e86e9eee82d20216684899";
retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText);
ok(retval == 0, "CBC Zero Length String, IV NULL");
accum += retval;
plainText = NULL;
cipherText = "954f64f2e4e86e9eee82d20216684899";
retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText);
ok(retval == 0, "CBC NULL String, IV NULL");
accum += retval;
return accum != 0;
}
#endif