X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b04fe171f0375ecd5d8a24747ca1dff85720a0ca..6b200bc335dc93c5516ccb52f14bd896d8c7fad7:/SecurityTests/clxutils/threadTest/derDecode.cpp?ds=inline diff --git a/SecurityTests/clxutils/threadTest/derDecode.cpp b/SecurityTests/clxutils/threadTest/derDecode.cpp deleted file mode 100644 index 61b25ca0..00000000 --- a/SecurityTests/clxutils/threadTest/derDecode.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * DER decode test - */ -#include "testParams.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DO_BAD_DECODE 0 -#define DO_PAUSE 0 /* for malloc debug */ - -/* good DER, bad DER */ -static CSSM_DATA goodDer; -static CSSM_DATA badDer; - -typedef struct { - CSSM_DATA int1; - CSSM_DATA int2; -} twoInts; - -static const SecAsn1Template twoIntsTemp[] = { - { SEC_ASN1_SEQUENCE, - 0, NULL, sizeof(twoInts) }, - { SEC_ASN1_INTEGER, offsetof(twoInts, int1) }, - { SEC_ASN1_INTEGER, offsetof(twoInts, int2) }, - {0} -}; - -static uint8 int1[] = {1,2,3}; -static uint8 int2[] = {3,4,5,6,7}; - -#define DECODES_PER_LOOP 1 - -int derDecodeInit( - TestParams *testParams) -{ - /* - * DER encode a sequence of two integers - */ - twoInts ti; - ti.int1.Data = int1; - ti.int1.Length = sizeof(int1); - ti.int2.Data = int2; - ti.int2.Length = sizeof(int2); - - /* encode --> tempDer */ - SecAsn1CoderRef coder; - SecAsn1CoderCreate(&coder); - - CSSM_DATA tmpDer = {0, NULL}; - if(SecAsn1EncodeItem(coder, &ti, twoIntsTemp, &tmpDer)) { - printf("***derDecodeInit: Error on encodeItem()\n"); - return -1; - } - - /* copy to goodDer and badDer */ - appCopyCssmData(&tmpDer, &goodDer); - appCopyCssmData(&tmpDer, &badDer); - - /* increment the length of the outer sequence to force error */ - badDer.Data[1]++; - SecAsn1CoderRelease(coder); - return 0; -} - -int derDecodeTest(TestParams *testParams) -{ - /* which flavor - good or bad? */ - const CSSM_DATA *derSrc; - bool expectErr = false; - - if((testParams->threadNum & 1) || !DO_BAD_DECODE) { - derSrc = &goodDer; - } - else { - derSrc = &badDer; - expectErr = true; - } - for(unsigned loop=0; loopnumLoops; loop++) { - if(testParams->verbose) { - printf("derDecode thread %d: loop %d\n", - testParams->threadNum, loop); - } - else if(!testParams->quiet) { - printChar(testParams->progressChar); - } - - for(unsigned dex=0; dex