]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/ccCtxSize/ccCtxSize.c
2 * measure and report min context sizes for all CCCryptor ops and algorithms.
8 #include <CommonCrypto/CommonCryptor.h>
9 #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacErrors.h>
18 size_t cryptorLength
= 0;
20 CCCryptorRef cryptorRef
;
23 crtn
= CCCryptorCreateFromData(op
, alg
, 0, key
, 4, NULL
,
24 buf
, 1, &cryptorRef
, &cryptorLength
);
27 printf("***Unuexpected success on CCCryptorCreate()\n");
29 case kCCBufferTooSmall
:
32 printf("***Unexpected result on CCCryptorCreate: expect %d got %d\n",
33 (int)kCCBufferTooSmall
, (int)crtn
);
36 printf("%s : %lu bytes\n", name
, (unsigned long)cryptorLength
);
37 if(definedSize
< cryptorLength
) {
38 printf("***Defined context size (%u) is less than reported!\n",
39 (unsigned)definedSize
);
43 int main(int argc
, char **argv
)
45 report("kCCAlgorithmAES128 ", kCCEncrypt
, kCCAlgorithmAES128
, kCCContextSizeAES128
);
46 report("kCCAlgorithmDES ", kCCEncrypt
, kCCAlgorithmDES
, kCCContextSizeDES
);
47 report("kCCAlgorithm3DES ", kCCEncrypt
, kCCAlgorithm3DES
, kCCContextSize3DES
);
48 report("kCCAlgorithmCAST ", kCCEncrypt
, kCCAlgorithmCAST
, kCCContextSizeCAST
);
49 report("kCCAlgorithmRC4 ", kCCEncrypt
, kCCAlgorithmRC4
, kCCContextSizeRC4
);
55 sizeof(CCCryptor) = 24 including the spiCtx[] array
56 sizeof(struct _CCCryptContext) = 60 including algCtx[]
57 sizeof(DES_key_schedule) = 128
58 sizeof(DES3_Schedule) = 384
60 sizeof(_ccHmacContext) = 180