Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Update CommonCrypto from Apple's source code dump for Mac OS 10.8 (Mountain Lion, r60026) |
---|---|
Timelines: | family | ancestors | Apple | r60026 |
Files: | files | file ages | folders |
SHA1: |
46f9f7687d6de22bc98b71507ad6e883 |
User & Date: | thebeing 2012-08-11 11:27:40 |
2012-08-11
| ||
11:27 | Update CommonCrypto from Apple's source code dump for Mac OS 10.8 (Mountain Lion, r60026) Leaf check-in: 46f9f7687d user: thebeing tags: Apple, r60026 | |
2012-03-08
| ||
13:39 | Update CommonCrypto source to r55010 (from Mac OS X 10.7.3) check-in: 101e407fb2 user: thebeing tags: Apple, r55010 | |
Added CCRegression/CommonCrypto/CCCryptorTestFuncs.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | /* * CCCryptorTestFuncs.c * CCRegressions * * */ #include <stdio.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" CCCryptorStatus CCCryptWithMode(CCOperation op, CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, const void *key, size_t keyLength, const void *tweak, size_t tweakLength, int numRounds, CCModeOptions options, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved) #ifdef CRYPTORWITHMODE { CCCryptorRef cref; CCCryptorStatus retval; size_t moved; if((retval = CCCryptorCreateWithMode(op, mode, alg, padding, iv, key, keyLength, tweak, tweakLength, numRounds, options, &cref)) != kCCSuccess) { return retval; } if((retval = CCCryptorUpdate(cref, dataIn, dataInLength, dataOut, dataOutAvailable, &moved)) != kCCSuccess) { return retval; } dataOut += moved; dataOutAvailable -= moved; *dataOutMoved = moved; if((retval = CCCryptorFinal(cref, dataOut, dataOutAvailable, &moved)) != kCCSuccess) { return retval; } *dataOutMoved += moved; CCCryptorRelease(cref); return kCCSuccess; } #else { return kCCSuccess; } #endif CCCryptorStatus CCMultiCrypt(CCOperation op, CCAlgorithm alg, CCOptions options, const void *key, size_t keyLength, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved) { CCCryptorRef cref; CCCryptorStatus retval; size_t p1, p2; size_t newmoved; size_t finalSize; retval = CCCryptorCreate(op, alg, options, key, keyLength, iv, &cref); if(retval != kCCSuccess) { diag("Cryptor Create Failed\n"); return retval; } p1 = ( dataInLength / 16 ) * 16 - 1; if(p1 > 16) p1 = dataInLength; p2 = dataInLength - p1; // diag("Processing length %d in two parts %d and %d\n", (int) dataInLength, (int) p1, (int) p2); *dataOutMoved = 0; if(p1) { retval = CCCryptorUpdate(cref, dataIn, p1, dataOut, dataOutAvailable, dataOutMoved); if(retval) { diag("P1 - Tried to move %d - failed retval = %d\n", (int) p1, (int) retval); return retval; } dataIn += p1; dataOut += *dataOutMoved; dataOutAvailable -= *dataOutMoved; } if(p2) { retval = CCCryptorUpdate(cref, dataIn, p2, dataOut, dataOutAvailable, &newmoved); if(retval) { diag("P2 - Tried to move %d - failed\n", (int) p2); return retval; } dataIn += p2; dataOut += newmoved; dataOutAvailable -= newmoved; *dataOutMoved += newmoved; } /* We've had reports that Final fails on some platforms if it's only cipher blocksize. */ switch(alg) { case kCCAlgorithmDES: /* fallthrough */ case kCCAlgorithm3DES: finalSize = kCCBlockSizeDES; break; case kCCAlgorithmAES128: finalSize = kCCBlockSizeAES128; break; case kCCAlgorithmCAST: finalSize = kCCBlockSizeCAST; break; case kCCAlgorithmRC2: finalSize = kCCBlockSizeRC2; break; default: finalSize = dataOutAvailable; } retval = CCCryptorFinal(cref, dataOut, finalSize, &newmoved); if(retval) { diag("Final - failed %d\n", (int) retval); return retval; } retval = CCCryptorRelease(cref); if(retval) { diag("Final - release failed %d\n", (int) retval); return retval; } *dataOutMoved += newmoved; return kCCSuccess; } CCCryptorStatus CCMultiCryptWithMode(CCOperation op, CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, const void *key, size_t keyLength, const void *tweak, size_t tweakLength, int numRounds, CCModeOptions options, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved) #ifdef CRYPTORWITHMODE { CCCryptorRef cref; CCCryptorStatus retval; size_t p1, p2; size_t newmoved; if((retval = CCCryptorCreateWithMode(op, mode, alg, padding, iv, key, keyLength, tweak, tweakLength, numRounds, options, &cref)) != kCCSuccess) { return retval; } p1 = ( dataInLength / 16 ) * 16 - 1; if(p1 > 16) p1 = dataInLength; p2 = dataInLength - p1; // diag("Processing length %d in two parts %d and %d\n", (int) dataInLength, (int) p1, (int) p2); *dataOutMoved = 0; if(p1) { retval = CCCryptorUpdate(cref, dataIn, p1, dataOut, dataOutAvailable, dataOutMoved); if(retval) { diag("P1 - Tried to move %d - failed retval = %d\n", (int) p1, (int) retval); return retval; } dataIn += p1; dataOut += *dataOutMoved; dataOutAvailable -= *dataOutMoved; } if(p2) { retval = CCCryptorUpdate(cref, dataIn, p2, dataOut, dataOutAvailable, &newmoved); if(retval) { diag("P2 - Tried to move %d - failed\n", (int) p2); return retval; } dataIn += p2; dataOut += newmoved; dataOutAvailable -= newmoved; *dataOutMoved += newmoved; } retval = CCCryptorFinal(cref, dataOut, dataOutAvailable, &newmoved); if(retval) { diag("Final - failed %d\n", (int) retval); return retval; } retval = CCCryptorRelease(cref); if(retval) { diag("Final - release failed %d\n", (int) retval); return retval; } *dataOutMoved += newmoved; return kCCSuccess; } #else { return kCCSuccess; } #endif static byteBuffer ccConditionalTextBuffer(char *inputText) { byteBuffer ret; if(inputText) ret = hexStringToBytes(inputText); else { ret = hexStringToBytes(""); ret->bytes = NULL; } return ret; } int CCCryptTestCase(char *keyStr, char *ivStr, CCAlgorithm alg, CCOptions options, char *cipherText, char *plainText) { byteBuffer key, iv; byteBuffer pt, ct; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; size_t dataOutMoved; byteBuffer bb; key = hexStringToBytes(keyStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); if((retval = CCCrypt(kCCEncrypt, alg, options, key->bytes, key->len, iv->bytes, pt->bytes, pt->len, cipherDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Encrypt Failed %d\n", retval); return 1; } bb = bytesToBytes(cipherDataOut, dataOutMoved); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) pt->len, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL Encrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); if((retval = CCCrypt(kCCDecrypt, alg, options, key->bytes, key->len, iv->bytes, cipherDataOut, dataOutMoved, plainDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataOutMoved); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } // if(ct->bytes && iv->bytes) diag("PASS Test for length %d\n", (int) pt->len); // if(ct && (iv->bytes == NULL)) diag("PASS NULL IV Test for length %d\n", (int) pt->len); free(pt); free(ct); free(key); free(iv); return 0; } int CCMultiCryptTestCase(char *keyStr, char *ivStr, CCAlgorithm alg, CCOptions options, char *cipherText, char *plainText) { byteBuffer key, iv; byteBuffer pt, ct; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; size_t dataOutMoved; byteBuffer bb; key = hexStringToBytes(keyStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); if((retval = CCMultiCrypt(kCCEncrypt, alg, options, key->bytes, key->len, iv->bytes, pt->bytes, pt->len, cipherDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Encrypt Failed\n"); return 1; } bb = bytesToBytes(cipherDataOut, dataOutMoved); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) pt->len, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL Encrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); if((retval = CCMultiCrypt(kCCDecrypt, alg, options, key->bytes, key->len, iv->bytes, cipherDataOut, dataOutMoved, plainDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataOutMoved); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } // if(ct && iv->bytes) diag("PASS Test for length %d\n", (int) pt->len); // if(ct && (iv->bytes == NULL)) diag("PASS NULL IV Test for length %d\n", (int) pt->len); free(pt); free(ct); free(key); free(iv); return 0; } int CCModeTestCase(char *keyStr, char *ivStr, CCMode mode, CCAlgorithm alg, CCPadding padding, char *cipherText, char *plainText) #ifdef CRYPTORWITHMODE { byteBuffer key, iv; byteBuffer pt, ct; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; size_t dataOutMoved; byteBuffer bb; key = hexStringToBytes(keyStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); if((retval = CCCryptWithMode(kCCEncrypt, mode, alg, padding, iv->bytes, key->bytes, key->len, NULL, 0, 0, 0, pt->bytes, pt->len, cipherDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Encrypt Failed\n"); return 1; } bb = bytesToBytes(cipherDataOut, dataOutMoved); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) pt->len, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL\nEncrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); if((retval = CCCryptWithMode(kCCDecrypt, mode, alg, padding, iv->bytes, key->bytes, key->len, NULL, 0, 0, 0, cipherDataOut, dataOutMoved, plainDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataOutMoved); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } // if(ct->bytes && iv->bytes) diag("PASS Test for length %d\n", (int) pt->len); // if(ct->bytes && (iv->bytes == NULL)) diag("PASS NULL IV Test for length %d\n", (int) pt->len); free(pt); free(ct); free(key); free(iv); return 0; } #else { return 0; } #endif int CCMultiModeTestCase(char *keyStr, char *ivStr, CCMode mode, CCAlgorithm alg, CCPadding padding, char *cipherText, char *plainText) #ifdef CRYPTORWITHMODE { byteBuffer key, iv; byteBuffer pt, ct; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; size_t dataOutMoved; byteBuffer bb; key = hexStringToBytes(keyStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); if((retval = CCMultiCryptWithMode(kCCEncrypt, mode, alg, padding, iv->bytes,key->bytes, key->len, NULL, 0,0, 0, pt->bytes, pt->len, cipherDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Encrypt Failed\n"); return 1; } bb = bytesToBytes(cipherDataOut, dataOutMoved); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) pt->len, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL\nEncrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); if((retval = CCMultiCryptWithMode(kCCEncrypt, mode, alg, padding, iv->bytes, key->bytes, key->len, NULL, 0, 0, 0, cipherDataOut, dataOutMoved, plainDataOut, 4096, &dataOutMoved)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataOutMoved); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } // if(ct && iv->bytes) diag("PASS Test for length %d\n", (int) pt->len); // if(ct && (iv->bytes == NULL)) diag("PASS NULL IV Test for length %d\n", (int) pt->len); free(pt); free(ct); free(key); free(iv); return 0; } #else { return kCCSuccess; } #endif #ifdef CCSYMGCM static CCCryptorStatus CCCryptorGCMDiscreet( CCOperation op, /* kCCEncrypt, kCCDecrypt */ CCAlgorithm alg, const void *key, /* raw key material */ size_t keyLength, const void *iv, size_t ivLen, const void *aData, size_t aDataLen, const void *dataIn, size_t dataInLength, void *dataOut, const void *tag, size_t *tagLength) { CCCryptorStatus retval; CCCryptorRef cref; retval = CCCryptorCreateWithMode(op, kCCModeGCM, alg, ccNoPadding, NULL, key, keyLength, NULL, 0, 0, 0, &cref); if(retval != kCCSuccess) return retval; retval = CCCryptorGCMAddIV(cref, iv, ivLen); if(retval != kCCSuccess) { printf("Failed to add IV\n"); goto out; } retval = CCCryptorGCMaddAAD(cref, aData, aDataLen); if(retval != kCCSuccess) { printf("Failed to add ADD\n"); goto out; } if(kCCEncrypt == op) { retval = CCCryptorGCMEncrypt(cref, dataIn, dataInLength, dataOut); if(retval != kCCSuccess) { printf("Failed to Encrypt\n"); goto out; } } else { retval = CCCryptorGCMDecrypt(cref, dataIn, dataInLength, dataOut); if(retval != kCCSuccess) { printf("Failed to Decrypt\n"); goto out; } } retval = CCCryptorGCMFinal(cref, tag, tagLength); if(retval != kCCSuccess) { printf("Failed to Finalize and get tag\n"); goto out; } retval = CCCryptorGCMReset(cref); if(retval != kCCSuccess) { printf("Failed to Reset\n"); } out: CCCryptorRelease(cref); return retval; } int CCCryptorGCMTestCase(char *keyStr, char *ivStr, char *aDataStr, char *tagStr, CCAlgorithm alg, char *cipherText, char *plainText) { byteBuffer key, iv; byteBuffer pt, ct; byteBuffer adata, tag; byteBuffer bb; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; char tagDataOut[4096]; size_t tagDataOutlen; size_t dataLen; key = hexStringToBytes(keyStr); adata = ccConditionalTextBuffer(aDataStr); tag = hexStringToBytes(tagStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); dataLen = pt->len; tagDataOutlen = tag->len; memset(tagDataOut, 0, 16); if((retval = CCCryptorGCM(kCCEncrypt, alg, key->bytes, key->len, iv->bytes, iv->len, adata->bytes, adata->len, pt->bytes, dataLen, cipherDataOut, tagDataOut, &tagDataOutlen)) != kCCSuccess) { diag("Encrypt Failed\n"); return 1; } bb = bytesToBytes(cipherDataOut, dataLen); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) dataLen, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL Encrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); #if NEVER bb = bytesToBytes(tagDataOut, tagDataOutlen); if (!bytesAreEqual(tag, bb)) { diag("FAIL Tag on plaintext is wrong\n got %s\n expected %s\n", bytesToHexString(bb), bytesToHexString(tag)); return 1; } #endif tagDataOutlen = tag->len; memset(tagDataOut, 0, 16); if((retval = CCCryptorGCM(kCCDecrypt, alg, key->bytes, key->len, iv->bytes, iv->len, adata->bytes, adata->len, cipherDataOut, dataLen, plainDataOut, tagDataOut, &tagDataOutlen)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataLen); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } free(bb); bb = bytesToBytes(tagDataOut, tagDataOutlen); if (!bytesAreEqual(tag, bb)) { diag("FAIL Tag on ciphertext is wrong\n got %s\n expected %s\n", bytesToHexString(bb), bytesToHexString(tag)); return 1; } free(bb); free(pt); free(ct); free(key); free(iv); // diag("Pass One-Shot GCM Test\n"); return 0; } int CCCryptorGCMDiscreetTestCase(char *keyStr, char *ivStr, char *aDataStr, char *tagStr, CCAlgorithm alg, char *cipherText, char *plainText) { byteBuffer key, iv; byteBuffer pt, ct; byteBuffer adata, tag; byteBuffer bb; CCCryptorStatus retval; char cipherDataOut[4096]; char plainDataOut[4096]; char tagDataOut[4096]; size_t tagDataOutlen; size_t dataLen; key = hexStringToBytes(keyStr); adata = ccConditionalTextBuffer(aDataStr); tag = hexStringToBytes(tagStr); pt = ccConditionalTextBuffer(plainText); ct = ccConditionalTextBuffer(cipherText); iv = ccConditionalTextBuffer(ivStr); dataLen = pt->len; tagDataOutlen = tag->len; memset(tagDataOut, 0, 4096); if((retval = CCCryptorGCMDiscreet(kCCEncrypt, alg, key->bytes, key->len, iv->bytes, iv->len, adata->bytes, adata->len, pt->bytes, dataLen, cipherDataOut, tagDataOut, &tagDataOutlen)) != kCCSuccess) { diag("Encrypt Failed\n"); return 1; } bb = bytesToBytes(cipherDataOut, dataLen); // If ct isn't defined we're gathering data - print the ciphertext result if(!ct->bytes) { diag("Input Length %d Result: %s\n", (int) dataLen, bytesToHexString(bb)); } else { if (!bytesAreEqual(ct, bb)) { diag("FAIL Encrypt Output %s\nEncrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(ct)); return 1; } } free(bb); #ifdef NEVER bb = bytesToBytes(tagDataOut, tagDataOutlen); if (!bytesAreEqual(tag, bb)) { diag("FAIL Tag on plaintext is wrong\n got %s\n expected %s\n", bytesToHexString(bb), bytesToHexString(tag)); return 1; } #endif tagDataOutlen = tag->len; memset(tagDataOut, 0, 4096); if((retval = CCCryptorGCMDiscreet(kCCDecrypt, alg, key->bytes, key->len, iv->bytes, iv->len, adata->bytes, adata->len, cipherDataOut, dataLen, plainDataOut, tagDataOut, &tagDataOutlen)) != kCCSuccess) { diag("Decrypt Failed\n"); return 1; } bb = bytesToBytes(plainDataOut, dataLen); if (!bytesAreEqual(pt, bb)) { diag("FAIL Decrypt Output %s\nDecrypt Expect %s\n", bytesToHexString(bb), bytesToHexString(pt)); return 1; } free(bb); bb = bytesToBytes(tagDataOut, tagDataOutlen); if (!bytesAreEqual(tag, bb)) { diag("FAIL Tag on ciphertext is wrong\n got %s\n expected %s\n", bytesToHexString(bb), bytesToHexString(tag)); return 1; } free(bb); free(pt); free(ct); free(key); free(iv); // diag("Pass Discreet GCM Test\n"); return 0; } #endif |
Added CCRegression/CommonCrypto/CCCryptorTestFuncs.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /* * CCCryptorTestFuncs.h * CCRegressions * * */ #include "capabilities.h" #include <CommonCrypto/CommonCryptor.h> #ifdef CRYPTORWITHMODE #include <CommonCrypto/CommonCryptorSPI.h> #else typedef uint32_t CCMode; typedef uint32_t CCPadding; typedef uint32_t CCModeOptions; #endif /* This is a CCCrypt with the Updates split into two parts */ CCCryptorStatus CCMultiCrypt(CCOperation op, CCAlgorithm alg, CCOptions options, const void *key, size_t keyLength, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved); /* This is a CCCrypt allowing mode specification */ CCCryptorStatus CCCryptWithMode(CCOperation op, CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, const void *key, size_t keyLength, const void *tweak, size_t tweakLength, int numRounds, CCModeOptions options, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved); CCCryptorStatus CCMultiCryptWithMode(CCOperation op, CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, const void *key, size_t keyLength, const void *tweak, size_t tweakLength, int numRounds, CCModeOptions options, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved); /* This is a Test Case "doer" using CCCrypt */ int CCCryptTestCase(char *keyStr, char *ivStr, CCAlgorithm alg, CCOptions options, char *cipherText, char *plainText); /* This is a Test Case "doer" using CCMultiCrypt */ int CCMultiCryptTestCase(char *keyStr, char *ivStr, CCAlgorithm alg, CCOptions options, char *cipherText, char *plainText); /* This is a Test Case "doer" using CCCryptWithMode */ int CCModeTestCase(char *keyStr, char *ivStr, CCMode mode, CCAlgorithm alg, CCPadding padding, char *cipherText, char *plainText); /* This is a Test Case "doer" using CCMultiCryptWithMode */ int CCMultiModeTestCase(char *keyStr, char *ivStr, CCMode mode, CCAlgorithm alg, CCPadding padding, char *cipherText, char *plainText); /* This is a Test Case "doer" using CCCryptorGCM */ int CCCryptorGCMTestCase(char *keyStr, char *ivStr, char *aDataStr, char *tagStr, CCAlgorithm alg, char *cipherText, char *plainText); int CCCryptorGCMDiscreetTestCase(char *keyStr, char *ivStr, char *aDataStr, char *tagStr, CCAlgorithm alg, char *cipherText, char *plainText); |
Added CCRegression/CommonCrypto/CommonBaseEncoding.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | // // CNEncoding.c // CCRegressions // #include <stdio.h> #include "testbyteBuffer.h" #include "capabilities.h" #include "testmore.h" #if (CNENCODER == 0) entryPoint(CommonBaseEncoding,"Base XX Encoding") #else #include <CommonCrypto/CommonBaseXX.h> static int kTestTestCount = 358; #define BUFSIZ 1024 static int doWithEncoders(CNEncoderRef encoder, CNEncoderRef decoder, char *input, char *expected) { CNStatus retval; char outBuf[BUFSIZ], secondBuf[BUFSIZ]; size_t outLen, outAvailable, secondLen, secondAvailable; outAvailable = BUFSIZ; outLen = 0; retval = CNEncoderUpdate(encoder, input, strlen(input), outBuf, &outAvailable); ok(retval == kCNSuccess, "encoded"); outLen = outAvailable; outAvailable = BUFSIZ - outLen; retval = CNEncoderFinal(encoder, &outBuf[outLen], &outAvailable); ok(retval == kCNSuccess, "finalized"); outLen += outAvailable; if(expected) { ok(strncmp(expected, outBuf, strlen(expected)) == 0, "output matches"); if(strncmp(expected, outBuf, strlen(expected))) { printf("Encoding %s\n%s\n%s\n", input, expected, outBuf); } } retval = CNEncoderRelease(&encoder); ok(retval == kCNSuccess, "released"); secondAvailable = BUFSIZ; secondLen = 0; retval = CNEncoderUpdate(decoder, outBuf, outLen, secondBuf, &secondAvailable); ok(retval == kCNSuccess, "encoded"); secondLen = secondAvailable; secondAvailable = BUFSIZ - secondLen; retval = CNEncoderFinal(decoder, &secondBuf[secondLen], &secondLen); ok(retval == kCNSuccess, "finalized"); secondLen += secondAvailable; ok(strncmp(input, secondBuf, strlen(input)) == 0, "output matches"); retval = CNEncoderRelease(&decoder); ok(retval == kCNSuccess, "encoder Released"); return 0; } static int doEncoder(CNEncodings encodingStrat, char *input, char *expected) { CNStatus retval; CNEncoderRef encoder, decoder; retval = CNEncoderCreate(encodingStrat, kCNEncode, &encoder); ok(retval == kCNSuccess, "got an encoder"); retval = CNEncoderCreate(encodingStrat, kCNDecode, &decoder); ok(retval == kCNSuccess, "got a decoder"); doWithEncoders(encoder, decoder, input, expected); return 0; } static int doCustomEncoder(const char *name, const uint8_t baseNum, const char *charMap, const uint8_t padChar, char *input, char *expected) { CNStatus retval; CNEncoderRef encoder, decoder; retval = CNEncoderCreateCustom(name, baseNum, charMap, padChar, kCNEncode, &encoder); ok(retval == kCNSuccess, "got an encoder"); retval = CNEncoderCreateCustom(name, baseNum, charMap, padChar, kCNDecode, &decoder); ok(retval == kCNSuccess, "got a decoder"); doWithEncoders(encoder, decoder, input, expected); return 0; } static int doOneShotStyle(CNEncodings encodingStrat, char *input, char *expected) { CNStatus retval; char outBuf[BUFSIZ], secondBuf[BUFSIZ]; size_t outLen, outAvailable, secondLen, secondAvailable; outAvailable = BUFSIZ; retval = CNEncode(encodingStrat, kCNEncode, input, strlen(input), outBuf, &outAvailable); outLen = outAvailable; if(expected) { ok(strncmp(expected, outBuf, strlen(expected)) == 0, "output matches"); if(strncmp(expected, outBuf, strlen(expected))) { printf("Encoding %s\n%s\n%s\n", input, expected, outBuf); } } secondAvailable = BUFSIZ; retval = CNEncode(encodingStrat, kCNDecode, outBuf, outLen, secondBuf, &secondAvailable); secondLen = secondAvailable; ok(strncmp(input, secondBuf, strlen(input)) == 0, "output matches"); if(strncmp(input, secondBuf, strlen(input))) { printf("input: %s\n", input); printf("result: %s\n", secondBuf); } return 0; } int CommonBaseEncoding(int argc, char *const *argv) { int accum = 0; plan_tests(kTestTestCount); // diag("Base64\n"); doEncoder(kCNEncodingBase64, "", ""); doEncoder(kCNEncodingBase64, "f", "Zg=="); doEncoder(kCNEncodingBase64, "fo", "Zm8="); doEncoder(kCNEncodingBase64, "foo", "Zm9v"); doEncoder(kCNEncodingBase64, "foob", "Zm9vYg=="); doEncoder(kCNEncodingBase64, "fooba", "Zm9vYmE="); doEncoder(kCNEncodingBase64, "foobar", "Zm9vYmFy"); //diag("Base32\n"); doEncoder(kCNEncodingBase32, "", ""); doEncoder(kCNEncodingBase32, "f", "MY======"); doEncoder(kCNEncodingBase32, "fo", "MZXQ===="); doEncoder(kCNEncodingBase32, "foo", "MZXW6==="); doEncoder(kCNEncodingBase32, "foob", "MZXW6YQ="); doEncoder(kCNEncodingBase32, "fooba", "MZXW6YTB"); doEncoder(kCNEncodingBase32, "foobar", "MZXW6YTBOI======"); //diag("Base32HEX\n"); doEncoder(kCNEncodingBase32HEX, "", ""); doEncoder(kCNEncodingBase32HEX, "f", "CO======"); doEncoder(kCNEncodingBase32HEX, "fo", "CPNG===="); doEncoder(kCNEncodingBase32HEX, "foo", "CPNMU==="); doEncoder(kCNEncodingBase32HEX, "foob", "CPNMUOG="); doEncoder(kCNEncodingBase32HEX, "fooba", "CPNMUOJ1"); doEncoder(kCNEncodingBase32HEX, "foobar", "CPNMUOJ1E8======"); //diag("Base16\n"); doEncoder(kCNEncodingBase16, "", ""); doEncoder(kCNEncodingBase16, "f", "66"); doEncoder(kCNEncodingBase16, "fo", "666F"); doEncoder(kCNEncodingBase16, "foo", "666F6F"); doEncoder(kCNEncodingBase16, "foob", "666F6F62"); doEncoder(kCNEncodingBase16, "fooba", "666F6F6261"); doEncoder(kCNEncodingBase16, "foobar", "666F6F626172"); //diag("Base64 Long\n"); accum |= doEncoder(kCNEncodingBase64, "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.", ""); <<<<<<< HEAD //diag("Custom\n"); ======= diag("Base64 - One-Shot\n"); doOneShotStyle(kCNEncodingBase64, "", ""); doOneShotStyle(kCNEncodingBase64, "f", "Zg=="); doOneShotStyle(kCNEncodingBase64, "fo", "Zm8="); doOneShotStyle(kCNEncodingBase64, "foo", "Zm9v"); doOneShotStyle(kCNEncodingBase64, "foob", "Zm9vYg=="); doOneShotStyle(kCNEncodingBase64, "fooba", "Zm9vYmE="); doOneShotStyle(kCNEncodingBase64, "foobar", "Zm9vYmFy"); diag("Base32 - One-Shot\n"); doOneShotStyle(kCNEncodingBase32, "", ""); doOneShotStyle(kCNEncodingBase32, "f", "MY======"); doOneShotStyle(kCNEncodingBase32, "fo", "MZXQ===="); doOneShotStyle(kCNEncodingBase32, "foo", "MZXW6==="); doOneShotStyle(kCNEncodingBase32, "foob", "MZXW6YQ="); doOneShotStyle(kCNEncodingBase32, "fooba", "MZXW6YTB"); doOneShotStyle(kCNEncodingBase32, "foobar", "MZXW6YTBOI======"); diag("Base32HEX - One-Shot\n"); doOneShotStyle(kCNEncodingBase32HEX, "", ""); doOneShotStyle(kCNEncodingBase32HEX, "f", "CO======"); doOneShotStyle(kCNEncodingBase32HEX, "fo", "CPNG===="); doOneShotStyle(kCNEncodingBase32HEX, "foo", "CPNMU==="); doOneShotStyle(kCNEncodingBase32HEX, "foob", "CPNMUOG="); doOneShotStyle(kCNEncodingBase32HEX, "fooba", "CPNMUOJ1"); doOneShotStyle(kCNEncodingBase32HEX, "foobar", "CPNMUOJ1E8======"); diag("Base16 - One-Shot\n"); doOneShotStyle(kCNEncodingBase16, "", ""); doOneShotStyle(kCNEncodingBase16, "f", "66"); doOneShotStyle(kCNEncodingBase16, "fo", "666F"); doOneShotStyle(kCNEncodingBase16, "foo", "666F6F"); doOneShotStyle(kCNEncodingBase16, "foob", "666F6F62"); doOneShotStyle(kCNEncodingBase16, "fooba", "666F6F6261"); doOneShotStyle(kCNEncodingBase16, "foobar", "666F6F626172"); diag("Base64 Long - One-Shot\n"); accum |= doOneShotStyle(kCNEncodingBase64, "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.", ""); diag("Custom\n"); accum |= doCustomEncoder("Custom64", 64, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/", '*', "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.", ""); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonBigDigest.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | #include <stdio.h> #include "testbyteBuffer.h" #include "capabilities.h" #include "testmore.h" #include <string.h> #include <CommonCrypto/CommonDigest.h> #if (CCBIGDIGEST == 0) entryPoint(CommonBigDigest,"CommonCrypto CCDigest Large Size test") #else #include <CommonCrypto/CommonDigestSPI.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> static void DigestInChunks(CCDigestAlgorithm algorithm, size_t chunksize, const uint8_t *bytesToDigest, size_t numbytes, uint8_t *outbuf) { CCDigestRef d = CCDigestCreate(algorithm); while(numbytes) { size_t n = (numbytes < chunksize) ? numbytes: chunksize; CCDigestUpdate(d, bytesToDigest, n); numbytes -= n; bytesToDigest += n; } if(CCDigestFinal(d, outbuf)) return; CCDigestDestroy(d); } /* * Compute the digest of a whole file */ static int checksum_file(char *filename, CCDigestAlgorithm algorithm) { struct stat st; size_t digestsize = CCDigestGetOutputSize(algorithm); uint8_t mdwhole[digestsize]; uint8_t mdchunk[digestsize]; size_t blocksz = 0x40000000L; // 1 GB off_t filesize; u_char *buf; int fd; fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); return -1; } if (fstat(fd, &st) < 0) { perror(filename); (void) close(fd); return -1; } filesize = st.st_size; buf = (u_char *) mmap(NULL, filesize, PROT_READ, MAP_PRIVATE | MAP_NOCACHE, fd, 0); if (buf == (u_char *) -1) { perror("mmap"); close(fd); return -1; } (void) madvise(buf, filesize, MADV_SEQUENTIAL); printf("File is mapped\n"); /* * First do it in one big chunk */ CCDigest(algorithm, buf, filesize, mdwhole); /* * Now do it in several 1GB chunks */ DigestInChunks(algorithm, blocksz, buf, filesize, mdchunk); (void) munmap(buf, filesize); (void) close(fd); int cmpval = memcmp(mdchunk, mdwhole, digestsize); ok(cmpval == 0, "Results are the same for both digests"); return 0; } static const int kTestTestCount = 1000; int CommonBigDigest(int argc, char *const *argv) { plan_tests(kTestTestCount); char *testpath = "/Volumes/Data/Users/murf/Downloads/Zin_12A130_AppleInternal_038-2423-191.dmg"; checksum_file(testpath, kCCDigestSHA1); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonBigNum.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #include "CommonRandomSPI.h" #if (CCBIGNUM == 0) entryPoint(CommonBigNum,"Big Number Arithmetic") #else #include <CommonCrypto/CommonBigNum.h> static int kTestTestCount = 7; #define STRESSSIZE 5000 static int testCreateFree() { CCStatus status; CCBigNumRef stress[STRESSSIZE]; for(size_t i=0; i<STRESSSIZE; i++) stress[i] = NULL; byteBuffer bb = hexStringToBytes("0102030405060708091011121314151617181920"); for(int i=0; i<100; i++) { for(int j=0; j<100; j++) { CCBigNumRef r = CCBigNumCreateRandom(&status, 31, 31, 0); ok(status == kCCSuccess, "Created Random Number"); size_t ri = CCBigNumGetI(&status, r); ok(status == kCCSuccess, "translated to int"); ri %= STRESSSIZE; if(stress[ri] == NULL) { int sel = ri % 3; switch(sel) { case 0: /* printf("(%lu) BigNum\n", ri); */ stress[ri] = CCCreateBigNum(&status); break; case 1: /* printf("(%lu) FromHex\n", ri); */ stress[ri] = CCBigNumFromHexString(&status, "0003"); break; case 2: /* printf("(%lu) FromData\n", ri); */ stress[ri] = CCBigNumFromData(&status, bb->bytes, bb->len); break; } ok(status == kCCSuccess, "BigNum Created"); } else { /* printf("(%lu) Freeing\n", ri); */ CCBigNumClear(stress[ri]); CCBigNumFree(stress[ri]); stress[ri] = NULL; } CCBigNumFree(r); } } return 0; } static int testHexString() { CCStatus status; char *hexstring = "1002030405060708090021222324252627282920"; CCBigNumRef num1 = CCBigNumFromHexString(&status, hexstring); char *output; ok(status == 0, "BigNum Created"); output = CCBigNumToHexString(&status, num1); ok(status == 0, "Value retrieved"); ok(strcmp(output, hexstring) == 0, "strings are equal"); if(strcmp(output, hexstring)) { printf("output: %s\n", output); printf("input : %s\n", hexstring); } free(output); CCBigNumFree(num1); return 0; } static int testData() { CCStatus status; char *hexstring = "1002030405060708090021222324252627282920"; byteBuffer bb = hexStringToBytes(hexstring); CCBigNumRef num1 = CCBigNumFromData(&status, bb->bytes, bb->len); char *output; ok(status == 0, "BigNum Created"); output = CCBigNumToHexString(&status, num1); ok(status == 0, "Value retrieved"); ok(strcmp(output, hexstring) == 0, "strings are equal"); if(strcmp(output, hexstring)) { printf("output: %s\n", output); printf("input : %s\n", hexstring); } free(output); byteBuffer outbuf = mallocByteBuffer(64); outbuf->len = CCBigNumToData(&status, num1, outbuf->bytes); ok(status == 0, "Value retrieved 2"); ok(bytesAreEqual(bb, outbuf), "input == output"); free(bb); free(outbuf); CCBigNumFree(num1); return 0; } static int testI() { CCStatus status; uint32_t I=0x10203040; char *hexstring = "10203040"; byteBuffer bb = hexStringToBytes(hexstring); CCBigNumRef num1 = CCCreateBigNum(&status); char *output; ok(status == 0, "BigNum Created"); status = CCBigNumSetI(num1, I); ok(status == 0, "BigNum Set to I"); output = CCBigNumToHexString(&status, num1); ok(status == 0, "Value retrieved"); ok(strcmp(output, hexstring) == 0, "strings are equal"); if(strcmp(output, hexstring)) { printf("output: %s\n", output); printf("input : %s\n", hexstring); } free(output); uint32_t outI = CCBigNumGetI(&status, num1); ok(status == 0, "Value retrieved 2"); ok(outI == I, "input == output"); free(bb); CCBigNumFree(num1); return 0; } static int testCompare() { CCStatus status; char *lowstring = "030405060708090021222324252627282920"; char *midstring = "1002030405060708090021222324252627282920"; char *histring = "1002030405060708090f21222324252627282920"; CCBigNumRef low = CCBigNumFromHexString(&status, lowstring); ok(status == 0, "BigNum Created"); CCBigNumRef mid = CCBigNumFromHexString(&status, midstring); ok(status == 0, "BigNum Created"); CCBigNumRef midsame = CCBigNumFromHexString(&status, midstring); ok(status == 0, "BigNum Created"); CCBigNumRef hi = CCBigNumFromHexString(&status, histring); ok(status == 0, "BigNum Created"); CCBigNumRef iVal = CCCreateBigNum(&status); ok(status == 0, "BigNum Created"); status = CCBigNumSetI(iVal, 67); ok(CCBigNumCompare(mid, low) == 1, "mid > low"); ok(CCBigNumCompare(mid, hi) == -1, "mid < hi"); ok(CCBigNumCompare(mid, midsame) == 0, "mid == midsame"); ok(CCBigNumCompareI(iVal, 67) == 0, "iVal equality is correct"); ok(CCBigNumCompareI(iVal, 66) > 0, "iVal greater is correct"); ok(CCBigNumCompareI(iVal, 68) < 0, "iVal less than is correct"); CCBigNumFree(low); CCBigNumFree(mid); CCBigNumFree(midsame); CCBigNumFree(hi); CCBigNumFree(iVal); return 0; } static int testBitCount() { CCStatus status; char *hexstring = "1002030405060708090021222324252627282920"; CCBigNumRef num1 = CCBigNumFromHexString(&status, hexstring); ok(status == 0, "BigNum Created"); int bits = CCBigNumBitCount(num1); ok(bits == 157, "bit count is correct"); CCBigNumFree(num1); return 0; } static int testAddSub() { CCStatus status; char *hex1 = "1002030405060708090021222324252627282920"; char *hex2 = "1002030405060708090021222324252627282920"; char *result = "200406080a0c0e101200424446484a4c4e505240"; CCBigNumRef num1 = CCBigNumFromHexString(&status, hex1); CCBigNumRef num2 = CCBigNumFromHexString(&status, hex2); CCBigNumRef output = CCCreateBigNum(&status); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, result); status = CCBigNumAdd(output, num1, num2); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); status = CCBigNumSub(output, num1, num2); ok(status == 0, "operation completed"); CCBigNumSetI(resultExpected, 0); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); CCBigNumFree(num1); CCBigNumFree(num2); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testAddSubI() { CCStatus status; char *hex1 = "1002030405060708090021222324252627282920"; char *result = "1002030405060708090021222324252627282921"; CCBigNumRef num1 = CCBigNumFromHexString(&status, hex1); CCBigNumRef output = CCCreateBigNum(&status); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, result); status = CCBigNumAddI(output, num1, 1); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); status = CCBigNumSubI(output, output, 1); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, num1) == 0, "expected operation result"); CCBigNumFree(num1); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testShift() { CCStatus status; // Shift n right by 11 CCBigNumRef n = CCBigNumFromHexString(&status, "1002030405060708090021222324252627282920"); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "200406080a0c0e101200424446484a4c4e505"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumRightShift(output, n, 11); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); // Shift n left by 14 CCBigNumRef resultExpected2 = CCBigNumFromHexString(&status, "40080c1014181c20240084888c9094989ca0a480000"); status = CCBigNumLeftShift(output, n, 14); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected2) == 0, "expected operation result"); CCBigNumFree(n); CCBigNumFree(output); CCBigNumFree(resultExpected); CCBigNumFree(resultExpected2); return 0; } static int testModExp() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); CCBigNumRef b = CCBigNumFromHexString(&status, "010001"); CCBigNumRef c = CCBigNumFromHexString(&status, "354c912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "0fb978a4f4fccdb14c7268918b784c4f6d5281c0d6ff43e60e88e97f97f2617608de2488c84eb99a3f467013c860536ec74f4968abeccbc1b026ee5873e40bdd292f8f7416a93df619288b49ba21d3e09aa796cb35a340b1abfda4e3b6cd92df2de64967e6a59f787586929c4d2920da20caeb384594d7f2b7e999dab0d6a1ac"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumModExp(output, a, b, c); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(b); CCBigNumFree(c); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testMod() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); CCBigNumRef c = CCBigNumFromHexString(&status, "354c912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "2983308b3538c60b245899a58b98f08c2e74c53950b30de70314f29af2df858d72df6651a38ceb4f1612231227604c1150c4cc412968c97afa545cbe18ee04a1d102bfa6a5bf7498996a41e70b4c7991f3c9e87984321915b87f8ce5c1aeca2b6015b6384f8a59bae351d662f52f1634c3257434fb8eed85d93fb1ecaf344d7e"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumMod(output, a, c); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(c); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testModI() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); uint32_t c=63; uint32_t resultExpected = 23; uint32_t output; status = CCBigNumModI(&output, a, c); ok(status == 0, "operation completed"); ok(resultExpected == output, "expected operation result"); CCBigNumFree(a); return 0; } static int testMul() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); CCBigNumRef c = CCBigNumFromHexString(&status, "354c912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "29eef49086721db0707b81175570af0db1517307f313564ff3a07f695514e92f525efea63ab5de4830c06b365f5c21cba747b96c6cb315d5b3dfa6642324e0a30f0a999acd196c1c78b99bff4d53e1e1e5d02b521a964a286279129e9bfbb51738743617a73f896bfd21e7c4c24e8f72a4a995781b0b4fa1b37a2320b935b0c5e130f27a65135ac4b7247db58e7f752550d92e08b177a84d5d0364cd8c74d4e2bb086d1cd9bc4c541e86ecf66940be30b73675a63921f9fd1fdfa6db57bd4b13304ac0ac84d64c262d5802a1363ee1d519f88b8ca0997a77f7ece081042d88814da526c44f1323c7ac5b7eeedccda0e28bc65bc415bba767d34f161ab34f9788"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumMul(output, a, c); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(c); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testMulI() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); uint32_t c = 63; CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "3190d01f086e095c7657953ef0bb1a412e3a2e28e8c17b19cbe4e0dc253a1a674fe2665b392bb9cca437e84bdadc8fbb8e3544fee55b0652e552c07a8a48320a9c9760a21d644633475b07e945e4739af1fe769d5eaf493adcbfdeb1876f2f24ca524688a58f0b323f9f3493667d4ec8d0b261410f7dc3f22264a0858de289e246"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumMulI(output, a, c); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; } static int testPrime() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "09c75b"); ok(CCBigNumIsPrime(&status, a), "prime number"); CCBigNumRef b = CCBigNumFromHexString(&status, "09c75c"); ok(!CCBigNumIsPrime(&status, b), "not prime number"); return 0; } static int testDiv() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); CCBigNumRef c = CCBigNumFromHexString(&status, "354c912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, "03"); CCBigNumRef c2 = CCBigNumFromHexString(&status, "43"); // dec 67 CCBigNumRef resultExpected2 = CCBigNumFromHexString(&status, "30190c6ded9da99f49e63e76ef8ba736d1f1fbaac2b0786cf88f03904dd9e4210da7b80d5121e11dea7fe13c3482557f99574b04cfc3dc2ad6a5d1097089039e578b6f4c9708551a690684fa61c8850b87e8acd70e8d970eb9b5086018ae5ceec10e08e33675949951d00b3ba487e8fc9b35cceffc985d96f6fb16e2c25456f"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumDiv(output, NULL, a, c); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); status = CCBigNumDiv(output, NULL, a, c2); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected2) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(c); CCBigNumFree(c2); CCBigNumFree(output); CCBigNumFree(resultExpected); CCBigNumFree(resultExpected2); return 0; } static int testMulMod() { CCStatus status; // Shift n right by 11 CCBigNumRef a = CCBigNumFromHexString(&status, "c968e40c5304364b057425920b18cc358f254ddb0f42f84850d6deec46006b4a692e52b7c3bddead45f77f2c1be1c606521d8a24260429f362d65b57873dbf270e97e210b872e45e97cb4cd87977ad20491e53c48cf0e88da9a61312675a2527c86ac537740c5e4206972f09c0f91fa1c9f14a2cf1be07e82a3b6fd58dc12c3a"); CCBigNumRef c = CCBigNumFromHexString(&status, "354c912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef mod1 = CCBigNumFromHexString(&status, "912b09ee7abff5b3d94ed52a9e8dcae582e094daa375c495f970710af73efcc4f9776010511f654c7408a6d5d351ab1d94a0fede757d782b54ddcf6fe8d714870b78b0e67a9754cb03a5cf63bbda1c71791902ea4527fb0cd76437391e5422c704ffb6d6018261171d8cee98adcf0243f1fd520fb3761afe94a2f4d99f94"); CCBigNumRef mod2 = CCBigNumFromHexString(&status, "43"); // dec 67 CCBigNumRef resultExpected1 = CCBigNumFromHexString(&status, "57c1dfcd53105f1f653539172a789fc97067101320d12b93dd400eaad0bbb9d8d9857beeeae28c1ad0614075f1d59bb12556f78d85e4af9d2283fa5d3c192a03a59932dd537d4c1a9d74a8a2d647f266cc4fe9365c5c9b8ac4d5afc960002850243b2175eb09842d1f1cfd59bdd5c2564cb056586d2186aae39583061a88"); CCBigNumRef resultExpected2 = CCBigNumFromHexString(&status, "3d"); CCBigNumRef output = CCCreateBigNum(&status); status = CCBigNumMulMod(output, a, c, mod1); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected1) == 0, "expected operation result"); status = CCBigNumMulMod(output, a, c, mod2); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected2) == 0, "expected operation result"); CCBigNumFree(a); CCBigNumFree(c); CCBigNumFree(output); CCBigNumFree(resultExpected1); CCBigNumFree(resultExpected2); CCBigNumFree(mod1); CCBigNumFree(mod2); return 0; } int CommonBigNum(int argc, char *const *argv) { plan_tests(kTestTestCount); for(int i=0; i<10; i++) { testCreateFree(); testHexString(); testData(); testI(); testCompare(); testBitCount(); testAddSub(); testAddSubI(); testShift(); testMod(); testModI(); testModExp(); testMul(); testMulI(); testPrime(); testDiv(); testMulMod(); } return 0; } #endif /* CCBigNum */ |
Added CCRegression/CommonCrypto/CommonCMac.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | // // CCCMACtests.c // CCRegressions // #include <stdio.h> #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCCMAC == 0) entryPoint(CommonCMac,"Common CMac") #else #include <CommonCrypto/CommonCMACSPI.h> static int CMACTest(char *input, char *keystr, char *expected) { byteBuffer mdBuf; byteBuffer inputBytes, expectedBytes, keyBytes; char *digestName; char outbuf[160]; int retval = 0; inputBytes = hexStringToBytes(input); expectedBytes = hexStringToBytes(expected); keyBytes = hexStringToBytes(keystr); mdBuf = mallocByteBuffer(CC_CMACAES_DIGEST_LENGTH); digestName = "CMAC-AES"; CCAESCmac(keyBytes->bytes, inputBytes->bytes, inputBytes->len, mdBuf->bytes); sprintf(outbuf, "Hmac-%s test for %s", digestName, input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("HMAC FAIL: HMAC-%s(\"%s\")\n expected %s\n got %s\n", digestName, input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // diag("HMAC PASS: HMAC-%s(\"%s\")\n", digestName, input); } free(mdBuf); free(expectedBytes); free(keyBytes); free(inputBytes); return retval; } static int kTestTestCount = 4; int CommonCMac (int argc, char *const *argv) { char *strvalue, *keyvalue; plan_tests(kTestTestCount); int accum = 0; strvalue = ""; keyvalue = "2b7e151628aed2a6abf7158809cf4f3c"; accum |= CMACTest(strvalue, keyvalue, "bb1d6929e95937287fa37d129b756746"); strvalue = "6bc1bee22e409f96e93d7e117393172a"; accum |= CMACTest(strvalue, keyvalue, "070a16b46b4d4144f79bdd9dd04a287c"); strvalue = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411"; accum |= CMACTest(strvalue, keyvalue, "dfa66747de9ae63030ca32611497c827"); strvalue = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710"; accum |= CMACTest(strvalue, keyvalue, "51f0bebf7e3b9d92fc49741779363cfe"); return accum; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoCTSPadding.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include <stdio.h> #include <stdint.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonCryptorSPI.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "capabilities.h" #include "testmore.h" #if (CCPADCTS == 0) entryPoint(CommonCryptoCTSPadding,"CommonCrypto CTS Padding Testing") #else static int kTestTestCount = 9; int CommonCryptoCTSPadding(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; CCMode mode; CCAlgorithm alg; CCPadding padding; int retval, accum = 0; char *test; keyStr = "636869636b656e207465726979616b69"; iv = "0f0e0d0c0b0a09080706050403020100"; mode = kCCModeCBC; alg = kCCAlgorithmAES128; padding = ccCBCCTS1; plan_tests(kTestTestCount); test = "CTS1 Test - Length 64"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee2dc88b70f6ae0243d2dbcd6822a1058604b1c432a7a71395b36d820e2c3de4ee"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS1 Test - Length 63"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee2dc88b70f6ae0243d2dbcd6822a105950b6576660739916d058623d688e27e"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS1 Test - Length 57"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee2dc88b70f6ae0243d2db751002ef7a0f9d915d15346571eee7aa"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; padding = ccCBCCTS2; test = "CTS2 Test - Length 64"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee2dc88b70f6ae0243d2dbcd6822a1058604b1c432a7a71395b36d820e2c3de4ee"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS2 Test - Length 63"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee950b6576660739916d058623d688e27e2dc88b70f6ae0243d2dbcd6822a105"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS2 Test - Length 57"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee751002ef7a0f9d915d15346571eee7aa2dc88b70f6ae0243d2db"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; padding = ccCBCCTS3; test = "CTS3 Test - Length 64"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee04b1c432a7a71395b36d820e2c3de4ee2dc88b70f6ae0243d2dbcd6822a10586"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS3 Test - Length 63"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee950b6576660739916d058623d688e27e2dc88b70f6ae0243d2dbcd6822a105"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; test = "CTS3 Test - Length 57"; plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "e22abba9d2a201b18dc2f57e04aba21a16e0ed6358164c59ca64d204f33247ee751002ef7a0f9d915d15346571eee7aa2dc88b70f6ae0243d2db"; diag(test); retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, test); accum += retval; return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoReset.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | // // CommonCryptoReset.c // CommonCrypto // // Created by Richard Murphy on 2/10/12. // Copyright (c) 2012 McKenzie-Murphy. All rights reserved. // #include "capabilities.h" #include <stdio.h> #include <string.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonCryptorSPI.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #if (CCRESET == 0) entryPoint(CommonCryptoReset,"CommonCrypto Reset Testing") #else static int kTestTestCount = 13; int CommonCryptoReset(int argc, char *const *argv) { CCCryptorRef cref; CCCryptorStatus retval; size_t moved; uint8_t key[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; uint8_t plain[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; uint8_t nulliv[16]; uint8_t cipher1[16], cipher2[16], cipher3[16], cipher4[16], cipher5[16], unused[16]; plan_tests(kTestTestCount); bzero(nulliv, 16); retval = CCCryptorCreateWithMode(kCCEncrypt, kCCModeCBC, kCCAlgorithmAES128, ccNoPadding, NULL, key, 16, NULL, 0, 0, 0, &cref); ok(retval == kCCSuccess, "cryptor created"); retval = CCCryptorUpdate(cref, plain, 16, cipher1, 16, &moved); ok((retval == kCCSuccess && moved == 16), "first update"); retval = CCCryptorUpdate(cref, plain, 16, cipher2, 16, &moved); ok((retval == kCCSuccess && moved == 16), "second (chained) update"); ok(memcmp(cipher1, cipher2, 16) != 0, "chained crypts shouldn't be the same even with the same data"); retval = CCCryptorReset(cref, NULL); ok(retval == kCCSuccess, "cryptor NULL reset"); retval = CCCryptorUpdate(cref, plain, 16, cipher3, 16, &moved); ok((retval == kCCSuccess && moved == 16), "third update - NULL Reset"); ok(memcmp(cipher1, cipher3, 16) == 0, "reset crypt should be the same as the start"); retval = CCCryptorReset(cref, nulliv); ok(retval == kCCSuccess, "cryptor zero iv reset"); retval = CCCryptorUpdate(cref, plain, 16, cipher4, 16, &moved); ok((retval == kCCSuccess && moved == 16), "fourth update - zero iv Reset"); ok(memcmp(cipher1, cipher4, 16) == 0, "reset crypt should be the same as the start"); retval = CCCryptorUpdate(cref, plain, 16, cipher5, 16, &moved); ok((retval == kCCSuccess && moved == 16), "fifth (chained) update"); ok(memcmp(cipher2, cipher5, 16) == 0, "reset crypt should be the same as the second"); retval = CCCryptorFinal(cref, unused, 16, &moved); ok((retval == kCCSuccess && moved == 0), "Final - no work"); CCCryptorRelease(cref); return kCCSuccess; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymCBC.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CBCTest.c * CommonCrypto */ #include <stdio.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMCBC == 0) entryPoint(CommonCryptoSymCBC,"CommonCrypto Symmetric CBC Testing") #else static int kTestTestCount = 28; int CommonCryptoSymCBC(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; CCAlgorithm alg; CCOptions options; int retval; int accum = 0; keyStr = "000102030405060708090a0b0c0d0e0f"; iv = "0f0e0d0c0b0a09080706050403020100"; alg = kCCAlgorithmAES128; options = kCCOptionPKCS7Padding; plan_tests(kTestTestCount); accum = (int) genRandomSize(1,10); // 1 plainText = "0a"; cipherText = "a385b047a4108a8748bf96b435738213"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 1 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 1 byte Multiple Updates"); accum |= retval; // 15 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "324a44cf3395b14214861084019f9257"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 15 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 15 byte Multiple Updates"); accum |= retval; // 16 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "16d67a52c1e8384f7ed887c2011605346544febcf84574c334f1145d17567047"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 16 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 16 byte Multiple Updates"); accum |= retval; // 17 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "16d67a52c1e8384f7ed887c2011605348b72cecb00bbc00f328af6bb69085b02"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 17 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 17 byte Multiple Updates"); accum |= retval; // 31 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "16d67a52c1e8384f7ed887c2011605347175cf878a75bc1947ae79c6c6835030"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 31 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 31 byte Multiple Updates"); accum |= retval; // 32 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "16d67a52c1e8384f7ed887c20116053486869f3b83f3b3a83531e4169e97b7244a49199daa033fa88f07dd4be52ae78e"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 32 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 32 byte Multiple Updates"); accum |= retval; // 33 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "16d67a52c1e8384f7ed887c20116053486869f3b83f3b3a83531e4169e97b724d0080fb874dd556fa86b314acc4f597b"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 33 byte CCCrypt"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 33 byte Multiple Updates"); accum |= retval; iv = NULL; // 1 plainText = "0a"; cipherText = "27cae51ac763b250945fd805c937119b"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 1 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 1 byte Multiple Updates NULL IV"); accum |= retval; // 15 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "feb9c3a005dcbd1e2630af742e988e81"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 15 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 15 byte Multiple Updates NULL IV"); accum |= retval; // 16 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "d307b25d3abaf87c0053e8188152992a8b002a94911ee1e157d815a026cfadeb"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 16 byte CCCrypt NULL IV"); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 16 byte Multiple Updates NULL IV"); accum |= retval; // 17 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "d307b25d3abaf87c0053e8188152992ab8fe4130b613e93617b2eda2e0c5c678"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 17 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 17 byte Multiple Updates NULL IV"); accum |= retval; // 31 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "d307b25d3abaf87c0053e8188152992a4157ad665141a79481f463357707f759"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 31 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 31 byte Multiple Updates NULL IV"); accum |= retval; // 32 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "d307b25d3abaf87c0053e8188152992a923832530aa268661a6c1fa3c69d6a23dc6d5c0d7fa8127cfd601cae71b4c14f"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 32 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 32 byte Multiple Updates NULL IV"); accum |= retval; // 33 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "d307b25d3abaf87c0053e8188152992a923832530aa268661a6c1fa3c69d6a2382178b537aa2946f7a4124ee33744edd"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 33 byte CCCrypt NULL IV"); accum |= retval; retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); ok(retval == 0, "CBC with Padding 33 byte Multiple Updates NULL IV"); accum |= retval; return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymCFB.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include <stdio.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMCFB == 0) entryPoint(CommonCryptoSymCFB,"CommonCrypto Symmetric CFB Testing") #else static int kTestTestCount = 5; int CommonCryptoSymCFB(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; CCMode mode; CCAlgorithm alg; CCPadding padding; int retval, accum = 0; keyStr = "00000000000000000000000000000000"; mode = kCCModeCFB; alg = kCCAlgorithmAES128; padding = ccNoPadding; plan_tests(kTestTestCount); plainText = "00000000000000000000000000000000"; iv = "80000000000000000000000000000000"; cipherText = "3ad78e726c1ec02b7ebfe92b23d9ec34"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test 1"); accum += retval; plainText = "00000000000000000000000000000000"; iv = "c0000000000000000000000000000000"; cipherText = "aae5939c8efdf2f04e60b9fe7117b2c2"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test 2"); accum += retval; plainText = "00000000000000000000000000000000"; iv = "ffffffffffffffffffffffc000000000"; cipherText = "90684a2ac55fe1ec2b8ebd5622520b73"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test 3"); accum += retval; keyStr = "f36f40aeb3e20c19440081919df4ecb9"; plainText = "5552ee4fbf25859cdfecf34742d640855c55a00a1c6aa571c322b4ddf561b6e110de0f9dbe6fd42ac687383928fc48f6680ed9332aa6bec2ffdb3e227fbac55f9847d93325bf5071c220c0a3dfeb38f214292d47b4acb7b0a597fe056f21eecb"; iv = "cf75d0cae8dbce85e0bc0e58eb4e82c0"; cipherText = "d579c0e622047e0efef9ddacc94be36450d09366e38ea9e4ed3c2e39923f580fdc436a874e34fb39330f8a8a7bf1f68d8a93644a2b9d1fed260eb6e7c8ac874d616ec02b57d08f043aae552fc52bf11eb4a4ed5918ff81738b3ea3ce244c9cd1"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test 4"); accum += retval; keyStr = "02f5f980a3c6af2984c9eed684f5224f"; plainText = "cb9056b3c195cef43da2634271f2f34e556868ac41d0ea35bb6854aa8e9fe49a1c1c3685f4027341a773c69dd8530f45934edce5e01c95919703f665759ec26870deb6b6484ebcdf5f9b628aca538a5ea8ed6322b20a982214fac7d57c8234be70dcbf90e40013950c2221506f7ccd623d4de6aae2225cb0db54ad44c8d2a162c3203759f1a0df2c5611e939ee553e18f9774ec696ec4903931992f88416711d"; iv = "7844c96a2c65e9c334573b9894d91046"; cipherText = "227d8e80650e60c1c9e9ab2f8fe8bc24185725f1f1b8e326b73c04501e91995d5a7be17d0c74ce1cd2d5a3d917738dea486fb523297aea2badc6f8766ffdfcc6e8efd640a8d5d1f55d1e4fe4f03bb9f66956eaa9864ee760d1ad3e5faaae6da36476c55d1f25d7c064b9c518ce5b3f42ecdb1c3ef57c7b3fa3ef188218d0d0c417056935bcc76a90ff277f9e698ff9a599ebaa6c2723288c9f0817694e400ce6"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test 5"); accum += retval; keyStr = "e0000000000000000000000000000000"; iv = NULL; plainText = "00000000000000000000000000000000"; cipherText = "72a1da770f5d7ac4c9ef94d822affd97"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "CFB Test NULLIV"); accum += retval; return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymCTR.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include <stdio.h> #include <CommonCrypto/CommonCryptor.h> #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMCTR == 0) entryPoint(CommonCryptoSymCTR,"CommonCrypto Symmetric CTR Testing") #else static int kTestTestCount = 10; static CCCryptorStatus doCrypt(char *in, char *out, CCCryptorRef cryptor) { byteBuffer inbb = hexStringToBytes(in); byteBuffer outbb = hexStringToBytes(out); byteBuffer buf = mallocByteBuffer(64); CCCryptorStatus retval = CCCryptorUpdate(cryptor, inbb->bytes, inbb->len, buf->bytes, buf->len, &buf->len); if(!retval) { ok(bytesAreEqual(outbb, buf), "crypt results are equal"); } return retval; } int CommonCryptoSymCTR(int argc, char *const *argv) { CCCryptorStatus retval; CCCryptorRef cryptor; plan_tests(kTestTestCount); byteBuffer key = hexStringToBytes("2b7e151628aed2a6abf7158809cf4f3c"); byteBuffer counter = hexStringToBytes("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"); retval = CCCryptorCreateWithMode(kCCEncrypt, kCCModeCTR, kCCAlgorithmAES128, ccNoPadding, counter->bytes, key->bytes, key->len, NULL, 0, 0, kCCModeOptionCTR_LE, &cryptor); ok(retval == kCCUnimplemented, "CTR Mode Encrypt unavailable for kCCModeOptionCTR_LE"); retval = CCCryptorCreateWithMode(kCCEncrypt, kCCModeCTR, kCCAlgorithmAES128, ccNoPadding, counter->bytes, key->bytes, key->len, NULL, 0, 0, kCCModeOptionCTR_BE, &cryptor); ok(retval == kCCSuccess, "CTR Mode Encrypt"); retval = doCrypt("6bc1bee22e409f96e93d7e117393172a", "874d6191b620e3261bef6864990db6ce", cryptor); ok(retval == kCCSuccess, "CTR Mode Encrypt"); retval = doCrypt("ae2d8a571e03ac9c9eb76fac45af8e51", "9806f66b7970fdff8617187bb9fffdff", cryptor); ok(retval == kCCSuccess, "CTR Mode Encrypt"); retval = doCrypt("30c81c46a35ce411e5fbc1191a0a52ef", "5ae4df3edbd5d35e5b4f09020db03eab", cryptor); ok(retval == kCCSuccess, "CTR Mode Encrypt"); retval = doCrypt("f69f2445df4f9b17ad2b417be66c3710", "1e031dda2fbe03d1792170a0f3009cee", cryptor); ok(retval == kCCSuccess, "CTR Mode Encrypt"); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymGCM.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CCGCMTest.c * CommonCrypto */ #include "capabilities.h" #include <stdio.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonCryptorSPI.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #if (CCSYMGCM == 0) entryPoint(CommonCryptoSymGCM,"CommonCrypto Symmetric GCM Testing") #else static int kTestTestCount = 7; int CommonCryptoSymGCM(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; char *adata; char *tag; CCAlgorithm alg; int retval, accum = 0; alg = kCCAlgorithmAES128; plan_tests(kTestTestCount); /* testcase #1 */ keyStr = "00000000000000000000000000000000"; adata = ""; iv = "000000000000000000000000"; plainText = ""; cipherText = ""; tag = "58e2fccefa7e3061367f1d57a4e7455a"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 1"); accum += retval; /* testcase #2 */ keyStr = "00000000000000000000000000000000"; adata = ""; iv = "000000000000000000000000"; plainText = "00000000000000000000000000000000"; cipherText = "0388dace60b6a392f328c2b971b2fe78"; tag = "ab6e47d42cec13bdf53a67b21257bddf"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 2"); accum += retval; /* testcase #3 */ keyStr = "feffe9928665731c6d6a8f9467308308"; adata = ""; iv = "cafebabefacedbaddecaf888"; plainText = "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; cipherText = "42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985"; tag = "4d5c2af327cd64a62cf35abd2ba6fab4"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 3"); accum += retval; /* testcase #4 */ keyStr = "feffe9928665731c6d6a8f9467308308"; adata = "feedfacedeadbeeffeedfacedeadbeefabaddad2"; iv = "cafebabefacedbaddecaf888"; plainText = "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; cipherText = "42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091"; tag = "5bc94fbc3221a5db94fae95ae7121a47"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 4"); accum += retval; /* testcase #5 */ keyStr = "feffe9928665731c6d6a8f9467308308"; adata = "feedfacedeadbeeffeedfacedeadbeefabaddad2"; iv = "cafebabefacedbad"; plainText = "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; cipherText = "61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598"; tag = "3612d2e79e3b0785561be14aaca2fccb"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 5"); accum += retval; /* testcase #6 */ keyStr = "feffe9928665731c6d6a8f9467308308"; adata = "feedfacedeadbeeffeedfacedeadbeefabaddad2"; iv = "9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; plainText = "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; cipherText = "8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5"; tag = "619cc5aefffe0bfa462af43c1699d050"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 6"); accum += retval; /* testcase #46 from BG (catchestheLTCbugofv1.15) */ keyStr = "00000000000000000000000000000000"; adata = "688e1aa984de926dc7b4c47f44"; iv = "b72138b5a05ff5070e8cd94183f761d8"; plainText = "a2aab3ad8b17acdda288426cd7c429b7ca86b7aca05809c70ce82db25711cb5302eb2743b036f3d750d6cf0dc0acb92950d546db308f93b4ff244afa9dc72bcd758d2c"; cipherText = "cbc8d2f15481a4cc7dd1e19aaa83de5678483ec359ae7dec2ab8d534e0906f4b4663faff58a8b2d733b845eef7c9b331e9e10eb2612c995feb1ac15a6286cce8b297a8"; tag = "8d2d2a9372626f6bee8580276a6366bf"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); ok(retval == 0, "AES-GCM Testcase 7"); accum += retval; /* testcase #8 - #1 with NULL IV and AAD */ keyStr = "00000000000000000000000000000000"; adata = ""; iv = ""; plainText = ""; cipherText = ""; tag = "66e94bd4ef8a2c3b884cfa59ca342b2e"; retval = CCCryptorGCMTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); retval = CCCryptorGCMDiscreetTestCase(keyStr, iv, adata, tag, alg, cipherText, plainText); return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymOFB.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include <stdio.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMOFB == 0) entryPoint(CommonCryptoSymOFB,"CommonCrypto Symmetric OFB Testing") #else static int kTestTestCount = 5; int CommonCryptoSymOFB(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; CCMode mode; CCAlgorithm alg; CCPadding padding; int retval, accum = 0; keyStr = "000102030405060708090a0b0c0d0e0f"; iv = "0f0e0d0c0b0a09080706050403020100"; mode = kCCModeOFB; alg = kCCAlgorithmAES128; padding = ccNoPadding; plan_tests(kTestTestCount); // 1 plainText = "0a"; cipherText = "2a"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "OFB Mode single byte"); accum += retval; // 15 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "2aa3f398be4651e20e15f6d666a493a"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "OFB Mode 15 byte"); accum += retval; // 16 plainText = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"; cipherText = "2aa3f398be4651e20e15f6d666a49360a"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "OFB Mode single byte"); accum += retval; // from OFBVarTxt256e KAT test 1 keyStr = "0000000000000000000000000000000000000000000000000000000000000000"; iv = "80000000000000000000000000000000"; mode = kCCModeOFB; alg = kCCAlgorithmAES128; padding = ccNoPadding; plainText = "00000000000000000000000000000000"; cipherText = "ddc6bf790c15760d8d9aeb6f9a75fd4e"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "OFB Mode OFBVarTxt256e KAT test 1"); accum += retval; // from OFBVarTxt256e KAT test 13 keyStr = "0000000000000000000000000000000000000000000000000000000000000000"; iv = "fffc0000000000000000000000000000"; mode = kCCModeOFB; alg = kCCAlgorithmAES128; padding = ccNoPadding; plainText = "00000000000000000000000000000000"; cipherText = "dc8f0e4915fd81ba70a331310882f6da"; retval = CCModeTestCase(keyStr, iv, mode, alg, padding, cipherText, plainText); ok(retval == 0, "OFB Mode OFBVarTxt256e KAT test 13"); accum += retval; return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymOffset.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CCSymOffset.c * CommonCrypto */ #include <stdio.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonCryptorSPI.h> #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMOFFSET == 0) entryPoint(CommonCryptoSymOffset,"CommonCrypto Symmetric Unaligned Testing") #else #define ILIKEEMDISBIG 4096 #define ALITTLEONTHESIDE 5 static int kTestTestCount = ALITTLEONTHESIDE; int CommonCryptoSymOffset(int argc, char *const *argv) { int accum = 0; uint8_t iLikeBigBuffs[ILIKEEMDISBIG]; uint8_t andICannotLie[ILIKEEMDISBIG]; uint8_t iLikeEmRoundandBig[ILIKEEMDISBIG]; int i; size_t moved; CCCryptorStatus retval; byteBuffer key = hexStringToBytes("010203040506070809000a0b0c0d0e0f"); plan_tests(kTestTestCount); for(i=0; i<ALITTLEONTHESIDE; i++) { retval = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, 0, key->bytes, key->len, NULL, iLikeBigBuffs+i, ILIKEEMDISBIG-16, andICannotLie+i, ILIKEEMDISBIG, &moved); retval = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, 0, key->bytes, key->len, NULL, andICannotLie+i, moved, iLikeEmRoundandBig+i, ILIKEEMDISBIG, &moved); if(moved != (ILIKEEMDISBIG-16)) retval = 99; else if(memcmp(iLikeBigBuffs+i, iLikeEmRoundandBig+i, moved)) retval = 999; ok(retval == 0, "Encrypt/Decrypt Cycle"); accum += retval; } return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymRC2.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CCRC2KAT.c * CCRegressions * */ #include <stdio.h> #include "CCCryptorTestFuncs.h" #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMRC2 == 0) entryPoint(CommonCryptoSymRC2,"Common Crypto RC2 Test") #else #ifdef WEIRDCASE static int kTestTestCount = 12; #else static int kTestTestCount = 8; #endif int CommonCryptoSymRC2(int argc, char *const *argv) { char *keyStr; char *iv; char *plainText; char *cipherText; CCAlgorithm alg; CCOptions options; int retval; int rkeylen, ekeylenBits; char printString[128]; alg = kCCAlgorithmRC2; iv = NULL; options = 0; plan_tests(kTestTestCount); rkeylen = 8; ekeylenBits = 63; keyStr = "0000000000000000"; plainText = "0000000000000000"; cipherText = "ebb773f993278eff"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); rkeylen = 8; ekeylenBits = 64; keyStr = "ffffffffffffffff"; plainText = "ffffffffffffffff"; cipherText = "278b27e42e2f0d49"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); rkeylen = 8; ekeylenBits = 64; keyStr = "3000000000000000"; plainText = "1000000000000001"; cipherText = "30649edf9be7d2c2"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); #ifdef WEIRDCASE rkeylen = 1; ekeylenBits = 64; keyStr = "88"; plainText = "0000000000000000"; cipherText = "61a8a244adacccf0"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); rkeylen = 7; ekeylenBits = 64; keyStr = "88bca90e90875a"; plainText = "0000000000000000"; cipherText = "6ccf4308974c267f"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); rkeylen = 16; ekeylenBits = 64; keyStr = "88bca90e90875a7f0f79c384627bafb2"; plainText = "0000000000000000"; cipherText = "1a807d272bbe5db1"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); #endif rkeylen = 16; ekeylenBits = 128; keyStr = "88bca90e90875a7f0f79c384627bafb2"; plainText = "0000000000000000"; cipherText = "2269552ab0f85ca6"; retval = CCCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) One-Shot", rkeylen, ekeylenBits); ok(retval == 0, printString); retval = CCMultiCryptTestCase(keyStr, iv, alg, options, cipherText, plainText); sprintf(printString, "RC2 %d byte Key (effective %d bits) Multi", rkeylen, ekeylenBits); ok(retval == 0, printString); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymRegression.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | /* Copyright 2006 Apple Computer, Inc. * * ccSymTest.c - test CommonCrypto symmetric encrypt/decrypt. */ #include "testmore.h" #include "capabilities.h" #if (CCSYMREGRESSION == 0) entryPoint(CommonCryptoSymRegression,"CommonCrypto Base Behavior Regression Tests") #else #include <string.h> #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <CommonCrypto/CommonCryptor.h> #include <fcntl.h> #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> // #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacErrors.h> /* * Defaults. */ #define LOOPS_DEF 500 #define MIN_DATA_SIZE 8 #define MAX_DATA_SIZE 10000 /* bytes */ #define MAX_KEY_SIZE kCCKeySizeMaxRC4 /* bytes */ #define MAX_BLOCK_SIZE kCCBlockSizeAES128 /* bytes */ #define LOOP_NOTIFY 250 /* * Enumerate algs our own way to allow iteration. */ typedef enum { ALG_AES_128 = 1, /* 128 bit block, 128 bit key */ ALG_AES_192, /* 128 bit block, 192 bit key */ ALG_AES_256, /* 128 bit block, 256 bit key */ ALG_DES, ALG_3DES, ALG_CAST, ALG_RC4, /* these aren't in CommonCrypto (yet?) */ ALG_RC2, ALG_RC5, ALG_BFISH, ALG_ASC, ALG_NULL /* normally not used */ } SymAlg; #define ALG_FIRST ALG_AES_128 #define ALG_LAST ALG_RC4 #define LOG_SIZE 0 #if LOG_SIZE #define logSize(s) diag s #else #define logSize(s) #endif static void appGetRandomBytes(void *keyBytes, size_t keySizeInBytes) { int fd; if((fd = open("/dev/random", O_RDONLY)) < 0) { diag("Can't open Random\n"); exit(0); } if(read(fd, keyBytes, keySizeInBytes) != keySizeInBytes) { diag("Can't read Random\n"); exit(0); } close(fd); } /* min <= return <= max */ static unsigned genRand(unsigned min, unsigned max) { unsigned i; if(min == max) { return min; } appGetRandomBytes(&i, 4); return (min + (i % (max - min + 1))); } static void printCCError(const char *str, CCCryptorStatus crtn) { const char *errStr; char unknownStr[200]; switch(crtn) { case kCCSuccess: errStr = "kCCSuccess"; break; case kCCParamError: errStr = "kCCParamError"; break; case kCCBufferTooSmall: errStr = "kCCBufferTooSmall"; break; case kCCMemoryFailure: errStr = "kCCMemoryFailure"; break; case kCCAlignmentError: errStr = "kCCAlignmentError"; break; case kCCDecodeError: errStr = "kCCDecodeError"; break; case kCCUnimplemented: errStr = "kCCUnimplemented"; break; default: sprintf(unknownStr, "Unknown(%ld)\n", (long)crtn); errStr = unknownStr; break; } diag("***%s returned %s\n", str, errStr); } /* max context size */ #define CC_MAX_CTX_SIZE kCCContextSizeRC4 /* * We write a marker at end of expected output and at end of caller-allocated * CCCryptorRef, and check at the end to make sure they weren't written */ #define MARKER_LENGTH 8 #define MARKER_BYTE 0x7e /* * Test harness for CCCryptor with lots of options. */ static CCCryptorStatus doCCCrypt( bool forEncrypt, CCAlgorithm encrAlg, bool doCbc, bool doPadding, const void *keyBytes, size_t keyLen, const void *iv, bool randUpdates, bool inPlace, /* !doPadding only */ size_t ctxSize, /* if nonzero, we allocate ctx */ bool askOutSize, const uint8_t *inText, size_t inTextLen, uint8_t **outText, size_t *outTextLen) /* both returned, WE malloc */ { CCCryptorRef cryptor = NULL; CCCryptorStatus crtn; CCOperation op = forEncrypt ? kCCEncrypt : kCCDecrypt; CCOptions options = 0; uint8_t *outBuf = NULL; /* mallocd output buffer */ uint8_t *outp; /* running ptr into outBuf */ const uint8_t *inp; /* running ptr into inText */ size_t outLen = 0; /* bytes remaining in outBuf */ size_t toMove; /* bytes remaining in inText */ size_t thisMoveOut; /* output from CCCryptUpdate()/CCCryptFinal() */ size_t outBytes; /* total bytes actually produced in outBuf */ char ctx[CC_MAX_CTX_SIZE]; /* for CCCryptorCreateFromData() */ uint8_t *textMarker = NULL; /* 8 bytes of marker here after expected end of * output */ char *ctxMarker = NULL; /* ditto for caller-provided context */ unsigned dex; size_t askedOutSize; /* from the lib */ size_t thisOutLen; /* dataOutAvailable we use */ if(0) diag("%s %s %s keylen %d %s %s %s %s %s input length %ld\n", forEncrypt ? "Encrypting": "Decrypting", doCbc ? "CBC": "ECB", doPadding ? "Padding ON": "Padding OFF", (int) keyLen, iv ? "IV Provided": "No IV Provided", randUpdates ? "Random Updates": "Non-Random Updates", inPlace ? "In Place": "Separate Buffers", ctxSize ? "We Allocate": "CC Allocated", askOutSize ? "Ask OutSize": "Don't Ask OutSize", inTextLen); if(ctxSize > CC_MAX_CTX_SIZE) { diag("***HEY! Adjust CC_MAX_CTX_SIZE!\n"); exit(1); } if(!doCbc) { options |= kCCOptionECBMode; } if(doPadding) { options |= kCCOptionPKCS7Padding; } /* just hack this one */ outLen = inTextLen; if(forEncrypt) { outLen += MAX_BLOCK_SIZE; } outBuf = (uint8_t *)malloc(outLen + MARKER_LENGTH); memset(outBuf, 0xEE, outLen + MARKER_LENGTH); /* library should not touch this memory */ textMarker = outBuf + outLen; memset(textMarker, MARKER_BYTE, MARKER_LENGTH); /* subsequent errors to errOut: */ if(inPlace) { memmove(outBuf, inText, inTextLen); inp = outBuf; } else { inp = inText; } if(!randUpdates) { /* one shot */ if(askOutSize) { crtn = CCCrypt(op, encrAlg, options, keyBytes, keyLen, iv, inp, inTextLen, outBuf, 0, &askedOutSize); if(crtn != kCCBufferTooSmall) { diag("***Did not get kCCBufferTooSmall as expected\n"); diag(" alg %d inTextLen %lu cbc %d padding %d keyLen %lu\n", (int)encrAlg, (unsigned long)inTextLen, (int)doCbc, (int)doPadding, (unsigned long)keyLen); printCCError("CCCrypt", crtn); crtn = -1; goto errOut; } outLen = askedOutSize; } crtn = CCCrypt(op, encrAlg, options, keyBytes, keyLen, iv, inp, inTextLen, outBuf, outLen, &outLen); if(crtn) { printCCError("CCCrypt", crtn); goto errOut; } *outText = outBuf; *outTextLen = outLen; goto errOut; } /* random multi updates */ if(ctxSize) { size_t ctxSizeCreated; if(askOutSize) { crtn = CCCryptorCreateFromData(op, encrAlg, options, keyBytes, keyLen, iv, ctx, 0 /* ctxSize */, &cryptor, &askedOutSize); if(crtn != kCCBufferTooSmall) { diag("***Did not get kCCBufferTooSmall as expected\n"); printCCError("CCCryptorCreateFromData", crtn); crtn = -1; goto errOut; } ctxSize = askedOutSize; } crtn = CCCryptorCreateFromData(op, encrAlg, options, keyBytes, keyLen, iv, ctx, ctxSize, &cryptor, &ctxSizeCreated); if(crtn) { printCCError("CCCryptorCreateFromData", crtn); return crtn; } ctxMarker = ctx + ctxSizeCreated; memset(ctxMarker, MARKER_BYTE, MARKER_LENGTH); } else { crtn = CCCryptorCreate(op, encrAlg, options, keyBytes, keyLen, iv, &cryptor); if(crtn) { printCCError("CCCryptorCreate", crtn); return crtn; } } toMove = inTextLen; /* total to go */ outp = outBuf; outBytes = 0; /* bytes actually produced in outBuf */ while(toMove) { size_t thisMoveIn; /* input to CCryptUpdate() */ thisMoveIn = (size_t) genRand(1, (unsigned int) toMove); logSize(("###ptext segment len %lu\n", (unsigned long)thisMoveIn)); if(askOutSize) { thisOutLen = CCCryptorGetOutputLength(cryptor, thisMoveIn, false); } else { thisOutLen = outLen; } crtn = CCCryptorUpdate(cryptor, inp, thisMoveIn, outp, thisOutLen, &thisMoveOut); if(crtn) { printCCError("CCCryptorUpdate", crtn); goto errOut; } inp += thisMoveIn; toMove -= thisMoveIn; outp += thisMoveOut; outLen -= thisMoveOut; outBytes += thisMoveOut; } if(doPadding) { /* Final is not needed if padding is disabled */ if(askOutSize) { thisOutLen = CCCryptorGetOutputLength(cryptor, 0, true); } else { thisOutLen = outLen; } crtn = CCCryptorFinal(cryptor, outp, thisOutLen, &thisMoveOut); } else { thisMoveOut = 0; crtn = kCCSuccess; } if(crtn) { printCCError("CCCryptorFinal", crtn); goto errOut; } outBytes += thisMoveOut; *outText = outBuf; *outTextLen = outBytes; crtn = kCCSuccess; for(dex=0; dex<MARKER_LENGTH; dex++) { if(textMarker[dex] != MARKER_BYTE) { diag("***lib scribbled on our textMarker memory (op=%s)!\n", forEncrypt ? "encrypt" : "decrypt"); crtn = (CCCryptorStatus)-1; } } if(ctxSize) { for(dex=0; dex<MARKER_LENGTH; dex++) { if(ctxMarker[dex] != MARKER_BYTE) { diag("***lib scribbled on our ctxMarker memory (op=%s)!\n", forEncrypt ? "encrypt" : "decrypt"); crtn = (CCCryptorStatus)-1; } } } errOut: if(crtn) { if(outBuf) { free(outBuf); } } if(cryptor) { CCCryptorRelease(cryptor); } return crtn; } static int doTest(const uint8_t *ptext, size_t ptextLen, CCAlgorithm encrAlg, bool doCbc, bool doPadding, bool nullIV, /* if CBC, use NULL IV */ uint32_t keySizeInBytes, bool stagedEncr, bool stagedDecr, bool inPlace, size_t ctxSize, bool askOutSize, bool quiet) { uint8_t keyBytes[MAX_KEY_SIZE]; uint8_t iv[MAX_BLOCK_SIZE]; uint8_t *ivPtrEncrypt; uint8_t *ivPtrDecrypt; uint8_t *ctext = NULL; /* mallocd by doCCCrypt */ size_t ctextLen = 0; uint8_t *rptext = NULL; /* mallocd by doCCCrypt */ size_t rptextLen; CCCryptorStatus crtn; int rtn = 0; /* random key */ appGetRandomBytes(keyBytes, keySizeInBytes); /* random IV if needed */ if(doCbc) { if(nullIV) { memset(iv, 0, MAX_BLOCK_SIZE); /* flip a coin, give one side NULL, the other size zeroes */ if(genRand(1,2) == 1) { ivPtrEncrypt = NULL; ivPtrDecrypt = iv; } else { ivPtrEncrypt = iv; ivPtrDecrypt = NULL; } } else { appGetRandomBytes(iv, MAX_BLOCK_SIZE); ivPtrEncrypt = iv; ivPtrDecrypt = iv; } } else { ivPtrEncrypt = NULL; ivPtrDecrypt = NULL; } crtn = doCCCrypt(true, encrAlg, doCbc, doPadding, keyBytes, keySizeInBytes, ivPtrEncrypt, stagedEncr, inPlace, ctxSize, askOutSize, ptext, ptextLen, &ctext, &ctextLen); ok(crtn == 0, "doCCCrypt"); if(crtn) { diag("Test Failure Encrypt encrAlg = %d dodCbc = %d doPadding %d\n", encrAlg, doCbc, doPadding); } logSize(("###ctext len %lu\n", ctextLen)); crtn = doCCCrypt(false, encrAlg, doCbc, doPadding, keyBytes, keySizeInBytes, ivPtrDecrypt, stagedDecr, inPlace, ctxSize, askOutSize, ctext, ctextLen, &rptext, &rptextLen); ok(crtn == 0, "doCCCrypt"); if(crtn) { diag("Test Failure Encrypt encrAlg = %d dodCbc = %d doPadding %d\n", encrAlg, doCbc, doPadding); } logSize(("###rptext len %lu\n", rptextLen)); /* compare ptext, rptext */ if(ptextLen != rptextLen) { diag("Ptext length mismatch: expect %lu, got %lu\n", ptextLen, rptextLen); } if(memcmp(ptext, rptext, ptextLen)) { diag("***data miscompare\n"); } abort: if(ctext) { free(ctext); } if(rptext) { free(rptext); } return rtn; } static bool isBitSet(unsigned bit, unsigned word) { if(bit > 31) { diag("We don't have that many bits\n"); exit(1); } unsigned mask = 1 << bit; return (word & mask) ? true : false; } static int kTestTestCount = 1; int CommonCryptoSymRegression(int argc, char *const *argv) { unsigned loop; uint8_t *ptext; size_t ptextLen; bool stagedEncr = false; bool stagedDecr = false; bool doPadding; bool doCbc = false; bool nullIV; const char *algStr; CCAlgorithm encrAlg; int i; int currAlg; // ALG_xxx uint32_t minKeySizeInBytes; uint32_t maxKeySizeInBytes; uint32_t keySizeInBytes = 0; int rtn = 0; uint32_t blockSize; // for noPadding case size_t ctxSize; // always set per alg size_t ctxSizeUsed; // passed to doTest bool askOutSize; // inquire output size each op /* * User-spec'd params */ bool keySizeSpec = false; // false: use rand key size SymAlg minAlg = ALG_FIRST; SymAlg maxAlg = ALG_LAST; unsigned loops = LOOPS_DEF; bool verbose = false; size_t minPtextSize = MIN_DATA_SIZE; size_t maxPtextSize = MAX_DATA_SIZE; bool quiet = true; unsigned pauseInterval = 0; bool paddingSpec = false; // true: user calls doPadding, const bool cbcSpec = false; // ditto for doCbc bool stagedSpec = false; // ditto for stagedEncr and stagedDecr bool inPlace = false; // en/decrypt in place for ECB bool allocCtxSpec = false; // use allocCtx bool allocCtx = false; // allocate context ourself plan_tests(kTestTestCount); ptext = (uint8_t *)malloc(maxPtextSize); if(ptext == NULL) { diag("Insufficient heap space\n"); exit(1); } /* ptext length set in test loop */ if(!quiet) diag("Starting ccSymTest; args: "); for(i=1; i<argc; i++) { if(!quiet) diag("%s ", argv[i]); } if(!quiet) diag("\n"); if(pauseInterval) { fpurge(stdin); diag("Top of test; hit CR to proceed: "); getchar(); } for(currAlg=minAlg; currAlg<=maxAlg; currAlg++) { switch(currAlg) { case ALG_DES: encrAlg = kCCAlgorithmDES; blockSize = kCCBlockSizeDES; minKeySizeInBytes = kCCKeySizeDES; maxKeySizeInBytes = minKeySizeInBytes; ctxSize = kCCContextSizeDES; algStr = "DES"; diag("Running DES Tests"); break; case ALG_3DES: encrAlg = kCCAlgorithm3DES; blockSize = kCCBlockSize3DES; minKeySizeInBytes = kCCKeySize3DES; maxKeySizeInBytes = minKeySizeInBytes; ctxSize = kCCContextSize3DES; algStr = "3DES"; diag("Running 3DES Tests"); break; case ALG_AES_128: encrAlg = kCCAlgorithmAES128; blockSize = kCCBlockSizeAES128; minKeySizeInBytes = kCCKeySizeAES128; maxKeySizeInBytes = minKeySizeInBytes; ctxSize = kCCContextSizeAES128; algStr = "AES128"; diag("Running AES (128 bit key) Tests"); break; case ALG_AES_192: encrAlg = kCCAlgorithmAES128; blockSize = kCCBlockSizeAES128; minKeySizeInBytes = kCCKeySizeAES192; maxKeySizeInBytes = minKeySizeInBytes; ctxSize = kCCContextSizeAES128; algStr = "AES192"; diag("Running AES (192 bit key) Tests"); break; case ALG_AES_256: encrAlg = kCCAlgorithmAES128; blockSize = kCCBlockSizeAES128; minKeySizeInBytes = kCCKeySizeAES256; maxKeySizeInBytes = minKeySizeInBytes; ctxSize = kCCContextSizeAES128; algStr = "AES256"; diag("Running AES (256 bit key) Tests"); break; case ALG_CAST: encrAlg = kCCAlgorithmCAST; blockSize = kCCBlockSizeCAST; minKeySizeInBytes = kCCKeySizeMinCAST; maxKeySizeInBytes = kCCKeySizeMaxCAST; ctxSize = kCCContextSizeCAST; algStr = "CAST"; diag("Running CAST Tests"); break; case ALG_RC4: encrAlg = kCCAlgorithmRC4; blockSize = 0; minKeySizeInBytes = kCCKeySizeMinRC4; maxKeySizeInBytes = kCCKeySizeMaxRC4; ctxSize = kCCContextSizeRC4; algStr = "RC4"; diag("Running RC4 Tests"); break; default: diag("***BRRZAP!\n"); exit(1); } if(!quiet || verbose) { diag("Testing alg %s\n", algStr); } for(loop=1; ; loop++) { ptextLen = (size_t) genRand((unsigned int) minPtextSize, (unsigned int) maxPtextSize); appGetRandomBytes(ptext, ptextLen); /* per-loop settings */ if(!keySizeSpec) { if(minKeySizeInBytes == maxKeySizeInBytes) { keySizeInBytes = minKeySizeInBytes; } else { keySizeInBytes = genRand(minKeySizeInBytes, maxKeySizeInBytes); } } if(blockSize == 0) { /* stream cipher */ doCbc = false; doPadding = false; } else { if(!cbcSpec) { doCbc = isBitSet(0, loop); } if(!paddingSpec) { doPadding = isBitSet(1, loop); } } if(!doPadding && (blockSize != 0)) { /* align plaintext */ ptextLen = (ptextLen / blockSize) * blockSize; if(ptextLen == 0) { ptextLen = blockSize; } } if(!stagedSpec) { stagedEncr = isBitSet(2, loop); stagedDecr = isBitSet(3, loop); } if(doCbc) { nullIV = isBitSet(4, loop); } else { nullIV = false; } inPlace = isBitSet(5, loop); if(allocCtxSpec) { ctxSizeUsed = allocCtx ? ctxSize : 0; } else if(isBitSet(6, loop)) { ctxSizeUsed = ctxSize; } else { ctxSizeUsed = 0; } askOutSize = isBitSet(7, loop); if(!quiet) { if(verbose || ((loop % LOOP_NOTIFY) == 0)) { diag("..loop %3d ptextLen %lu keyLen %d cbc=%d padding=%d stagedEncr=%d " "stagedDecr=%d\n", loop, (unsigned long)ptextLen, (int)keySizeInBytes, (int)doCbc, (int)doPadding, (int)stagedEncr, (int)stagedDecr); diag(" nullIV %d inPlace %d ctxSize %d askOutSize %d\n", (int)nullIV, (int)inPlace, (int)ctxSizeUsed, (int)askOutSize); } } if(doTest(ptext, ptextLen, encrAlg, doCbc, doPadding, nullIV, keySizeInBytes, stagedEncr, stagedDecr, inPlace, ctxSizeUsed, askOutSize, quiet)) { rtn = 1; break; } if(pauseInterval && ((loop % pauseInterval) == 0)) { char c; fpurge(stdin); diag("Hit CR to proceed, q to abort: "); c = getchar(); if(c == 'q') { goto testDone; } } if(loops && (loop == loops)) { break; } } /* main loop */ if(rtn) { break; } } /* for algs */ testDone: ok(rtn == 0, "ccSymTest"); if(pauseInterval) { fpurge(stdin); diag("ModuleDetach/Unload complete; hit CR to exit: "); getchar(); } if((rtn == 0) && !quiet) { diag("%s test complete\n", argv[0]); } free(ptext); return rtn; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymXTS.c.
more than 10,000 changes
Added CCRegression/CommonCrypto/CommonCryptoSymZeroLength.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #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); /* Two Test cases - "" and NULL WITH an IV */ keyStr = "000102030405060708090a0b0c0d0e0f"; iv = "0f0e0d0c0b0a09080706050403020100"; // 1 plainText = ""; cipherText = "efddc425a6fa0c5f25e444092eb0f503"; retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText); ok(retval == 0, "CBC Zero Length String, IV defined"); accum += retval; // 1 plainText = NULL; cipherText = "efddc425a6fa0c5f25e444092eb0f503"; retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText); ok(retval == 0, "CBC NULL String, IV defined"); accum += retval; /* Two more Test cases - "" and NULL WITH IV=NULL */ keyStr = "000102030405060708090a0b0c0d0e0f"; iv = NULL; // 1 plainText = ""; cipherText = "954f64f2e4e86e9eee82d20216684899"; retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText); ok(retval == 0, "CBC Zero Length String, IV NULL"); accum += retval; // 1 plainText = NULL; cipherText = "954f64f2e4e86e9eee82d20216684899"; retval = CCCryptTestCase(keyStr, iv, kCCAlgorithmAES128, kCCOptionPKCS7Padding, cipherText, plainText); //retval = 0; ok(retval == 0, "CBC NULL String, IV NULL"); accum += retval; return accum != 0; } #endif |
Added CCRegression/CommonCrypto/CommonCryptoSymmetricWrap.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | // // CommonCryptoSymmetricWrap.c // CCRegressions // // Created by Richard Murphy on 1/13/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #include <stdio.h> #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCSYMWRAP == 0) entryPoint(CommonSymmetricWrap,"Symmetric Wrap") #else #include <CommonCrypto/CommonSymmetricKeywrap.h> static int wrapTest(char *kekstr, char *keystr, char *wrapped_keystr) { byteBuffer kek, key, wrapped_key, bb; kek = hexStringToBytes(kekstr); key = hexStringToBytes(keystr); if(wrapped_keystr) wrapped_key = hexStringToBytes(wrapped_keystr); else wrapped_key = hexStringToBytes("0x00"); const uint8_t *iv = CCrfc3394_iv; const size_t ivLen = CCrfc3394_ivLen; size_t wrapped_size = CCSymmetricWrappedSize(kCCWRAPAES, key->len); uint8_t wrapped[wrapped_size]; // printf("Wrapped Size %lu\n", wrapped_size); ok(CCSymmetricKeyWrap(kCCWRAPAES, iv , ivLen, kek->bytes, kek->len, key->bytes, key->len, wrapped, &wrapped_size) == 0, "function is successful"); if(wrapped_keystr) { bb = bytesToBytes(wrapped, wrapped_size); if(!strcmp(wrapped_keystr, "")) printByteBuffer(bb, "Result: "); ok(bytesAreEqual(bb, wrapped_key), "Equal to expected wrapping"); // printByteBuffer(bb, "Result: "); // printByteBuffer(wrapped_key, "Expected: "); free(bb); } size_t unwrapped_size = CCSymmetricUnwrappedSize(kCCWRAPAES, wrapped_size); uint8_t unwrapped[unwrapped_size]; ok(CCSymmetricKeyUnwrap(kCCWRAPAES, iv, ivLen, kek->bytes, kek->len, wrapped, wrapped_size, unwrapped, &unwrapped_size) == 0, "function is successful"); bb = bytesToBytes(unwrapped, unwrapped_size); ok(bytesAreEqual(bb, key), "Equal to original key"); free(bb); free(kek); free(key); free(wrapped_key); return 0; } static int kTestTestCount = 35; int CommonSymmetricWrap(int argc, char *const *argv) { char *kek, *key, *wrapped_key; int accum = 0; plan_tests(kTestTestCount); diag("Test 1"); kek = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; key = "00112233445566778899aabbccddeeff000102030405060708090a0b0c0d0e0f"; wrapped_key = "28C9F404C4B810F4CBCCB35CFB87F8263F5786E2D80ED326CBC7F0E71A99F43BFB988B9B7A02DD21"; accum |= wrapTest(kek, key, wrapped_key); diag("Test 2"); kek = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; key = "00112233445566778899aabbccddeeff00010203040506070"; wrapped_key = "a8f9bc1612c68b3ff6e6f4fbe30e71e4769c8b80a32cb8958cd5d17d6b254da1"; accum |= wrapTest(kek, key, wrapped_key); diag("Test 3"); byteBuffer keybuf = mallocByteBuffer(2048); for(int i=0; i<2048; i++) keybuf->bytes[i] = i%256; key = bytesToHexString(keybuf); accum |= wrapTest(kek, key, NULL); diag("Test Vectors from RFC 3394"); diag("4.1 Wrap 128 bits of Key Data with a 128-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F"; key = "00112233445566778899AABBCCDDEEFF"; wrapped_key = "1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5"; accum |= wrapTest(kek, key, wrapped_key); diag("4.2 Wrap 128 bits of Key Data with a 192-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F1011121314151617"; key = "00112233445566778899AABBCCDDEEFF"; wrapped_key = "96778B25AE6CA435F92B5B97C050AED2468AB8A17AD84E5D"; accum |= wrapTest(kek, key, wrapped_key); diag("4.3 Wrap 128 bits of Key Data with a 256-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"; key = "00112233445566778899AABBCCDDEEFF"; wrapped_key = "64E8C3F9CE0F5BA263E9777905818A2A93C8191E7D6E8AE7"; accum |= wrapTest(kek, key, wrapped_key); diag("4.4 Wrap 192 bits of Key Data with a 192-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F1011121314151617"; key = "00112233445566778899AABBCCDDEEFF0001020304050607"; wrapped_key = "031D33264E15D33268F24EC260743EDCE1C6C7DDEE725A936BA814915C6762D2"; accum |= wrapTest(kek, key, wrapped_key); diag("4.5 Wrap 192 bits of Key Data with a 256-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"; key = "00112233445566778899AABBCCDDEEFF0001020304050607"; wrapped_key = "A8F9BC1612C68B3FF6E6F4FBE30E71E4769C8B80A32CB8958CD5D17D6B254DA1"; accum |= wrapTest(kek, key, wrapped_key); diag("4.6 Wrap 256 bits of Key Data with a 256-bit KEK"); kek = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"; key = "00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F"; wrapped_key = "28C9F404C4B810F4CBCCB35CFB87F8263F5786E2D80ED326CBC7F0E71A99F43BFB988B9B7A02DD21"; accum |= wrapTest(kek, key, wrapped_key); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonDHtest.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <Availability.h> #include "capabilities.h" #include "testmore.h" #include "testbyteBuffer.h" #if (CCDH == 0) entryPoint(CommonDH,"Diffie-Hellman Key Agreement") #else #include "CommonDH.h" static int kTestTestCount = 2; int CommonDH(int argc, char *const *argv) { CCDHRef dh1, dh2; plan_tests(kTestTestCount); dh1 = CCDHCreate(kCCDHRFC2409Group2); ok(dh1 == NULL, "kCCDHRFC2409Group2 isn't implemented in corecrypto"); dh1 = CCDHCreate(kCCDHRFC3526Group5); ok(dh1 != NULL, "got a DH ref"); dh2 = CCDHCreate(kCCDHRFC3526Group5); ok(dh2 != NULL, "got a DH ref"); diag("CCDHRefs Created\n"); uint8_t pubkey1[4096], pubkey2[4096]; size_t len1 = 4096, len2 = 4096; int ret1 = CCDHGenerateKey(dh1, pubkey1, &len1); int ret2 = CCDHGenerateKey(dh2, pubkey2, &len2); ok(ret1 != -1 && ret2 != -1, "pubkeys generated"); diag("Pubkeys Created\n"); uint8_t sharedkey1[4096], sharedkey2[4096]; size_t slen1 = 4096, slen2 = 4096; int sret1 = CCDHComputeKey(sharedkey1, &slen1, pubkey2, len2, dh1); int sret2 = CCDHComputeKey(sharedkey2, &slen2, pubkey1, len1, dh2); ok(sret1 != -1 && sret2 != -1, "shared keys generated"); ok(slen1 == slen2, "shared key lengths are equal"); ok(memcmp(sharedkey1, sharedkey2, slen1) == 0, "shared keys are equal"); CCDHRelease(dh1); ok(1, "Didn't crash"); return 0; } #endif |
Added CCRegression/CommonCrypto/CommonDigest.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | #include <stdio.h> #include "testbyteBuffer.h" #include "capabilities.h" #include "testmore.h" #include <string.h> #define COMMON_DIGEST_FOR_RFC_1321 #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonDigest.h> #include <CommonCrypto/CommonHMAC.h> #ifdef CCDIGEST #include <CommonCrypto/CommonDigestSPI.h> #endif #ifdef CCKEYDERIVATION #include <CommonCrypto/CommonKeyDerivation.h> #endif static char *digestName(CCDigestAlgorithm digestSelector) { switch(digestSelector) { default: return "None"; case kCCDigestMD2: return "MD2"; case kCCDigestMD4: return "MD4"; case kCCDigestMD5: return "MD5"; case kCCDigestRMD128: return "RMD128"; case kCCDigestRMD160: return "RMD160"; case kCCDigestRMD256: return "RMD256"; case kCCDigestRMD320: return "RMD320"; case kCCDigestSHA1: return "SHA1"; case kCCDigestSHA224: return "SHA224"; case kCCDigestSHA256: return "SHA256"; case kCCDigestSHA384: return "SHA384"; case kCCDigestSHA512: return "SHA512"; case kCCDigestSkein128: return "Skein128"; case kCCDigestSkein160: return "Skein160"; case kCCDigestSkein224: return "Skein224"; case kCCDigestSkein256: return "Skein256"; case kCCDigestSkein384: return "Skein384"; case kCCDigestSkein512: return "Skein512"; } } static size_t nullstrlen(const char *s) { if(!s) return 0; return strlen(s); } #define MAX_DIGEST_SIZE CC_SHA512_DIGEST_LENGTH #if (CCKEYDERIVATION == 1) static int PBKDF2Test(char *password, uint8_t *salt, size_t saltlen, int rounds, CCDigestAlgorithm PRF, int dklen, char *expected) { byteBuffer derivedKey; byteBuffer expectedBytes; char outbuf[80]; int retval = 0; if(expected) expectedBytes = hexStringToBytes(expected); derivedKey = mallocByteBuffer(dklen); switch(PRF) { case 0: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), (uint8_t *) salt, saltlen, 0, rounds, derivedKey->bytes, derivedKey->len); break; case kCCDigestSHA1: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), salt, saltlen, kCCPRFHmacAlgSHA1, rounds, derivedKey->bytes, derivedKey->len); break; case kCCDigestSHA224: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), salt, saltlen, kCCPRFHmacAlgSHA224, rounds, derivedKey->bytes, derivedKey->len); break; case kCCDigestSHA256: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), salt, saltlen, kCCPRFHmacAlgSHA256, rounds, derivedKey->bytes, derivedKey->len); break; case kCCDigestSHA384: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), salt, saltlen, kCCPRFHmacAlgSHA384, rounds, derivedKey->bytes, derivedKey->len); break; case kCCDigestSHA512: CCKeyDerivationPBKDF(kCCPBKDF2, password, strlen(password), salt, saltlen, kCCPRFHmacAlgSHA512, rounds, derivedKey->bytes, derivedKey->len); break; default: return 1; } sprintf(outbuf, "PBKDF2-HMAC-%s test for %s", digestName(PRF), password); if(expected) { ok(bytesAreEqual(derivedKey, expectedBytes), outbuf); if(!bytesAreEqual(derivedKey, expectedBytes)) { diag("KEYDERIVE FAIL: PBKDF2-HMAC-%s(\"%s\")\n expected %s\n got %s\n", digestName(PRF), password, expected, bytesToHexString(derivedKey)); retval = 1; } else { //printf("KEYDERIVE PASS: PBKDF2-HMAC-%s(\"%s\")\n", digestName(PRF), password); } free(expectedBytes); } free(derivedKey); return retval; } #endif static byteBuffer mallocDigestBuffer(CCDigestAlgorithm digestSelector) { size_t len; switch(digestSelector) { default: len = CCDigestGetOutputSize(digestSelector); break; case kCCDigestMD2: len = CC_MD2_DIGEST_LENGTH; break; case kCCDigestMD4: len = CC_MD4_DIGEST_LENGTH; break; case kCCDigestMD5: len = CC_MD5_DIGEST_LENGTH; break; case kCCDigestSHA1: len = CC_SHA1_DIGEST_LENGTH; break; case kCCDigestSHA224: len = CC_SHA224_DIGEST_LENGTH; break; case kCCDigestSHA256: len = CC_SHA256_DIGEST_LENGTH; break; case kCCDigestSHA384: len = CC_SHA384_DIGEST_LENGTH; break; case kCCDigestSHA512: len = CC_SHA512_DIGEST_LENGTH; break; } return mallocByteBuffer(len); } static void OneShotHmac(CCHmacAlgorithm hmacAlg, uint8_t *key, size_t keylen, const char *data, size_t datalen, uint8_t *output) { CCHmacContext ctx; CCHmacInit(&ctx, hmacAlg, key, keylen); CCHmacUpdate(&ctx, data, datalen); CCHmacFinal(&ctx, output); } static int HMACTest(const char *input, char *keystr, CCDigestAlgorithm digestSelector, char *expected) { CCHmacAlgorithm hmacAlg; size_t inputLen = nullstrlen(input); char outbuf[80]; int retval = 0; byteBuffer expectedBytes = hexStringToBytes(expected); byteBuffer keyBytes = hexStringToBytes(keystr); byteBuffer mdBuf = mallocDigestBuffer(digestSelector); switch(digestSelector) { case kCCDigestMD5: hmacAlg = kCCHmacAlgMD5; break; case kCCDigestSHA1: hmacAlg = kCCHmacAlgSHA1; break; case kCCDigestSHA224: hmacAlg = kCCHmacAlgSHA224; break; case kCCDigestSHA256: hmacAlg = kCCHmacAlgSHA256; break; case kCCDigestSHA384: hmacAlg = kCCHmacAlgSHA384; break; case kCCDigestSHA512: hmacAlg = kCCHmacAlgSHA512; break; default: return 1; } CCHmac(hmacAlg, keyBytes->bytes, keyBytes->len, input, inputLen, mdBuf->bytes); sprintf(outbuf, "Hmac-%s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("HMAC FAIL: HMAC-%s(\"%s\")\n expected %s\n got %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("HMAC PASS: HMAC-%s(\"%s\")\n", digestName(digestSelector), input); } OneShotHmac(hmacAlg, keyBytes->bytes, keyBytes->len, input, inputLen, mdBuf->bytes); sprintf(outbuf, "Hmac-%s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("HMAC FAIL: HMAC-%s(\"%s\")\n expected %s\n got %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { //printf("HMAC PASS: HMAC-%s(\"%s\")\n", digestName(digestSelector), input); } free(mdBuf); free(expectedBytes); free(keyBytes); return retval; } #if (CCDIGEST == 1) static void OneShotDigest(CCDigestAlgorithm algorithm, const uint8_t *bytesToDigest, size_t numbytes, uint8_t *outbuf) { CCDigestRef d; *outbuf = 0; if((d = CCDigestCreate(algorithm)) == NULL) return; size_t fromAlg = CCDigestGetOutputSize(algorithm); size_t fromRef = CCDigestGetOutputSizeFromRef(d); size_t fromOldRoutine = CCDigestOutputSize(d); ok(fromAlg == fromRef, "Size is the same from ref or alg"); ok(fromAlg == fromOldRoutine, "Size is the same from ref or alg"); if(CCDigestUpdate(d, bytesToDigest, numbytes)) return; if(CCDigestFinal(d, outbuf)) return; uint8_t dupBuf[fromRef]; CCDigestReset(d); if(CCDigestUpdate(d, bytesToDigest, numbytes)) return; if(CCDigestFinal(d, dupBuf)) return; ok(memcmp(outbuf, dupBuf, fromRef) == 0, "result should be the same from recycled context"); CCDigestDestroy(d); } static int newHashTest(char *input, CCDigestAlgorithm digestSelector, char *expected) { size_t inputLen = nullstrlen(input); char outbuf[4096]; int retval = 0; byteBuffer expectedBytes = hexStringToBytes(expected); byteBuffer mdBuf = mallocByteBuffer(CCDigestGetOutputSize(digestSelector)); CCDigest(digestSelector, (const uint8_t *) input, inputLen, mdBuf->bytes); sprintf(outbuf, "new interface %s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("Digestor FAIL: %s(\"%s\")\nexpected %s\ngot %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("Digestor PASS: %s(\"%s\")\n", digestName(digestSelector), input); } printf("Digest is %s\n", digestName(digestSelector)); OneShotDigest(digestSelector, (const uint8_t *) input, inputLen, mdBuf->bytes); sprintf(outbuf, "composite interface %s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("Digestor FAIL: %s(\"%s\")\nexpected %s\ngot %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("Digestor PASS: %s(\"%s\")\n", digestName(digestSelector), input); } free(mdBuf); free(expectedBytes); return retval; } static int unHashTest(CCDigestAlgorithm digestSelector) { char *buf[128]; int retval; CCDigestRef retref; retval = CCDigest(digestSelector, (const uint8_t *) buf, 128, (uint8_t *) buf); ok(retval == kCCUnimplemented, "Unsupported Digest returns kCCUnimplemented"); retref = CCDigestCreate(digestSelector); ok(retref == NULL, "Unsupported Digest returns NULL"); return 0; } #endif #define CC_SHA224_CTX CC_SHA256_CTX #define CC_SHA384_CTX CC_SHA512_CTX #define OLD_ALL_IN_ONE_HASH(name,input,len,out) \ { \ CC_##name##_CTX ctx; \ ok(CC_##name##_Init(&ctx) == 1, "Old Hash init should result in 1\n"); \ ok(CC_##name##_Update(&ctx, input, len) == 1, "Old Hash update should result in 1\n"); \ ok(CC_##name##_Final(out, &ctx) == 1, "Old Hash final should result in 1\n"); \ } \ break static int hashTest(char *input, CCDigestAlgorithm digestSelector, char *expected) { CC_LONG inputLen = (CC_LONG) nullstrlen(input); char outbuf[4096]; int retval = 0; byteBuffer mdBuf = mallocDigestBuffer(digestSelector); byteBuffer expectedBytes = hexStringToBytes(expected); switch(digestSelector) { case kCCDigestMD2: CC_MD2(input, inputLen, mdBuf->bytes); break; case kCCDigestMD4: CC_MD4(input, inputLen, mdBuf->bytes); break; case kCCDigestMD5: CC_MD5(input, inputLen, mdBuf->bytes); break; case kCCDigestSHA1: CC_SHA1(input, inputLen, mdBuf->bytes); break; case kCCDigestSHA224: CC_SHA224(input, inputLen, mdBuf->bytes); break; case kCCDigestSHA256: CC_SHA256(input, inputLen, mdBuf->bytes); break; case kCCDigestSHA384: CC_SHA384(input, inputLen, mdBuf->bytes); break; case kCCDigestSHA512: CC_SHA512(input, inputLen, mdBuf->bytes); break; default: return 1; } sprintf(outbuf, "Legacy %s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("Legacy FAIL: %s(\"%s\") expected %s got %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("Legacy PASS: %s(\"%s\")\n", digestName(digestSelector), input); } switch(digestSelector) { case kCCDigestMD2: OLD_ALL_IN_ONE_HASH(MD2, input, inputLen, mdBuf->bytes); case kCCDigestMD4: OLD_ALL_IN_ONE_HASH(MD4, input, inputLen, mdBuf->bytes); case kCCDigestMD5: OLD_ALL_IN_ONE_HASH(MD5, input, inputLen, mdBuf->bytes); case kCCDigestSHA1: OLD_ALL_IN_ONE_HASH(SHA1, input, inputLen, mdBuf->bytes); case kCCDigestSHA224: OLD_ALL_IN_ONE_HASH(SHA224, input, inputLen, mdBuf->bytes); case kCCDigestSHA256: OLD_ALL_IN_ONE_HASH(SHA256, input, inputLen, mdBuf->bytes); case kCCDigestSHA384: OLD_ALL_IN_ONE_HASH(SHA384, input, inputLen, mdBuf->bytes); case kCCDigestSHA512: OLD_ALL_IN_ONE_HASH(SHA512, input, inputLen, mdBuf->bytes); default: return 1; } sprintf(outbuf, "Legacy %s test for %s", digestName(digestSelector), input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("Legacy FAIL: %s(\"%s\") expected %s got %s\n", digestName(digestSelector), input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("Legacy PASS: %s(\"%s\")\n", digestName(digestSelector), input); } free(mdBuf); free(expectedBytes); return retval; } static int rfc1321Test(char *input, char *expected) { CC_LONG inputLen = (CC_LONG) nullstrlen(input); char outbuf[80]; int retval = 0; MD5_CTX ctx; byteBuffer expectedBytes = hexStringToBytes(expected); byteBuffer mdBuf = mallocByteBuffer(CC_MD5_DIGEST_LENGTH); MD5Init(&ctx); MD5Update(&ctx, input, inputLen); MD5Final(mdBuf->bytes, &ctx); sprintf(outbuf, "Legacy MD5-1321 test for %s", input); ok(bytesAreEqual(mdBuf, expectedBytes), outbuf); if(!bytesAreEqual(mdBuf, expectedBytes)) { diag("Legacy FAIL: MD5-1321(\"%s\") expected %s got %s\n", input, expected, bytesToHexString(mdBuf)); retval = 1; } else { // printf("Legacy PASS: MD5-1321(\"%s\")\n", input); } free(mdBuf); free(expectedBytes); return retval; } static int kTestTestCount = 250; int CommonDigest(int argc, char *const *argv) { char *strvalue, *keyvalue; plan_tests(kTestTestCount); int accum = 0; /* strvalue of NULL and strvalue of "" must end up the same */ strvalue = NULL; accum |= hashTest(strvalue, kCCDigestMD2, "8350e5a3e24c153df2275c9f80692773"); accum |= hashTest(strvalue, kCCDigestMD4, "31d6cfe0d16ae931b73c59d7e0c089c0"); accum |= hashTest(strvalue, kCCDigestMD5, "d41d8cd98f00b204e9800998ecf8427e"); accum |= hashTest(strvalue, kCCDigestSHA1, "da39a3ee5e6b4b0d3255bfef95601890afd80709"); accum |= hashTest(strvalue, kCCDigestSHA224, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"); accum |= hashTest(strvalue, kCCDigestSHA256, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); accum |= hashTest(strvalue, kCCDigestSHA384, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"); accum |= hashTest(strvalue, kCCDigestSHA512, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); #if (CCDIGEST == 1) accum |= newHashTest(strvalue, kCCDigestMD2, "8350e5a3e24c153df2275c9f80692773"); accum |= newHashTest(strvalue, kCCDigestMD4, "31d6cfe0d16ae931b73c59d7e0c089c0"); accum |= newHashTest(strvalue, kCCDigestMD5, "d41d8cd98f00b204e9800998ecf8427e"); accum |= newHashTest(strvalue, kCCDigestSHA1, "da39a3ee5e6b4b0d3255bfef95601890afd80709"); accum |= newHashTest(strvalue, kCCDigestSHA224, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"); accum |= newHashTest(strvalue, kCCDigestSHA256, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); accum |= newHashTest(strvalue, kCCDigestSHA384, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"); accum |= newHashTest(strvalue, kCCDigestSHA512, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); accum |= newHashTest(strvalue, kCCDigestRMD128, "cdf26213a150dc3ecb610f18f6b38b46"); accum |= newHashTest(strvalue, kCCDigestRMD160, "9c1185a5c5e9fc54612808977ee8f548b2258d31"); accum |= newHashTest(strvalue, kCCDigestRMD256, "02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d"); accum |= newHashTest(strvalue, kCCDigestRMD320, "22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8"); #else diag("No Testing of the new Digest Interfaces\n"); #endif strvalue = ""; accum |= hashTest(strvalue, kCCDigestMD2, "8350e5a3e24c153df2275c9f80692773"); accum |= hashTest(strvalue, kCCDigestMD4, "31d6cfe0d16ae931b73c59d7e0c089c0"); accum |= hashTest(strvalue, kCCDigestMD5, "d41d8cd98f00b204e9800998ecf8427e"); accum |= hashTest(strvalue, kCCDigestSHA1, "da39a3ee5e6b4b0d3255bfef95601890afd80709"); accum |= hashTest(strvalue, kCCDigestSHA224, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"); accum |= hashTest(strvalue, kCCDigestSHA256, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); accum |= hashTest(strvalue, kCCDigestSHA384, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"); accum |= hashTest(strvalue, kCCDigestSHA512, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); #if (CCDIGEST == 1) accum |= newHashTest(strvalue, kCCDigestMD2, "8350e5a3e24c153df2275c9f80692773"); accum |= newHashTest(strvalue, kCCDigestMD4, "31d6cfe0d16ae931b73c59d7e0c089c0"); accum |= newHashTest(strvalue, kCCDigestMD5, "d41d8cd98f00b204e9800998ecf8427e"); accum |= newHashTest(strvalue, kCCDigestSHA1, "da39a3ee5e6b4b0d3255bfef95601890afd80709"); accum |= newHashTest(strvalue, kCCDigestSHA224, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"); accum |= newHashTest(strvalue, kCCDigestSHA256, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); accum |= newHashTest(strvalue, kCCDigestSHA384, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"); accum |= newHashTest(strvalue, kCCDigestSHA512, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); accum |= newHashTest(strvalue, kCCDigestRMD128, "cdf26213a150dc3ecb610f18f6b38b46"); accum |= newHashTest(strvalue, kCCDigestRMD160, "9c1185a5c5e9fc54612808977ee8f548b2258d31"); accum |= newHashTest(strvalue, kCCDigestRMD256, "02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d"); accum |= newHashTest(strvalue, kCCDigestRMD320, "22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8"); #if defined(TESTSKEIN) accum |= newHashTest(strvalue, kCCDigestSkein128, "030085a5c5e9fc54612808977ee8f548"); accum |= newHashTest(strvalue, kCCDigestSkein160, "030085a5c5e9fc54612808977ee8f548b2258d31"); accum |= newHashTest(strvalue, kCCDigestSkein224, "030085a5c5e9fc54612808977ee8f548b2258d31009b934ca495991b"); accum |= newHashTest(strvalue, kCCDigestSkein256, "0900d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); accum |= newHashTest(strvalue, kCCDigestSkein384, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); accum |= newHashTest(strvalue, kCCDigestSkein512, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); #else accum |= unHashTest(kCCDigestSkein128); accum |= unHashTest(kCCDigestSkein160); accum |= unHashTest(kCCDigestSkein224); accum |= unHashTest(kCCDigestSkein256); accum |= unHashTest(kCCDigestSkein384); accum |= unHashTest(kCCDigestSkein512); #endif #else diag("No Testing of the new Digest Interfaces\n"); #endif strvalue = "Test vector from febooti.com"; accum |= hashTest(strvalue, kCCDigestMD2, "db128d6e0d20a1192a6bd1fade401150"); accum |= hashTest(strvalue, kCCDigestMD4, "6578f2664bc56e0b5b3f85ed26ecc67b"); accum |= hashTest(strvalue, kCCDigestMD5, "500ab6613c6db7fbd30c62f5ff573d0f"); accum |= hashTest(strvalue, kCCDigestSHA1, "a7631795f6d59cd6d14ebd0058a6394a4b93d868"); accum |= hashTest(strvalue, kCCDigestSHA224, "3628b402254caa96827e3c79c0a559e4558da8ee2b65f1496578137d"); accum |= hashTest(strvalue, kCCDigestSHA256, "077b18fe29036ada4890bdec192186e10678597a67880290521df70df4bac9ab"); accum |= hashTest(strvalue, kCCDigestSHA384, "388bb2d487de48740f45fcb44152b0b665428c49def1aaf7c7f09a40c10aff1cd7c3fe3325193c4dd35d4eaa032f49b0"); accum |= hashTest(strvalue, kCCDigestSHA512, "09fb898bc97319a243a63f6971747f8e102481fb8d5346c55cb44855adc2e0e98f304e552b0db1d4eeba8a5c8779f6a3010f0e1a2beb5b9547a13b6edca11e8a"); accum |= rfc1321Test(strvalue, "500ab6613c6db7fbd30c62f5ff573d0f"); #if (CCDIGEST == 1) accum |= newHashTest(strvalue, kCCDigestMD2, "db128d6e0d20a1192a6bd1fade401150"); accum |= newHashTest(strvalue, kCCDigestMD4, "6578f2664bc56e0b5b3f85ed26ecc67b"); accum |= newHashTest(strvalue, kCCDigestMD5, "500ab6613c6db7fbd30c62f5ff573d0f"); accum |= newHashTest(strvalue, kCCDigestSHA1, "a7631795f6d59cd6d14ebd0058a6394a4b93d868"); accum |= newHashTest(strvalue, kCCDigestSHA224, "3628b402254caa96827e3c79c0a559e4558da8ee2b65f1496578137d"); accum |= newHashTest(strvalue, kCCDigestSHA256, "077b18fe29036ada4890bdec192186e10678597a67880290521df70df4bac9ab"); accum |= newHashTest(strvalue, kCCDigestSHA384, "388bb2d487de48740f45fcb44152b0b665428c49def1aaf7c7f09a40c10aff1cd7c3fe3325193c4dd35d4eaa032f49b0"); accum |= newHashTest(strvalue, kCCDigestSHA512, "09fb898bc97319a243a63f6971747f8e102481fb8d5346c55cb44855adc2e0e98f304e552b0db1d4eeba8a5c8779f6a3010f0e1a2beb5b9547a13b6edca11e8a"); #if defined(TESTSKEIN) accum |= newHashTest(strvalue, kCCDigestSkein128, "03000000000000700000000000000070"); accum |= newHashTest(strvalue, kCCDigestSkein160, "0300000000000070000000000000007000000000"); accum |= newHashTest(strvalue, kCCDigestSkein224, "030000000000007000000000000000700000000000000070ca030210"); accum |= newHashTest(strvalue, kCCDigestSkein256, "0000000000000000000000000000000000000000000000000000000000000000"); accum |= newHashTest(strvalue, kCCDigestSkein384, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); accum |= newHashTest(strvalue, kCCDigestSkein512, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); #endif #else diag("No Testing of the new Digest Interfaces\n"); #endif // Test Case 1 http://www.faqs.org/rfcs/rfc4231.html strvalue = "Hi There"; keyvalue = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; accum |= HMACTest(strvalue, keyvalue, kCCDigestSHA224, "896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22"); accum |= HMACTest(strvalue, keyvalue, kCCDigestSHA256, "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"); accum |= HMACTest(strvalue, keyvalue, kCCDigestSHA384, "afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"); accum |= HMACTest(strvalue, keyvalue, kCCDigestSHA512, "87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"); // Test Vector from http://www.faqs.org/rfcs/rfc2104.html keyvalue = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; accum |= HMACTest(strvalue, keyvalue, kCCDigestMD5, "9294727a3638bb1c13f48ef8158bfc9d"); #if (CCKEYDERIVATION == 1) // Test Case PBKDF2 - HMACSHA1 http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-00 accum |= PBKDF2Test("password", (uint8_t *) "salt", 4, 1, kCCDigestSHA1, 20, "0c60c80f961f0e71f3a9b524af6012062fe037a6"); accum |= PBKDF2Test("password", (uint8_t *) "salt", 4, 2, kCCDigestSHA1, 20, "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"); accum |= PBKDF2Test("password", (uint8_t *) "salt", 4, 4096, kCCDigestSHA1, 20, "4b007901b765489abead49d926f721d065a429c1"); // This crashes accum |= PBKDF2Test("password", (uint8_t *) "salt", 4, 1, 0, 20, NULL); #else diag("No Key Derivation Support Testing\n"); #endif // Test from <rdar://problem/11285435> CC_SHA512_Init(),CC_SHA512_Update(),CC_SHA512_Final() gives wrong digest strvalue = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; accum |= hashTest(strvalue, kCCDigestSHA512, "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"); accum |= newHashTest(strvalue, kCCDigestSHA512, "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"); return accum; } |
Added CCRegression/CommonCrypto/CommonEC.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #include <Availability.h> #include "capabilities.h" #include "testmore.h" #include "testbyteBuffer.h" #if (CCEC == 0) entryPoint(CommonEC,"Elliptic Curve Cryptography") #else #include <CommonCrypto/CommonECCryptor.h> static int kTestTestCount = 18; int CommonEC(int argc, char *const *argv) { CCCryptorStatus retval; size_t keysize; CCECCryptorRef publicKey, privateKey; CCECCryptorRef publicKey2; // byteBuffer keydata, dekeydata; byteBuffer hash; char encryptedKey[8192]; size_t encryptedKeyLen = 8192; // char decryptedKey[8192]; // size_t decryptedKeyLen = 8192; char signature[8192]; size_t signatureLen = 8192; char importexport[8192]; size_t importexportLen = 8192; uint32_t valid; int accum = 0; int debug = 0; plan_tests(kTestTestCount); keysize = 256; retval = CCECCryptorGeneratePair(keysize, &publicKey, &privateKey); if(debug) printf("Keys Generated\n"); ok(retval == 0, "Generate an EC Key Pair"); accum |= retval; #ifdef ECDH keydata = hexStringToBytes("000102030405060708090a0b0c0d0e0f"); retval = CCECCryptorWrapKey(publicKey, keydata->bytes, keydata->len, encryptedKey, &encryptedKeyLen, kCCDigestSHA1); ok(retval == 0, "Wrap Key Data with EC Encryption - ccPKCS1Padding"); accum |= retval; retval = CCECCryptorUnwrapKey(privateKey, encryptedKey, encryptedKeyLen, decryptedKey, &decryptedKeyLen); ok(retval == 0, "Unwrap Key Data with EC Encryption - ccPKCS1Padding"); accum |= retval; dekeydata = bytesToBytes(decryptedKey, decryptedKeyLen); ok(bytesAreEqual(dekeydata, keydata), "Round Trip CCECCryptorWrapKey/CCECCryptorUnwrapKey"); accum |= retval; #endif hash = hexStringToBytes("000102030405060708090a0b0c0d0e0f"); retval = CCECCryptorSignHash(privateKey, hash->bytes, hash->len, signature, &signatureLen); ok(retval == 0, "EC Signing"); valid = 0; accum |= retval; if(debug) printf("Signing Complete\n"); retval = CCECCryptorVerifyHash(publicKey, hash->bytes, hash->len, signature, signatureLen, &valid); ok(retval == 0, "EC Verifying"); accum |= retval; ok(valid, "EC Validity"); accum |= retval; if(debug) printf("Verify Complete\n"); // Mess with the sig - see what happens signature[signatureLen-3] += 3; retval = CCECCryptorVerifyHash(publicKey, hash->bytes, hash->len, signature, signatureLen, &valid); ok(retval == 0, "EC Verifying"); accum |= retval; ok(!valid, "EC Invalid Signature"); accum |= retval; if(debug) printf("Verify2 Complete\n"); encryptedKeyLen = 8192; retval = CCECCryptorExportPublicKey(publicKey, importexport, &importexportLen); ok(retval == 0, "EC Export Public Key"); accum |= retval; retval = CCECCryptorImportPublicKey(importexport, importexportLen, &publicKey2); ok(retval == 0, "EC Import Public Key"); accum |= retval; encryptedKeyLen = 8192; retval = CCECCryptorComputeSharedSecret(privateKey, publicKey, encryptedKey, &encryptedKeyLen); ok(retval == 0, "EC Shared Secret"); accum |= retval; return accum; } #endif /* CCEC */ |
Added CCRegression/CommonCrypto/CommonHMacClone.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | /* * ccHmacClone - test CommonCrypto's clone context for HMAC. * * Written 3/30/2006 by Doug Mitchell. */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <time.h> #include <string.h> #include <CommonCrypto/CommonHMAC.h> #include "testmore.h" #include "testbyteBuffer.h" #include "capabilities.h" #if (CCHMACCLONE == 0) entryPoint(CommonHMacClone,"Common HMac Cloning") #else /* * Defaults. */ #define LOOPS_DEF 200 #define MIN_DATA_SIZE 8 #define MAX_DATA_SIZE 10000 /* bytes */ #define MIN_KEY_SIZE 1 #define MAX_KEY_SIZE 256 /* bytes */ #define LOOP_NOTIFY 20 /* * Enumerate algs our own way to allow iteration. */ typedef enum { ALG_MD5 = 1, ALG_SHA1, ALG_SHA224, ALG_SHA256, ALG_SHA384, ALG_SHA512, } HmacAlg; #define ALG_FIRST ALG_MD5 #define ALG_LAST ALG_SHA512 #define LOG_SIZE 0 #if LOG_SIZE #define logSize(s) diag(s) #else #define logSize(s) #endif /* * Given an initialized CCHmacContext, feed it some data and get the result. */ static void hmacRun( CCHmacContext *ctx, bool randomUpdates, const unsigned char *ptext, size_t ptextLen, void *dataOut) { while(ptextLen) { size_t thisMoveIn; /* input to CCryptUpdate() */ if(randomUpdates) { thisMoveIn = genRandomSize(1, ptextLen); } else { thisMoveIn = ptextLen; } logSize(("###ptext segment (1) len %lu\n", (unsigned long)thisMoveIn)); CCHmacUpdate(ctx, ptext, thisMoveIn); ptext += thisMoveIn; ptextLen -= thisMoveIn; } CCHmacFinal(ctx, dataOut); } #define MAX_HMAC_SIZE CC_SHA512_DIGEST_LENGTH static int doHMacCloneTest(const uint8_t *ptext, size_t ptextLen, CCHmacAlgorithm hmacAlg, uint32_t keySizeInBytes, bool stagedOrig, bool stagedClone, bool quiet, bool verbose) { uint8_t *keyBytes; uint8_t hmacOrig[MAX_HMAC_SIZE]; uint8_t hmacClone[MAX_HMAC_SIZE]; int rtn = 1; CCHmacContext ctxOrig; CCHmacContext ctxClone; unsigned die; /* 0..3 indicates when to clone */ unsigned loopNum = 0; size_t hmacLen; bool didClone = false; switch(hmacAlg) { case kCCHmacAlgSHA1: if(verbose) diag("hmac-sha1\n"); hmacLen = CC_SHA1_DIGEST_LENGTH; break; case kCCHmacAlgMD5: if(verbose) diag("hmac-md5\n"); hmacLen = CC_MD5_DIGEST_LENGTH; break; case kCCHmacAlgSHA224: if(verbose) diag("hmac-sha224\n"); hmacLen = CC_SHA224_DIGEST_LENGTH; break; case kCCHmacAlgSHA256: if(verbose) diag("hmac-sha256\n"); hmacLen = CC_SHA256_DIGEST_LENGTH; break; case kCCHmacAlgSHA384: if(verbose) diag("hmac-sha384\n"); hmacLen = CC_SHA384_DIGEST_LENGTH; break; case kCCHmacAlgSHA512: if(verbose) diag("hmac-sha512\n"); hmacLen = CC_SHA512_DIGEST_LENGTH; break; default: if(verbose) diag("***BRRRZAP!\n"); return 0; } /* random key */ byteBuffer keyBuffer = genRandomByteBuffer(keySizeInBytes, keySizeInBytes); keyBytes = keyBuffer->bytes; /* cook up first context */ CCHmacInit(&ctxOrig, hmacAlg, keyBytes, keySizeInBytes); /* roll the dice */ die = (unsigned) genRandomSize(0, 3); /* * In this loop we do updates to the ctxOrig up until we * clone it, then we use hmacRun to finish both of them. */ while(ptextLen) { if((die == loopNum) || !stagedOrig) { /* make the clone now */ if(verbose) { diag(" ...cloning at loop %u\n", loopNum); } ctxClone = ctxOrig; didClone = true; if(memcmp(&ctxClone, &ctxOrig, CC_HMAC_CONTEXT_SIZE * sizeof(uint32_t))) { if(verbose) diag("*** context miscompare\n"); } else { if(verbose) diag("*** context clone worked\n"); } /* do all of the clone's updates and final here */ hmacRun(&ctxClone, stagedClone, ptext, ptextLen, hmacClone); /* now do all remaining updates and final for original */ hmacRun(&ctxOrig, stagedOrig, ptext, ptextLen, hmacOrig); /* we're all done, time to check the HMAC values */ break; } /* making clone */ /* feed some data into cryptorOrig */ size_t thisMove; if(stagedOrig) { thisMove = genRandomSize(1, ptextLen); } else { thisMove = ptextLen; } logSize(("###ptext segment (2) len %lu\n", (unsigned long)thisMove)); CCHmacUpdate(&ctxOrig, ptext, thisMove); ptext += thisMove; ptextLen -= thisMove; loopNum++; } /* * It's possible to get here without cloning or doing any finals, * if we ran thru multiple updates and finished ptextLen for cryptorOrig * before we hit the cloning spot. */ if(!didClone) { if(verbose) { diag("...ctxOrig finished before we cloned; skipping test\n"); } return 1; } if(memcmp(hmacOrig, hmacClone, hmacLen)) { diag("***data miscompare\n"); rtn = 0; } else { if(verbose) diag("*** clone worked\n"); rtn = 1; } if(keyBuffer) free(keyBuffer); return rtn; } static bool isBitSet(unsigned bit, unsigned word) { if(bit > 31) { diag("We don't have that many bits\n"); return -1; } unsigned mask = 1 << bit; return (word & mask) ? true : false; } static int kTestTestCount = 1200; int CommonHMacClone(int argc, char *const *argv) { unsigned loop; uint8_t *ptext; size_t ptextLen; bool stagedOrig; bool stagedClone; const char *algStr; CCHmacAlgorithm hmacAlg; int currAlg; // ALG_xxx uint32_t keySizeInBytes; int rtn = 0; /* * User-spec'd params */ bool keySizeSpec = false; // false: use rand key size HmacAlg minAlg = ALG_FIRST; HmacAlg maxAlg = ALG_LAST; unsigned loops = LOOPS_DEF; bool verbose = false; size_t minPtextSize = MIN_DATA_SIZE; size_t maxPtextSize = MAX_DATA_SIZE; bool quiet = true; bool stagedSpec = false; // true means caller fixed stagedOrig and stagedClone /* ptext length set in test loop */ plan_tests(kTestTestCount); for(currAlg=minAlg; currAlg<=maxAlg; currAlg++) { /* when zero, set size randomly or per user setting */ switch(currAlg) { case ALG_MD5: hmacAlg = kCCHmacAlgMD5; algStr = "HMACMD5"; break; case ALG_SHA1: hmacAlg = kCCHmacAlgSHA1; algStr = "HMACSHA1"; break; case ALG_SHA224: hmacAlg = kCCHmacAlgSHA224; algStr = "HMACSHA224"; break; case ALG_SHA256: hmacAlg = kCCHmacAlgSHA256; algStr = "HMACSHA256"; break; case ALG_SHA384: hmacAlg = kCCHmacAlgSHA384; algStr = "HMACSHA384"; break; case ALG_SHA512: hmacAlg = kCCHmacAlgSHA512; algStr = "HMACSHA512"; break; default: diag("***BRRZAP!\n"); return -1; } if(verbose) { diag("Testing alg %s\n", algStr); } for(loop=0; loop < loops; loop++) { byteBuffer bb = genRandomByteBuffer(minPtextSize, maxPtextSize); ptextLen = bb->len; ptext = bb->bytes; if(!keySizeSpec) { keySizeInBytes = (uint32_t)genRandomSize(MIN_KEY_SIZE, MAX_KEY_SIZE); } /* per-loop settings */ if(!stagedSpec) { stagedOrig = isBitSet(1, loop); stagedClone = isBitSet(2, loop); } if(!quiet) { if(verbose || ((loop % LOOP_NOTIFY) == 0)) { diag("..loop %d ptextLen %4lu keySize %3lu stagedOrig=%d " "stagedClone=%d\n", loop, (unsigned long)ptextLen, (unsigned long)keySizeInBytes, (int)stagedOrig, (int)stagedClone); } } ok(doHMacCloneTest(ptext, ptextLen, hmacAlg, keySizeInBytes, stagedOrig, stagedClone, quiet, verbose), "HMacClone Test"); if(loops && (loop == loops)) { break; } free(bb); } /* main loop */ } /* for algs */ testDone: if((rtn != 0) && verbose) { diag("%s test complete\n", argv[0]); } return rtn; } #endif |
Added CCRegression/CommonCrypto/CommonRSA.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | #include "testbyteBuffer.h" #include "testmore.h" #include "capabilities.h" #if (CCRSA == 0) entryPoint(CommonRSA,"RSA Cryptography") #else #include <CommonCrypto/CommonRSACryptor.h> static int kTestTestCount = 18; static bool RSAVerifyTest(byteBuffer modulus, byteBuffer exponent, byteBuffer message, byteBuffer signature, CCDigestAlgorithm digestSelector, int verbose, CCAsymetricPadding padding) { CCRSACryptorRef CAVPubKey; CCCryptorStatus retval; byteBuffer digestValue = mallocByteBuffer(1024); byteBuffer decodedSignature = mallocByteBuffer(1024); retval = CCRSACryptorCreateFromData(ccRSAKeyPublic, modulus->bytes, modulus->len, exponent->bytes, exponent->len, NULL, 0, NULL, 0, &CAVPubKey); ok(retval == 0, "Build a CAVS test public key using CCRSACryptorCreateFromData"); CCDigest(digestSelector, message->bytes, message->len, digestValue->bytes); digestValue->len = CCDigestGetOutputSize(digestSelector); if(verbose) { retval = CCRSACryptorCrypt(CAVPubKey, signature->bytes, 128, decodedSignature->bytes, &decodedSignature->len); printf("retval = %d\n", retval); printf("Decoded Signature %s\n", bytesToHexString(decodedSignature)); printf("Digest of message %s\n\n\n", bytesToHexString(digestValue)); } // ccOAEPPadding ccPKCS1Padding ccX931Padding retval = CCRSACryptorVerify(CAVPubKey, padding, digestValue->bytes, digestValue->len, digestSelector, 0, signature->bytes, signature->len); printf("CCRSACryptorVerify returned %d\n", retval); free(digestValue); free(decodedSignature); return retval == kCCSuccess; } static void RSAX931BuildTest(uint32_t e, char *xp1str, char *xp2str, char *xpstr, char *xq1str, char *xq2str, char *xqstr, char *pstr, char *qstr, char *mstr, char *dstr, CCRSACryptorRef *retpublicKey, CCRSACryptorRef *retprivateKey) { byteBuffer xp1, xp2, xp, xq1, xq2, xq, p, q, m, d; int verbose = 1; CCRSACryptorRef publicKey, privateKey; xp1 = hexStringToBytes(xp1str); xp2 = hexStringToBytes(xp2str); xp = hexStringToBytes(xpstr); xq1 = hexStringToBytes(xq1str); xq2 = hexStringToBytes(xq2str); xq = hexStringToBytes(xqstr); p = hexStringToBytes(pstr); q = hexStringToBytes(qstr); m = hexStringToBytes(mstr); d = hexStringToBytes(dstr); uint8_t modulus[1024], exponent[1024], pval[1024], qval[1024]; size_t modulusLength, exponentLength, pLength, qLength; modulusLength = exponentLength = pLength = qLength = 1024; CCRSACryptorCreatePairFromData(e, xp1->bytes, xp1->len, xp2->bytes, xp2->len, xp->bytes, xp->len, xq1->bytes, xq1->len, xq2->bytes, xq2->len, xq->bytes, xq->len, &publicKey, &privateKey, pval, &pLength, qval, &qLength, modulus, &modulusLength, exponent, &exponentLength); /* retval = CCRSAGetKeyComponents(privateKey, modulus, &modulusLength, exponent, &exponentLength, pval, &pLength, qval, &qLength); ok(retval == 0, "got private key components"); */ byteBuffer retP = bytesToBytes(pval, pLength); byteBuffer retQ = bytesToBytes(qval, qLength); byteBuffer retD = bytesToBytes(exponent, exponentLength); byteBuffer retM = bytesToBytes(modulus, modulusLength); if(bytesAreEqual(retP, q) && bytesAreEqual(retQ, p)) { byteBuffer tmp = p; p = q; q = tmp; printf("Swapped P and Q\n"); } ok(bytesAreEqual(retP, p), "p is built correctly"); ok(bytesAreEqual(retQ, q), "q is built correctly"); ok(bytesAreEqual(retD, d), "n is built correctly"); ok(bytesAreEqual(retM, m), "d is built correctly"); if(verbose) { if(!bytesAreEqual(retP, p)) printf("P\nreturned: %s\nexpected: %s\n\n", bytesToHexString(retP), bytesToHexString(p)); else printf("P is correct\n"); if(!bytesAreEqual(retQ, q)) printf("Q\nreturned: %s\nexpected: %s\n\n", bytesToHexString(retQ), bytesToHexString(q)); else printf("Q is correct\n"); if(!bytesAreEqual(retD, d)) printf("D\nreturned: %s\nexpected: %s\n\n", bytesToHexString(retD), bytesToHexString(d)); else printf("D is correct\n"); if(!bytesAreEqual(retM, m)) printf("M\nreturned: %s\nexpected: %s\n\n", bytesToHexString(retM), bytesToHexString(m)); else printf("M is correct\n"); } *retpublicKey = publicKey; *retprivateKey = privateKey; } int CommonRSA (int argc, char *const *argv) { CCCryptorStatus retval; size_t keysize; CCRSACryptorRef publicKey, privateKey; byteBuffer keydata, dekeydata, hash; char encryptedKey[8192]; size_t encryptedKeyLen = 8192; char decryptedKey[8192]; size_t decryptedKeyLen = 8192; char signature[8192]; size_t signatureLen = 8192; // char importexport[8192]; // size_t importexportLen = 8192; char inputpadded[128], outputpadded[128]; int accum = 0; int debug = 0; // int verbose = 1; plan_tests(kTestTestCount); keysize = 1024; if(debug) printf("Keygen\n"); retval = CCRSACryptorGeneratePair(keysize, 65537, &publicKey, &privateKey); ok(retval == 0, "Generate an RSA Key Pair"); accum += retval; if(debug) printf("Encrypt/Decrypt\n"); keydata = hexStringToBytes("000102030405060708090a0b0c0d0e0f"); retval = CCRSACryptorEncrypt(publicKey, ccPKCS1Padding, keydata->bytes, keydata->len, encryptedKey, &encryptedKeyLen, "murf", 4, kCCDigestSHA1); ok(retval == 0, "Wrap Key Data with RSA Encryption - ccPKCS1Padding"); accum += retval; retval = CCRSACryptorDecrypt(privateKey, ccPKCS1Padding, encryptedKey, encryptedKeyLen, decryptedKey, &decryptedKeyLen,"murf", 4, kCCDigestSHA1); ok(retval == 0, "Unwrap Key Data with RSA Encryption - ccPKCS1Padding"); accum += retval; dekeydata = bytesToBytes(decryptedKey, decryptedKeyLen); ok(bytesAreEqual(dekeydata, keydata), "Round Trip ccPKCS1Padding"); accum += !bytesAreEqual(dekeydata, keydata); if(debug) printf("Encrypt/Decrypt 2\n"); encryptedKeyLen = 8192; decryptedKeyLen = 8192; retval = CCRSACryptorEncrypt(publicKey, ccOAEPPadding, keydata->bytes, keydata->len, encryptedKey, &encryptedKeyLen, "murf", 4, kCCDigestSHA1); ok(retval == 0, "Wrap Key Data with RSA Encryption - ccOAEPPadding"); accum += retval; retval = CCRSACryptorDecrypt(privateKey, ccOAEPPadding, encryptedKey, encryptedKeyLen, decryptedKey, &decryptedKeyLen,"murf", 4, kCCDigestSHA1); ok(retval == 0, "Unwrap Key Data with RSA Encryption - ccOAEPPadding"); accum += retval; dekeydata = bytesToBytes(decryptedKey, decryptedKeyLen); ok(bytesAreEqual(dekeydata, keydata), "Round Trip ccOAEPPadding"); if(debug) printf("Sign/Verify\n"); hash = hexStringToBytes("000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"); retval = CCRSACryptorSign(privateKey, ccPKCS1Padding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA256), kCCDigestSHA256, 16, signature, &signatureLen); ok(retval == 0, "RSA Signing"); accum += retval; retval = CCRSACryptorVerify(publicKey, ccPKCS1Padding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA256), kCCDigestSHA256, 16, signature, signatureLen); ok(retval == 0, "RSA Verifying"); accum += retval; signatureLen = 8192; retval = CCRSACryptorSign(privateKey, ccOAEPPadding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA1), kCCDigestSHA1, 16, signature, &signatureLen); ok(retval == 0, "RSA Signing OAEP"); accum += retval; retval = CCRSACryptorVerify(publicKey, ccOAEPPadding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA1), kCCDigestSHA1, 16, signature, signatureLen); ok(retval == 0, "RSA Verifying OAEP"); accum += retval; #ifdef NEVER memset(signature, 5, 8192); retval = CCRSACryptorSign(privateKey, ccX931Padding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA1), kCCDigestSHA1, 16, signature, &signatureLen); //diag("Signature retval = %d\n", retval); ok(retval == 0, "RSA Signing"); accum += retval; retval = CCRSACryptorVerify(publicKey, ccX931Padding, hash->bytes, CCDigestGetOutputSize(kCCDigestSHA1), kCCDigestSHA1, 16, signature, signatureLen); ok(retval == 0, "RSA Verifying"); accum += retval; retval = CCRSACryptorExport(publicKey, importexport, &importexportLen); ok(retval == 0, "RSA Export Public Key"); accum += retval; retval = CCRSACryptorImport(importexport, importexportLen, &publicKey2); ok(retval == 0, "RSA Import Public Key"); accum += retval; importexportLen = 8192; retval = CCRSACryptorExport(privateKey, importexport, &importexportLen); ok(retval == 0, "RSA Export Private Key"); accum += retval; retval = CCRSACryptorImport(importexport, importexportLen, &privateKey2); ok(retval == 0, "RSA Import Private Key"); accum += retval; #endif if(debug) printf("Starting to build key from data\n"); uint32_t e = 3; char *xp1, *xp2, *xp, *xq1, *xq2, *xq, *p, *q, *m, *d; xp1 = "1eaa9ade4a0da46dd40824d814"; xp2 = "17379044dc2c6105423da807f8"; xp = "fd3f368d01a95944bc1578f8ae58a9b6c17f529da1599a8bcd361df6efede4176924944e30cbe5c2ddea5648019d2086b95c68588380b8725003b047db88f92a"; xq1 = "1da08feb13d9fba526190d3756"; xq2 = "10d93d84466d213a3e776c61f6"; xq = "f67b5f051126a8956171561b62f572090cde4b09b13f73ee28a90bea2bfb4001fe7b16bd51266524684520e77941dddc56b892ae4bd09dd44acc08bf45dd0a58"; p = "fd3f368d01a95944bc1578f8ae58a9b6c17f529da1599a8bcd361df6efede4176924944e30d114d4c767d573d1149e005267e6fe36c51d86968cf6f65afcb973"; q = "f67b5f051126a8956171561b62f572090cde4b09b13f73ee28a90bea2bfb4001fe7b16bd5129f06dc6e1f8b4f739c7eb1eb8dcacca3b41cd484fc0c693367037"; m = "f3d4c9ca2dca5d4b893919ae7bee0d174d1e7bd2190287f79a7db6f21366108e8b0aa37cc972989ff3730d629620076555884da0e895d4e426449c60e36fad1d0208dd4ade1c45fc90da5e76c9c89fd95d13ce76a97530ee83ea3cfbe96cf28f85c4756797cd0123683194b7b2fcd185c3ea984cb0ef90580f95d57a44b027b5"; d = "28a376f707a1ba3741898447bf525783e22fbf4daed5c153ef14f3d3033bad6d172c7094cc3dc41aa8932ce5c3b0013b8e4162457c18f8d0b10b6f657b3d478482626149773760b0688ded3b1ebf16044273b2cd3924b068c2572dd9cceb4d13afb0cc64ae4da9facefbf66d271d11ef0dcc4e1af2a7dd80b2c984f4e3bf7fad"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); e = 0x010001; xp1 = "155e67ddb99eefb13e4b77a7f0"; xp2 = "17044df236c14e8ec333e92506"; xp = "d4f2b30f4f062ad2d05fc742e91bc20ca3ee8a2d126aff592c7de19edb3b884550ddd6f99b0a6b2b785617b46c0995bc112176dbae9a5b7f0bec678e84d6f44c"; p = "d4f2b30f4f062ad2d05fc742e91bc20ca3ee8a2d126aff592c7de19edb3b884550ddd6f99b13e5dd56ffb2ac1867030f385597e712f65ac8dd1de502857c1a41"; xq1 = "1e2923b103c935e3788ebd10e4"; xq2 = "11a2ccec655a8b362b5ec5fcc4"; xq = "f7c6a68cff2467f300b82591e5123b1d1256546d999a37f4b18fe4896464df6987e7cc80efee3ce4e2f5c7a3cc085bbe33e4d375ed59cbc591f2b3302bd823bc"; q = "f7c6a68cff2467f300b82591e5123b1d1256546d999a37f4b18fe4896464df6987e7cc80efeeb4c59165f7d1aec9be2b34889dbe221147e7ceefb5c9bd5cb945"; m = "ce1b6904ec27f4a8f420414860704f4797a202ed16a9a35f63a16511a31675ccb046b02b192ef121b328385922f5faa032113332d42f84c70d4323133e216b0f339ebaf672f6214d0d7c13bea301174485ec44f44fae0e8a7f8d3c81ced5df77723331816158c3added7dc55f1436a7e5f14730be22cf3bebab1b62915c80c85"; d = "18d16522721b5793169e61ae08eacd291641ac6f8718933313c8a5e66b487393dbb00f5b89334556e4ff5555aa678b2fca07972e2a2db4a3d15d81b639f7852ffe71657918d0280ff1be2f8f5d90b3e68195ab35e5069a3053540958bc6d58489fecf8baab0981f4af7b4db43550bcf01114e5ecdcb18f228db1c617b5d09781"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); #ifdef NEVER e = 3; xp1 = "1c36bd0874761109bb0575ee16"; xp2 = "1777c33935db08546dd66b6d96"; xp = "d040fa5fe5e32eab84bac6cab4c512dae938cbbe4a29f972b78b149b0b5f6a639e29c0830fa13ca140ac83dda18a1ea7b25122d3c39a10effe7afad4a8b4e77ba42c7912399fcd4f1592a3059188bff536788fe6807e0df8e3d1e7350cf5dd69"; p = "d040fa5fe5e32eab84bac6cab4c512dae938cbbe4a29f972b78b149b0b5f6a639e29c0830fa13ca140ac83dda18a1ea7b25122d3c39a10effe7afad4a8b4e77ba42c791239acf889977037a0efe181d54b93279b7e46a2fdcf674039fb11e89b"; xq1 = "14c70e475b12870bc6efd3b944"; xq2 = "1432548a4959eed65b858cd316"; xq = "e4d222daf062a01a3a9ddfc82a229613403b772ff05fa9fab1fc77de51744af98b65d47bdb2e8f5091af66002550b1d3ca446738450f8f670045f8465a952a8942079c1e048228c86291bb0ae7665146782021262c49143b5ea37ce400240372"; q = "e4d222daf062a01a3a9ddfc82a229613403b772ff05fa9fab1fc77de51744af98b65d47bdb2e8f5091af66002550b1d3ca446738450f8f670045f8465a952a8942079c1e04937b7eb94b8d322faefd691b6fa2b0ef4a2333ed791afe8ac3ac41"; m = "ba24d0a5878c01f6ad9140b6271b42309887a6815d5ef1bc3415a381b7b511a42b8d2b8d9df59faa0b69456ff908e24b4ccb835420404ce449c9ce4ca65dc4ae4eb6bb8403b809d530ef4b37e5b211c13a03e2a69afb8c748b90c97d52023ae9a24c1f1f4b3b87685eaa649f54e41b6439e29700543f0747f09658ed392f96ee568a50ad7b5441c88ad37c581526ff296b1c6cc87e352d4f921960b6b630f8f546f1077a7586b839ee07717de84e0a19cd52eceb358ff2c69387b13a83e5335b"; d = "1f0622c641420053c7983573b12f35b2c4169bc03a3a7d9f5e039b404948d846074231ecefa8eff1ac918b92a9817b0c8ccc95e35ab562260c4c4d0cc664f61d0d1e7496009eac4e32d28c8950f302f589ab507119d49768c1ed76ea3855b47bfcded5a6137e49706fe2f50213aa1313ad67b8adaef390a46bd7ccbdfa0f5042dcd4749d181613a3c9694314626207c7a7c125ca139742296de412449dd1267d6574d30c5e8bb60844e1f21c76ca41cf3bb805c521553218ce71390055029a6b"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); e = 3; xp1 = "1408766e2cb2d47ebfee7ea614"; xp2 = "16292b77507cffd2f798b7c9f2"; xp = "f74435451a7ddaa163c8c8ad03dfde97fe066360dfee52e3a9d8f41310fdb484e92e302de0b88c6c698a0b4af99ae001758441bbeb74be9d8047d104a9edb60e9e127c5d0cfd5d170ab84b314f71cbeea22006a2916a1dbc66c5be0357def520fd38445d0815f5ac3099afeb6f2d48666d22da9e3c961949459ce399829719c1"; p = "f74435451a7ddaa163c8c8ad03dfde97fe066360dfee52e3a9d8f41310fdb484e92e302de0b88c6c698a0b4af99ae001758441bbeb74be9d8047d104a9edb60e9e127c5d0cfd5d170ab84b314f71cbeea22006a2916a1dbc66c5be0357def520fd38445d081fbe68dd24e14f0711cc0351fec8641d8ea7d22c4709f233e6349b"; xq1 = "161d77eb77c6f257d8f8a3b0ca"; xq2 = "152f11dfc70b78f0fc6c9137b8"; xq = "c4d3feeb0e561be3727fd83dedaeaaecba01c798e917dd8bb11a03ce07fcf08f6f006ac6137d021912dffffc1aee981c395366fef05718e38aef69f0abf64f8b2cb9750826b8ec854dab1e1280c403169e3497ee9af08bd6d2b53a0d9c49e034220506f7719041f0cced1cc846b853a090ac42af0f699c2c3174606e02800952"; q = "c4d3feeb0e561be3727fd83dedaeaaecba01c798e917dd8bb11a03ce07fcf08f6f006ac6137d021912dffffc1aee981c395366fef05718e38aef69f0abf64f8b2cb9750826b8ec854dab1e1280c403169e3497ee9af08bd6d2b53a0d9c49e034220506f771942204f0890fb5e617c580aa98a7482b5457215badc119f23b21c3"; m = "be1cfc39868d8e9a8239f504482be60c01071cbdab4355b03c10edafe85d9ca10689d86036b6d35829a364a8a2b69f28743e50e5e27ac6b6fe8962809e1c2e0765b2d7508d61bfa538085dfb685595c6965bc5e0855a6dd8807a83e2ee7fc50b5b48f2d232195b672f2c325eb6649dee9758ce76f690107f3b0d10afef427777fb0bac0a41e23717fc54d9194a344d1823bdc18fa364e5373da39a3e41bcc4d88a688a711b56c6387b669d37c4fd7878559b93473869ae8190c46605f03cf25038bf771246fb81a27bc9d44ba67bfce94a3051856511661dbe0803d220809695ad707022c4acd24d40e011eb3752e39568f66cdd2d90369a67295e19dadb0d11"; d = "1faf7f5eebc2426f15b45380b6b1fbacaad684ca4735e39d5f58279d5164ef702bc1a410091e788eb19b3b717073c53168b50d7ba5bf211e7fc1906ac504b25690f323e2c23af546340164ff3c0e43a1190f4ba56b8f124ec0146b507d154b81e48c28785daee49132875dba73bb6fa7c3e42269291802bfdf2cd81d528b13e90a7de94f042d0ac33102095d0ec64b433c9e43c3a4651e215072c5ba3175aff6085efd3f868589487fd4c2fd72be000f1bcb51c20f6fa3d56b97872d6f0ed21e67a896478336340105e6672bf90bb250ac4f487e0973ca17161781f58763f58ac25ddb77b7297da53dddb02661b18dad920fd4dd7b7233f125336dd79e1ef3c9"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); e = 3; xp1 = "164511563871556a9babc022c8"; xp2 = "1ae2a7a04f23efe080f48a24b0"; xp = "db5c4ccf412b17041b6e20b7e0cb45d807ef4da8282428e05e26782fef3251ea2f613d00a134842c6070aa6ebd2c38bb2a28c0f457601b159ae1f5af94dc8c9812f9b4e031ed1f08c64fdb6ffca71c0d3fc93c63596100b2dbce1d6cbf34fae84bccb859397f700114b4bba2e56678360f79c9df784e5f21e995f84fb8622543a48351520012ff80144653efc08ed49e62e17050fa4fc1c98cdd8e40c68f9512e3c687b4cfcc55eb8caeaa3fd44ab8ad00a8389c288eac128c4ee82832e3d0bb"; p = "db5c4ccf412b17041b6e20b7e0cb45d807ef4da8282428e05e26782fef3251ea2f613d00a134842c6070aa6ebd2c38bb2a28c0f457601b159ae1f5af94dc8c9812f9b4e031ed1f08c64fdb6ffca71c0d3fc93c63596100b2dbce1d6cbf34fae84bccb859397f700114b4bba2e56678360f79c9df784e5f21e995f84fb8622543a48351520012ff80144653efc08ed49e62e17050fa4fc1c98cdd8e40c68f9512e3c687b4d000a836a83d21ea810c683a30e79e5fc8626e78961f076aef2f89ab"; xq1 = "18ab1ad30607288890b387858a"; xq2 = "19975a38d9368fa99deda7e986"; xq = "bd7cc6c56616fb5b41f35d8de2a5c61d1894895dfa46aa95c2de4ea5dfe370eb4543d6670898431d29a9efbbb034347cfaeb8a4c55bcb52dca553dd93ae81fa9ad2bc2b5e6a42c3d3b237648a3907d8a11e6db8b008016064f94168f50fddd791c3d72f729c21e811e68db7ae5400a0f02906462241a33e8faa1c20f48aa12253a80ce75f87a81b37a80079a9ecc42d378ee0e19e913769b738628a14b772673b0fcbf777c55be99f974e1eff5bd8c9d190abff776f246e6614b2f8d81ed812c"; q = "bd7cc6c56616fb5b41f35d8de2a5c61d1894895dfa46aa95c2de4ea5dfe370eb4543d6670898431d29a9efbbb034347cfaeb8a4c55bcb52dca553dd93ae81fa9ad2bc2b5e6a42c3d3b237648a3907d8a11e6db8b008016064f94168f50fddd791c3d72f729c21e811e68db7ae5400a0f02906462241a33e8faa1c20f48aa12253a80ce75f87a81b37a80079a9ecc42d378ee0e19e913769b738628a14b772673b0fcbf777c640b3b2f869336b823710bb296f32aaba903f90af79239c3d97279"; m = "a25e0fbcc06a40ac879bba988e78b9df8f88b800077d580b615e3f2f663c9ce631eb0229ee7a4d5166122378bd055f686dd382e63c1564c96127ec191c88d1ba02fcf90f1efcfe29bdfab0fd6413dcb4027512d15c2e337f7111e7acc7679cd1b96581461466ca63af5fbfc0579d322ca02413b75a6dce25c529d6475fafbc5d07504a29039c0f567cbb9dff2938687a6e6d4633f9ae46383536060dc7efb90ff99a6e97449e8f8ad24853f70726953b3f1dc82222f8407f98250f2060777cbd05d0b2ed6abb99d86ac30974df41da16bc1e3abd610df6bcff49a2be932baeedf163911eec026dcbd5937734b47ceb48db97c27bd2a35338f90332b75374ae4404913ae82caf14bba7410c638676a544046aed0b6605562186a4ba6b3695ab25f900899bd03a8f3e68d548b4eadbd9a348a142618954b1b9d73245926d6c57e26454db887c6272280c2d0efff1b856762da7c8be77a0006da3ea589b21ee5efec36574c041d8e506af55de52083225242642cafdcdadfa9663e4424a2bb937d3"; d = "1b0fad4a2011b5721699f46ec269744fed417400013f8eac903a5fdd3bb4c4d10851d5b1a7bf0ce2e6585b3eca2b8fe6bcf895d10a0390cc3adbfcaeda16cd9f007f7ed7da7f7fb19fa9c82a3b58a4c8ab138322e4b25dea92d85147769144cd9ee6403658bbcc65f28ff54ab944ddb21ab0adf3e467a25ba0dc4e613a9d4a0f81380c5c2b44ad3914c9efaa86debc1467bce108a99d0bb408de5657a1529ed7feef126e8b6fc297230c0dfe813118df352fa15b05d40abfeeb0d7dababe94c9e77e9a8ecb3eebe9823aec87d9f8225aef4465f3dfc5db367a60cf517603a7596a1fbf9e8b08f115b73ecf81b684bfad73c093df30ebc07e434caa87c09d55ab0b674b3858afa1939ba249c7265fd747731f2384d75b5fe6b9e06bbd3110787618290fb73cd42aca08f3f2ee855e393a5e6e835aa77cafc7d329c1dde7655abeeb8d74a015f8d2d36a3bc8939864dfd60da40c63435f76ac1b411af42d5145e95d1b0798a8e8b2ee23edb188228061fa60760993399b16b0cb2246c63ec809f3"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); e = 3; xp1 = "1a02a180a22a37d3ab4d5523fe"; xp2 = "1179fc502dbe82ff9946c00392"; xp = "d94a30017127e43b0005e99016c2f4efb8e0c91e61805b52478e35fddf3918e7a3a6e68013e5be75fa246981f222f5862ae79fdc67b3f7e849343ef1d0fb13301e314f267f862d33a66bae633a813b8b91518c95bb3dca18c2b6f02c30b0777cd253329cbcf4779d8d437fdff4c60f27738658f163081d08397e1353073f8df24675588ad215e4dc3615a59d2ad9b9815aeecb9a69fa37e036f36f115e909dbb02fd8a96cad3be182947e944e3a281c3cdf1ad35d4fd62c9417dcb0b3c8beffe8e558e6bab154b78ef43117c2808af1255f7c56dadf8e4ebe384f1eca918cae473e32caf7dc2d5250f6fe5ef00f68a997968dce7fbd2066da370a75aad1f7895"; p = "d94a30017127e43b0005e99016c2f4efb8e0c91e61805b52478e35fddf3918e7a3a6e68013e5be75fa246981f222f5862ae79fdc67b3f7e849343ef1d0fb13301e314f267f862d33a66bae633a813b8b91518c95bb3dca18c2b6f02c30b0777cd253329cbcf4779d8d437fdff4c60f27738658f163081d08397e1353073f8df24675588ad215e4dc3615a59d2ad9b9815aeecb9a69fa37e036f36f115e909dbb02fd8a96cad3be182947e944e3a281c3cdf1ad35d4fd62c9417dcb0b3c8beffe8e558e6bab154b78ef43117c2808af1255f7c56dadf8e4ebe384f1eca918cae473e32caf7dd1126fd14c73ebcce310791625550d6582891713c38ac374993099"; xq1 = "1fb621dce29cbb6a66cc3bf7d6"; xq2 = "122325102c2e57c27d462e1e06"; xq = "facc7f5f089ed9267363bc23c6c7b8f73208a36f61fa8ea8084ff777bc154107068061c4b9ead9788318eab4c3bf05729a4684f845ce9700aa70811530c50440d4ac19e47a47e5e78047e912996a79bbd9416fa10c3720174ccf8f65d32de16b0dd81187f1bee5b992792105f1d0fa191681cd305f3e113617f58b2d4a54c0cfd88db075c956c137e034fa5573fa71d67a8c076ee5e952a53369db3640438ab55e515e75a81861a99303dcc9c6efc7382cec83234742ccacc7b3e9485b002565c7af8351370aae57d26b2f2b93b7e2885429ab172c516593fb5c1b2b43957b273a2c87cf1d368e88c6f65b41815bac0d1cc9e6113d1d06a1f8ebdba6a1097343"; q = "facc7f5f089ed9267363bc23c6c7b8f73208a36f61fa8ea8084ff777bc154107068061c4b9ead9788318eab4c3bf05729a4684f845ce9700aa70811530c50440d4ac19e47a47e5e78047e912996a79bbd9416fa10c3720174ccf8f65d32de16b0dd81187f1bee5b992792105f1d0fa191681cd305f3e113617f58b2d4a54c0cfd88db075c956c137e034fa5573fa71d67a8c076ee5e952a53369db3640438ab55e515e75a81861a99303dcc9c6efc7382cec83234742ccacc7b3e9485b002565c7af8351370aae57d26b2f2b93b7e2885429ab172c516593fb5c1b2b43957b273a2c87cf1d710fc707b5e6d58b6f3cb377b286466c4da41f592c749ebf97fca3"; m = "d4e0061c2150cdf177232b89266af9153902cbd434a39cab549d997ed6dadcb4e84bbac6d49658428728a01bd7036bab4b0003f7e6ccf69df1effad985185c4ab0756237e4be92b2f42085d4388a29f461af98649c700d6dad5e0fe352513b578b3bff5f19b144e6304defe1b4fb43b37ecb4ed7c0e97377802d9e79c6d742837b3b71fd101fcf5ead4a114d9419af008a421d8a4c5efd4e6da8cc3c967502bd4cc1bda09e87bf7a1d0badaf0783a6dbef5c98359c59d6bda1cc9bacfaa962c841ddfa3670211e38a68998508ea1a2be519718a168d09cc0d2c1d0f8d56ca1d7199b0c4fc78ddb595f6681e5b1b96309251c0714bf134d46f58419a0273bfaab3328b59d75d8ada5e6e2745e816d17ded27b52f0b5632088ee6bf9675793adc52591abc3eacbf3ae4b59871ac9c94e98708801f534ad0a99791827e91cbacf7afbbd72e162698aeba0380f74462b8dd097fb576a99d70ad2117efee8f6ef51d6afd6fb8ce9b6c234ebf00d24d44ad505305e48af1a8037fed9a2a44235980d395bf69489309d37a04b66f236d223b1af759232ecf9d6556a71cd74c4936fc6d3efe6efb3311eea1574e0cebd657a9d36142f0719b95c98900bd32b9cdb6702ff92a7eefc5ec99c6f12709cb3a118cdaf56284dd195e0633dd689889924c42d3e6579e403bb3ecb08310128c673de301c3bea248f3bd0f63cab3f2545da9f8d6b"; d = "237aabaf5ae2ccfd93db31ec3111d42e342b21f8b3709a1c8e1a443fce79cf737c0c9f21236e640b1686c559f92b3c9c8c8000a95122291a52fd5479962eba0c72be3b0950ca6dc87e056ba35ec1b1a8baf299661a12ace79ce502a5e30d89e3ec89ffe52ef2e0d1080cfd5048d48b489521e2794ad1933e955cefbef67935c09489e854d8054d3a723702e243599d2ac1b5af970cba7f8d1246ccb4c3be2b1f8ccaf4f01a6bf53f04d7479d2beb4679fd3a195e44b9a3ca45a219f229c6e5cc0afa545e680585097116eeb817c59b1fb843d9703c22c4cacdcaf82978e7704e8444820d4becf9e43a9115a648499081862f5683752de2367e40aef00689ff1c3a83010a2a02fd60bde977c71b5066fea69851107da6b3c26fc24ca84a0b8df91491bb3fda29e49ff7af5dd0adfbe3454739a4dac131bf48163de6a5af29c957017aac4e66c493f81440beaa685ff96c323c0f334dbb057055a96a8e7dd8297d229c9e915f2b3b7a4cb33cb5279df74b710e5b178eb456f56c07d64afb55f513df7dec96c388184208da0db6088d410e9aae8ffb46fdcc7b813d5c6a28c49a65ed1956711fb321b89ec38172747c0e09aee2ce756f84bc2f00703e8c35f9d2448a1b24dfea1c45c50d75ba01fb8eb4ae1cabcf8cc9ee5974fe9c14958958fbddc93c5d40daaa1c22e3ffcd00d9eca5d29d030c3491aacc2bb50d30fb4667bab3"; RSAX931BuildTest(e, xp1, xp2, xp, xq1, xq2, xq, p, q, m, d, &publicKey, &privateKey); #endif bzero(inputpadded, 128); bzero(outputpadded, 128); bcopy(keydata->bytes, inputpadded, keydata->len); decryptedKeyLen = 128; retval = CCRSACryptorCrypt(privateKey, inputpadded, 128, encryptedKey, &encryptedKeyLen); ok(retval == 0, "RSA Raw Private Key Crypt"); accum += retval; retval = CCRSACryptorCrypt(publicKey, encryptedKey, encryptedKeyLen, outputpadded, &decryptedKeyLen); ok(retval == 0, "RSA Raw Private Key Crypt"); accum += retval; bcopy(outputpadded, decryptedKey, keydata->len); dekeydata = bytesToBytes(decryptedKey, keydata->len); ok(bytesAreEqual(dekeydata, keydata), "RSA Raw Encrypt/Decrypt Round-Trip"); if(!bytesAreEqual(dekeydata, keydata)) { diag("expected: %s\n", bytesToHexString(keydata)); diag(" got: %s\n", bytesToHexString(dekeydata)); diag("len = %d\n", (int) decryptedKeyLen); } static const uint8_t kAirTunesRSAPublicKey[] = { 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xE7, 0xD7, 0x44, 0xF2, 0xA2, 0xE2, 0x78, 0x8B, 0x6C, 0x1F, 0x55, 0xA0, 0x8E, 0xB7, 0x05, 0x44, 0xA8, 0xFA, 0x79, 0x45, 0xAA, 0x8B, 0xE6, 0xC6, 0x2C, 0xE5, 0xF5, 0x1C, 0xBD, 0xD4, 0xDC, 0x68, 0x42, 0xFE, 0x3D, 0x10, 0x83, 0xDD, 0x2E, 0xDE, 0xC1, 0xBF, 0xD4, 0x25, 0x2D, 0xC0, 0x2E, 0x6F, 0x39, 0x8B, 0xDF, 0x0E, 0x61, 0x48, 0xEA, 0x84, 0x85, 0x5E, 0x2E, 0x44, 0x2D, 0xA6, 0xD6, 0x26, 0x64, 0xF6, 0x74, 0xA1, 0xF3, 0x04, 0x92, 0x9A, 0xDE, 0x4F, 0x68, 0x93, 0xEF, 0x2D, 0xF6, 0xE7, 0x11, 0xA8, 0xC7, 0x7A, 0x0D, 0x91, 0xC9, 0xD9, 0x80, 0x82, 0x2E, 0x50, 0xD1, 0x29, 0x22, 0xAF, 0xEA, 0x40, 0xEA, 0x9F, 0x0E, 0x14, 0xC0, 0xF7, 0x69, 0x38, 0xC5, 0xF3, 0x88, 0x2F, 0xC0, 0x32, 0x3D, 0xD9, 0xFE, 0x55, 0x15, 0x5F, 0x51, 0xBB, 0x59, 0x21, 0xC2, 0x01, 0x62, 0x9F, 0xD7, 0x33, 0x52, 0xD5, 0xE2, 0xEF, 0xAA, 0xBF, 0x9B, 0xA0, 0x48, 0xD7, 0xB8, 0x13, 0xA2, 0xB6, 0x76, 0x7F, 0x6C, 0x3C, 0xCF, 0x1E, 0xB4, 0xCE, 0x67, 0x3D, 0x03, 0x7B, 0x0D, 0x2E, 0xA3, 0x0C, 0x5F, 0xFF, 0xEB, 0x06, 0xF8, 0xD0, 0x8A, 0xDD, 0xE4, 0x09, 0x57, 0x1A, 0x9C, 0x68, 0x9F, 0xEF, 0x10, 0x72, 0x88, 0x55, 0xDD, 0x8C, 0xFB, 0x9A, 0x8B, 0xEF, 0x5C, 0x89, 0x43, 0xEF, 0x3B, 0x5F, 0xAA, 0x15, 0xDD, 0xE6, 0x98, 0xBE, 0xDD, 0xF3, 0x59, 0x96, 0x03, 0xEB, 0x3E, 0x6F, 0x61, 0x37, 0x2B, 0xB6, 0x28, 0xF6, 0x55, 0x9F, 0x59, 0x9A, 0x78, 0xBF, 0x50, 0x06, 0x87, 0xAA, 0x7F, 0x49, 0x76, 0xC0, 0x56, 0x2D, 0x41, 0x29, 0x56, 0xF8, 0x98, 0x9E, 0x18, 0xA6, 0x35, 0x5B, 0xD8, 0x15, 0x97, 0x82, 0x5E, 0x0F, 0xC8, 0x75, 0x34, 0x3E, 0xC7, 0x82, 0x11, 0x76, 0x25, 0xCD, 0xBF, 0x98, 0x44, 0x7B, 0x02, 0x03, 0x01, 0x00, 0x01, 0xD4, 0x9D }; CCRSACryptorRef key; retval = CCRSACryptorImport( kAirTunesRSAPublicKey, sizeof( kAirTunesRSAPublicKey ), &key ); ok(retval == kCCSuccess, "Imported Airport Key"); accum += retval; return accum != 0; } #endif /* CCRSA */ |
Added CCRegression/CommonCrypto/CommonRandom.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * randomTest * CommonCrypto */ #include "testmore.h" #include "capabilities.h" #include "testbyteBuffer.h" #if (CCRANDOM == 0) entryPoint(CommonRandom,"Random Number Generation") #else #include <CommonCrypto/CommonRandomSPI.h> static const int kTestTestCount = 1000; static const int bufmax = kTestTestCount + 16; int CommonRandom(int argc, char *const *argv) { int i; uint8_t buf1[bufmax], buf2[bufmax], buf3[bufmax], buf4[bufmax], buf5[bufmax], buf6[bufmax]; CCRandomRef rngref; CCRNGStatus retval; plan_tests(kTestTestCount *3); retval = CCRNGCreate(0, &rngref); struct ccrng_state *devRandom = ccDevRandomGetRngState(); struct ccrng_state *drbg = ccDRBGGetRngState(); for(i=0; i<kTestTestCount; i++) { size_t len = i+16; CCRandomCopyBytes(kCCRandomDefault, buf1, len); CCRandomCopyBytes(kCCRandomDevRandom, buf2, len); CCRandomCopyBytes(rngref, buf3, len); CCRandomCopyBytes(NULL, buf4, len); ccrng_generate(devRandom, len, buf5); ccrng_generate(drbg, len, buf6); ok(memcmp(buf1, buf2, len), "Buffers aren't the same"); ok(memcmp(buf3, buf4, len), "Buffers aren't the same"); ok(memcmp(buf2, buf3, len), "Buffers aren't the same"); ok(memcmp(buf5, buf6, len), "Buffers aren't the same"); ok(memcmp(buf5, buf2, len), "Buffers aren't the same"); ok(memcmp(buf6, buf1, len), "Buffers aren't the same"); } retval = CCRNGRelease(rngref); return 0; } #endif |
Added CCRegression/CommonCrypto/CryptorPadFailure.c.
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 | // // CryptorPadFailure.c // CCRegressions // // Created by Richard Murphy on 5/11/11. // Copyright 2011 McKenzie-Murphy. All rights reserved. // #include <stdio.h> |
Added CCRegression/README.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | regression test suite for security components. by Michael Brouwer GOALS ===== The goals of this test setup are to have something that required 0 configuration and setup and allows developers to quickly write new standalone test cases. USAGE ===== The tests are runnable from the top level Makefile by typing: make test or individually from the command line or with gdb. Tests will be built into a directory called build by default or into LOCAL_BUILD_DIR if you set that in your environment. DIRECTORY LAYOUT ================ Currently there are subdirectories for a number of different parts of the security stack. Each directory contains some of the unit tests I've managed to find from radar and other places. The test programs output their results in a format called TAP. This is described here: http://search.cpan.org/~petdance/Test-Harness-2.46/lib/Test/Harness/TAP.pod Because of this we can use Perl's Test::Harness to run the tests and produce some nice looking output without the need to write an entire test harness. Tests can be written in C, C++ or Objective-C or perl (using Test::More in perl). WRITING TESTS ============= To add a new test simply copy one of the existing ones and hack away. Any file with a main() function in it will be built into a test automatically by the top level Makefile (no configuration required). To use the testmore C "library" all you need to do is #include "testmore.h" in your test program. Then in your main function you must call: plan_tests(NUMTESTS) where NUMTESTS is the number of test cases you test program will run. After that you can start writing tests. There are a couple of macros to help you get started: The following are ways to run an actual test case (as in they count towards the NUMTESTS number above): ok(EXPR, NAME) Evaluate EXPR if it's true the test passes if false it fails. The second argument is a descriptive name of the test for debugging purposes. is(EXPR, VALUE, NAME) Evaluate EXPR if it's equal to VALUE the test passes otherwise it fails. This is equivalent to ok(EXPR == VALUE, NAME) except this produces nicer output in a failure case. CAVEAT: Currently EXPR and VALUE must both be type int. isnt(EXPR, VALUE, NAME) Opposite of is() above. CAVEAT: Currently EXPR and VALUE must both be type int. cmp_ok(EXPR, OP, VALUE, NAME) Succeeds if EXPR OP VALUE is true. Produces a diagnostic if not. CAVEAT: Currently EXPR and VALUE must both be type int. ok_status(EXPR, NAME) Evaluate EXPR, if it's 0 the test passes otherwise print a diagnostic with the name and number of the error returned. is_status(EXPR, VALUE, NAME) Evaluate EXPR, if the error returned equals VALUE the test passes, otherwise print a diagnostic with the expected and actual error returned. ok_unix(EXPR, NAME) Evaluate EXPR, if it's >= 0 the test passes otherwise print a diagnostic with the name and number of the errno. is_unix(EXPR, VALUE, NAME) Evaluate EXPR, if the errno set by it equals VALUE the test passes, otherwise print a diagnostic with the expected and actual errno. Finally if you somehow can't express the success or failure of a test using the macros above you can use pass(NAME) or fail(NAME) explicitly. These are equivalent to ok(1, NAME) and ok(0, NAME) respectively. LEAKS ===== If you want to check for leaks in your test you can #include "testleaks.h" in your program and call: ok_leaks(NAME) Passes if there are no leaks in your program. is_leaks(VALUE, NAME) Passes if there are exactly VALUE leaks in your program. Useful if you are calling code that is known to leak and you can't fix it. But you still want to make sure there are no new leaks in your code. C++ === For C++ programs you can #include "testcpp.h" which defines these additional macros: no_throw(EXPR, NAME) Success if EXPR doesn't throw. does_throw(EXPR, NAME) Success if EXPR does throw. is_throw(EXPR, CLASS, FUNC, VALUE, NAME) Success if EXPR throws an exception of type CLASS and CLASS.FUNC == VALUE. Example usage: is_throw(CssmError::throwMe(42), CssmError, osStatus(), 42, "throwMe(42)"); TODO and SKIP ============= Sometimes you write a test case that is known to fail (because you found a bug). Rather than commenting out that test case you should put it inside a TODO block. This will cause the test to run but the failure will not be reported as an error. When the test starts passing (presumably because someone fixed the bug) you can comment out the TODO block and leave the test in place. The syntax for doing this looks like so: TODO: { todo("<rdar://problem/4000000> ER: AAPL target: $4,000,000/share"); cmp_ok(apple_stock_price(), >=, 4000000, "stock over 4M"); } Sometimes you don't want to run a particular test case or set of test cases because something in the environment is missing or you are running on a different version of the OS than the test was designed for. To achieve this you can use a SKIP block. The syntax for a SKIP block looks like so: SKIP: { skip("only runs on Tiger and later", 4, os_version() >= os_tiger); ok(tiger_test1(), "test1"); ok(tiger_test2(), "test2"); ok(tiger_test3(), "test3"); ok(tiger_test4(), "test4"); } How it works is like so: If the third argument to skip evaluates to false it breaks out of the SKIP block and reports N tests as being skipped (where N is the second argument to skip) The reason for the test being skipped is given as the first argument to skip. Utility Functions ================= Anyone writing tests can add new utility functions. Currently there is a pair called tests_begin and tests_end. To get them #include "testenv.h". Calling them doesn't count as running a test case, unless you wrap them in an ok() macro. tests_begin creates a unique dir in /tmp and sets HOME in the environment to that dir. tests_end cleans up the mess that tests_begin made. When writing your own utility functions you will probably want to use the setup("task") macro so that any uses of ok() and other macros don't count as actual test cases run, but do report errors when they fail. Here is an example of how tests_end() does this: int tests_end(int result) { setup("tests_end"); /* Restore previous cwd and remove scratch dir. */ return (ok_unix(fchdir(current_dir), "fchdir") && ok_unix(close(current_dir), "close") && ok_unix(rmdir_recursive(scratch_dir), "rmdir_recursive")); } Setup cases all tests unil the end of the current funtion to not count against your test cases test count and they output nothing if they succeed. There is also a simple utility header called "testcssm.h" which currently defines cssm_attach and cssm_detach functions for loading and initializing cssm and loading a module. |
Added CCRegression/inc/IPC/Run3.pm.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | package IPC::Run3; $VERSION = 0.010; =head1 NAME IPC::Run3 - Run a subprocess in batch mode (a la system) on Unix, Win32, etc. =head1 SYNOPSIS use IPC::Run3; ## Exports run3() by default use IPC::Run3 (); ## Don't pollute run3 \@cmd, \$in, \$out, \$err; run3 \@cmd, \@in, \&out, \$err; =head1 DESCRIPTION This module allows you to run a subprocess and redirect stdin, stdout, and/or stderr to files and perl data structures. It aims to satisfy 99% of the need for using system()/qx``/open3() with a simple, extremely Perlish API and none of the bloat and rarely used features of IPC::Run. Speed (of Perl code; which is often much slower than the kind of buffered I/O that this module uses to spool input to and output from the child command), simplicity, and portability are paramount. Disk space is not. Note that passing in \undef explicitly redirects the associated file descriptor for STDIN, STDOUT, or STDERR from or to the local equivalent of /dev/null (this does I<not> pass a closed filehandle). Passing in "undef" (or not passing a redirection) allows the child to inherit the corresponding STDIN, STDOUT, or STDERR from the parent. Because the redirects come last, this allows STDOUT and STDERR to default to the parent's by just not specifying them; a common use case. B<Note>: This means that: run3 \@cmd, undef, \$out; ## Pass on parent's STDIN B<does not close the child's STDIN>, it passes on the parent's. Use run3 \@cmd, \undef, \$out; ## Close child's STDIN for that. It's not ideal, but it does work. If the exact same value is passed for $stdout and $stderr, then the child will write both to the same filehandle. In general, this means that run3 \@cmd, \undef, "foo.txt", "foo.txt"; run3 \@cmd, \undef, \$both, \$both; will DWYM and pass a single file handle to the child for both STDOUT and STDERR, collecting all into $both. =head1 DEBUGGING To enable debugging use the IPCRUN3DEBUG environment variable to a non-zero integer value: $ IPCRUN3DEBUG=1 myapp . =head1 PROFILING To enable profiling, set IPCRUN3PROFILE to a number to enable emitting profile information to STDERR (1 to get timestamps, 2 to get a summary report at the END of the program, 3 to get mini reports after each run) or to a filename to emit raw data to a file for later analysis. =head1 COMPARISON Here's how it stacks up to existing APIs: =over =item compared to system(), qx'', open "...|", open "|...": =over =item + redirects more than one file descriptor =item + returns TRUE on success, FALSE on failure =item + throws an error if problems occur in the parent process (or the pre-exec child) =item + allows a very perlish interface to perl data structures and subroutines =item + allows 1 word invocations to avoid the shell easily: run3 ["foo"]; ## does not invoke shell =item - does not return the exit code, leaves it in $? =back =item compared to open2(), open3(): =over =item + No lengthy, error prone polling / select loop needed =item + Hides OS dependancies =item + Allows SCALAR, ARRAY, and CODE references to source and sink I/O =item + I/O parameter order is like open3() (not like open2()). =item - Does not allow interaction with the subprocess =back =item compared to IPC::Run::run(): =over =item + Smaller, lower overhead, simpler, more portable =item + No select() loop portability issues =item + Does not fall prey to Perl closure leaks =item - Does not allow interaction with the subprocess (which IPC::Run::run() allows by redirecting subroutines). =item - Lacks many features of IPC::Run::run() (filters, pipes, redirects, pty support). =back =back =cut @EXPORT = qw( run3 ); %EXPORT_TAGS = ( all => \@EXPORT ); @ISA = qw( Exporter ); use Exporter; use strict; use constant debugging => $ENV{IPCRUN3DEBUG} || $ENV{IPCRUNDEBUG} || 0; use constant profiling => $ENV{IPCRUN3PROFILE} || $ENV{IPCRUNPROFILE} || 0; use constant is_win32 => 0 <= index $^O, "Win32"; BEGIN { if ( is_win32 ) { eval "use Win32 qw( GetOSName ); 1" or die $@; } } #use constant is_win2k => is_win32 && GetOSName() =~ /Win2000/i; #use constant is_winXP => is_win32 && GetOSName() =~ /WinXP/i; use Carp qw( croak ); use File::Temp qw( tempfile ); use UNIVERSAL qw( isa ); use POSIX qw( dup dup2 ); ## We cache the handles of our temp files in order to ## keep from having to incur the (largish) overhead of File::Temp my %fh_cache; my $profiler; sub _profiler { $profiler } ## test suite access BEGIN { if ( profiling ) { eval "use Time::HiRes qw( gettimeofday ); 1" or die $@; if ( $ENV{IPCRUN3PROFILE} =~ /\A\d+\z/ ) { require IPC::Run3::ProfPP; $profiler = IPC::Run3::ProfPP->new( Level => $ENV{IPCRUN3PROFILE}, ); } else { my ( $dest, undef, $class ) = reverse split /(=)/, $ENV{IPCRUN3PROFILE}, 2; $class = "IPC::Run3::ProfLogger" unless defined $class && length $class; unless ( eval "require $class" ) { my $x = $@; $class = "IPC::Run3::$class"; eval "require IPC::Run3::$class" or die $x; } $profiler = $class->new( Destination => $dest, ); } $profiler->app_call( [ $0, @ARGV ], scalar gettimeofday() ); } } END { $profiler->app_exit( scalar gettimeofday() ) if profiling; } sub _spool_data_to_child { my ( $type, $source, $binmode_it ) = @_; ## If undef (not \undef) passed, they want the child to inherit ## the parent's STDIN. return undef unless defined $source; warn "binmode()ing STDIN\n" if is_win32 && debugging && $binmode_it; my $fh; if ( ! $type ) { local *FH; ## Do this the backcompat way open FH, "<$source" or croak "$!: $source"; $fh = *FH{IO}; if ( is_win32 ) { binmode ":raw"; ## Remove all layers binmode ":crlf" unless $binmode_it; } warn "run3(): feeding file '$source' to child STDIN\n" if debugging >= 2; } elsif ( $type eq "FH" ) { $fh = $source; warn "run3(): feeding filehandle '$source' to child STDIN\n" if debugging >= 2; } else { $fh = $fh_cache{in} ||= tempfile; truncate $fh, 0; seek $fh, 0, 0; if ( is_win32 ) { binmode $fh, ":raw"; ## Remove any previous layers binmode $fh, ":crlf" unless $binmode_it; } my $seekit; if ( $type eq "SCALAR" ) { ## When the run3()'s caller asks to feed an empty file ## to the child's stdin, we want to pass a live file ## descriptor to an empty file (like /dev/null) so that ## they don't get surprised by invalid fd errors and get ## normal EOF behaviors. return $fh unless defined $$source; ## \undef passed warn "run3(): feeding SCALAR to child STDIN", debugging >= 3 ? ( ": '", $$source, "' (", length $$source, " chars)" ) : (), "\n" if debugging >= 2; $seekit = length $$source; print $fh $$source or die "$! writing to temp file"; } elsif ( $type eq "ARRAY" ) { warn "run3(): feeding ARRAY to child STDIN", debugging >= 3 ? ( ": '", @$source, "'" ) : (), "\n" if debugging >= 2; print $fh @$source or die "$! writing to temp file"; $seekit = grep length, @$source; } elsif ( $type eq "CODE" ) { warn "run3(): feeding output of CODE ref '$source' to child STDIN\n" if debugging >= 2; my $parms = []; ## TODO: get these from $options while (1) { my $data = $source->( @$parms ); last unless defined $data; print $fh $data or die "$! writing to temp file"; $seekit = length $data; } } seek $fh, 0, 0 or croak "$! seeking on temp file for child's stdin" if $seekit; } croak "run3() can't redirect $type to child stdin" unless defined $fh; return $fh; } sub _fh_for_child_output { my ( $what, $type, $dest, $binmode_it ) = @_; my $fh; if ( $type eq "SCALAR" && $dest == \undef ) { warn "run3(): redirecting child $what to oblivion\n" if debugging >= 2; $fh = $fh_cache{nul} ||= do { local *FH; open FH, ">" . File::Spec->devnull; *FH{IO}; }; } elsif ( !$type ) { warn "run3(): feeding child $what to file '$dest'\n" if debugging >= 2; local *FH; open FH, ">$dest" or croak "$!: $dest"; $fh = *FH{IO}; } else { warn "run3(): capturing child $what\n" if debugging >= 2; $fh = $fh_cache{$what} ||= tempfile; seek $fh, 0, 0; truncate $fh, 0; } if ( is_win32 ) { warn "binmode()ing $what\n" if debugging && $binmode_it; binmode $fh, ":raw"; binmode $fh, ":crlf" unless $binmode_it; } return $fh; } sub _read_child_output_fh { my ( $what, $type, $dest, $fh, $options ) = @_; return if $type eq "SCALAR" && $dest == \undef; seek $fh, 0, 0 or croak "$! seeking on temp file for child $what"; if ( $type eq "SCALAR" ) { warn "run3(): reading child $what to SCALAR\n" if debugging >= 3; ## two read()s are used instead of 1 so that the first will be ## logged even it reads 0 bytes; the second won't. my $count = read $fh, $$dest, 10_000; while (1) { croak "$! reading child $what from temp file" unless defined $count; last unless $count; warn "run3(): read $count bytes from child $what", debugging >= 3 ? ( ": '", substr( $$dest, -$count ), "'" ) : (), "\n" if debugging >= 2; $count = read $fh, $$dest, 10_000, length $$dest; } } elsif ( $type eq "ARRAY" ) { @$dest = <$fh>; if ( debugging >= 2 ) { my $count = 0; $count += length for @$dest; warn "run3(): read ", scalar @$dest, " records, $count bytes from child $what", debugging >= 3 ? ( ": '", @$dest, "'" ) : (), "\n"; } } elsif ( $type eq "CODE" ) { warn "run3(): capturing child $what to CODE ref\n" if debugging >= 3; local $_; while ( <$fh> ) { warn "run3(): read ", length, " bytes from child $what", debugging >= 3 ? ( ": '", $_, "'" ) : (), "\n" if debugging >= 2; $dest->( $_ ); } } else { croak "run3() can't redirect child $what to a $type"; } # close $fh; } sub _type { my ( $redir ) = @_; return "FH" if isa $redir, "IO::Handle"; my $type = ref $redir; return $type eq "GLOB" ? "FH" : $type; } sub _max_fd { my $fd = dup(0); POSIX::close $fd; return $fd; } my $run_call_time; my $sys_call_time; my $sys_exit_time; sub run3 { $run_call_time = gettimeofday() if profiling; my $options = @_ && ref $_[-1] eq "HASH" ? pop : {}; my ( $cmd, $stdin, $stdout, $stderr ) = @_; print STDERR "run3(): running ", join( " ", map "'$_'", ref $cmd ? @$cmd : $cmd ), "\n" if debugging; if ( ref $cmd ) { croak "run3(): empty command" unless @$cmd; croak "run3(): undefined command" unless defined $cmd->[0]; croak "run3(): command name ('')" unless length $cmd->[0]; } else { croak "run3(): missing command" unless @_; croak "run3(): undefined command" unless defined $cmd; croak "run3(): command ('')" unless length $cmd; } my $in_type = _type $stdin; my $out_type = _type $stdout; my $err_type = _type $stderr; ## This routine procedes in stages so that a failure in an early ## stage prevents later stages from running, and thus from needing ## cleanup. my $in_fh = _spool_data_to_child $in_type, $stdin, $options->{binmode_stdin} if defined $stdin; my $out_fh = _fh_for_child_output "stdout", $out_type, $stdout, $options->{binmode_stdout} if defined $stdout; my $tie_err_to_out = defined $stderr && defined $stdout && $stderr eq $stdout; my $err_fh = $tie_err_to_out ? $out_fh : _fh_for_child_output "stderr", $err_type, $stderr, $options->{binmode_stderr} if defined $stderr; ## this should make perl close these on exceptions local *STDIN_SAVE; local *STDOUT_SAVE; local *STDERR_SAVE; my $saved_fd0 = dup( 0 ) if defined $in_fh; # open STDIN_SAVE, "<&STDIN"# or croak "run3(): $! saving STDIN" # if defined $in_fh; open STDOUT_SAVE, ">&STDOUT" or croak "run3(): $! saving STDOUT" if defined $out_fh; open STDERR_SAVE, ">&STDERR" or croak "run3(): $! saving STDERR" if defined $err_fh; my $ok = eval { ## The open() call here seems to not force fd 0 in some cases; ## I ran in to trouble when using this in VCP, not sure why. ## the dup2() seems to work. dup2( fileno $in_fh, 0 ) # open STDIN, "<&=" . fileno $in_fh or croak "run3(): $! redirecting STDIN" if defined $in_fh; # close $in_fh or croak "$! closing STDIN temp file" # if ref $stdin; open STDOUT, ">&" . fileno $out_fh or croak "run3(): $! redirecting STDOUT" if defined $out_fh; open STDERR, ">&" . fileno $err_fh or croak "run3(): $! redirecting STDERR" if defined $err_fh; $sys_call_time = gettimeofday() if profiling; my $r = ref $cmd ? system {$cmd->[0]} is_win32 ? map { ## Probably need to offer a win32 escaping ## option, every command may be different. ( my $s = $_ ) =~ s/"/"""/g; $s = qq{"$s"}; $s; } @$cmd : @$cmd : system $cmd; $sys_exit_time = gettimeofday() if profiling; unless ( defined $r ) { if ( debugging ) { my $err_fh = defined $err_fh ? \*STDERR_SAVE : \*STDERR; print $err_fh "run3(): system() error $!\n" } die $!; } if ( debugging ) { my $err_fh = defined $err_fh ? \*STDERR_SAVE : \*STDERR; print $err_fh "run3(): \$? is $?\n" } 1; }; my $x = $@; my @errs; if ( defined $saved_fd0 ) { dup2( $saved_fd0, 0 ); POSIX::close( $saved_fd0 ); } # open STDIN, "<&STDIN_SAVE"# or push @errs, "run3(): $! restoring STDIN" # if defined $in_fh; open STDOUT, ">&STDOUT_SAVE" or push @errs, "run3(): $! restoring STDOUT" if defined $out_fh; open STDERR, ">&STDERR_SAVE" or push @errs, "run3(): $! restoring STDERR" if defined $err_fh; croak join ", ", @errs if @errs; die $x unless $ok; _read_child_output_fh "stdout", $out_type, $stdout, $out_fh, $options if defined $out_fh && $out_type && $out_type ne "FH"; _read_child_output_fh "stderr", $err_type, $stderr, $err_fh, $options if defined $err_fh && $err_type && $err_type ne "FH" && !$tie_err_to_out; $profiler->run_exit( $cmd, $run_call_time, $sys_call_time, $sys_exit_time, scalar gettimeofday ) if profiling; return 1; } my $in_fh; my $in_fd; my $out_fh; my $out_fd; my $err_fh; my $err_fd; $in_fh = tempfile; $in_fd = fileno $in_fh; $out_fh = tempfile; $out_fd = fileno $out_fh; $err_fh = tempfile; $err_fd = fileno $err_fh; my $saved_fd0 = dup 0; my $saved_fd1 = dup 1; my $saved_fd2 = dup 2; my $r; my ( $cmd, $stdin, $stdout, $stderr ); sub _run3 { ( $cmd, $stdin, $stdout, $stderr ) = @_; truncate $in_fh, 0; seek $in_fh, 0, 0; print $in_fh $$stdin or die "$! writing to temp file"; seek $in_fh, 0, 0; seek $out_fh, 0, 0; truncate $out_fh, 0; seek $err_fh, 0, 0; truncate $err_fh, 0; dup2 $in_fd, 0 or croak "run3(): $! redirecting STDIN"; dup2 $out_fd, 1 or croak "run3(): $! redirecting STDOUT"; dup2 $err_fd, 2 or croak "run3(): $! redirecting STDERR"; $r = system {$cmd->[0]} is_win32 ? map { ## Probably need to offer a win32 escaping ## option, every command is different. ( my $s = $_ ) =~ s/"/"""/g; $s = q{"$s"} if /[^\w.:\/\\'-]/; $s; } @$cmd : @$cmd; die $! unless defined $r; dup2 $saved_fd0, 0; dup2 $saved_fd1, 1; dup2 $saved_fd2, 2; seek $out_fh, 0, 0 or croak "$! seeking on temp file for child output"; my $count = read $out_fh, $$stdout, 10_000; while ( $count == 10_000 ) { $count = read $out_fh, $$stdout, 10_000, length $$stdout; } croak "$! reading child output from temp file" unless defined $count; seek $err_fh, 0, 0 or croak "$! seeking on temp file for child errput"; $count = read $err_fh, $$stderr, 10_000; while ( $count == 10_000 ) { $count = read $err_fh, $$stderr, 10_000, length $$stdout; } croak "$! reading child stderr from temp file" unless defined $count; return 1; } =cut =head1 TODO pty support =head1 LIMITATIONS Often uses intermediate files (determined by File::Temp, and thus by the File::Spec defaults and the TMPDIR env. variable) for speed, portability and simplicity. =head1 COPYRIGHT Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved =head1 LICENSE You may use this module under the terms of the BSD, Artistic, or GPL licenses, any version. =head1 AUTHOR Barrie Slaymaker <barries@slaysys.com> =cut 1; |
Added CCRegression/inc/MyHarness.pm.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | use warnings; use strict; package MyStraps; use base qw( Test::Harness::Straps ); sub _command_line { my $self = shift; my $file = shift; $file = qq["$file"] if ($file =~ /\s/) && ($file !~ /^".*"$/); my $line = "$file"; return $line; } sub _default_inc { return @INC; } package MyHarness; use base qw( Test::Harness ); #my $Strap = MyStraps->new(); $Test::Harness::Strap = MyStraps->new(); sub strap { return $Test::Harness::Strap } 1; |
Added CCRegression/main.c.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | #include <stdio.h> #include "testenv.h" int main (int argc, char * const *argv) { printf("WARNING: If running those tests on a device with a passcode, DONT FORGET TO UNLOCK!!!\n"); tests_begin(argc, argv); return 0; } |
Added CCRegression/runscript/security.pl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #!/usr/bin/perl -w # # Copyright (c) 2006-2007 Apple Inc. All Rights Reserved. # my $pid = $$; END { return unless $$ == $pid; rm_test($_) for @TOCLEAN; } use strict; use Test::More; use IPC::Run3; sub plan_security { unless (1) { plan skip_all => "security not installed"; exit; }; plan @_; } use Carp; our @TOCLEAN; END { return unless $$ == $pid; $SIG{__WARN__} = sub { 1 }; cleanup_test($_) for @TOCLEAN; } our $output = ''; sub build_test { my $xd = "/tmp/test-$pid"; my $security = 'security'; $ENV{HOME} = $xd; push @TOCLEAN, [$xd, $security]; return ($xd, $security); } sub rm_test { my ($xd, $security) = @{+shift}; #rmtree [$xd]; } sub cleanup_test { return unless $ENV{TEST_VERBOSE}; my ($xd, $security) = @{+shift}; } sub is_output { my ($security, $cmd, $arg, $expected, $test) = @_; $output = ''; run3([$security, $cmd, @$arg], \undef, \$output, \$output); # open(STDOUT, ">&STDERR") || die "couldn't dup strerr: $!"; # open(my $out, '-|', $security, $cmd, @$arg); # while (<$out>) { $output .= $_; } my $cmp = (grep {ref ($_) eq 'Regexp'} @$expected) ? \&is_deeply_like : \&is_deeply; @_ = ([sort split (/\r?\n/, $output)], [sort @$expected], $test || join(' ', $cmd, @$arg)); goto &$cmp; } 1; |
Added CCRegression/test/00testtest.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved. */ #include <stdlib.h> #include "testmore.h" int main(int argc, char *const *argv) { int rv = 1; plan_tests(6); TODO: { todo("ok 0 is supposed to fail"); rv = ok(0, "ok bad"); if (!rv) diag("ok bad not good today"); } rv &= ok(1, "ok ok"); #if 0 SKIP: { skip("is bad will fail", 1, 0); if (!is(0, 4, "is bad")) diag("is bad not good today"); } SKIP: { skip("is ok should not be skipped", 1, 1); is(3, 3, "is ok"); } #endif isnt(0, 4, "isnt ok"); TODO: { todo("isnt bad is supposed to fail"); isnt(3, 3, "isnt bad"); } TODO: { todo("cmp_ok bad is supposed to fail"); cmp_ok(3, &&, 0, "cmp_ok bad"); } cmp_ok(3, &&, 3, "cmp_ok ok"); return 0; } |
Added CCRegression/test/run_tests.sh.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #!/bin/sh # run_tests.sh # Security # # Created by Fabrice Gautier on 8/26/10. # Modified for use with CommonCrypto on 3/10/11 # Copyright 2011 Apple, Inc. All rights reserved. # Run a command line tool on the sim or the device CMD=CCRegressions if [ "${PLATFORM_NAME}" == "iphoneos" ]; then INSTALL_DIR= SCP_URL=phone:${INSTALL_DIR} #copy libcommonCrypto.dylib and CCRegressions program to the device, to /tmp #this will not replace the system CommonCrypto. #it is assumed that ssh is pre-setup on the device with pubkey authentication export RSYNC_PASSWORD=alpine echo "run_tests.sh:${LINENO}: note: Copying stuff to device" # scp ${CONFIGURATION_BUILD_DIR}/libcommonCrypto.dylib ${SCP_URL} scp ${CONFIGURATION_BUILD_DIR}/CCRegressions ${SCP_URL} echo "run_tests.sh:${LINENO}: note: Running the test" xcrun -sdk "$SDKROOT" PurpleExec --env "DYLD_FRAMEWORK_PATH=${INSTALL_DIR}" --cmd ${INSTALL_DIR}/${CMD} else echo "run_tests.sh:${LINENO}: note: Running test on simulator (${BUILT_PRODUCTS_DIR}/${CMD})" export DYLD_ROOT_PATH="${SDKROOT}" export DYLD_LIBRARY_PATH="${BUILT_PRODUCTS_DIR}" export DYLD_FRAMEWORK_PATH="${BUILT_PRODUCTS_DIR}" ${BUILT_PRODUCTS_DIR}/${CMD} fi |
Added CCRegression/test/testcpp.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * * testcpp.h */ #ifndef _TESTCPP_H_ #define _TESTCPP_H_ 1 #include "testmore.h" #ifdef __cplusplus #define no_throw(THIS, TESTNAME) \ ({ \ bool _this; \ try { THIS; _this = true; } catch (...) { _this = false; } \ test_ok(_this, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: <unknown excepetion>\n" \ "# expected: <no throw>\n"); \ }) #define does_throw(THIS, TESTNAME) \ ({ \ bool _this; \ try { THIS; _this = false; } catch (...) { _this = true; } \ test_ok(_this, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: <no throw>\n" \ "# expected: <any excepetion>\n"); \ }) #define is_throw(THIS, CLASS, METHOD, VALUE, TESTNAME) \ ({ \ bool _this; \ try \ { \ THIS; \ _this = test_ok(false, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: <no throw>\n" \ "# expected: %s.%s == %s\n", \ #CLASS, #METHOD, #VALUE); \ } \ catch (const CLASS &_exception) \ { \ _this = test_ok(_exception.METHOD == (VALUE), TESTNAME, \ test_directive, test_reason, __FILE__, __LINE__, \ "# got: %d\n" \ "# expected: %s.%s == %s\n", \ _exception.METHOD, #CLASS, #METHOD, #VALUE); \ } \ catch (...) \ { \ _this = test_ok(false, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: <unknown excepetion>\n" \ "# expected: %s.%s == %s\n", \ #CLASS, #METHOD, #VALUE); \ } \ _this; \ }) #endif /* __cplusplus */ #endif /* !_TESTCPP_H_ */ |
Added CCRegression/test/testenv.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /* * Copyright (c) 2005-2007,2009-2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * * testenv.c */ #include <fcntl.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <stdbool.h> #include "testmore.h" #include "testenv.h" #if NO_SERVER #include <securityd/spi.h> static int current_dir = -1; static char scratch_dir[50]; static char *home_var; static bool keep_scratch_dir = false; static int rmdir_recursive(const char *path) { char command_buf[256]; if (strlen(path) + 10 > sizeof(command_buf) || strchr(path, '\'')) { fprintf(stderr, "# rmdir_recursive: invalid path: %s", path); return -1; } sprintf(command_buf, "rm -rf '%s'", path); return system(command_buf); } #endif static int tests_init(void) { printf("[TEST] CommonCrypto\n"); #if NO_SERVER char preferences_dir[80]; char library_dir[70]; securityd_init(); setup("tests_init"); /* Create scratch dir for tests to run in. */ sprintf(scratch_dir, "/tmp/tst-%d", getpid()); if (keep_scratch_dir) { printf("running tests with HOME=%s\n", scratch_dir); } sprintf(library_dir, "%s/Library", scratch_dir); sprintf(preferences_dir, "%s/Preferences", library_dir); return (ok_unix(mkdir(scratch_dir, 0755), "mkdir") && ok_unix(current_dir = open(".", O_RDONLY), "open") && ok_unix(chdir(scratch_dir), "chdir") && ok_unix(setenv("HOME", scratch_dir, 1), "setenv") && /* @@@ Work around a bug that the prefs code in libsecurity_keychain never creates the Library/Preferences dir. */ ok_unix(mkdir(library_dir, 0755), "mkdir") && ok_unix(mkdir(preferences_dir, 0755), "mkdir") && ok(home_var = getenv("HOME"), "getenv")); #else return 0; #endif } static int tests_end(void) { printf("[SUMMARY]\n"); #if NO_SERVER setup("tests_end"); /* Restore previous cwd and remove scratch dir. */ int ok = ok_unix(fchdir(current_dir), "fchdir"); if (ok) ok = ok_unix(close(current_dir), "close"); if (ok) { if (!keep_scratch_dir) { ok = ok_unix(rmdir_recursive(scratch_dir), "rmdir_recursive"); } } return ok; #else return 0; #endif } static void usage(const char *progname) { fprintf(stderr, "usage: %s [-k][-w][testname [testargs] ...]\n", progname); exit(1); } static int tests_run_index(int i, int argc, char * const *argv) { int verbose = 0; int ch; while ((ch = getopt(argc, argv, "v")) != -1) { switch (ch) { case 'v': verbose++; break; default: usage(argv[0]); } } fprintf(stderr, "[BEGIN] %s\n", testlist[i].name); run_one_test(&testlist[i], argc, argv); if(testlist[i].failed_tests) { fprintf(stderr, "[FAIL] %s\n", testlist[i].name); } else { fprintf(stderr, "duration: %u ms\n", testlist[i].duration); fprintf(stderr, "[PASS] %s\n", testlist[i].name); } return 0; } static int tests_named_index(const char *testcase) { int i; for (i = 0; testlist[i].name; ++i) { if (strcmp(testlist[i].name, testcase) == 0) { return i; } } return -1; } static int tests_run_all(int argc, char * const *argv) { int curroptind = optind; int i; for (i = 0; testlist[i].name; ++i) { tests_run_index(i, argc, argv); optind = curroptind; } return 0; } int tests_begin(int argc, char * const *argv) { const char *testcase = NULL; bool initialized = false; int testix = -1; int ch; for (;;) { while (!testcase && (ch = getopt(argc, argv, "kw")) != -1) { switch (ch) { #ifdef NO_SERVER case 'k': keep_scratch_dir = true; break; #endif case 'w': sleep(100); break; case '?': default: printf("invalid option %c\n",ch); usage(argv[0]); } } if (optind < argc) { testix = tests_named_index(argv[optind]); if(testix<0) { printf("invalid test %s\n",argv[optind]); usage(argv[0]); } } if (testix < 0) { if (!initialized) { initialized = true; tests_init(); tests_run_all(argc, argv); } break; } else { if (!initialized) { tests_init(); initialized = true; } optind++; tests_run_index(testix, argc, argv); testix = -1; } } /* Cleanups */ tests_end(); return 0; } |
Added CCRegression/test/testenv.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * * testenv.h */ #ifndef _TESTENV_H_ #define _TESTENV_H_ 1 #ifdef __cplusplus extern "C" { #endif int tests_begin(int argc, char * const *argv); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* !_TESTENV_H_ */ |
Added CCRegression/test/testlist.c.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* This file contains an array of all test functions, last element is NULL */ #include "testmore.h" #include "testlist.h" #define ONE_TEST(x) {#x, x, 0 , 0, 0 }, #define DISABLED_ONE_TEST(x) struct one_test_s testlist[] = { #include "testlistInc.h" { NULL, NULL, 0, 0, 0}, }; #undef ONE_TEST #undef DISABLED_ONE_TEST |
Added CCRegression/test/testlist.h.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* This file contains all the prototypes for all the test functions */ #ifndef __TESTLIST_H__ #define __TESTLIST_H__ #define ONE_TEST(x) int x(int argc, char *const *argv); #define DISABLED_ONE_TEST(x) ONE_TEST(x) #include "testlistInc.h" #undef ONE_TEST #undef DISABLED_ONE_TEST #endif /* __TESTLIST_H__ */ |
Added CCRegression/test/testlistInc.h.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* To add a test, just add it here */ ONE_TEST(CommonRandom) ONE_TEST(CommonEC) ONE_TEST(CommonRSA) ONE_TEST(CommonHMacClone) ONE_TEST(CommonCMac) ONE_TEST(CommonCryptoSymCBC) ONE_TEST(CommonCryptoSymOFB) ONE_TEST(CommonCryptoSymGCM) ONE_TEST(CommonCryptoSymCTR) ONE_TEST(CommonCryptoSymXTS) ONE_TEST(CommonCryptoSymRC2) ONE_TEST(CommonCryptoSymRegression) ONE_TEST(CommonCryptoSymOffset) ONE_TEST(CommonCryptoSymZeroLength) ONE_TEST(CommonCryptoSymCFB) ONE_TEST(CommonCryptoCTSPadding) ONE_TEST(CommonSymmetricWrap) ONE_TEST(CommonDH) ONE_TEST(CommonDigest) ONE_TEST(CommonBaseEncoding) ONE_TEST(CommonCryptoReset) ONE_TEST(CommonBigNum) ONE_TEST(CommonBigDigest) |
Added CCRegression/test/testmore.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /* * Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * * testmore.c */ #include <fcntl.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> #include <unistd.h> // #include <AvailabilityMacros.h> #include "testmore.h" static int test_num = 0; static int test_fails = 0; static int test_cases = 0; static const char *test_plan_file; static int test_plan_line=0; const char *test_directive = NULL; const char *test_reason = NULL; void test_skip(const char *reason, int how_many, int unless) { if (unless) return; int done; for (done = 0; done < how_many; ++done) test_ok(1, NULL, "skip", reason, __FILE__, __LINE__, NULL); } void test_bail_out(const char *reason, const char *file, unsigned line) { printf("BAIL OUT! (%s at line %u) %s\n", file, line, reason); fflush(stdout); exit(255); } void test_plan_skip_all(const char *reason) { if (test_num > test_cases) { test_skip(reason, test_cases - test_num, 0); exit(test_fails > 255 ? 255 : test_fails); } } static void test_plan_exit(void) { int status = 0; fflush(stdout); if (!test_num) { if (test_cases) { fprintf(stderr, "%s:%u: warning: No tests run!\n", test_plan_file, test_plan_line); status = 255; } else { fprintf(stderr, "%s:%u: error: Looks like your test died before it could " "output anything.\n", test_plan_file, test_plan_line); status = 255; } } else if (test_num < test_cases) { fprintf(stderr, "%s:%u: warning: Looks like you planned %d tests but only ran %d.\n", test_plan_file, test_plan_line, test_cases, test_num); status = test_fails + test_cases - test_num; } else if (test_num > test_cases) { fprintf(stderr, "%s:%u: warning: Looks like you planned %d tests but ran %d extra.\n", test_plan_file, test_plan_line, test_cases, test_num - test_cases); status = test_fails; } else if (test_fails) { fprintf(stderr, "%s:%u: error: Looks like you failed %d tests of %d.\n", test_plan_file, test_plan_line, test_fails, test_cases); status = test_fails; } fflush(stderr); /* reset the test plan */ test_num = 0; test_fails = 0; test_cases = 0; } void test_plan_tests(int count, const char *file, unsigned line) { #if 0 if (atexit(test_plan_exit) < 0) { fprintf(stderr, "failed to setup atexit handler: %s\n", strerror(errno)); fflush(stderr); exit(255); } #endif if (test_cases) { fprintf(stderr, "%s:%u: error: You tried to plan twice!\n", file, line); fflush(stderr); exit(255); } else { if (!count) { fprintf(stderr, "%s:%u: warning: You said to run 0 tests! You've got to run " "something.\n", file, line); fflush(stderr); exit(255); } test_plan_file=file; test_plan_line=line; test_cases = count; fprintf(stderr, "%s:%u: note: 1..%d\n", file, line, test_cases); fflush(stdout); } } int test_diag(const char *directive, const char *reason, const char *file, unsigned line, const char *fmt, ...) { int is_todo = directive && !strcmp(directive, "TODO"); va_list args; va_start(args, fmt); if (is_todo) { fputs("# ", stdout); if (fmt) vprintf(fmt, args); fputs("\n", stdout); fflush(stdout); } else { fflush(stdout); fputs("# ", stderr); if (fmt) vfprintf(stderr, fmt, args); fputs("\n", stderr); fflush(stderr); } va_end(args); return 1; } int test_ok(int passed, const char *description, const char *directive, const char *reason, const char *file, unsigned line, const char *fmt, ...) { int is_todo = !passed && directive && !strcmp(directive, "TODO"); int is_setup = directive && !is_todo && !strcmp(directive, "SETUP"); if (is_setup) { if (!passed) { fflush(stdout); fprintf(stderr, "# SETUP not ok%s%s%s%s\n", description ? " - " : "", description ? description : "", reason ? " - " : "", reason ? reason : ""); } } else { if (!test_cases) { atexit(test_plan_exit); fprintf(stderr, "You tried to run a test without a plan! " "Gotta have a plan. at %s line %u\n", file, line); fflush(stderr); exit(255); } ++test_num; if (test_num > test_cases || (!passed && !is_todo)) ++test_fails; /* We dont need to print this unless we want to */ #if 0 fprintf(stderr, "%s:%u: note: %sok %d%s%s%s%s%s%s\n", file, line, passed ? "" : "not ", test_num, description ? " - " : "", description ? description : "", directive ? " # " : "", directive ? directive : "", reason ? " " : "", reason ? reason : ""); #endif } if (passed) fflush(stdout); else { va_list args; va_start(args, fmt); if (is_todo) { /* Enable this to output TODO as warning */ #if 0 printf("%s:%d: warning: Failed (TODO) test\n", file, line); if (fmt) vprintf(fmt, args); #endif fflush(stdout); } else { fflush(stdout); fprintf(stderr, "%s:%d: error: Failed test\n", file, line); if (fmt) vfprintf(stderr, fmt, args); fflush(stderr); } va_end(args); } return passed; } const char * sec_errstr(int err) { #if 1 static int bufnum = 0; static char buf[2][20]; bufnum = bufnum ? 0 : 1; sprintf(buf[bufnum], "0x%X", err); return buf[bufnum]; #else /* !1 */ if (err >= errSecErrnoBase && err <= errSecErrnoLimit) return strerror(err - 100000); #ifdef MAC_OS_X_VERSION_10_4 /* AvailabilityMacros.h would only define this if we are on a Tiger or later machine. */ extern const char *cssmErrorString(long); return cssmErrorString(err); #else /* !defined(MAC_OS_X_VERSION_10_4) */ extern const char *_ZN8Security15cssmErrorStringEl(long); return _ZN8Security15cssmErrorStringEl(err); #endif /* MAC_OS_X_VERSION_10_4 */ #endif /* !1 */ } /* run one test, described by test, return info in test struct */ int run_one_test(struct one_test_s *test, int argc, char * const *argv) { struct timeval start, stop; if(test->entry==NULL) { printf("%s:%d: error: wtf?\n", __FILE__, __LINE__); return -1; } gettimeofday(&start, NULL); test->entry(argc, argv); gettimeofday(&stop, NULL); test_plan_exit(); /* this may overflow... */ test->duration=(unsigned int) (stop.tv_sec-start.tv_sec)*1000+(stop.tv_usec/1000)-(start.tv_usec/1000); test->failed_tests=test_fails; return test_fails; }; |
Added CCRegression/test/testmore.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /* * Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * * testmore.h */ #ifndef _TESTMORE_H_ #define _TESTMORE_H_ 1 #include <errno.h> #include <string.h> #include <stdio.h> #ifdef __cplusplus extern "C" { #endif /* This is included here, because its already included by all the test case */ #include "testlist.h" typedef int (*one_test_entry)(int argc, char *const *argv); #define ONE_TEST_ENTRY(x) int x(int argc, char *const *argv) struct one_test_s { char *name; /* test name */ one_test_entry entry; /* entry point */ int sub_tests; /* number of subtests */ int failed_tests; /* number of failed tests*/ unsigned int duration; /* test duration in msecs */ /* add more later: timing, etc... */ }; extern struct one_test_s testlist[]; int run_one_test(struct one_test_s *test, int argc, char * const *argv); /* this test harnes rely on shadowing for TODO, SKIP and SETUP blocks */ #pragma GCC diagnostic ignored "-Wshadow" #define ok(THIS, TESTNAME) \ test_ok(!!(THIS), TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, NULL) #define is(THIS, THAT, TESTNAME) \ ({ \ __typeof__(THIS) _this = (THIS); \ __typeof__(THAT) _that = (THAT); \ test_ok((_this == _that), TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: '%d'\n" \ "# expected: '%d'\n", \ _this, _that); \ }) #define isnt(THIS, THAT, TESTNAME) \ cmp_ok((THIS), !=, (THAT), (TESTNAME)) #define diag(MSG, ARGS...) \ test_diag(test_directive, test_reason, __FILE__, __LINE__, MSG, ## ARGS) #define cmp_ok(THIS, OP, THAT, TESTNAME) \ ({ \ __typeof__(THIS) _this = (THIS); \ __typeof__(THAT) _that = (THAT); \ test_ok((_this OP _that), TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# '%d'\n" \ "# " #OP "\n" \ "# '%d'\n", \ _this, _that); \ }) #define eq_string(THIS, THAT, TESTNAME) \ ({ \ const char *_this = (THIS); \ const char *_that = (THAT); \ test_ok(!strcmp(_this, _that), TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# '%s'\n" \ "# eq\n" \ "# '%s'\n", \ _this, _that); \ }) #define eq_stringn(THIS, THISLEN, THAT, THATLEN, TESTNAME) \ ({ \ __typeof__(THISLEN) _thislen = (THISLEN); \ __typeof__(THATLEN) _thatlen = (THATLEN); \ const char *_this = (THIS); \ const char *_that = (THAT); \ test_ok(_thislen == _thatlen && !strncmp(_this, _that, _thislen), \ TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# '%.*s'\n" \ "# eq\n" \ "# '%.*s'\n", \ (int)_thislen, _this, (int)_thatlen, _that); \ }) #define like(THIS, REGEXP, TESTNAME) like_not_yet_implemented() #define unlike(THIS, REGEXP, TESTNAME) unlike_not_yet_implemented() #define is_deeply(STRUCT1, STRUCT2, TESTNAME) is_deeply_not_yet_implemented() #define TODO switch(0) default #define SKIP switch(0) default #define SETUP switch(0) default #define todo(REASON) const char *test_directive __attribute__((unused)) = "TODO", \ *test_reason __attribute__((unused)) = (REASON) #define skip(WHY, HOW_MANY, UNLESS) if (!(UNLESS)) \ { test_skip((WHY), (HOW_MANY), 0); break; } #define setup(REASON) const char *test_directive = "SETUP", \ *test_reason = (REASON) #define pass(TESTNAME) ok(1, (TESTNAME)) #define fail(TESTNAME) ok(0, (TESTNAME)) #define BAIL_OUT(WHY) test_bail_out(WHY, __FILE__, __LINE__) #define plan_skip_all(REASON) test_plan_skip_all(REASON) #define plan_tests(COUNT) test_plan_tests(COUNT, __FILE__, __LINE__) #define ok_status(THIS, TESTNAME) \ ({ \ OSStatus _this = (THIS); \ test_ok(!_this, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# status: %s(%ld)\n", \ sec_errstr(_this), _this); \ }) #define is_status(THIS, THAT, TESTNAME) \ ({ \ OSStatus _this = (THIS); \ OSStatus _that = (THAT); \ test_ok(_this == _that, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: %s(%ld)\n" \ "# expected: %s(%ld)\n", \ sec_errstr(_this), _this, sec_errstr(_that), _that); \ }) #define ok_unix(THIS, TESTNAME) \ ({ \ int _this = (THIS) < 0 ? errno : 0; \ test_ok(!_this, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: %s(%d)\n", \ strerror(_this), _this); \ }) #define is_unix(THIS, THAT, TESTNAME) \ ({ \ int _result = (THIS); \ int _this = _result < 0 ? errno : 0; \ int _that = (THAT); \ _that && _result < 0 \ ? test_ok(_this == _that, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: %s(%d)\n" \ "# expected: %s(%d)\n", \ strerror(_this), _this, strerror(_that), _that) \ : test_ok(_this == _that, TESTNAME, test_directive, test_reason, \ __FILE__, __LINE__, \ "# got: %d\n" \ "# expected errno: %s(%d)\n", \ _result, strerror(_that), _that); \ }) extern const char *test_directive; extern const char *test_reason; void test_bail_out(const char *reason, const char *file, unsigned line); int test_diag(const char *directive, const char *reason, const char *file, unsigned line, const char *fmt, ...); int test_ok(int passed, const char *description, const char *directive, const char *reason, const char *file, unsigned line, const char *fmt, ...); void test_plan_skip_all(const char *reason); void test_plan_tests(int count, const char *file, unsigned line); void test_skip(const char *reason, int how_many, int unless); const char *sec_errstr(int err); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* !_TESTMORE_H_ */ |
Added CCRegression/util/capabilities.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | // // capabilities.h // CCRegress // #include <Availability.h> #ifndef __CAPABILITIES_H__ #define __CAPABILITIES_H__ #define entryPoint(testname,supportname) \ int testname(int argc, char *const *argv) { \ char prString[80];\ sprintf(prString, "No %s Support in this release\n", supportname);\ plan_tests(1); \ diag(prString); \ ok(1, prString); \ return 0; \ } #define _SNOWLEOPARD_ 1060 #define _LION_ 1070 #define _ZIN_ 1080 #define _CAB_ 1090 #define _NMOS_ 1091 #if __MAC_OS_X_VERSION_MAX_ALLOWED < _NMOS_ #define CC_RMD128_DIGEST_LENGTH 16 #define CC_RMD160_DIGEST_LENGTH 20 #define CC_RMD256_DIGEST_LENGTH 32 #define CC_RMD320_DIGEST_LENGTH 40 #endif #define CRYPTORWITHMODE 1 #define CCDIGEST 1 #define CCRANDOM 1 #define CCKEYDERIVATION 1 #define CCCMAC 1 #define CCRSA 1 #define CCEC 1 #define CCDH 1 #define CCBIGNUM 1 #define CCRESET 1 #define CCSYMREGRESSION 1 #define CCSYMOFFSET 1 #define CCSYMZEROLEN 1 #define CCSYMCBC 1 #define CCSYMOFB 1 #define CCSYMCFB 1 #define CCSYMGCM 1 #define CCSYMXTS 1 #define CCSYMRC2 1 #define CCPADCTS 1 #define CCHMACCLONE 1 #define CCSELFTEST 0 #define CCSYMWRAP 1 #define CNENCODER 0 #define CCBIGDIGEST 0 #define CCSYMCTR 1 #endif /* __CAPABILITIES_H__ */ |
Added CCRegression/util/testbyteBuffer.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* * printByteBuffer.c * byteutils * * Created by Richard Murphy on 3/7/10. * Copyright 2010 McKenzie-Murphy. All rights reserved. * */ #include "testbyteBuffer.h" #include <CommonCrypto/CommonRandomSPI.h> void printBytes(uint8_t *buff, size_t len, char *name) { int i; printf("Dumping %d bytes from %s\n", (int) len, name); for(i=0; i<len; i++) { if(i > 0 && !(i%8)) putchar(' '); if(i > 0 && !(i%64)) putchar('\n'); printf("%02x", buff[i]); } putchar('\n'); } void printByteBuffer(byteBuffer bb, char *name) { printBytes(bb->bytes, bb->len, name); } byteBuffer mallocByteBuffer(size_t len) { byteBuffer retval; if((retval = (byteBuffer) malloc(sizeof(byteBufferStruct) + len + 1)) == NULL) return NULL; retval->len = len; retval->bytes = (uint8_t *) (retval + 1) ; /* just past the byteBuffer in malloc'ed space */ return retval; } size_t genRandomSize(size_t minSize, size_t maxSize) { size_t randomInt; if(minSize == maxSize) return minSize; // make theSize > minSize < maxSize; while(CCRandomCopyBytes(kCCRandomDefault, &randomInt, sizeof(uint32_t)) == -1) { printf("got -1 from CCRandomCopyBytes\n"); } randomInt = (randomInt % (maxSize - minSize)) + minSize; return randomInt; } byteBuffer genRandomByteBuffer(size_t minSize, size_t maxSize) { byteBuffer retval; size_t randomInt; CCCryptorStatus err; randomInt = genRandomSize(minSize, maxSize); retval = mallocByteBuffer(randomInt); if(retval == NULL) return NULL; if(retval->len != randomInt) return NULL; bzero(retval->bytes, retval->len); // fill bytes randomly while((err = CCRandomCopyBytes(kCCRandomDefault, retval->bytes, retval->len)) != kCCSuccess) { printf("got %d from CCRandomCopyBytes\n", err); } return retval; } /* utility function to convert hex character representation to their nibble (4 bit) values */ static uint8_t nibbleFromChar(char c) { if(c >= '0' && c <= '9') return c - '0'; if(c >= 'a' && c <= 'f') return c - 'a' + 10; if(c >= 'A' && c <= 'F') return c - 'A' + 10; return 255; } /* Convert a string of characters representing a hex buffer into a series of bytes of that real value */ byteBuffer hexStringToBytes(char *inhex) { byteBuffer retval; uint8_t *p; int len, i; len = (int) strlen(inhex) / 2; if((retval = mallocByteBuffer(len)) == NULL) return NULL; for(i=0, p = (uint8_t *) inhex; i<len; i++) { retval->bytes[i] = (nibbleFromChar(*p) << 4) | nibbleFromChar(*(p+1)); p += 2; } retval->bytes[len] = 0; return retval; } byteBuffer bytesToBytes(void *bytes, size_t len) { byteBuffer retval = mallocByteBuffer(len); memcpy(retval->bytes, bytes, len); return retval; } int bytesAreEqual(byteBuffer b1, byteBuffer b2) { if(b1->len != b2->len) return 0; return (memcmp(b1->bytes, b2->bytes, b1->len) == 0); } static char byteMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; static int byteMapLen = sizeof(byteMap); /* Utility function to convert nibbles (4 bit values) into a hex character representation */ static char nibbleToChar(uint8_t nibble) { if(nibble < byteMapLen) return byteMap[nibble]; return '*'; } /* Convert a buffer of binary values into a hex string representation */ char *bytesToHexString(byteBuffer bb) { char *retval; int i; retval = malloc(bb->len*2 + 1); for(i=0; i<bb->len; i++) { retval[i*2] = nibbleToChar(bb->bytes[i] >> 4); retval[i*2+1] = nibbleToChar(bb->bytes[i] & 0x0f); } retval[bb->len*2] = 0; return retval; } char *bytesToHexStringWithSpaces(byteBuffer bb, int breaks) { char *retval; int i, j; if(breaks == 0) { return bytesToHexString(bb); } breaks /= 2; retval = malloc(bb->len*2 + 1 + (bb->len*2 / breaks) + 10); for(i=0, j=0; i<bb->len; i++, j+=2) { retval[j] = nibbleToChar(bb->bytes[i] >> 4); retval[j+1] = nibbleToChar(bb->bytes[i] & 0x0f); if(((i+1) % breaks) == 0) { retval[j+2] = ' '; retval[j+3] = 0; j++; } } return retval; } |
Added CCRegression/util/testbyteBuffer.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * printByteBuffer.h * byteutils * */ #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #ifndef _BYTEBUFFER_H_ #define _BYTEBUFFER_H_ typedef struct byte_buf { size_t len; uint8_t *bytes; } byteBufferStruct, *byteBuffer; void printByteBuffer(byteBuffer bb, char *name); void printBytes(uint8_t *buff, size_t len, char *name); byteBuffer mallocByteBuffer(size_t len); byteBuffer hexStringToBytes(char *inhex); byteBuffer hexStringToBytesWithSpaces(char *inhex, int breaks); char *bytesToHexStringWithSpaces(byteBuffer bb, int breaks); byteBuffer bytesToBytes(void *bytes, size_t len); int bytesAreEqual(byteBuffer b1, byteBuffer b2); char *bytesToHexString(byteBuffer bytes); byteBuffer genRandomByteBuffer(size_t minSize, size_t maxSize); size_t genRandomSize(size_t minSize, size_t maxSize); #endif /* _BYTEBUFFER_H_ */ |
Changes to CommonCrypto.xcodeproj/project.pbxproj.
︙ | ︙ | |||
28 29 30 31 32 33 34 | 05CE942F0A37850A007C91D6 /* CopyFiles */, ); dependencies = ( ); name = "Copy Open Source Docs"; productName = "Copy Open Source Docs"; }; | | | | > > > > > > > > > > > | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < > > > > > > > > > > > > | | | | | | > > > > > | | > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < > > > > > < | < | | | < | < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < | < | < < | | | | < | | | | | < < < < < < < < | | < < < < < < < < < | | < < < < | | | < < < | < < < | | | < < < | | | < < | < < | < < < < < < < | < | | | | < < < < < < < < < | | < < < < < < < < < | | | | | | | < < < | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < | | | | < | | | | | | < | | | | | | < | | | | < < | < | < < < < < < < < < < < | | | | | < < | | | | | < < < | | | < | | < < < | < < < < | | < | < | < < | | | | | < < < | < | < < < < < < < | | < < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | 05CE942F0A37850A007C91D6 /* CopyFiles */, ); dependencies = ( ); name = "Copy Open Source Docs"; productName = "Copy Open Source Docs"; }; 4C99FCB61326E14F0040AD38 /* commonCryptoMacIOS */ = { isa = PBXAggregateTarget; buildConfigurationList = 4C99FCB71326E14F0040AD38 /* Build configuration list for PBXAggregateTarget "commonCryptoMacIOS" */; buildPhases = ( ); dependencies = ( 4C58A28D13281C2100A17BAC /* PBXTargetDependency */, ); name = commonCryptoMacIOS; productName = FIPSModeIOS; }; 4CA675141332C16C00C45A71 /* CommonCrypto_Sim */ = { isa = PBXAggregateTarget; buildConfigurationList = 4CA675151332C16C00C45A71 /* Build configuration list for PBXAggregateTarget "CommonCrypto_Sim" */; buildPhases = ( 4CA6751A1332C18C00C45A71 /* ShellScript */, ); dependencies = ( 4CA675191332C17900C45A71 /* PBXTargetDependency */, ); name = CommonCrypto_Sim; productName = commonCryptoMacIOSSim; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0511C47E0A37892C0028BFC3 /* CommonCrypto.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 05CE942C0A37850A007C91D6 /* CommonCrypto.txt */; }; 054BBECE05F6AA7200344873 /* CommonDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = 054BBECD05F6AA7200344873 /* CommonDigest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 05CE942D0A37850A007C91D6 /* CommonCrypto.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 05CE942B0A37850A007C91D6 /* CommonCrypto.plist */; }; 05D8D97D09E411AB00E03504 /* CommonHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D8D97C09E411AA00E03504 /* CommonHMAC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 05D9F61909D85F4A00AD30A7 /* CommonCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D9F61609D85F4A00AD30A7 /* CommonCryptor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12FA0DB011F7962100917A4E /* CommonRandomSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 12FA0DAF11F7962100917A4E /* CommonRandomSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48067F871362405D005DDEBC /* CommonCryptoAESShoefly.c in Sources */ = {isa = PBXBuildFile; fileRef = 48685586127B641800B88D39 /* CommonCryptoAESShoefly.c */; }; 48096B2311A5EF900043F67F /* CommonDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48096B2211A5EF900043F67F /* CommonDigest.c */; }; 48165CD9125AC5D50015A267 /* CommonDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = 054BBECD05F6AA7200344873 /* CommonDigest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165CDA125AC5D50015A267 /* CommonCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D9F61609D85F4A00AD30A7 /* CommonCryptor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165CDB125AC5D50015A267 /* CommonHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D8D97C09E411AA00E03504 /* CommonHMAC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165CDC125AC5D50015A267 /* CommonKeyDerivation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C01116307500CAFA18 /* CommonKeyDerivation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165CDD125AC5D50015A267 /* CommonSymmetricKeywrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C11116307500CAFA18 /* CommonSymmetricKeywrap.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165CF0125AC5D50015A267 /* ccdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 489D982D11A4E8C20004DB89 /* ccdebug.h */; }; 48165CF1125AC5D50015A267 /* CommonCryptorSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5411A5C8B800E7DA82 /* CommonCryptorSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165CF2125AC5D50015A267 /* CommonDigestSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5511A5C8B800E7DA82 /* CommonDigestSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165CF3125AC5D50015A267 /* CommonCryptoPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A41A11A5C94A00862178 /* CommonCryptoPriv.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165CF4125AC5D50015A267 /* CommonCryptorPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42C11A5CB4700862178 /* CommonCryptorPriv.h */; settings = {ATTRIBUTES = (); }; }; 48165CF5125AC5D50015A267 /* CommonDigestPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42D11A5CB4700862178 /* CommonDigestPriv.h */; }; 48165CF7125AC5D50015A267 /* CommonRandomSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 12FA0DAF11F7962100917A4E /* CommonRandomSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165D78125AC5D50015A267 /* ccdebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 489D982C11A4E8C20004DB89 /* ccdebug.c */; }; 48165D79125AC5D50015A267 /* CommonCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42B11A5CB4700862178 /* CommonCryptor.c */; }; 48165D7A125AC5D50015A267 /* CommonHMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42E11A5CB4700862178 /* CommonHMAC.c */; }; 48165D7B125AC5D50015A267 /* CommonKeyDerivation.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42F11A5CB4700862178 /* CommonKeyDerivation.c */; }; 48165D7C125AC5D50015A267 /* CommonSymmetricKeywrap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A43111A5CB4700862178 /* CommonSymmetricKeywrap.c */; }; 48165D7D125AC5D50015A267 /* CommonDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48096B2211A5EF900043F67F /* CommonDigest.c */; }; 48165DBC125AC5F20015A267 /* CommonDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = 054BBECD05F6AA7200344873 /* CommonDigest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165DBD125AC5F20015A267 /* CommonCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D9F61609D85F4A00AD30A7 /* CommonCryptor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165DBE125AC5F20015A267 /* CommonHMAC.h in Headers */ = {isa = PBXBuildFile; fileRef = 05D8D97C09E411AA00E03504 /* CommonHMAC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165DBF125AC5F20015A267 /* CommonKeyDerivation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C01116307500CAFA18 /* CommonKeyDerivation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165DC0125AC5F20015A267 /* CommonSymmetricKeywrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C11116307500CAFA18 /* CommonSymmetricKeywrap.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48165DD3125AC5F20015A267 /* ccdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 489D982D11A4E8C20004DB89 /* ccdebug.h */; }; 48165DD4125AC5F20015A267 /* CommonCryptorSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5411A5C8B800E7DA82 /* CommonCryptorSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165DD5125AC5F20015A267 /* CommonDigestSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5511A5C8B800E7DA82 /* CommonDigestSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165DD6125AC5F20015A267 /* CommonCryptoPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A41A11A5C94A00862178 /* CommonCryptoPriv.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165DD7125AC5F20015A267 /* CommonCryptorPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42C11A5CB4700862178 /* CommonCryptorPriv.h */; settings = {ATTRIBUTES = (); }; }; 48165DD8125AC5F20015A267 /* CommonDigestPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42D11A5CB4700862178 /* CommonDigestPriv.h */; }; 48165DDA125AC5F20015A267 /* CommonRandomSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 12FA0DAF11F7962100917A4E /* CommonRandomSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48165E5B125AC5F20015A267 /* ccdebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 489D982C11A4E8C20004DB89 /* ccdebug.c */; }; 48165E5C125AC5F20015A267 /* CommonCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42B11A5CB4700862178 /* CommonCryptor.c */; }; 48165E5D125AC5F20015A267 /* CommonHMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42E11A5CB4700862178 /* CommonHMAC.c */; }; 48165E5E125AC5F20015A267 /* CommonKeyDerivation.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42F11A5CB4700862178 /* CommonKeyDerivation.c */; }; 48165E5F125AC5F20015A267 /* CommonSymmetricKeywrap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A43111A5CB4700862178 /* CommonSymmetricKeywrap.c */; }; 48165E60125AC5F20015A267 /* CommonDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48096B2211A5EF900043F67F /* CommonDigest.c */; }; 4823B0EA14C1013F008F689F /* CCCryptorTestFuncs.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0AE14C10022008F689F /* CCCryptorTestFuncs.c */; }; 4823B0EC14C1013F008F689F /* CommonBaseEncoding.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B014C10022008F689F /* CommonBaseEncoding.c */; }; 4823B0ED14C1013F008F689F /* CommonBigNum.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B114C10022008F689F /* CommonBigNum.c */; }; 4823B0EE14C1013F008F689F /* CommonCMac.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B214C10022008F689F /* CommonCMac.c */; }; 4823B0EF14C1013F008F689F /* CommonCryptoCTSPadding.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B314C10022008F689F /* CommonCryptoCTSPadding.c */; }; 4823B0F014C1013F008F689F /* CommonCryptoSymCBC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B414C10022008F689F /* CommonCryptoSymCBC.c */; }; 4823B0F114C1013F008F689F /* CommonCryptoSymGCM.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B514C10022008F689F /* CommonCryptoSymGCM.c */; }; 4823B0F214C1013F008F689F /* CommonCryptoSymmetricWrap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B614C10022008F689F /* CommonCryptoSymmetricWrap.c */; }; 4823B0F314C1013F008F689F /* CommonCryptoSymOFB.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B714C10022008F689F /* CommonCryptoSymOFB.c */; }; 4823B0F414C1013F008F689F /* CommonCryptoSymOffset.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B814C10022008F689F /* CommonCryptoSymOffset.c */; }; 4823B0F514C1013F008F689F /* CommonCryptoSymRC2.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B914C10022008F689F /* CommonCryptoSymRC2.c */; }; 4823B0F614C1013F008F689F /* CommonCryptoSymRegression.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BA14C10022008F689F /* CommonCryptoSymRegression.c */; }; 4823B0F714C1013F008F689F /* CommonCryptoSymXTS.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BB14C10022008F689F /* CommonCryptoSymXTS.c */; }; 4823B0F814C1013F008F689F /* CommonCryptoSymZeroLength.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BC14C10022008F689F /* CommonCryptoSymZeroLength.c */; }; 4823B0F914C1013F008F689F /* CommonDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BD14C10022008F689F /* CommonDigest.c */; }; 4823B0FA14C1013F008F689F /* CommonEC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BE14C10022008F689F /* CommonEC.c */; }; 4823B0FB14C1013F008F689F /* CommonHMacClone.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BF14C10022008F689F /* CommonHMacClone.c */; }; 4823B0FC14C1013F008F689F /* CommonRandom.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C014C10022008F689F /* CommonRandom.c */; }; 4823B0FD14C1013F008F689F /* CommonRSA.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C114C10022008F689F /* CommonRSA.c */; }; 4823B0FF14C1013F008F689F /* CryptorPadFailure.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C314C10022008F689F /* CryptorPadFailure.c */; }; 4823B10014C10155008F689F /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C814C10022008F689F /* main.c */; }; 4823B10214C1016B008F689F /* testenv.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D014C10022008F689F /* testenv.c */; }; 4823B10414C1016B008F689F /* testlist.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D214C10022008F689F /* testlist.c */; }; 4823B10714C1016B008F689F /* testmore.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D514C10022008F689F /* testmore.c */; }; 4823B10914C1017C008F689F /* testbyteBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D814C10022008F689F /* testbyteBuffer.c */; }; 4825AAF61314CDCD00413A64 /* CommonBigNum.h in Headers */ = {isa = PBXBuildFile; fileRef = 4825AAF31314CDCD00413A64 /* CommonBigNum.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4825AAF71314CDCD00413A64 /* CommonBigNum.h in Headers */ = {isa = PBXBuildFile; fileRef = 4825AAF31314CDCD00413A64 /* CommonBigNum.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4825AAF81314CDCD00413A64 /* CommonBigNum.h in Headers */ = {isa = PBXBuildFile; fileRef = 4825AAF31314CDCD00413A64 /* CommonBigNum.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4834A85314F47A9400438E3D /* libcorecrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4834A85214F47A9400438E3D /* libcorecrypto.dylib */; }; 4834A85814F47B6200438E3D /* testbyteBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D814C10022008F689F /* testbyteBuffer.c */; }; 4834A85C14F47B6200438E3D /* testenv.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D014C10022008F689F /* testenv.c */; }; 4834A85E14F47B6200438E3D /* testlist.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D214C10022008F689F /* testlist.c */; }; 4834A86114F47B6200438E3D /* testmore.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0D514C10022008F689F /* testmore.c */; }; 4834A86314F47B6200438E3D /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C814C10022008F689F /* main.c */; }; 4834A86414F47B6200438E3D /* CCCryptorTestFuncs.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0AE14C10022008F689F /* CCCryptorTestFuncs.c */; }; 4834A86614F47B6200438E3D /* CommonBaseEncoding.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B014C10022008F689F /* CommonBaseEncoding.c */; }; 4834A86714F47B6200438E3D /* CommonBigNum.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B114C10022008F689F /* CommonBigNum.c */; }; 4834A86814F47B6200438E3D /* CommonCMac.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B214C10022008F689F /* CommonCMac.c */; }; 4834A86914F47B6200438E3D /* CommonCryptoCTSPadding.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B314C10022008F689F /* CommonCryptoCTSPadding.c */; }; 4834A86A14F47B6200438E3D /* CommonCryptoSymCBC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B414C10022008F689F /* CommonCryptoSymCBC.c */; }; 4834A86B14F47B6200438E3D /* CommonCryptoSymGCM.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B514C10022008F689F /* CommonCryptoSymGCM.c */; }; 4834A86C14F47B6200438E3D /* CommonCryptoSymmetricWrap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B614C10022008F689F /* CommonCryptoSymmetricWrap.c */; }; 4834A86D14F47B6200438E3D /* CommonCryptoSymOFB.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B714C10022008F689F /* CommonCryptoSymOFB.c */; }; 4834A86E14F47B6200438E3D /* CommonCryptoSymOffset.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B814C10022008F689F /* CommonCryptoSymOffset.c */; }; 4834A86F14F47B6200438E3D /* CommonCryptoSymRC2.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0B914C10022008F689F /* CommonCryptoSymRC2.c */; }; 4834A87014F47B6200438E3D /* CommonCryptoSymRegression.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BA14C10022008F689F /* CommonCryptoSymRegression.c */; }; 4834A87114F47B6200438E3D /* CommonCryptoSymXTS.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BB14C10022008F689F /* CommonCryptoSymXTS.c */; }; 4834A87214F47B6200438E3D /* CommonCryptoSymZeroLength.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BC14C10022008F689F /* CommonCryptoSymZeroLength.c */; }; 4834A87314F47B6200438E3D /* CommonDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BD14C10022008F689F /* CommonDigest.c */; }; 4834A87414F47B6200438E3D /* CommonEC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BE14C10022008F689F /* CommonEC.c */; }; 4834A87514F47B6200438E3D /* CommonHMacClone.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0BF14C10022008F689F /* CommonHMacClone.c */; }; 4834A87614F47B6200438E3D /* CommonRandom.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C014C10022008F689F /* CommonRandom.c */; }; 4834A87714F47B6200438E3D /* CommonRSA.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C114C10022008F689F /* CommonRSA.c */; }; 4834A87814F47B6200438E3D /* CryptorPadFailure.c in Sources */ = {isa = PBXBuildFile; fileRef = 4823B0C314C10022008F689F /* CryptorPadFailure.c */; }; 4834A87914F47B6200438E3D /* CommonCryptoReset.c in Sources */ = {isa = PBXBuildFile; fileRef = 486BE17C14E6019B00346AC4 /* CommonCryptoReset.c */; }; 4834A88214F47C9A00438E3D /* libcommonCrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 054BBEBE05F6A97700344873 /* libcommonCrypto.dylib */; }; 4836A42111A5C94A00862178 /* CommonCryptoPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A41A11A5C94A00862178 /* CommonCryptoPriv.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4836A43211A5CB4700862178 /* CommonCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42B11A5CB4700862178 /* CommonCryptor.c */; }; 4836A43311A5CB4700862178 /* CommonCryptorPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42C11A5CB4700862178 /* CommonCryptorPriv.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4836A43411A5CB4700862178 /* CommonDigestPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 4836A42D11A5CB4700862178 /* CommonDigestPriv.h */; }; 4836A43511A5CB4700862178 /* CommonHMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42E11A5CB4700862178 /* CommonHMAC.c */; }; 4836A43611A5CB4700862178 /* CommonKeyDerivation.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A42F11A5CB4700862178 /* CommonKeyDerivation.c */; }; 4836A43811A5CB4700862178 /* CommonSymmetricKeywrap.c in Sources */ = {isa = PBXBuildFile; fileRef = 4836A43111A5CB4700862178 /* CommonSymmetricKeywrap.c */; }; 4846CA5611A5C8B800E7DA82 /* CommonCryptorSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5411A5C8B800E7DA82 /* CommonCryptorSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4846CA5711A5C8B800E7DA82 /* CommonDigestSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4846CA5511A5C8B800E7DA82 /* CommonDigestSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 484D40FF14DC96A600C93734 /* libcorecrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 484D40FE14DC96A600C93734 /* libcorecrypto.dylib */; }; 4852C24A1505F8CD00676BCC /* CommonCryptoSymCFB.c in Sources */ = {isa = PBXBuildFile; fileRef = 4852C2491505F8CD00676BCC /* CommonCryptoSymCFB.c */; }; 4852C24B1505F8CD00676BCC /* CommonCryptoSymCFB.c in Sources */ = {isa = PBXBuildFile; fileRef = 4852C2491505F8CD00676BCC /* CommonCryptoSymCFB.c */; }; 4854BAD6152177CC007B5B08 /* CommonCryptoSymCTR.c in Sources */ = {isa = PBXBuildFile; fileRef = 4854BAD5152177CC007B5B08 /* CommonCryptoSymCTR.c */; }; 4854BAD7152177CC007B5B08 /* CommonCryptoSymCTR.c in Sources */ = {isa = PBXBuildFile; fileRef = 4854BAD5152177CC007B5B08 /* CommonCryptoSymCTR.c */; }; 4854F9C21116307500CAFA18 /* CommonKeyDerivation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C01116307500CAFA18 /* CommonKeyDerivation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4854F9C31116307500CAFA18 /* CommonSymmetricKeywrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4854F9C11116307500CAFA18 /* CommonSymmetricKeywrap.h */; settings = {ATTRIBUTES = (Public, ); }; }; 485FED50131475A400FF0F82 /* CommonBigNumPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 485FED4A131475A400FF0F82 /* CommonBigNumPriv.h */; }; 485FED51131475A400FF0F82 /* CommonBigNum.c in Sources */ = {isa = PBXBuildFile; fileRef = 485FED4B131475A400FF0F82 /* CommonBigNum.c */; }; 485FED54131475A400FF0F82 /* CommonBigNumPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 485FED4A131475A400FF0F82 /* CommonBigNumPriv.h */; }; 485FED55131475A400FF0F82 /* CommonBigNum.c in Sources */ = {isa = PBXBuildFile; fileRef = 485FED4B131475A400FF0F82 /* CommonBigNum.c */; }; 485FED56131475A400FF0F82 /* CommonBigNumPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 485FED4A131475A400FF0F82 /* CommonBigNumPriv.h */; }; 485FED57131475A400FF0F82 /* CommonBigNum.c in Sources */ = {isa = PBXBuildFile; fileRef = 485FED4B131475A400FF0F82 /* CommonBigNum.c */; }; 48685584127B63F200B88D39 /* aes.h in Headers */ = {isa = PBXBuildFile; fileRef = 48685583127B63F200B88D39 /* aes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48685587127B641800B88D39 /* CommonCryptoAESShoefly.c in Sources */ = {isa = PBXBuildFile; fileRef = 48685586127B641800B88D39 /* CommonCryptoAESShoefly.c */; }; 4868BB1414B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 4868BB1314B7C7F300072488 /* corecryptoSymmetricBridge.h */; }; 4868BB1514B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 4868BB1314B7C7F300072488 /* corecryptoSymmetricBridge.h */; }; 4868BB1614B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 4868BB1314B7C7F300072488 /* corecryptoSymmetricBridge.h */; }; 486BE17D14E6019B00346AC4 /* CommonCryptoReset.c in Sources */ = {isa = PBXBuildFile; fileRef = 486BE17C14E6019B00346AC4 /* CommonCryptoReset.c */; }; 4873A7281445099D0011B4FA /* CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 4873A7271445099D0011B4FA /* CommonCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4873A72A1445099D0011B4FA /* CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 4873A7271445099D0011B4FA /* CommonCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4873A72B1445099D0011B4FA /* CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 4873A7271445099D0011B4FA /* CommonCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; 488FCCB3139D6DD7007F2FC4 /* aes.h in Headers */ = {isa = PBXBuildFile; fileRef = 48685583127B63F200B88D39 /* aes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 489D982E11A4E8C20004DB89 /* ccdebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 489D982C11A4E8C20004DB89 /* ccdebug.c */; }; 489D982F11A4E8C20004DB89 /* ccdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 489D982D11A4E8C20004DB89 /* ccdebug.h */; }; 489E06F914B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */ = {isa = PBXBuildFile; fileRef = 489E06F814B7AB0800B0A282 /* corecryptoSymmetricBridge.c */; }; 489E06FA14B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */ = {isa = PBXBuildFile; fileRef = 489E06F814B7AB0800B0A282 /* corecryptoSymmetricBridge.c */; }; 489E06FB14B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */ = {isa = PBXBuildFile; fileRef = 489E06F814B7AB0800B0A282 /* corecryptoSymmetricBridge.c */; }; 489EECB1149809A800B44D5A /* asn1Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA2149809A800B44D5A /* asn1Types.h */; }; 489EECB2149809A800B44D5A /* asn1Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA2149809A800B44D5A /* asn1Types.h */; }; 489EECB3149809A800B44D5A /* asn1Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA2149809A800B44D5A /* asn1Types.h */; }; 489EECB4149809A800B44D5A /* DER_CertCrl.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA3149809A800B44D5A /* DER_CertCrl.c */; }; 489EECB5149809A800B44D5A /* DER_CertCrl.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA3149809A800B44D5A /* DER_CertCrl.c */; }; 489EECB6149809A800B44D5A /* DER_CertCrl.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA3149809A800B44D5A /* DER_CertCrl.c */; }; 489EECB7149809A800B44D5A /* DER_CertCrl.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA4149809A800B44D5A /* DER_CertCrl.h */; }; 489EECB8149809A800B44D5A /* DER_CertCrl.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA4149809A800B44D5A /* DER_CertCrl.h */; }; 489EECB9149809A800B44D5A /* DER_CertCrl.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA4149809A800B44D5A /* DER_CertCrl.h */; }; 489EECBA149809A800B44D5A /* DER_Decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA5149809A800B44D5A /* DER_Decode.c */; }; 489EECBB149809A800B44D5A /* DER_Decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA5149809A800B44D5A /* DER_Decode.c */; }; 489EECBC149809A800B44D5A /* DER_Decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA5149809A800B44D5A /* DER_Decode.c */; }; 489EECBD149809A800B44D5A /* DER_Decode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA6149809A800B44D5A /* DER_Decode.h */; }; 489EECBE149809A800B44D5A /* DER_Decode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA6149809A800B44D5A /* DER_Decode.h */; }; 489EECBF149809A800B44D5A /* DER_Decode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA6149809A800B44D5A /* DER_Decode.h */; }; 489EECC0149809A800B44D5A /* DER_Digest.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA7149809A800B44D5A /* DER_Digest.c */; }; 489EECC1149809A800B44D5A /* DER_Digest.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA7149809A800B44D5A /* DER_Digest.c */; }; 489EECC2149809A800B44D5A /* DER_Digest.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA7149809A800B44D5A /* DER_Digest.c */; }; 489EECC3149809A800B44D5A /* DER_Digest.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA8149809A800B44D5A /* DER_Digest.h */; }; 489EECC4149809A800B44D5A /* DER_Digest.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA8149809A800B44D5A /* DER_Digest.h */; }; 489EECC5149809A800B44D5A /* DER_Digest.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECA8149809A800B44D5A /* DER_Digest.h */; }; 489EECC6149809A800B44D5A /* DER_Encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA9149809A800B44D5A /* DER_Encode.c */; }; 489EECC7149809A800B44D5A /* DER_Encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA9149809A800B44D5A /* DER_Encode.c */; }; 489EECC8149809A800B44D5A /* DER_Encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECA9149809A800B44D5A /* DER_Encode.c */; }; 489EECC9149809A800B44D5A /* DER_Encode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAA149809A800B44D5A /* DER_Encode.h */; }; 489EECCA149809A800B44D5A /* DER_Encode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAA149809A800B44D5A /* DER_Encode.h */; }; 489EECCB149809A800B44D5A /* DER_Encode.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAA149809A800B44D5A /* DER_Encode.h */; }; 489EECCC149809A800B44D5A /* DER_Keys.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAB149809A800B44D5A /* DER_Keys.c */; }; 489EECCD149809A800B44D5A /* DER_Keys.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAB149809A800B44D5A /* DER_Keys.c */; }; 489EECCE149809A800B44D5A /* DER_Keys.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAB149809A800B44D5A /* DER_Keys.c */; }; 489EECCF149809A800B44D5A /* DER_Keys.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAC149809A800B44D5A /* DER_Keys.h */; }; 489EECD0149809A800B44D5A /* DER_Keys.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAC149809A800B44D5A /* DER_Keys.h */; }; 489EECD1149809A800B44D5A /* DER_Keys.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAC149809A800B44D5A /* DER_Keys.h */; }; 489EECD2149809A800B44D5A /* libDER.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAD149809A800B44D5A /* libDER.h */; }; 489EECD3149809A800B44D5A /* libDER.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAD149809A800B44D5A /* libDER.h */; }; 489EECD4149809A800B44D5A /* libDER.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAD149809A800B44D5A /* libDER.h */; }; 489EECD5149809A800B44D5A /* libDER_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAE149809A800B44D5A /* libDER_config.h */; }; 489EECD6149809A800B44D5A /* libDER_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAE149809A800B44D5A /* libDER_config.h */; }; 489EECD7149809A800B44D5A /* libDER_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECAE149809A800B44D5A /* libDER_config.h */; }; 489EECD8149809A800B44D5A /* oids.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAF149809A800B44D5A /* oids.c */; }; 489EECD9149809A800B44D5A /* oids.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAF149809A800B44D5A /* oids.c */; }; 489EECDA149809A800B44D5A /* oids.c in Sources */ = {isa = PBXBuildFile; fileRef = 489EECAF149809A800B44D5A /* oids.c */; }; 489EECDB149809A800B44D5A /* oids.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECB0149809A800B44D5A /* oids.h */; }; 489EECDC149809A800B44D5A /* oids.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECB0149809A800B44D5A /* oids.h */; }; 489EECDD149809A800B44D5A /* oids.h in Headers */ = {isa = PBXBuildFile; fileRef = 489EECB0149809A800B44D5A /* oids.h */; }; 489F2442141AA3D0005E80FD /* CommonCMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 489F2441141AA3D0005E80FD /* CommonCMAC.c */; }; 489F2444141AA3D0005E80FD /* CommonCMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 489F2441141AA3D0005E80FD /* CommonCMAC.c */; }; 489F2445141AA3D0005E80FD /* CommonCMAC.c in Sources */ = {isa = PBXBuildFile; fileRef = 489F2441141AA3D0005E80FD /* CommonCMAC.c */; }; 489FD30C13187B1D00ACB86D /* CommonHMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 489FD30B13187B1D00ACB86D /* CommonHMacSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 489FD30E13187B1D00ACB86D /* CommonHMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 489FD30B13187B1D00ACB86D /* CommonHMacSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 489FD30F13187B1D00ACB86D /* CommonHMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 489FD30B13187B1D00ACB86D /* CommonHMacSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48A5CBA2131EE096002A6E85 /* CommonGCMCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48A5CBA0131EE096002A6E85 /* CommonGCMCryptor.c */; }; 48A5CBA6131EE096002A6E85 /* CommonGCMCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48A5CBA0131EE096002A6E85 /* CommonGCMCryptor.c */; }; 48A5CBA8131EE096002A6E85 /* CommonGCMCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48A5CBA0131EE096002A6E85 /* CommonGCMCryptor.c */; }; 48AC47CF1381EFDC00F584F5 /* byteBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 48AC47CD1381EFDC00F584F5 /* byteBuffer.c */; }; 48AC47D11381EFDC00F584F5 /* byteBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 48AC47CD1381EFDC00F584F5 /* byteBuffer.c */; }; 48AC47D21381EFDC00F584F5 /* byteBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 48AC47CD1381EFDC00F584F5 /* byteBuffer.c */; }; 48AC47D51381EFDC00F584F5 /* byteBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 48AC47CE1381EFDC00F584F5 /* byteBuffer.h */; }; 48AC47D71381EFDC00F584F5 /* byteBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 48AC47CE1381EFDC00F584F5 /* byteBuffer.h */; }; 48AC47D81381EFDC00F584F5 /* byteBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 48AC47CE1381EFDC00F584F5 /* byteBuffer.h */; }; 48B4651412848FB800311799 /* CommonRSACryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B4651112848FB800311799 /* CommonRSACryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48B4651512848FB800311799 /* CommonRSACryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B4651112848FB800311799 /* CommonRSACryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48B4651712848FB800311799 /* CommonRSACryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B4651112848FB800311799 /* CommonRSACryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48B4651D1284907600311799 /* CommonRSACryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48B4651B1284907600311799 /* CommonRSACryptor.c */; }; 48B4651E1284907600311799 /* CommonRSACryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48B4651B1284907600311799 /* CommonRSACryptor.c */; }; 48B4651F1284907600311799 /* CommonRSACryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48B4651B1284907600311799 /* CommonRSACryptor.c */; }; 48C5CB9214FD747500F4472E /* CommonDHtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48C5CB9114FD747500F4472E /* CommonDHtest.c */; }; 48C5CB9314FD747500F4472E /* CommonDHtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48C5CB9114FD747500F4472E /* CommonDHtest.c */; }; 48CCD26514F6F189002B6043 /* CommonBigDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48CCD26414F6F189002B6043 /* CommonBigDigest.c */; }; 48CCD26614F6F1E1002B6043 /* CommonBigDigest.c in Sources */ = {isa = PBXBuildFile; fileRef = 48CCD26414F6F189002B6043 /* CommonBigDigest.c */; }; 48D076C1130B2A510052D1AC /* CommonDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C0130B2A510052D1AC /* CommonDH.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076C3130B2A510052D1AC /* CommonDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C0130B2A510052D1AC /* CommonDH.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076C5130B2A510052D1AC /* CommonDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C0130B2A510052D1AC /* CommonDH.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076C8130B2A620052D1AC /* CommonECCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C7130B2A620052D1AC /* CommonECCryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076CA130B2A620052D1AC /* CommonECCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C7130B2A620052D1AC /* CommonECCryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076CC130B2A620052D1AC /* CommonECCryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48D076C7130B2A620052D1AC /* CommonECCryptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48D076D0130B2A9C0052D1AC /* CommonDH.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CE130B2A9C0052D1AC /* CommonDH.c */; }; 48D076D1130B2A9C0052D1AC /* CommonECCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CF130B2A9C0052D1AC /* CommonECCryptor.c */; }; 48D076D4130B2A9C0052D1AC /* CommonDH.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CE130B2A9C0052D1AC /* CommonDH.c */; }; 48D076D5130B2A9C0052D1AC /* CommonECCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CF130B2A9C0052D1AC /* CommonECCryptor.c */; }; 48D076D8130B2A9C0052D1AC /* CommonDH.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CE130B2A9C0052D1AC /* CommonDH.c */; }; 48D076D9130B2A9C0052D1AC /* CommonECCryptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 48D076CF130B2A9C0052D1AC /* CommonECCryptor.c */; }; 48E93DCB136867F500B33DB8 /* CommonCMACSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E93DCA136867F500B33DB8 /* CommonCMACSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48E93DCC136867F500B33DB8 /* CommonCMACSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E93DCA136867F500B33DB8 /* CommonCMACSPI.h */; }; 48E93DCD136867F500B33DB8 /* CommonCMACSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E93DCA136867F500B33DB8 /* CommonCMACSPI.h */; }; 48F5355314902894000D2D1F /* CommonRandom.c in Sources */ = {isa = PBXBuildFile; fileRef = 48F5355214902894000D2D1F /* CommonRandom.c */; }; 48F5355414902894000D2D1F /* CommonRandom.c in Sources */ = {isa = PBXBuildFile; fileRef = 48F5355214902894000D2D1F /* CommonRandom.c */; }; 48FC4BD613959D0600DA4760 /* lionCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FC4BD513959D0600DA4760 /* lionCompat.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48FC4BD81395ACE600DA4760 /* CommonCryptoCASTShoefly.c in Sources */ = {isa = PBXBuildFile; fileRef = 48FC4BD71395ACE600DA4760 /* CommonCryptoCASTShoefly.c */; }; 48FD6C3A1354DD4000F55B8B /* ccErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C371354DD4000F55B8B /* ccErrors.h */; }; 48FD6C3B1354DD4000F55B8B /* ccMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C381354DD4000F55B8B /* ccMemory.h */; }; 48FD6C401354DD4000F55B8B /* ccErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C371354DD4000F55B8B /* ccErrors.h */; }; 48FD6C411354DD4000F55B8B /* ccMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C381354DD4000F55B8B /* ccMemory.h */; }; 48FD6C431354DD4000F55B8B /* ccErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C371354DD4000F55B8B /* ccErrors.h */; }; 48FD6C441354DD4000F55B8B /* ccMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 48FD6C381354DD4000F55B8B /* ccMemory.h */; }; 4CDDFB7E133BD3BA00B4770F /* aes.h in Headers */ = {isa = PBXBuildFile; fileRef = 48685583127B63F200B88D39 /* aes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4CF7820B1339B543004A56DF /* CommonCryptoAESShoefly.c in Sources */ = {isa = PBXBuildFile; fileRef = 48685586127B641800B88D39 /* CommonCryptoAESShoefly.c */; }; 5DB80D3E14FC5CB3002C9A03 /* CommonRandom.c in Sources */ = {isa = PBXBuildFile; fileRef = 48F5355214902894000D2D1F /* CommonRandom.c */; }; D6658D950BD8178400D18063 /* CC_crypto.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 05DF6D1109CF2D7200D9A3E8 /* CC_crypto.3cc */; }; D6658D960BD8178400D18063 /* CC_MD2.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5B60BC6D67000878B42 /* CC_MD2.3cc */; }; D6658D970BD8178400D18063 /* CC_MD2_Final.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5B70BC6D67000878B42 /* CC_MD2_Final.3cc */; }; D6658D980BD8178400D18063 /* CC_MD2_Init.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5B80BC6D67000878B42 /* CC_MD2_Init.3cc */; }; D6658D990BD8178400D18063 /* CC_MD2_Update.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5B90BC6D67000878B42 /* CC_MD2_Update.3cc */; }; D6658D9A0BD8178400D18063 /* CC_MD4.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5BA0BC6D67000878B42 /* CC_MD4.3cc */; }; D6658D9B0BD8178400D18063 /* CC_MD4_Final.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5BB0BC6D67000878B42 /* CC_MD4_Final.3cc */; }; |
︙ | ︙ | |||
531 532 533 534 535 536 537 | D6658DC10BD8178400D18063 /* CCHmacInit.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5DF0BC6D67000878B42 /* CCHmacInit.3cc */; }; D6658DC20BD8178400D18063 /* CCHmacUpdate.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E00BC6D67000878B42 /* CCHmacUpdate.3cc */; }; D6658DC30BD8178400D18063 /* CCryptorCreateFromData.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E10BC6D67000878B42 /* CCryptorCreateFromData.3cc */; }; D6658DC40BD8178400D18063 /* Common Crypto.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E20BC6D67000878B42 /* Common Crypto.3cc */; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ | | > > > > > > > > > > > > > > > > > | | | | < < < < < < < < < < < < < < | | | | | | | | | < < < < < < < | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | D6658DC10BD8178400D18063 /* CCHmacInit.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5DF0BC6D67000878B42 /* CCHmacInit.3cc */; }; D6658DC20BD8178400D18063 /* CCHmacUpdate.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E00BC6D67000878B42 /* CCHmacUpdate.3cc */; }; D6658DC30BD8178400D18063 /* CCryptorCreateFromData.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E10BC6D67000878B42 /* CCryptorCreateFromData.3cc */; }; D6658DC40BD8178400D18063 /* Common Crypto.3cc in CopyFiles */ = {isa = PBXBuildFile; fileRef = D671B5E20BC6D67000878B42 /* Common Crypto.3cc */; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ 48165DB5125AC5D50015A267 /* PBXBuildRule */ = { isa = PBXBuildRule; compilerSpec = com.apple.compilers.gcc; fileType = sourcecode.c; isEditable = 1; outputFiles = ( ); }; 48165E98125AC5F20015A267 /* PBXBuildRule */ = { isa = PBXBuildRule; compilerSpec = com.apple.compilers.gcc; fileType = sourcecode.c; isEditable = 1; outputFiles = ( ); }; 48B5F5281361D6A500134C9F /* PBXBuildRule */ = { isa = PBXBuildRule; compilerSpec = com.apple.compilers.llvmgcc42; fileType = sourcecode.nasm; isEditable = 1; outputFiles = ( ); script = "$(DEVELOPER_BIN_DIR)/nasm\n"; }; B125268E0713742A00BB8157 /* PBXBuildRule */ = { isa = PBXBuildRule; compilerSpec = com.apple.compilers.llvmgcc42; fileType = sourcecode.c; isEditable = 1; outputFiles = ( ); }; /* End PBXBuildRule section */ /* Begin PBXContainerItemProxy section */ 0511C4620A3785340028BFC3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 05CE94290A3784D4007C91D6; remoteInfo = "Copy Open Source Docs"; }; 4823B10C14C101CC008F689F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 054BBEBD05F6A97700344873; remoteInfo = libCommonCryptoMacOSX; }; 4834A88314F47CA300438E3D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 48165CD7125AC5D50015A267; remoteInfo = libCommonCryptoMacIOS; }; 4C58A28C13281C2100A17BAC /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 48165CD7125AC5D50015A267; remoteInfo = libCommonCryptoMacIOS; }; 4CA675181332C17900C45A71 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 48165DBA125AC5F20015A267; remoteInfo = libCommonCryptoMacIOSSim; }; 5D936FFA110E7FFF006855B0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 054BBEA605F6A8DE00344873 /* Project object */; proxyType = 1; remoteGlobalIDString = 054BBEBD05F6A97700344873; remoteInfo = commonCrypto; }; /* End PBXContainerItemProxy section */ |
︙ | ︙ | |||
633 634 635 636 637 638 639 640 641 642 643 644 645 646 | 05CE942F0A37850A007C91D6 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; dstPath = /usr/local/OpenSourceLicenses/; dstSubfolderSpec = 0; files = ( 0511C47E0A37892C0028BFC3 /* CommonCrypto.txt in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; D6658DC80BD817B600D18063 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; dstPath = /usr/share/man/man3; | > > > > > > > > > > > > > > > > > > | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | 05CE942F0A37850A007C91D6 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; dstPath = /usr/local/OpenSourceLicenses/; dstSubfolderSpec = 0; files = ( 0511C47E0A37892C0028BFC3 /* CommonCrypto.txt in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; 4823B0DE14C10064008F689F /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = /usr/share/man/man1/; dstSubfolderSpec = 0; files = ( ); runOnlyForDeploymentPostprocessing = 1; }; 4834A87C14F47B6200438E3D /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = /usr/share/man/man1/; dstSubfolderSpec = 0; files = ( ); runOnlyForDeploymentPostprocessing = 1; }; D6658DC80BD817B600D18063 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; dstPath = /usr/share/man/man3; |
︙ | ︙ | |||
690 691 692 693 694 695 696 | D6658DBE0BD8178400D18063 /* CCCryptorUpdate.3cc in CopyFiles */, D6658DBF0BD8178400D18063 /* CCHmac.3cc in CopyFiles */, D6658DC00BD8178400D18063 /* CCHmacFinal.3cc in CopyFiles */, D6658DC10BD8178400D18063 /* CCHmacInit.3cc in CopyFiles */, D6658DC20BD8178400D18063 /* CCHmacUpdate.3cc in CopyFiles */, D6658DC30BD8178400D18063 /* CCryptorCreateFromData.3cc in CopyFiles */, D6658DC40BD8178400D18063 /* Common Crypto.3cc in CopyFiles */, | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > | > | | > | > > > > | > > | < > > > < < | | | < < < < < < < < < < | | < | | | | | | < < | < < < < | | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < | | | | < | | | | | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | | | | < < | < | | < < < < < | | < < < | | | | | | | | | | | | | < < < < < | < < < < < < < < < < | | | | | < < < | < | < | < | | | < | < < < | < < < | | | | | > | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | D6658DBE0BD8178400D18063 /* CCCryptorUpdate.3cc in CopyFiles */, D6658DBF0BD8178400D18063 /* CCHmac.3cc in CopyFiles */, D6658DC00BD8178400D18063 /* CCHmacFinal.3cc in CopyFiles */, D6658DC10BD8178400D18063 /* CCHmacInit.3cc in CopyFiles */, D6658DC20BD8178400D18063 /* CCHmacUpdate.3cc in CopyFiles */, D6658DC30BD8178400D18063 /* CCryptorCreateFromData.3cc in CopyFiles */, D6658DC40BD8178400D18063 /* Common Crypto.3cc in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 054BBEBE05F6A97700344873 /* libcommonCrypto.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcommonCrypto.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 054BBEC605F6A98900344873 /* libcommonCrypto.dylib */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcommonCrypto.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 054BBECD05F6AA7200344873 /* CommonDigest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CommonDigest.h; sourceTree = "<group>"; }; 05CE942B0A37850A007C91D6 /* CommonCrypto.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = CommonCrypto.plist; path = doc/CommonCrypto.plist; sourceTree = "<group>"; }; 05CE942C0A37850A007C91D6 /* CommonCrypto.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CommonCrypto.txt; path = doc/CommonCrypto.txt; sourceTree = "<group>"; }; 05D8D97C09E411AA00E03504 /* CommonHMAC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonHMAC.h; sourceTree = "<group>"; }; 05D9F61609D85F4A00AD30A7 /* CommonCryptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptor.h; sourceTree = "<group>"; }; 05DF6D1109CF2D7200D9A3E8 /* CC_crypto.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_crypto.3cc; path = doc/CC_crypto.3cc; sourceTree = "<group>"; }; 05DF6D1209CF2D7200D9A3E8 /* CC_MD5.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD5.3cc; path = doc/CC_MD5.3cc; sourceTree = "<group>"; }; 05DF6D1309CF2D7200D9A3E8 /* CC_SHA.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_SHA.3cc; path = doc/CC_SHA.3cc; sourceTree = "<group>"; }; 12FA0DAF11F7962100917A4E /* CommonRandomSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonRandomSPI.h; sourceTree = "<group>"; }; 48096B2211A5EF900043F67F /* CommonDigest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonDigest.c; sourceTree = "<group>"; }; 48165DB9125AC5D50015A267 /* libcommonCrypto.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcommonCrypto.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 48165E9C125AC5F20015A267 /* libcommonCrypto_sim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcommonCrypto_sim.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 4823B0AE14C10022008F689F /* CCCryptorTestFuncs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CCCryptorTestFuncs.c; sourceTree = "<group>"; }; 4823B0AF14C10022008F689F /* CCCryptorTestFuncs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCCryptorTestFuncs.h; sourceTree = "<group>"; }; 4823B0B014C10022008F689F /* CommonBaseEncoding.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonBaseEncoding.c; sourceTree = "<group>"; }; 4823B0B114C10022008F689F /* CommonBigNum.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonBigNum.c; sourceTree = "<group>"; }; 4823B0B214C10022008F689F /* CommonCMac.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCMac.c; sourceTree = "<group>"; }; 4823B0B314C10022008F689F /* CommonCryptoCTSPadding.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoCTSPadding.c; sourceTree = "<group>"; }; 4823B0B414C10022008F689F /* CommonCryptoSymCBC.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymCBC.c; sourceTree = "<group>"; }; 4823B0B514C10022008F689F /* CommonCryptoSymGCM.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymGCM.c; sourceTree = "<group>"; }; 4823B0B614C10022008F689F /* CommonCryptoSymmetricWrap.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymmetricWrap.c; sourceTree = "<group>"; }; 4823B0B714C10022008F689F /* CommonCryptoSymOFB.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymOFB.c; sourceTree = "<group>"; }; 4823B0B814C10022008F689F /* CommonCryptoSymOffset.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymOffset.c; sourceTree = "<group>"; }; 4823B0B914C10022008F689F /* CommonCryptoSymRC2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymRC2.c; sourceTree = "<group>"; }; 4823B0BA14C10022008F689F /* CommonCryptoSymRegression.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymRegression.c; sourceTree = "<group>"; }; 4823B0BB14C10022008F689F /* CommonCryptoSymXTS.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymXTS.c; sourceTree = "<group>"; }; 4823B0BC14C10022008F689F /* CommonCryptoSymZeroLength.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymZeroLength.c; sourceTree = "<group>"; }; 4823B0BD14C10022008F689F /* CommonDigest.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonDigest.c; sourceTree = "<group>"; }; 4823B0BE14C10022008F689F /* CommonEC.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonEC.c; sourceTree = "<group>"; }; 4823B0BF14C10022008F689F /* CommonHMacClone.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonHMacClone.c; sourceTree = "<group>"; }; 4823B0C014C10022008F689F /* CommonRandom.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonRandom.c; sourceTree = "<group>"; }; 4823B0C114C10022008F689F /* CommonRSA.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CommonRSA.c; sourceTree = "<group>"; }; 4823B0C314C10022008F689F /* CryptorPadFailure.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CryptorPadFailure.c; sourceTree = "<group>"; }; 4823B0C614C10022008F689F /* Run3.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = Run3.pm; sourceTree = "<group>"; }; 4823B0C714C10022008F689F /* MyHarness.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = MyHarness.pm; sourceTree = "<group>"; }; 4823B0C814C10022008F689F /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; }; 4823B0C914C10022008F689F /* README */ = {isa = PBXFileReference; lastKnownFileType = text; path = README; sourceTree = "<group>"; }; 4823B0CB14C10022008F689F /* security.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = security.pl; sourceTree = "<group>"; }; 4823B0CD14C10022008F689F /* 00testtest.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = 00testtest.c; sourceTree = "<group>"; }; 4823B0CE14C10022008F689F /* run_tests.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = run_tests.sh; sourceTree = "<group>"; }; 4823B0CF14C10022008F689F /* testcpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testcpp.h; sourceTree = "<group>"; }; 4823B0D014C10022008F689F /* testenv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testenv.c; sourceTree = "<group>"; }; 4823B0D114C10022008F689F /* testenv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testenv.h; sourceTree = "<group>"; }; 4823B0D214C10022008F689F /* testlist.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testlist.c; sourceTree = "<group>"; }; 4823B0D314C10022008F689F /* testlist.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testlist.h; sourceTree = "<group>"; }; 4823B0D414C10022008F689F /* testlistInc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testlistInc.h; sourceTree = "<group>"; }; 4823B0D514C10022008F689F /* testmore.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testmore.c; sourceTree = "<group>"; }; 4823B0D614C10022008F689F /* testmore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testmore.h; sourceTree = "<group>"; }; 4823B0D814C10022008F689F /* testbyteBuffer.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testbyteBuffer.c; sourceTree = "<group>"; }; 4823B0D914C10022008F689F /* testbyteBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testbyteBuffer.h; sourceTree = "<group>"; }; 4823B0DA14C10022008F689F /* capabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = capabilities.h; sourceTree = "<group>"; }; 4823B0E014C10064008F689F /* CCRegression */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CCRegression; sourceTree = BUILT_PRODUCTS_DIR; }; 4825AAF31314CDCD00413A64 /* CommonBigNum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonBigNum.h; sourceTree = "<group>"; }; 4834A85214F47A9400438E3D /* libcorecrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcorecrypto.dylib; path = usr/lib/system/libcorecrypto.dylib; sourceTree = SDKROOT; }; 4834A88014F47B6200438E3D /* CCRegression copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "CCRegression copy"; sourceTree = BUILT_PRODUCTS_DIR; }; 4836A41A11A5C94A00862178 /* CommonCryptoPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoPriv.h; sourceTree = "<group>"; }; 4836A42B11A5CB4700862178 /* CommonCryptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptor.c; sourceTree = "<group>"; }; 4836A42C11A5CB4700862178 /* CommonCryptorPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptorPriv.h; sourceTree = "<group>"; }; 4836A42D11A5CB4700862178 /* CommonDigestPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonDigestPriv.h; sourceTree = "<group>"; }; 4836A42E11A5CB4700862178 /* CommonHMAC.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonHMAC.c; sourceTree = "<group>"; }; 4836A42F11A5CB4700862178 /* CommonKeyDerivation.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonKeyDerivation.c; sourceTree = "<group>"; }; 4836A43111A5CB4700862178 /* CommonSymmetricKeywrap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonSymmetricKeywrap.c; sourceTree = "<group>"; }; 4846CA5411A5C8B800E7DA82 /* CommonCryptorSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptorSPI.h; sourceTree = "<group>"; }; 4846CA5511A5C8B800E7DA82 /* CommonDigestSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonDigestSPI.h; sourceTree = "<group>"; }; 484D40FE14DC96A600C93734 /* libcorecrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcorecrypto.dylib; path = ../../../../../../usr/lib/system/libcorecrypto.dylib; sourceTree = "<group>"; }; 4852C2491505F8CD00676BCC /* CommonCryptoSymCFB.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymCFB.c; sourceTree = "<group>"; }; 4854BAD5152177CC007B5B08 /* CommonCryptoSymCTR.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptoSymCTR.c; sourceTree = "<group>"; }; 4854F9C01116307500CAFA18 /* CommonKeyDerivation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonKeyDerivation.h; sourceTree = "<group>"; }; 4854F9C11116307500CAFA18 /* CommonSymmetricKeywrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonSymmetricKeywrap.h; sourceTree = "<group>"; }; 4857A12A11BDA6E0001F5A9A /* libSystem.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSystem.dylib; path = usr/lib/libSystem.dylib; sourceTree = SDKROOT; }; 4857A13011BDA737001F5A9A /* System.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = System.framework; path = /System/Library/Frameworks/System.framework; sourceTree = "<absolute>"; }; 485FED4A131475A400FF0F82 /* CommonBigNumPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonBigNumPriv.h; sourceTree = "<group>"; }; 485FED4B131475A400FF0F82 /* CommonBigNum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonBigNum.c; sourceTree = "<group>"; }; 486130D7126681290036EA02 /* CC_base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_base.xcconfig; sourceTree = "<group>"; }; 486130D8126681290036EA02 /* CC_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_deployment.xcconfig; sourceTree = "<group>"; }; 486130D9126681290036EA02 /* CC_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_development.xcconfig; sourceTree = "<group>"; }; 486130DA126681290036EA02 /* CC_dynamic.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_dynamic.xcconfig; sourceTree = "<group>"; }; 486130DB126681290036EA02 /* CC_dynamic_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_dynamic_deployment.xcconfig; sourceTree = "<group>"; }; 486130DC126681290036EA02 /* CC_dynamic_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_dynamic_development.xcconfig; sourceTree = "<group>"; }; 486130DD126681290036EA02 /* CC_static.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_static.xcconfig; sourceTree = "<group>"; }; 486130DE126681290036EA02 /* CC_static_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_static_deployment.xcconfig; sourceTree = "<group>"; }; 486130DF126681290036EA02 /* CC_static_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_static_development.xcconfig; sourceTree = "<group>"; }; 486130E0126681290036EA02 /* CC_umbrellaMember.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_umbrellaMember.xcconfig; sourceTree = "<group>"; }; 486130E2126681290036EA02 /* CC_iOSClient.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSClient.xcconfig; sourceTree = "<group>"; }; 486130E3126681290036EA02 /* CC_iOSClientSim.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSClientSim.xcconfig; sourceTree = "<group>"; }; 486130E5126681290036EA02 /* CC_MacOSXClient.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_MacOSXClient.xcconfig; sourceTree = "<group>"; }; 486130E8126681290036EA02 /* CC_iOSClient_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSClient_deployment.xcconfig; sourceTree = "<group>"; }; 486130E9126681290036EA02 /* CC_iOSClient_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSClient_development.xcconfig; sourceTree = "<group>"; }; 486130EC126681290036EA02 /* CC_iOSSim_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSSim_deployment.xcconfig; sourceTree = "<group>"; }; 486130ED126681290036EA02 /* CC_iOSSim_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_iOSSim_development.xcconfig; sourceTree = "<group>"; }; 486130EE126681290036EA02 /* CC_MacOSXClient_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_MacOSXClient_deployment.xcconfig; sourceTree = "<group>"; }; 486130EF126681290036EA02 /* CC_MacOSXClient_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_MacOSXClient_development.xcconfig; sourceTree = "<group>"; }; 486130F3126681290036EA02 /* CC_localtest.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_localtest.xcconfig; sourceTree = "<group>"; }; 486130F4126681290036EA02 /* CC_unittest_base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_base.xcconfig; sourceTree = "<group>"; }; 486130F5126681290036EA02 /* CC_unittest_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_deployment.xcconfig; sourceTree = "<group>"; }; 486130F6126681290036EA02 /* CC_unittest_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_development.xcconfig; sourceTree = "<group>"; }; 486130F7126681290036EA02 /* CC_unittest_dynamic_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_dynamic_deployment.xcconfig; sourceTree = "<group>"; }; 486130F8126681290036EA02 /* CC_unitTest_dynamic_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unitTest_dynamic_development.xcconfig; sourceTree = "<group>"; }; 486130F9126681290036EA02 /* CC_unittest_static_deployment.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_static_deployment.xcconfig; sourceTree = "<group>"; }; 486130FA126681290036EA02 /* CC_unittest_static_development.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CC_unittest_static_development.xcconfig; sourceTree = "<group>"; }; 48685583127B63F200B88D39 /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = "<group>"; }; 48685586127B641800B88D39 /* CommonCryptoAESShoefly.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptoAESShoefly.c; sourceTree = "<group>"; }; 4868BB1314B7C7F300072488 /* corecryptoSymmetricBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = corecryptoSymmetricBridge.h; sourceTree = "<group>"; }; 486BE17C14E6019B00346AC4 /* CommonCryptoReset.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptoReset.c; sourceTree = "<group>"; }; 4873A7271445099D0011B4FA /* CommonCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCrypto.h; sourceTree = "<group>"; }; 489D982C11A4E8C20004DB89 /* ccdebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccdebug.c; sourceTree = "<group>"; }; 489D982D11A4E8C20004DB89 /* ccdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccdebug.h; sourceTree = "<group>"; }; 489E06F814B7AB0800B0A282 /* corecryptoSymmetricBridge.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = corecryptoSymmetricBridge.c; sourceTree = "<group>"; }; 489EECA2149809A800B44D5A /* asn1Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1Types.h; sourceTree = "<group>"; }; 489EECA3149809A800B44D5A /* DER_CertCrl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_CertCrl.c; sourceTree = "<group>"; }; 489EECA4149809A800B44D5A /* DER_CertCrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_CertCrl.h; sourceTree = "<group>"; }; 489EECA5149809A800B44D5A /* DER_Decode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Decode.c; sourceTree = "<group>"; }; 489EECA6149809A800B44D5A /* DER_Decode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Decode.h; sourceTree = "<group>"; }; 489EECA7149809A800B44D5A /* DER_Digest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Digest.c; sourceTree = "<group>"; }; 489EECA8149809A800B44D5A /* DER_Digest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Digest.h; sourceTree = "<group>"; }; 489EECA9149809A800B44D5A /* DER_Encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Encode.c; sourceTree = "<group>"; }; 489EECAA149809A800B44D5A /* DER_Encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Encode.h; sourceTree = "<group>"; }; 489EECAB149809A800B44D5A /* DER_Keys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Keys.c; sourceTree = "<group>"; }; 489EECAC149809A800B44D5A /* DER_Keys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Keys.h; sourceTree = "<group>"; }; 489EECAD149809A800B44D5A /* libDER.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libDER.h; sourceTree = "<group>"; }; 489EECAE149809A800B44D5A /* libDER_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libDER_config.h; sourceTree = "<group>"; }; 489EECAF149809A800B44D5A /* oids.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = oids.c; sourceTree = "<group>"; }; 489EECB0149809A800B44D5A /* oids.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = oids.h; sourceTree = "<group>"; }; 489F2441141AA3D0005E80FD /* CommonCMAC.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCMAC.c; sourceTree = "<group>"; }; 489FD30B13187B1D00ACB86D /* CommonHMacSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonHMacSPI.h; sourceTree = "<group>"; }; 48A5CBA0131EE096002A6E85 /* CommonGCMCryptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonGCMCryptor.c; sourceTree = "<group>"; }; 48AC47CD1381EFDC00F584F5 /* byteBuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = byteBuffer.c; sourceTree = "<group>"; }; 48AC47CE1381EFDC00F584F5 /* byteBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = byteBuffer.h; sourceTree = "<group>"; }; 48B4651112848FB800311799 /* CommonRSACryptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonRSACryptor.h; sourceTree = "<group>"; }; 48B4651B1284907600311799 /* CommonRSACryptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonRSACryptor.c; sourceTree = "<group>"; }; 48C5CB9114FD747500F4472E /* CommonDHtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonDHtest.c; sourceTree = "<group>"; }; 48CCD26414F6F189002B6043 /* CommonBigDigest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonBigDigest.c; sourceTree = "<group>"; }; 48D076C0130B2A510052D1AC /* CommonDH.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonDH.h; sourceTree = "<group>"; }; 48D076C7130B2A620052D1AC /* CommonECCryptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonECCryptor.h; sourceTree = "<group>"; }; 48D076CE130B2A9C0052D1AC /* CommonDH.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonDH.c; sourceTree = "<group>"; }; 48D076CF130B2A9C0052D1AC /* CommonECCryptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonECCryptor.c; sourceTree = "<group>"; }; 48E93DCA136867F500B33DB8 /* CommonCMACSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCMACSPI.h; sourceTree = "<group>"; }; 48F5355214902894000D2D1F /* CommonRandom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonRandom.c; sourceTree = "<group>"; }; 48FC4BD513959D0600DA4760 /* lionCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lionCompat.h; sourceTree = "<group>"; }; 48FC4BD71395ACE600DA4760 /* CommonCryptoCASTShoefly.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CommonCryptoCASTShoefly.c; sourceTree = "<group>"; }; 48FD6C371354DD4000F55B8B /* ccErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccErrors.h; sourceTree = "<group>"; }; 48FD6C381354DD4000F55B8B /* ccMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccMemory.h; sourceTree = "<group>"; }; 48FD6C631354E06A00F55B8B /* CommonCrypto.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = CommonCrypto.exp; sourceTree = "<group>"; }; 48FD6C641354E06A00F55B8B /* CommonCryptoIOS5.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = CommonCryptoIOS5.exp; sourceTree = "<group>"; }; 5D8037A514FECB5900E93214 /* libcorecrypto_sim.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcorecrypto_sim.dylib; path = Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/system/libcorecrypto_sim.dylib; sourceTree = DEVELOPER_DIR; }; D671B5B60BC6D67000878B42 /* CC_MD2.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD2.3cc; path = doc/CC_MD2.3cc; sourceTree = "<group>"; }; D671B5B70BC6D67000878B42 /* CC_MD2_Final.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD2_Final.3cc; path = doc/CC_MD2_Final.3cc; sourceTree = "<group>"; }; D671B5B80BC6D67000878B42 /* CC_MD2_Init.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD2_Init.3cc; path = doc/CC_MD2_Init.3cc; sourceTree = "<group>"; }; D671B5B90BC6D67000878B42 /* CC_MD2_Update.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD2_Update.3cc; path = doc/CC_MD2_Update.3cc; sourceTree = "<group>"; }; D671B5BA0BC6D67000878B42 /* CC_MD4.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD4.3cc; path = doc/CC_MD4.3cc; sourceTree = "<group>"; }; D671B5BB0BC6D67000878B42 /* CC_MD4_Final.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD4_Final.3cc; path = doc/CC_MD4_Final.3cc; sourceTree = "<group>"; }; D671B5BC0BC6D67000878B42 /* CC_MD4_Init.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CC_MD4_Init.3cc; path = doc/CC_MD4_Init.3cc; sourceTree = "<group>"; }; |
︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 | D671B5DF0BC6D67000878B42 /* CCHmacInit.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCHmacInit.3cc; path = doc/CCHmacInit.3cc; sourceTree = "<group>"; }; D671B5E00BC6D67000878B42 /* CCHmacUpdate.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCHmacUpdate.3cc; path = doc/CCHmacUpdate.3cc; sourceTree = "<group>"; }; D671B5E10BC6D67000878B42 /* CCryptorCreateFromData.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCryptorCreateFromData.3cc; path = doc/CCryptorCreateFromData.3cc; sourceTree = "<group>"; }; D671B5E20BC6D67000878B42 /* Common Crypto.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "Common Crypto.3cc"; path = "doc/Common Crypto.3cc"; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ | | < | | | < | < < | | < < | | > > > < | | < > | > | < < < < < < | | > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | D671B5DF0BC6D67000878B42 /* CCHmacInit.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCHmacInit.3cc; path = doc/CCHmacInit.3cc; sourceTree = "<group>"; }; D671B5E00BC6D67000878B42 /* CCHmacUpdate.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCHmacUpdate.3cc; path = doc/CCHmacUpdate.3cc; sourceTree = "<group>"; }; D671B5E10BC6D67000878B42 /* CCryptorCreateFromData.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = CCryptorCreateFromData.3cc; path = doc/CCryptorCreateFromData.3cc; sourceTree = "<group>"; }; D671B5E20BC6D67000878B42 /* Common Crypto.3cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "Common Crypto.3cc"; path = "doc/Common Crypto.3cc"; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 4823B0DD14C10064008F689F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 4834A87A14F47B6200438E3D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4834A88214F47C9A00438E3D /* libcommonCrypto.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 48CCF15612FA99B600D6DAE9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4834A85314F47A9400438E3D /* libcorecrypto.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 4CA674F41331747E00C45A71 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; EEB70419131C5BCB007CF918 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 484D40FF14DC96A600C93734 /* libcorecrypto.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 054BBEA205F6A8DE00344873 = { isa = PBXGroup; children = ( 5D8037A514FECB5900E93214 /* libcorecrypto_sim.dylib */, 4834A85214F47A9400438E3D /* libcorecrypto.dylib */, 484D40FE14DC96A600C93734 /* libcorecrypto.dylib */, 48FD6C621354E06A00F55B8B /* Exports */, 5DB4936310FBC4E200E45951 /* Configurations */, 054BBEB105F6A90E00344873 /* Public Headers */, 054BBEB405F6A91E00344873 /* Source */, 05DF6D0E09CF2D5B00D9A3E8 /* Doc */, 4823B0AC14C10022008F689F /* CCRegression */, 054BBEBF05F6A97700344873 /* Products */, 4857A12A11BDA6E0001F5A9A /* libSystem.dylib */, 4857A13011BDA737001F5A9A /* System.framework */, ); sourceTree = "<group>"; }; 054BBEB105F6A90E00344873 /* Public Headers */ = { isa = PBXGroup; children = ( 4854F9C01116307500CAFA18 /* CommonKeyDerivation.h */, 4854F9C11116307500CAFA18 /* CommonSymmetricKeywrap.h */, 054BBECD05F6AA7200344873 /* CommonDigest.h */, 05D9F61609D85F4A00AD30A7 /* CommonCryptor.h */, 05D8D97C09E411AA00E03504 /* CommonHMAC.h */, 4873A7271445099D0011B4FA /* CommonCrypto.h */, ); name = "Public Headers"; path = CommonCrypto; sourceTree = "<group>"; }; 054BBEB405F6A91E00344873 /* Source */ = { isa = PBXGroup; children = ( 489EECA1149809A800B44D5A /* libDER */, 48CA258512C149EF002330C4 /* descriptors */, 4836A42A11A5CB4700862178 /* API */, 4846CA5311A5C8B800E7DA82 /* SPI */, 489D982B11A4E8C20004DB89 /* ccUtilities */, ); path = Source; sourceTree = "<group>"; }; 054BBEBF05F6A97700344873 /* Products */ = { isa = PBXGroup; children = ( 054BBEBE05F6A97700344873 /* libcommonCrypto.dylib */, 054BBEC605F6A98900344873 /* libcommonCrypto.dylib */, 48165DB9125AC5D50015A267 /* libcommonCrypto.dylib */, 48165E9C125AC5F20015A267 /* libcommonCrypto_sim.dylib */, 4823B0E014C10064008F689F /* CCRegression */, 4834A88014F47B6200438E3D /* CCRegression copy */, ); name = Products; sourceTree = "<group>"; }; 05DF6D0E09CF2D5B00D9A3E8 /* Doc */ = { isa = PBXGroup; children = ( D671B5B60BC6D67000878B42 /* CC_MD2.3cc */, D671B5B70BC6D67000878B42 /* CC_MD2_Final.3cc */, D671B5B80BC6D67000878B42 /* CC_MD2_Init.3cc */, D671B5B90BC6D67000878B42 /* CC_MD2_Update.3cc */, D671B5BA0BC6D67000878B42 /* CC_MD4.3cc */, D671B5BB0BC6D67000878B42 /* CC_MD4_Final.3cc */, D671B5BC0BC6D67000878B42 /* CC_MD4_Init.3cc */, |
︙ | ︙ | |||
1264 1265 1266 1267 1268 1269 1270 | 05DF6D1109CF2D7200D9A3E8 /* CC_crypto.3cc */, 05DF6D1209CF2D7200D9A3E8 /* CC_MD5.3cc */, 05DF6D1309CF2D7200D9A3E8 /* CC_SHA.3cc */, ); name = Doc; sourceTree = "<group>"; }; | | | | | | | < | < | | < > > > > > | > > | | < > | | < > | | | | | | | | | > > > > | | | | < > | | > | > > | | | | < < < < < < < | | > > | | > > > > > > < | | | | > < | | > > > < > > | > > > > | > > > > | > > | | < > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | | | | < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < | < < < < < < < < < > | | < > | | < > | < < < < < < < | < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < | | | < | | | < < < < | < < | > | | | | | | | < > | | < < | < | < < < | | | < < > > | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > < < < < < < < < < < < < < | | < | < < | | | | | | | | | | | < < < | < < < | | | | < < < < | | | | | | < | < | < | | < < | > | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | > > > | > > > | | | | | | | | | | | | < | | | < | > > | | | | | | | | | | < < < > | | | | > | | > > | < > | < < < < < < < < < < < < < < < < < > | | > < | | | | | | | | > | | | | | | | | | < | | | | < > | < | | < | < < < < < < < < < < < < < < | | | | > > > | > | < < < < | | > > | | | | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | < < < | < < < < < | | < < < < | | | < | | | | < | < < | | | | | < < < > | > | < | > > | | < < < > > > > > > > > > > > > | < < < | | < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | < < | < < | | | < | < | < < < | < > | < > | | | | | | | | | < | | | | | < < < < < < < < | | | | | | < | | | | | | | | < | | | < | < < | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < | > | < | < | > | | | > | > | | > | | | < < < > > > | | < > > | > > | > > | | | | | | | | | | < < < < < < < < < < | | | < < < < < | | < < < < < < < < < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < | | < < < < < | > < < < < < < < < < < < < < < < < | < < < < < < | < | | | | > > > > > > > | | | | | > > > > > > | | > < > | > | | | > > | > | | | > > > > > | | | | | > > | > > > | < < < < > > > > | | > | | > > | > > | < < | > > | | | | < | | > | < > > | > > > > > > | > > > | < > > > > > > | < | < | > > > | > > > > > | > > | > | | | < | < | > > | | < > > | | < < < | < | | | | > | > > > > > > > > > | > | > | | | | | | < > > > | > > > | > > | > > | < | | | | | | > | > > > > | | < | | | > > > > > > > < > > > > > | | | | | | | | | | | | | | | | | | | | < < < < < < < < < | | | | | | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 | 05DF6D1109CF2D7200D9A3E8 /* CC_crypto.3cc */, 05DF6D1209CF2D7200D9A3E8 /* CC_MD5.3cc */, 05DF6D1309CF2D7200D9A3E8 /* CC_SHA.3cc */, ); name = Doc; sourceTree = "<group>"; }; 4823B0AC14C10022008F689F /* CCRegression */ = { isa = PBXGroup; children = ( 4823B0AD14C10022008F689F /* CommonCrypto */, 4823B0C414C10022008F689F /* inc */, 4823B0C814C10022008F689F /* main.c */, 4823B0C914C10022008F689F /* README */, 4823B0CA14C10022008F689F /* runscript */, 4823B0CC14C10022008F689F /* test */, 4823B0D714C10022008F689F /* util */, ); path = CCRegression; sourceTree = "<group>"; }; 4823B0AD14C10022008F689F /* CommonCrypto */ = { isa = PBXGroup; children = ( 4823B0AE14C10022008F689F /* CCCryptorTestFuncs.c */, 4823B0AF14C10022008F689F /* CCCryptorTestFuncs.h */, 4823B0B014C10022008F689F /* CommonBaseEncoding.c */, 4823B0B114C10022008F689F /* CommonBigNum.c */, 4823B0B214C10022008F689F /* CommonCMac.c */, 4823B0B314C10022008F689F /* CommonCryptoCTSPadding.c */, 4823B0B414C10022008F689F /* CommonCryptoSymCBC.c */, 4823B0B514C10022008F689F /* CommonCryptoSymGCM.c */, 4823B0B614C10022008F689F /* CommonCryptoSymmetricWrap.c */, 4852C2491505F8CD00676BCC /* CommonCryptoSymCFB.c */, 4823B0B714C10022008F689F /* CommonCryptoSymOFB.c */, 4823B0B814C10022008F689F /* CommonCryptoSymOffset.c */, 4823B0B914C10022008F689F /* CommonCryptoSymRC2.c */, 4823B0BA14C10022008F689F /* CommonCryptoSymRegression.c */, 486BE17C14E6019B00346AC4 /* CommonCryptoReset.c */, 4823B0BB14C10022008F689F /* CommonCryptoSymXTS.c */, 4823B0BC14C10022008F689F /* CommonCryptoSymZeroLength.c */, 4823B0BD14C10022008F689F /* CommonDigest.c */, 4823B0BE14C10022008F689F /* CommonEC.c */, 4823B0BF14C10022008F689F /* CommonHMacClone.c */, 4823B0C014C10022008F689F /* CommonRandom.c */, 4823B0C114C10022008F689F /* CommonRSA.c */, 4823B0C314C10022008F689F /* CryptorPadFailure.c */, 48CCD26414F6F189002B6043 /* CommonBigDigest.c */, 48C5CB9114FD747500F4472E /* CommonDHtest.c */, 4854BAD5152177CC007B5B08 /* CommonCryptoSymCTR.c */, ); path = CommonCrypto; sourceTree = "<group>"; }; 4823B0C414C10022008F689F /* inc */ = { isa = PBXGroup; children = ( 4823B0C514C10022008F689F /* IPC */, 4823B0C714C10022008F689F /* MyHarness.pm */, ); path = inc; sourceTree = "<group>"; }; 4823B0C514C10022008F689F /* IPC */ = { isa = PBXGroup; children = ( 4823B0C614C10022008F689F /* Run3.pm */, ); path = IPC; sourceTree = "<group>"; }; 4823B0CA14C10022008F689F /* runscript */ = { isa = PBXGroup; children = ( 4823B0CB14C10022008F689F /* security.pl */, ); path = runscript; sourceTree = "<group>"; }; 4823B0CC14C10022008F689F /* test */ = { isa = PBXGroup; children = ( 4823B0CD14C10022008F689F /* 00testtest.c */, 4823B0CE14C10022008F689F /* run_tests.sh */, 4823B0CF14C10022008F689F /* testcpp.h */, 4823B0D014C10022008F689F /* testenv.c */, 4823B0D114C10022008F689F /* testenv.h */, 4823B0D214C10022008F689F /* testlist.c */, 4823B0D314C10022008F689F /* testlist.h */, 4823B0D414C10022008F689F /* testlistInc.h */, 4823B0D514C10022008F689F /* testmore.c */, 4823B0D614C10022008F689F /* testmore.h */, ); path = test; sourceTree = "<group>"; }; 4823B0D714C10022008F689F /* util */ = { isa = PBXGroup; children = ( 4823B0D814C10022008F689F /* testbyteBuffer.c */, 4823B0D914C10022008F689F /* testbyteBuffer.h */, 4823B0DA14C10022008F689F /* capabilities.h */, ); path = util; sourceTree = "<group>"; }; 4836A42A11A5CB4700862178 /* API */ = { isa = PBXGroup; children = ( 489F2441141AA3D0005E80FD /* CommonCMAC.c */, 48A5CBA0131EE096002A6E85 /* CommonGCMCryptor.c */, 48685586127B641800B88D39 /* CommonCryptoAESShoefly.c */, 48FC4BD71395ACE600DA4760 /* CommonCryptoCASTShoefly.c */, 4836A42B11A5CB4700862178 /* CommonCryptor.c */, 4836A42C11A5CB4700862178 /* CommonCryptorPriv.h */, 4836A42E11A5CB4700862178 /* CommonHMAC.c */, 4836A42F11A5CB4700862178 /* CommonKeyDerivation.c */, 4836A43111A5CB4700862178 /* CommonSymmetricKeywrap.c */, 4836A42D11A5CB4700862178 /* CommonDigestPriv.h */, 48096B2211A5EF900043F67F /* CommonDigest.c */, 48B4651B1284907600311799 /* CommonRSACryptor.c */, 48D076CF130B2A9C0052D1AC /* CommonECCryptor.c */, 48D076CE130B2A9C0052D1AC /* CommonDH.c */, 485FED4A131475A400FF0F82 /* CommonBigNumPriv.h */, 485FED4B131475A400FF0F82 /* CommonBigNum.c */, 48F5355214902894000D2D1F /* CommonRandom.c */, ); path = API; sourceTree = "<group>"; }; 4846CA5311A5C8B800E7DA82 /* SPI */ = { isa = PBXGroup; children = ( 48FC4BD513959D0600DA4760 /* lionCompat.h */, 48E93DCA136867F500B33DB8 /* CommonCMACSPI.h */, 48685583127B63F200B88D39 /* aes.h */, 4836A41A11A5C94A00862178 /* CommonCryptoPriv.h */, 4846CA5411A5C8B800E7DA82 /* CommonCryptorSPI.h */, 4846CA5511A5C8B800E7DA82 /* CommonDigestSPI.h */, 12FA0DAF11F7962100917A4E /* CommonRandomSPI.h */, 48B4651112848FB800311799 /* CommonRSACryptor.h */, 48D076C7130B2A620052D1AC /* CommonECCryptor.h */, 48D076C0130B2A510052D1AC /* CommonDH.h */, 489FD30B13187B1D00ACB86D /* CommonHMacSPI.h */, 4825AAF31314CDCD00413A64 /* CommonBigNum.h */, ); name = SPI; path = CommonCryptoSPI; sourceTree = "<group>"; }; 486130D6126681290036EA02 /* components */ = { isa = PBXGroup; children = ( 486130D7126681290036EA02 /* CC_base.xcconfig */, 486130D8126681290036EA02 /* CC_deployment.xcconfig */, 486130D9126681290036EA02 /* CC_development.xcconfig */, 486130DA126681290036EA02 /* CC_dynamic.xcconfig */, 486130DB126681290036EA02 /* CC_dynamic_deployment.xcconfig */, 486130DC126681290036EA02 /* CC_dynamic_development.xcconfig */, 486130DD126681290036EA02 /* CC_static.xcconfig */, 486130DE126681290036EA02 /* CC_static_deployment.xcconfig */, 486130DF126681290036EA02 /* CC_static_development.xcconfig */, 486130E0126681290036EA02 /* CC_umbrellaMember.xcconfig */, ); name = components; path = Configurations/components; sourceTree = "<group>"; }; 486130E1126681290036EA02 /* platforms */ = { isa = PBXGroup; children = ( 486130E2126681290036EA02 /* CC_iOSClient.xcconfig */, 486130E3126681290036EA02 /* CC_iOSClientSim.xcconfig */, 486130E5126681290036EA02 /* CC_MacOSXClient.xcconfig */, ); name = platforms; path = Configurations/platforms; sourceTree = "<group>"; }; 486130E7126681290036EA02 /* targets */ = { isa = PBXGroup; children = ( 486130E8126681290036EA02 /* CC_iOSClient_deployment.xcconfig */, 486130E9126681290036EA02 /* CC_iOSClient_development.xcconfig */, 486130EC126681290036EA02 /* CC_iOSSim_deployment.xcconfig */, 486130ED126681290036EA02 /* CC_iOSSim_development.xcconfig */, 486130EE126681290036EA02 /* CC_MacOSXClient_deployment.xcconfig */, 486130EF126681290036EA02 /* CC_MacOSXClient_development.xcconfig */, ); name = targets; path = Configurations/targets; sourceTree = "<group>"; }; 486130F2126681290036EA02 /* tests */ = { isa = PBXGroup; children = ( 486130F3126681290036EA02 /* CC_localtest.xcconfig */, 486130F4126681290036EA02 /* CC_unittest_base.xcconfig */, 486130F5126681290036EA02 /* CC_unittest_deployment.xcconfig */, 486130F6126681290036EA02 /* CC_unittest_development.xcconfig */, 486130F7126681290036EA02 /* CC_unittest_dynamic_deployment.xcconfig */, 486130F8126681290036EA02 /* CC_unitTest_dynamic_development.xcconfig */, 486130F9126681290036EA02 /* CC_unittest_static_deployment.xcconfig */, 486130FA126681290036EA02 /* CC_unittest_static_development.xcconfig */, ); name = tests; path = Configurations/tests; sourceTree = "<group>"; }; 489D982B11A4E8C20004DB89 /* ccUtilities */ = { isa = PBXGroup; children = ( 48AC47CD1381EFDC00F584F5 /* byteBuffer.c */, 48AC47CE1381EFDC00F584F5 /* byteBuffer.h */, 48FD6C371354DD4000F55B8B /* ccErrors.h */, 48FD6C381354DD4000F55B8B /* ccMemory.h */, 489D982C11A4E8C20004DB89 /* ccdebug.c */, 489D982D11A4E8C20004DB89 /* ccdebug.h */, ); path = ccUtilities; sourceTree = "<group>"; }; 489EECA1149809A800B44D5A /* libDER */ = { isa = PBXGroup; children = ( 489EECA2149809A800B44D5A /* asn1Types.h */, 489EECA3149809A800B44D5A /* DER_CertCrl.c */, 489EECA4149809A800B44D5A /* DER_CertCrl.h */, 489EECA5149809A800B44D5A /* DER_Decode.c */, 489EECA6149809A800B44D5A /* DER_Decode.h */, 489EECA7149809A800B44D5A /* DER_Digest.c */, 489EECA8149809A800B44D5A /* DER_Digest.h */, 489EECA9149809A800B44D5A /* DER_Encode.c */, 489EECAA149809A800B44D5A /* DER_Encode.h */, 489EECAB149809A800B44D5A /* DER_Keys.c */, 489EECAC149809A800B44D5A /* DER_Keys.h */, 489EECAD149809A800B44D5A /* libDER.h */, 489EECAE149809A800B44D5A /* libDER_config.h */, 489EECAF149809A800B44D5A /* oids.c */, 489EECB0149809A800B44D5A /* oids.h */, ); name = libDER; path = libDER/libDER; sourceTree = "<group>"; }; 48CA258512C149EF002330C4 /* descriptors */ = { isa = PBXGroup; children = ( 489E06F814B7AB0800B0A282 /* corecryptoSymmetricBridge.c */, 4868BB1314B7C7F300072488 /* corecryptoSymmetricBridge.h */, ); path = descriptors; sourceTree = "<group>"; }; 48FD6C621354E06A00F55B8B /* Exports */ = { isa = PBXGroup; children = ( 48FD6C631354E06A00F55B8B /* CommonCrypto.exp */, 48FD6C641354E06A00F55B8B /* CommonCryptoIOS5.exp */, ); name = Exports; path = Source/Exports; sourceTree = "<group>"; }; 5DB4936310FBC4E200E45951 /* Configurations */ = { isa = PBXGroup; children = ( 486130D6126681290036EA02 /* components */, 486130E1126681290036EA02 /* platforms */, 486130E7126681290036EA02 /* targets */, 486130F2126681290036EA02 /* tests */, ); name = Configurations; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 054BBEBA05F6A97700344873 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 4873A7281445099D0011B4FA /* CommonCrypto.h in Headers */, 054BBECE05F6AA7200344873 /* CommonDigest.h in Headers */, 05D9F61909D85F4A00AD30A7 /* CommonCryptor.h in Headers */, 05D8D97D09E411AB00E03504 /* CommonHMAC.h in Headers */, 4854F9C21116307500CAFA18 /* CommonKeyDerivation.h in Headers */, 4854F9C31116307500CAFA18 /* CommonSymmetricKeywrap.h in Headers */, 489FD30E13187B1D00ACB86D /* CommonHMacSPI.h in Headers */, 488FCCB3139D6DD7007F2FC4 /* aes.h in Headers */, 4836A43311A5CB4700862178 /* CommonCryptorPriv.h in Headers */, 4825AAF81314CDCD00413A64 /* CommonBigNum.h in Headers */, 48E93DCB136867F500B33DB8 /* CommonCMACSPI.h in Headers */, 48D076C3130B2A510052D1AC /* CommonDH.h in Headers */, 48D076CA130B2A620052D1AC /* CommonECCryptor.h in Headers */, 48B4651512848FB800311799 /* CommonRSACryptor.h in Headers */, 48FC4BD613959D0600DA4760 /* lionCompat.h in Headers */, 489D982F11A4E8C20004DB89 /* ccdebug.h in Headers */, 4846CA5611A5C8B800E7DA82 /* CommonCryptorSPI.h in Headers */, 4846CA5711A5C8B800E7DA82 /* CommonDigestSPI.h in Headers */, 4836A42111A5C94A00862178 /* CommonCryptoPriv.h in Headers */, 4836A43411A5CB4700862178 /* CommonDigestPriv.h in Headers */, 12FA0DB011F7962100917A4E /* CommonRandomSPI.h in Headers */, 485FED56131475A400FF0F82 /* CommonBigNumPriv.h in Headers */, 48FD6C401354DD4000F55B8B /* ccErrors.h in Headers */, 48FD6C411354DD4000F55B8B /* ccMemory.h in Headers */, 48AC47D51381EFDC00F584F5 /* byteBuffer.h in Headers */, 489EECB1149809A800B44D5A /* asn1Types.h in Headers */, 489EECB7149809A800B44D5A /* DER_CertCrl.h in Headers */, 489EECBD149809A800B44D5A /* DER_Decode.h in Headers */, 489EECC3149809A800B44D5A /* DER_Digest.h in Headers */, 489EECC9149809A800B44D5A /* DER_Encode.h in Headers */, 489EECCF149809A800B44D5A /* DER_Keys.h in Headers */, 489EECD2149809A800B44D5A /* libDER.h in Headers */, 489EECD5149809A800B44D5A /* libDER_config.h in Headers */, 489EECDB149809A800B44D5A /* oids.h in Headers */, 4868BB1414B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; 48165CD8125AC5D50015A267 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 4873A72A1445099D0011B4FA /* CommonCrypto.h in Headers */, 48165CD9125AC5D50015A267 /* CommonDigest.h in Headers */, 48165CDA125AC5D50015A267 /* CommonCryptor.h in Headers */, 48165CDB125AC5D50015A267 /* CommonHMAC.h in Headers */, 48165CDC125AC5D50015A267 /* CommonKeyDerivation.h in Headers */, 48165CDD125AC5D50015A267 /* CommonSymmetricKeywrap.h in Headers */, 48165CF0125AC5D50015A267 /* ccdebug.h in Headers */, 48165CF1125AC5D50015A267 /* CommonCryptorSPI.h in Headers */, 48165CF2125AC5D50015A267 /* CommonDigestSPI.h in Headers */, 48165CF3125AC5D50015A267 /* CommonCryptoPriv.h in Headers */, 48165CF4125AC5D50015A267 /* CommonCryptorPriv.h in Headers */, 48165CF5125AC5D50015A267 /* CommonDigestPriv.h in Headers */, 48165CF7125AC5D50015A267 /* CommonRandomSPI.h in Headers */, 48685584127B63F200B88D39 /* aes.h in Headers */, 48B4651412848FB800311799 /* CommonRSACryptor.h in Headers */, 48D076C1130B2A510052D1AC /* CommonDH.h in Headers */, 48D076C8130B2A620052D1AC /* CommonECCryptor.h in Headers */, 489FD30C13187B1D00ACB86D /* CommonHMacSPI.h in Headers */, 485FED54131475A400FF0F82 /* CommonBigNumPriv.h in Headers */, 4825AAF61314CDCD00413A64 /* CommonBigNum.h in Headers */, 48FD6C3A1354DD4000F55B8B /* ccErrors.h in Headers */, 48FD6C3B1354DD4000F55B8B /* ccMemory.h in Headers */, 48E93DCC136867F500B33DB8 /* CommonCMACSPI.h in Headers */, 48AC47D71381EFDC00F584F5 /* byteBuffer.h in Headers */, 489EECB2149809A800B44D5A /* asn1Types.h in Headers */, 489EECB8149809A800B44D5A /* DER_CertCrl.h in Headers */, 489EECBE149809A800B44D5A /* DER_Decode.h in Headers */, 489EECC4149809A800B44D5A /* DER_Digest.h in Headers */, 489EECCA149809A800B44D5A /* DER_Encode.h in Headers */, 489EECD0149809A800B44D5A /* DER_Keys.h in Headers */, 489EECD3149809A800B44D5A /* libDER.h in Headers */, 489EECD6149809A800B44D5A /* libDER_config.h in Headers */, 489EECDC149809A800B44D5A /* oids.h in Headers */, 4868BB1514B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; 48165DBB125AC5F20015A267 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 4873A72B1445099D0011B4FA /* CommonCrypto.h in Headers */, 48165DBC125AC5F20015A267 /* CommonDigest.h in Headers */, 48165DBD125AC5F20015A267 /* CommonCryptor.h in Headers */, 48165DBE125AC5F20015A267 /* CommonHMAC.h in Headers */, 48165DBF125AC5F20015A267 /* CommonKeyDerivation.h in Headers */, 48165DC0125AC5F20015A267 /* CommonSymmetricKeywrap.h in Headers */, 48165DD3125AC5F20015A267 /* ccdebug.h in Headers */, 48165DD4125AC5F20015A267 /* CommonCryptorSPI.h in Headers */, 48165DD5125AC5F20015A267 /* CommonDigestSPI.h in Headers */, 48165DD6125AC5F20015A267 /* CommonCryptoPriv.h in Headers */, 48165DD7125AC5F20015A267 /* CommonCryptorPriv.h in Headers */, 48165DD8125AC5F20015A267 /* CommonDigestPriv.h in Headers */, 48165DDA125AC5F20015A267 /* CommonRandomSPI.h in Headers */, 48B4651712848FB800311799 /* CommonRSACryptor.h in Headers */, 48D076C5130B2A510052D1AC /* CommonDH.h in Headers */, 48D076CC130B2A620052D1AC /* CommonECCryptor.h in Headers */, 489FD30F13187B1D00ACB86D /* CommonHMacSPI.h in Headers */, 485FED50131475A400FF0F82 /* CommonBigNumPriv.h in Headers */, 4825AAF71314CDCD00413A64 /* CommonBigNum.h in Headers */, 4CDDFB7E133BD3BA00B4770F /* aes.h in Headers */, 48FD6C431354DD4000F55B8B /* ccErrors.h in Headers */, 48FD6C441354DD4000F55B8B /* ccMemory.h in Headers */, 48E93DCD136867F500B33DB8 /* CommonCMACSPI.h in Headers */, 48AC47D81381EFDC00F584F5 /* byteBuffer.h in Headers */, 489EECB3149809A800B44D5A /* asn1Types.h in Headers */, 489EECB9149809A800B44D5A /* DER_CertCrl.h in Headers */, 489EECBF149809A800B44D5A /* DER_Decode.h in Headers */, 489EECC5149809A800B44D5A /* DER_Digest.h in Headers */, 489EECCB149809A800B44D5A /* DER_Encode.h in Headers */, 489EECD1149809A800B44D5A /* DER_Keys.h in Headers */, 489EECD4149809A800B44D5A /* libDER.h in Headers */, 489EECD7149809A800B44D5A /* libDER_config.h in Headers */, 489EECDD149809A800B44D5A /* oids.h in Headers */, 4868BB1614B7C7F300072488 /* corecryptoSymmetricBridge.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 054BBEBD05F6A97700344873 /* libCommonCryptoMacOSX */ = { isa = PBXNativeTarget; buildConfigurationList = C27AD07D0987FCDA001272E0 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacOSX" */; buildPhases = ( 054BBEBA05F6A97700344873 /* Headers */, 054BBEBB05F6A97700344873 /* Sources */, EEB70419131C5BCB007CF918 /* Frameworks */, ); buildRules = ( 48B5F5281361D6A500134C9F /* PBXBuildRule */, B125268E0713742A00BB8157 /* PBXBuildRule */, ); dependencies = ( ); name = libCommonCryptoMacOSX; productName = commonCrypto; productReference = 054BBEBE05F6A97700344873 /* libcommonCrypto.dylib */; productType = "com.apple.product-type.library.dynamic"; }; 48165CD7125AC5D50015A267 /* libCommonCryptoMacIOS */ = { isa = PBXNativeTarget; buildConfigurationList = 48165DB6125AC5D50015A267 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacIOS" */; buildPhases = ( 48165CD8125AC5D50015A267 /* Headers */, 48165D30125AC5D50015A267 /* Sources */, 48CCF15612FA99B600D6DAE9 /* Frameworks */, ); buildRules = ( 48165DB5125AC5D50015A267 /* PBXBuildRule */, ); dependencies = ( ); name = libCommonCryptoMacIOS; productName = commonCrypto; productReference = 48165DB9125AC5D50015A267 /* libcommonCrypto.dylib */; productType = "com.apple.product-type.library.dynamic"; }; 48165DBA125AC5F20015A267 /* libCommonCryptoMacIOSSim */ = { isa = PBXNativeTarget; buildConfigurationList = 48165E99125AC5F20015A267 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacIOSSim" */; buildPhases = ( 48165DBB125AC5F20015A267 /* Headers */, 48165E13125AC5F20015A267 /* Sources */, 4CA674F41331747E00C45A71 /* Frameworks */, ); buildRules = ( 48165E98125AC5F20015A267 /* PBXBuildRule */, ); dependencies = ( ); name = libCommonCryptoMacIOSSim; productName = commonCrypto; productReference = 48165E9C125AC5F20015A267 /* libcommonCrypto_sim.dylib */; productType = "com.apple.product-type.library.dynamic"; }; 4823B0DF14C10064008F689F /* CCRegression */ = { isa = PBXNativeTarget; buildConfigurationList = 4823B0E714C10064008F689F /* Build configuration list for PBXNativeTarget "CCRegression" */; buildPhases = ( 4823B0DC14C10064008F689F /* Sources */, 4823B0DD14C10064008F689F /* Frameworks */, 4823B0DE14C10064008F689F /* CopyFiles */, ); buildRules = ( ); dependencies = ( 4823B10D14C101CC008F689F /* PBXTargetDependency */, ); name = CCRegression; productName = CCRegression; productReference = 4823B0E014C10064008F689F /* CCRegression */; productType = "com.apple.product-type.tool"; }; 4834A85414F47B6200438E3D /* CCRegressionIos */ = { isa = PBXNativeTarget; buildConfigurationList = 4834A87D14F47B6200438E3D /* Build configuration list for PBXNativeTarget "CCRegressionIos" */; buildPhases = ( 4834A85714F47B6200438E3D /* Sources */, 4834A87A14F47B6200438E3D /* Frameworks */, 4834A87C14F47B6200438E3D /* CopyFiles */, ); buildRules = ( ); dependencies = ( 4834A88414F47CA300438E3D /* PBXTargetDependency */, ); name = CCRegressionIos; productName = CCRegression; productReference = 4834A88014F47B6200438E3D /* CCRegression copy */; productType = "com.apple.product-type.tool"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 054BBEA605F6A8DE00344873 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0440; }; buildConfigurationList = C27AD0910987FCDA001272E0 /* Build configuration list for PBXProject "CommonCrypto" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, Japanese, French, German, ); mainGroup = 054BBEA205F6A8DE00344873; productRefGroup = 054BBEBF05F6A97700344873 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 054BBEB705F6A93300344873 /* world */, 4C99FCB61326E14F0040AD38 /* commonCryptoMacIOS */, 4CA675141332C16C00C45A71 /* CommonCrypto_Sim */, 05CE94290A3784D4007C91D6 /* Copy Open Source Docs */, 054BBEBD05F6A97700344873 /* libCommonCryptoMacOSX */, 48165CD7125AC5D50015A267 /* libCommonCryptoMacIOS */, 48165DBA125AC5F20015A267 /* libCommonCryptoMacIOSSim */, 4823B0DF14C10064008F689F /* CCRegression */, 4834A85414F47B6200438E3D /* CCRegressionIos */, ); }; /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ 4CA6751A1332C18C00C45A71 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; files = ( ); inputPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; shellScript = "set -x\ncd $DSTROOT\nmkdir -p ${SDKROOT#/}\ntar cf - usr | tar xvfC - ${SDKROOT#/}\nrm -rf usr"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 054BBEBB05F6A97700344873 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 48067F871362405D005DDEBC /* CommonCryptoAESShoefly.c in Sources */, 489D982E11A4E8C20004DB89 /* ccdebug.c in Sources */, 4836A43211A5CB4700862178 /* CommonCryptor.c in Sources */, 4836A43511A5CB4700862178 /* CommonHMAC.c in Sources */, 4836A43611A5CB4700862178 /* CommonKeyDerivation.c in Sources */, 4836A43811A5CB4700862178 /* CommonSymmetricKeywrap.c in Sources */, 48096B2311A5EF900043F67F /* CommonDigest.c in Sources */, 48B4651D1284907600311799 /* CommonRSACryptor.c in Sources */, 48D076D4130B2A9C0052D1AC /* CommonDH.c in Sources */, 48D076D5130B2A9C0052D1AC /* CommonECCryptor.c in Sources */, 48A5CBA6131EE096002A6E85 /* CommonGCMCryptor.c in Sources */, 485FED57131475A400FF0F82 /* CommonBigNum.c in Sources */, 48AC47CF1381EFDC00F584F5 /* byteBuffer.c in Sources */, 48FC4BD81395ACE600DA4760 /* CommonCryptoCASTShoefly.c in Sources */, 489F2442141AA3D0005E80FD /* CommonCMAC.c in Sources */, 48F5355314902894000D2D1F /* CommonRandom.c in Sources */, 489EECB4149809A800B44D5A /* DER_CertCrl.c in Sources */, 489EECBA149809A800B44D5A /* DER_Decode.c in Sources */, 489EECC0149809A800B44D5A /* DER_Digest.c in Sources */, 489EECC6149809A800B44D5A /* DER_Encode.c in Sources */, 489EECCC149809A800B44D5A /* DER_Keys.c in Sources */, 489EECD8149809A800B44D5A /* oids.c in Sources */, 489E06F914B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 48165D30125AC5D50015A267 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 48165D78125AC5D50015A267 /* ccdebug.c in Sources */, 48165D79125AC5D50015A267 /* CommonCryptor.c in Sources */, 48165D7A125AC5D50015A267 /* CommonHMAC.c in Sources */, 48165D7B125AC5D50015A267 /* CommonKeyDerivation.c in Sources */, 48165D7C125AC5D50015A267 /* CommonSymmetricKeywrap.c in Sources */, 48165D7D125AC5D50015A267 /* CommonDigest.c in Sources */, 48685587127B641800B88D39 /* CommonCryptoAESShoefly.c in Sources */, 48B4651E1284907600311799 /* CommonRSACryptor.c in Sources */, 48D076D0130B2A9C0052D1AC /* CommonDH.c in Sources */, 48D076D1130B2A9C0052D1AC /* CommonECCryptor.c in Sources */, 48A5CBA2131EE096002A6E85 /* CommonGCMCryptor.c in Sources */, 485FED55131475A400FF0F82 /* CommonBigNum.c in Sources */, 48AC47D11381EFDC00F584F5 /* byteBuffer.c in Sources */, 489F2444141AA3D0005E80FD /* CommonCMAC.c in Sources */, 48F5355414902894000D2D1F /* CommonRandom.c in Sources */, 489EECB5149809A800B44D5A /* DER_CertCrl.c in Sources */, 489EECBB149809A800B44D5A /* DER_Decode.c in Sources */, 489EECC1149809A800B44D5A /* DER_Digest.c in Sources */, 489EECC7149809A800B44D5A /* DER_Encode.c in Sources */, 489EECCD149809A800B44D5A /* DER_Keys.c in Sources */, 489EECD9149809A800B44D5A /* oids.c in Sources */, 489E06FA14B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 48165E13125AC5F20015A267 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 48165E5B125AC5F20015A267 /* ccdebug.c in Sources */, 48165E5C125AC5F20015A267 /* CommonCryptor.c in Sources */, 48165E5D125AC5F20015A267 /* CommonHMAC.c in Sources */, 48165E5E125AC5F20015A267 /* CommonKeyDerivation.c in Sources */, 48165E5F125AC5F20015A267 /* CommonSymmetricKeywrap.c in Sources */, 48165E60125AC5F20015A267 /* CommonDigest.c in Sources */, 48B4651F1284907600311799 /* CommonRSACryptor.c in Sources */, 48D076D8130B2A9C0052D1AC /* CommonDH.c in Sources */, 48D076D9130B2A9C0052D1AC /* CommonECCryptor.c in Sources */, 48A5CBA8131EE096002A6E85 /* CommonGCMCryptor.c in Sources */, 485FED51131475A400FF0F82 /* CommonBigNum.c in Sources */, 4CF7820B1339B543004A56DF /* CommonCryptoAESShoefly.c in Sources */, 48AC47D21381EFDC00F584F5 /* byteBuffer.c in Sources */, 489F2445141AA3D0005E80FD /* CommonCMAC.c in Sources */, 489EECB6149809A800B44D5A /* DER_CertCrl.c in Sources */, 489EECBC149809A800B44D5A /* DER_Decode.c in Sources */, 489EECC2149809A800B44D5A /* DER_Digest.c in Sources */, 489EECC8149809A800B44D5A /* DER_Encode.c in Sources */, 489EECCE149809A800B44D5A /* DER_Keys.c in Sources */, 489EECDA149809A800B44D5A /* oids.c in Sources */, 489E06FB14B7AB0900B0A282 /* corecryptoSymmetricBridge.c in Sources */, 5DB80D3E14FC5CB3002C9A03 /* CommonRandom.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4823B0DC14C10064008F689F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 4823B10914C1017C008F689F /* testbyteBuffer.c in Sources */, 4823B10214C1016B008F689F /* testenv.c in Sources */, 4823B10414C1016B008F689F /* testlist.c in Sources */, 4823B10714C1016B008F689F /* testmore.c in Sources */, 4823B10014C10155008F689F /* main.c in Sources */, 4823B0EA14C1013F008F689F /* CCCryptorTestFuncs.c in Sources */, 4823B0EC14C1013F008F689F /* CommonBaseEncoding.c in Sources */, 4823B0ED14C1013F008F689F /* CommonBigNum.c in Sources */, 4823B0EE14C1013F008F689F /* CommonCMac.c in Sources */, 4823B0EF14C1013F008F689F /* CommonCryptoCTSPadding.c in Sources */, 4823B0F014C1013F008F689F /* CommonCryptoSymCBC.c in Sources */, 4823B0F114C1013F008F689F /* CommonCryptoSymGCM.c in Sources */, 4823B0F214C1013F008F689F /* CommonCryptoSymmetricWrap.c in Sources */, 4823B0F314C1013F008F689F /* CommonCryptoSymOFB.c in Sources */, 4823B0F414C1013F008F689F /* CommonCryptoSymOffset.c in Sources */, 4823B0F514C1013F008F689F /* CommonCryptoSymRC2.c in Sources */, 4823B0F614C1013F008F689F /* CommonCryptoSymRegression.c in Sources */, 4823B0F714C1013F008F689F /* CommonCryptoSymXTS.c in Sources */, 4823B0F814C1013F008F689F /* CommonCryptoSymZeroLength.c in Sources */, 4823B0F914C1013F008F689F /* CommonDigest.c in Sources */, 4823B0FA14C1013F008F689F /* CommonEC.c in Sources */, 4823B0FB14C1013F008F689F /* CommonHMacClone.c in Sources */, 4823B0FC14C1013F008F689F /* CommonRandom.c in Sources */, 4823B0FD14C1013F008F689F /* CommonRSA.c in Sources */, 4823B0FF14C1013F008F689F /* CryptorPadFailure.c in Sources */, 486BE17D14E6019B00346AC4 /* CommonCryptoReset.c in Sources */, 48CCD26514F6F189002B6043 /* CommonBigDigest.c in Sources */, 48C5CB9214FD747500F4472E /* CommonDHtest.c in Sources */, 4852C24A1505F8CD00676BCC /* CommonCryptoSymCFB.c in Sources */, 4854BAD6152177CC007B5B08 /* CommonCryptoSymCTR.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4834A85714F47B6200438E3D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 48CCD26614F6F1E1002B6043 /* CommonBigDigest.c in Sources */, 4834A85814F47B6200438E3D /* testbyteBuffer.c in Sources */, 4834A85C14F47B6200438E3D /* testenv.c in Sources */, 4834A85E14F47B6200438E3D /* testlist.c in Sources */, 4834A86114F47B6200438E3D /* testmore.c in Sources */, 4834A86314F47B6200438E3D /* main.c in Sources */, 4834A86414F47B6200438E3D /* CCCryptorTestFuncs.c in Sources */, 4834A86614F47B6200438E3D /* CommonBaseEncoding.c in Sources */, 4834A86714F47B6200438E3D /* CommonBigNum.c in Sources */, 4834A86814F47B6200438E3D /* CommonCMac.c in Sources */, 4834A86914F47B6200438E3D /* CommonCryptoCTSPadding.c in Sources */, 4834A86A14F47B6200438E3D /* CommonCryptoSymCBC.c in Sources */, 4834A86B14F47B6200438E3D /* CommonCryptoSymGCM.c in Sources */, 4834A86C14F47B6200438E3D /* CommonCryptoSymmetricWrap.c in Sources */, 4834A86D14F47B6200438E3D /* CommonCryptoSymOFB.c in Sources */, 4834A86E14F47B6200438E3D /* CommonCryptoSymOffset.c in Sources */, 4834A86F14F47B6200438E3D /* CommonCryptoSymRC2.c in Sources */, 4834A87014F47B6200438E3D /* CommonCryptoSymRegression.c in Sources */, 4834A87114F47B6200438E3D /* CommonCryptoSymXTS.c in Sources */, 4834A87214F47B6200438E3D /* CommonCryptoSymZeroLength.c in Sources */, 4834A87314F47B6200438E3D /* CommonDigest.c in Sources */, 4834A87414F47B6200438E3D /* CommonEC.c in Sources */, 4834A87514F47B6200438E3D /* CommonHMacClone.c in Sources */, 4834A87614F47B6200438E3D /* CommonRandom.c in Sources */, 4834A87714F47B6200438E3D /* CommonRSA.c in Sources */, 4834A87814F47B6200438E3D /* CryptorPadFailure.c in Sources */, 4834A87914F47B6200438E3D /* CommonCryptoReset.c in Sources */, 48C5CB9314FD747500F4472E /* CommonDHtest.c in Sources */, 4852C24B1505F8CD00676BCC /* CommonCryptoSymCFB.c in Sources */, 4854BAD7152177CC007B5B08 /* CommonCryptoSymCTR.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 0511C4630A3785340028BFC3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 05CE94290A3784D4007C91D6 /* Copy Open Source Docs */; targetProxy = 0511C4620A3785340028BFC3 /* PBXContainerItemProxy */; }; 4823B10D14C101CC008F689F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 054BBEBD05F6A97700344873 /* libCommonCryptoMacOSX */; targetProxy = 4823B10C14C101CC008F689F /* PBXContainerItemProxy */; }; 4834A88414F47CA300438E3D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 48165CD7125AC5D50015A267 /* libCommonCryptoMacIOS */; targetProxy = 4834A88314F47CA300438E3D /* PBXContainerItemProxy */; }; 4C58A28D13281C2100A17BAC /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 48165CD7125AC5D50015A267 /* libCommonCryptoMacIOS */; targetProxy = 4C58A28C13281C2100A17BAC /* PBXContainerItemProxy */; }; 4CA675191332C17900C45A71 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 48165DBA125AC5F20015A267 /* libCommonCryptoMacIOSSim */; targetProxy = 4CA675181332C17900C45A71 /* PBXContainerItemProxy */; }; 5D936FFB110E7FFF006855B0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 054BBEBD05F6A97700344873 /* libCommonCryptoMacOSX */; targetProxy = 5D936FFA110E7FFF006855B0 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ 05CE94320A37850A007C91D6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; PRODUCT_NAME = "Copy Open Source Docs"; ZERO_LINK = NO; }; name = Release; }; 12F25D8511F7BF8A0036BC8E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_OUTPUT_FORMAT = binary; SDKROOT = iphoneos.internal; USER_HEADER_SEARCH_PATHS = "/Users/murf/BuildProducts/Build/Products/Debug/usr/local/include /Users/murf/BuildProducts/Build/Products/Debug/usr/include"; }; name = Debug; }; 12F25D8611F7BF8A0036BC8E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; PRODUCT_NAME = world; SECTORDER_FLAGS = ""; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); }; name = Debug; }; 12F25D8711F7BF8A0036BC8E /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130EF126681290036EA02 /* CC_MacOSXClient_development.xcconfig */; buildSettings = { EXPORTED_SYMBOLS_FILE = "$(SRCROOT)/Source/Exports/CommonCrypto.exp"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SYMROOT)\"/**", "\"$(SRCROOT)/../../BuildProducts/Products/Products/Debug\"", /usr/lib/system, ); OTHER_LDFLAGS = ""; SDKROOT = ""; }; name = Debug; }; 12F25D8811F7BF8A0036BC8E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; PRODUCT_NAME = "Copy Open Source Docs"; ZERO_LINK = NO; }; name = Debug; }; 48165DB7125AC5D50015A267 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130E8126681290036EA02 /* CC_iOSClient_deployment.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; EXPORTED_SYMBOLS_FILE = "$(SRCROOT)/Source/Exports/CommonCryptoIOS5.exp"; GCC_ENABLE_CPP_EXCEPTIONS = YES; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SYMROOT)\"/**", "\"$(SDKROOT)/usr/lib/system\"", ); ORDER_FILE = "$(SDKROOT)/AppleInternal/OrderFiles/libcommonCrypto.order"; OTHER_LDFLAGS = ""; SDKROOT = iphoneos.internal; }; name = Release; }; 48165DB8125AC5D50015A267 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130E9126681290036EA02 /* CC_iOSClient_development.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; EXPORTED_SYMBOLS_FILE = "$(SRCROOT)/Source/Exports/CommonCryptoIOS5.exp"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../../BuildProducts/Release-iphoneos\"", "\"$(SDKROOT)/usr/lib/system\"", ); ORDER_FILE = "$(SDKROOT)/AppleInternal/OrderFiles/libcommonCrypto.order"; OTHER_LDFLAGS = ""; SDKROOT = iphoneos.internal; }; name = Debug; }; 48165E9A125AC5F20015A267 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130EC126681290036EA02 /* CC_iOSSim_deployment.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; DEAD_CODE_STRIPPING = NO; EXPORTED_SYMBOLS_FILE = "$(SRCROOT)/Source/Exports/CommonCryptoIOS5.exp"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = ( "\"$(SYMROOT)\"/**", "\"$(SDKROOT)/usr/lib/system\"", "\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/system\"", ); OTHER_LDFLAGS = "-lcorecrypto_sim"; SDKROOT = iphoneos.internal; VALID_ARCHS = "armv6 i386 x86_64"; }; name = Release; }; 48165E9B125AC5F20015A267 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130ED126681290036EA02 /* CC_iOSSim_development.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; DEAD_CODE_STRIPPING = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SDKROOT)/usr/lib/system\"", "\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/system\"", ); OTHER_LDFLAGS = "-lcorecrypto_sim"; SDKROOT = iphoneos.internal; }; name = Debug; }; 4823B0E814C10064008F689F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; INSTALL_PATH = /usr/local/tests/CommonCrypto; LIBRARY_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; }; name = Release; }; 4823B0E914C10064008F689F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; INSTALL_PATH = /usr/local/tests/CommonCrypto; LIBRARY_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; }; name = Debug; }; 4834A87E14F47B6200438E3D /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = ""; PRODUCT_NAME = "CCRegression copy"; SDKROOT = iphoneos.internal; }; name = Release; }; 4834A87F14F47B6200438E3D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = ""; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "CCRegression copy"; SDKROOT = iphoneos.internal; }; name = Debug; }; 4C99FCB81326E14F0040AD38 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; 4C99FCB91326E14F0040AD38 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; 4CA675161332C16C00C45A71 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130EC126681290036EA02 /* CC_iOSSim_deployment.xcconfig */; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; 4CA675171332C16C00C45A71 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130ED126681290036EA02 /* CC_iOSSim_development.xcconfig */; buildSettings = { PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; C27AD07F0987FCDA001272E0 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 486130EE126681290036EA02 /* CC_MacOSXClient_deployment.xcconfig */; buildSettings = { EXPORTED_SYMBOLS_FILE = "$(SRCROOT)/Source/Exports/CommonCrypto.exp"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SYMROOT)\"/**", "\"$(SRCROOT)/../../BuildProducts/Products/Products/Debug\"", /usr/lib/system, ); OTHER_LDFLAGS = ""; SDKROOT = ""; }; name = Release; }; C27AD08F0987FCDA001272E0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; PRODUCT_NAME = world; SECTORDER_FLAGS = ""; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); }; name = Release; }; C27AD0930987FCDA001272E0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_OUTPUT_FORMAT = binary; SDKROOT = iphoneos.internal; USER_HEADER_SEARCH_PATHS = "/Users/murf/BuildProducts/Build/Products/Debug/usr/local/include /Users/murf/BuildProducts/Build/Products/Debug/usr/include"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 05CE94300A37850A007C91D6 /* Build configuration list for PBXAggregateTarget "Copy Open Source Docs" */ = { isa = XCConfigurationList; buildConfigurations = ( 05CE94320A37850A007C91D6 /* Release */, 12F25D8811F7BF8A0036BC8E /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 48165DB6125AC5D50015A267 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacIOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 48165DB7125AC5D50015A267 /* Release */, 48165DB8125AC5D50015A267 /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 48165E99125AC5F20015A267 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacIOSSim" */ = { isa = XCConfigurationList; buildConfigurations = ( 48165E9A125AC5F20015A267 /* Release */, 48165E9B125AC5F20015A267 /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4823B0E714C10064008F689F /* Build configuration list for PBXNativeTarget "CCRegression" */ = { isa = XCConfigurationList; buildConfigurations = ( 4823B0E814C10064008F689F /* Release */, 4823B0E914C10064008F689F /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4834A87D14F47B6200438E3D /* Build configuration list for PBXNativeTarget "CCRegressionIos" */ = { isa = XCConfigurationList; buildConfigurations = ( 4834A87E14F47B6200438E3D /* Release */, 4834A87F14F47B6200438E3D /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4C99FCB71326E14F0040AD38 /* Build configuration list for PBXAggregateTarget "commonCryptoMacIOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 4C99FCB81326E14F0040AD38 /* Release */, 4C99FCB91326E14F0040AD38 /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CA675151332C16C00C45A71 /* Build configuration list for PBXAggregateTarget "CommonCrypto_Sim" */ = { isa = XCConfigurationList; buildConfigurations = ( 4CA675161332C16C00C45A71 /* Release */, 4CA675171332C16C00C45A71 /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C27AD07D0987FCDA001272E0 /* Build configuration list for PBXNativeTarget "libCommonCryptoMacOSX" */ = { isa = XCConfigurationList; buildConfigurations = ( C27AD07F0987FCDA001272E0 /* Release */, 12F25D8711F7BF8A0036BC8E /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C27AD08D0987FCDA001272E0 /* Build configuration list for PBXAggregateTarget "world" */ = { isa = XCConfigurationList; buildConfigurations = ( C27AD08F0987FCDA001272E0 /* Release */, 12F25D8611F7BF8A0036BC8E /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C27AD0910987FCDA001272E0 /* Build configuration list for PBXProject "CommonCrypto" */ = { isa = XCConfigurationList; buildConfigurations = ( C27AD0930987FCDA001272E0 /* Release */, 12F25D8511F7BF8A0036BC8E /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 054BBEA605F6A8DE00344873 /* Project object */; } |
Added CommonCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata.
> > > > > > > | 1 2 3 4 5 6 7 | <?xml version="1.0" encoding="UTF-8"?> <Workspace version = "1.0"> <FileRef location = "self:CommonCrypto.xcodeproj"> </FileRef> </Workspace> |
Added CommonCrypto.xcodeproj/project.xcworkspace/xcuserdata/jimmur.xcuserdatad/UserInterfaceState.xcuserstate.
cannot compute difference between binary files
Added CommonCrypto.xcodeproj/project.xcworkspace/xcuserdata/stripes.xcuserdatad/UserInterfaceState.xcuserstate.
more than 10,000 changes
Added CommonCrypto.xcodeproj/project.xcworkspace/xcuserdata/stripes.xcuserdatad/WorkspaceSettings.xcsettings.
> > > > > > > > | 1 2 3 4 5 6 7 8 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>IDEWorkspaceUserSettings_BuildLocationStyle</key> <integer>2</integer> </dict> </plist> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/CCRegression.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/CCRegressionIos.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/Copy Open Source Docs.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "05CE94290A3784D4007C91D6" BuildableName = "Copy Open Source Docs" BlueprintName = "Copy Open Source Docs" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/libCommonCryptoMacIOS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165CD7125AC5D50015A267" BuildableName = "libcommonCrypto.dylib" BlueprintName = "libCommonCryptoMacIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/libCommonCryptoMacIOSSim.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165DBA125AC5F20015A267" BuildableName = "libcommonCrypto_sim.dylib" BlueprintName = "libCommonCryptoMacIOSSim" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/libCommonCryptoMacOSX.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEBD05F6A97700344873" BuildableName = "libcommonCrypto.dylib" BlueprintName = "libCommonCryptoMacOSX" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcshareddata/xcschemes/world.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEB705F6A93300344873" BuildableName = "world" BlueprintName = "world" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist.
> > > > > | 1 2 3 4 5 | <?xml version="1.0" encoding="UTF-8"?> <Bucket type = "1" version = "1.0"> </Bucket> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/CCRegression.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4823B0DF14C10064008F689F" BuildableName = "CCRegression" BlueprintName = "CCRegression" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/CCRegressionIos.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4834A85414F47B6200438E3D" BuildableName = "CCRegression copy" BlueprintName = "CCRegressionIos" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/CommonCrypto_Sim.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4CA675141332C16C00C45A71" BuildableName = "CommonCrypto_Sim" BlueprintName = "CommonCrypto_Sim" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/Copy Open Source Docs.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "05CE94290A3784D4007C91D6" BuildableName = "Copy Open Source Docs" BlueprintName = "Copy Open Source Docs" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/cc_fips_dbrg_test.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/cc_fips_test.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </MacroExpansion> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/cc_ios_tommath.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48CCEF5612FA879900D6DAE9" BuildableName = "libcc_tommath.a" BlueprintName = "cc_ios_tommath" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/cc_macosx_tommath.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48FD68BF1354BCB900F55B8B" BuildableName = "libcc_tommath.a" BlueprintName = "cc_macosx_tommath" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/commonCryptoMacIOS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C99FCB61326E14F0040AD38" BuildableName = "commonCryptoMacIOS" BlueprintName = "commonCryptoMacIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/commonCryptoMacIOSKext.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48166063125AC64C0015A267" BuildableName = "libiOScommonCrypto.dylib" BlueprintName = "commonCryptoMacIOSKext" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/commonCryptoMacOSXKext.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "EEBECDF8125E691800034935" BuildableName = "commonCryptoMacOSXKext.kext" BlueprintName = "commonCryptoMacOSXKext" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/libCommonCryptoMacIOS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165CD7125AC5D50015A267" BuildableName = "libcommonCrypto.dylib" BlueprintName = "libCommonCryptoMacIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/libCommonCryptoMacIOSSim.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165DBA125AC5F20015A267" BuildableName = "libcommonCrypto_sim.dylib" BlueprintName = "libCommonCryptoMacIOSSim" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/libCommonCryptoMacOSS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.7"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165E9D125AC6100015A267" BuildableName = "liboSScommonCrypto.dylib" BlueprintName = "libCommonCryptoMacOSS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> <InstallAction buildConfiguration = "Development"> </InstallAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/libCommonCryptoMacOSX.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEBD05F6A97700344873" BuildableName = "libcommonCrypto.dylib" BlueprintName = "libCommonCryptoMacOSX" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/world.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEB705F6A93300344873" BuildableName = "world" BlueprintName = "world" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/jimmur.xcuserdatad/xcschemes/xcschememanagement.plist.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>SchemeUserState</key> <dict> <key>CCRegression.xcscheme</key> <dict> <key>orderHint</key> <integer>11</integer> </dict> <key>CCRegressionIos.xcscheme</key> <dict> <key>orderHint</key> <integer>4</integer> </dict> <key>CommonCrypto_Sim.xcscheme</key> <dict> <key>orderHint</key> <integer>13</integer> </dict> <key>Copy Open Source Docs.xcscheme</key> <dict> <key>orderHint</key> <integer>21</integer> </dict> <key>cc_fips_dbrg_test.xcscheme</key> <dict> <key>orderHint</key> <integer>30</integer> </dict> <key>cc_fips_test.xcscheme</key> <dict> <key>orderHint</key> <integer>35</integer> </dict> <key>cc_ios_tommath.xcscheme</key> <dict> <key>orderHint</key> <integer>29</integer> </dict> <key>cc_macosx_tommath.xcscheme</key> <dict> <key>orderHint</key> <integer>31</integer> </dict> <key>commonCryptoMacIOS.xcscheme</key> <dict> <key>orderHint</key> <integer>8</integer> </dict> <key>commonCryptoMacIOSKext.xcscheme</key> <dict> <key>orderHint</key> <integer>33</integer> </dict> <key>commonCryptoMacOSXKext.xcscheme</key> <dict> <key>orderHint</key> <integer>32</integer> </dict> <key>libCommonCryptoMacIOS.xcscheme</key> <dict> <key>orderHint</key> <integer>7</integer> </dict> <key>libCommonCryptoMacIOSSim.xcscheme</key> <dict> <key>orderHint</key> <integer>16</integer> </dict> <key>libCommonCryptoMacOSS.xcscheme</key> <dict> <key>orderHint</key> <integer>34</integer> </dict> <key>libCommonCryptoMacOSX.xcscheme</key> <dict> <key>orderHint</key> <integer>2</integer> </dict> <key>world.xcscheme</key> <dict> <key>orderHint</key> <integer>20</integer> </dict> </dict> <key>SuppressBuildableAutocreation</key> <dict> <key>054BBEB705F6A93300344873</key> <dict> <key>primary</key> <true/> </dict> <key>054BBEBD05F6A97700344873</key> <dict> <key>primary</key> <true/> </dict> <key>05CE94290A3784D4007C91D6</key> <dict> <key>primary</key> <true/> </dict> <key>48165CD7125AC5D50015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48165DBA125AC5F20015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48165E9D125AC6100015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48166063125AC64C0015A267</key> <dict> <key>primary</key> <true/> </dict> <key>4823B0DF14C10064008F689F</key> <dict> <key>primary</key> <true/> </dict> <key>4834A85414F47B6200438E3D</key> <dict> <key>primary</key> <true/> </dict> <key>48CCEF5612FA879900D6DAE9</key> <dict> <key>primary</key> <true/> </dict> <key>48FD68BF1354BCB900F55B8B</key> <dict> <key>primary</key> <true/> </dict> <key>4C3CAC17132066C700AA3D18</key> <dict> <key>primary</key> <true/> </dict> <key>4C58A2511326F26000A17BAC</key> <dict> <key>primary</key> <true/> </dict> <key>4C99FCB61326E14F0040AD38</key> <dict> <key>primary</key> <true/> </dict> <key>4CA675141332C16C00C45A71</key> <dict> <key>primary</key> <true/> </dict> <key>EEBECDF8125E691800034935</key> <dict> <key>primary</key> <true/> </dict> </dict> </dict> </plist> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist.
> > > > > | 1 2 3 4 5 | <?xml version="1.0" encoding="UTF-8"?> <Bucket type = "1" version = "1.0"> </Bucket> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/CBCTest.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "128881641203673C0050B2E9" BuildableName = "CBCTest" BlueprintName = "CBCTest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "128881641203673C0050B2E9" BuildableName = "CBCTest" BlueprintName = "CBCTest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "128881641203673C0050B2E9" BuildableName = "CBCTest" BlueprintName = "CBCTest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/Copy Open Source Docs.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "05CE94290A3784D4007C91D6" BuildableName = "Copy Open Source Docs" BlueprintName = "Copy Open Source Docs" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/Unit Test World.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "5DC876F710FFB6BC0012A390" BuildableName = "Unit Test World" BlueprintName = "Unit Test World" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/XTStest.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "125B795011FF923D008C1AD3" BuildableName = "XTStest" BlueprintName = "XTStest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "125B795011FF923D008C1AD3" BuildableName = "XTStest" BlueprintName = "XTStest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "125B795011FF923D008C1AD3" BuildableName = "XTStest" BlueprintName = "XTStest" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/cc_fips_dbrg_test.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C58A2511326F26000A17BAC" BuildableName = "cc_fips_drgb_test" BlueprintName = "cc_fips_dbrg_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/cc_fips_test.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> <BuildableProductRunnable> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C3CAC17132066C700AA3D18" BuildableName = "cc_fips_test" BlueprintName = "cc_fips_test" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacIOS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "4C99FCB61326E14F0040AD38" BuildableName = "commonCryptoMacIOS" BlueprintName = "commonCryptoMacIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacIOSKext.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48166063125AC64C0015A267" BuildableName = "libiOScommonCrypto.dylib" BlueprintName = "commonCryptoMacIOSKext" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacIOSSim 2.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Debug"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacIOSSim.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165DBA125AC5F20015A267" BuildableName = "libcommonCrypto_sim.dylib" BlueprintName = "libCommonCryptoMacIOSSim" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> <TestableReference skipped = "NO"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48547185125B9483008158B1" BuildableName = "CommonCryptoUnitTest.octest" BlueprintName = "CommonCryptoUnitTestIOSSim" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </TestableReference> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacOSS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165E9D125AC6100015A267" BuildableName = "liboSScommonCrypto.dylib" BlueprintName = "commonCryptoMacOSS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacOSX.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEBD05F6A97700344873" BuildableName = "libcommonCrypto.dylib" BlueprintName = "commonCryptoMacOSX" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> <TestableReference skipped = "NO"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "5D735E4710FCDC04001AAD1E" BuildableName = "CommonCryptoUnitTest.octest" BlueprintName = "CommonCryptoUnitTestMacOSX" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </TestableReference> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/commonCryptoMacOSXKext.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "EEBECDF8125E691800034935" BuildableName = "commonCryptoMacOSXKext.kext" BlueprintName = "commonCryptoMacOSXKext" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/libCommonCryptoMacIOS.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48165CD7125AC5D50015A267" BuildableName = "libcommonCrypto.dylib" BlueprintName = "libCommonCryptoMacIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> <TestableReference skipped = "NO"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48547171125B9465008158B1" BuildableName = "CommonCryptoUnitTest.octest" BlueprintName = "CommonCryptoUnitTestIOS" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </TestableReference> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/tommath.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "48CCEF5612FA879900D6DAE9" BuildableName = "libtommath.a" BlueprintName = "tommath" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/world.xcscheme.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <Scheme version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "054BBEB705F6A93300344873" BuildableName = "world" BlueprintName = "world" ReferencedContainer = "container:CommonCrypto.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" shouldUseLaunchSchemeArgsEnv = "YES" buildConfiguration = "Development"> <Testables> </Testables> </TestAction> <LaunchAction selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" displayScaleIsEnabled = "NO" displayScale = "1.00" launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Development"> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction displayScaleIsEnabled = "NO" displayScale = "1.00" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" buildConfiguration = "Release"> </ProfileAction> <AnalyzeAction buildConfiguration = "Development"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> |
Added CommonCrypto.xcodeproj/xcuserdata/stripes.xcuserdatad/xcschemes/xcschememanagement.plist.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>SchemeUserState</key> <dict> <key>CBCTest.xcscheme</key> <dict> <key>orderHint</key> <integer>12</integer> </dict> <key>Copy Open Source Docs.xcscheme</key> <dict> <key>orderHint</key> <integer>2</integer> </dict> <key>Unit Test World.xcscheme</key> <dict> <key>orderHint</key> <integer>8</integer> </dict> <key>XTStest.xcscheme</key> <dict> <key>orderHint</key> <integer>13</integer> </dict> <key>cc_fips_dbrg_test.xcscheme</key> <dict> <key>orderHint</key> <integer>5</integer> </dict> <key>cc_fips_test.xcscheme</key> <dict> <key>orderHint</key> <integer>1</integer> </dict> <key>commonCryptoMacIOS.xcscheme</key> <dict> <key>orderHint</key> <integer>9</integer> </dict> <key>commonCryptoMacIOSKext.xcscheme</key> <dict> <key>orderHint</key> <integer>14</integer> </dict> <key>commonCryptoMacIOSSim 2.xcscheme</key> <dict> <key>orderHint</key> <integer>15</integer> </dict> <key>commonCryptoMacIOSSim.xcscheme</key> <dict> <key>orderHint</key> <integer>11</integer> </dict> <key>commonCryptoMacOSS.xcscheme</key> <dict> <key>orderHint</key> <integer>4</integer> </dict> <key>commonCryptoMacOSX.xcscheme</key> <dict> <key>orderHint</key> <integer>7</integer> </dict> <key>commonCryptoMacOSXKext.xcscheme</key> <dict> <key>orderHint</key> <integer>6</integer> </dict> <key>libCommonCryptoMacIOS.xcscheme</key> <dict> <key>orderHint</key> <integer>0</integer> </dict> <key>tommath.xcscheme</key> <dict> <key>orderHint</key> <integer>3</integer> </dict> <key>world.xcscheme</key> <dict> <key>orderHint</key> <integer>10</integer> </dict> </dict> <key>SuppressBuildableAutocreation</key> <dict> <key>054BBEB705F6A93300344873</key> <dict> <key>primary</key> <true/> </dict> <key>054BBEBD05F6A97700344873</key> <dict> <key>primary</key> <true/> </dict> <key>05CE94290A3784D4007C91D6</key> <dict> <key>primary</key> <true/> </dict> <key>125B795011FF923D008C1AD3</key> <dict> <key>primary</key> <true/> </dict> <key>128881641203673C0050B2E9</key> <dict> <key>primary</key> <true/> </dict> <key>48165CD7125AC5D50015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48165DBA125AC5F20015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48165E9D125AC6100015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48166063125AC64C0015A267</key> <dict> <key>primary</key> <true/> </dict> <key>48547171125B9465008158B1</key> <dict> <key>primary</key> <true/> </dict> <key>48547185125B9483008158B1</key> <dict> <key>primary</key> <true/> </dict> <key>48CCEF5612FA879900D6DAE9</key> <dict> <key>primary</key> <true/> </dict> <key>4C3CAC17132066C700AA3D18</key> <dict> <key>primary</key> <true/> </dict> <key>4C58A2511326F26000A17BAC</key> <dict> <key>primary</key> <true/> </dict> <key>4C99FCB61326E14F0040AD38</key> <dict> <key>primary</key> <true/> </dict> <key>4CA675141332C16C00C45A71</key> <dict> <key>primary</key> <true/> </dict> <key>5D735E4710FCDC04001AAD1E</key> <dict> <key>primary</key> <true/> </dict> <key>5DC876F710FFB6BC0012A390</key> <dict> <key>primary</key> <true/> </dict> <key>EEBECDF8125E691800034935</key> <dict> <key>primary</key> <true/> </dict> </dict> </dict> </plist> |
Added CommonCrypto/CommonCrypto.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2006-2012 Apple, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef __COMMONCRYPTO_PUBLIC__ #define __COMMONCRYPTO_PUBLIC__ #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonDigest.h> #include <CommonCrypto/CommonHMAC.h> #include <CommonCrypto/CommonKeyDerivation.h> #include <CommonCrypto/CommonSymmetricKeywrap.h> #endif /* __COMMONCRYPTO_PUBLIC__ */ |
Changes to CommonCrypto/CommonCryptor.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2006-2010 Apple, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
18 19 20 21 22 23 24 | * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /*! | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | > | | | | | | > > | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | > | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < < | | | | < > | < | | | | | | < | < | > > > > | | < < | < < < < < | > | | | | | | > | < > > | < < | | | > | < | | | < | | > | | < < < < > > | | > | | < < | | | | | | > > | | < | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /*! @header CommonCryptor.h @abstract Generic interface for symmetric encryption. @discussion This interface provides access to a number of symmetric encryption algorithms. Symmetric encryption algorithms come in two "flavors" - block ciphers, and stream ciphers. Block ciphers process data (while both encrypting and decrypting) in discrete chunks of data called blocks; stream ciphers operate on arbitrary sized data. The object declared in this interface, CCCryptor, provides access to both block ciphers and stream ciphers with the same API; however some options are available for block ciphers that do not apply to stream ciphers. The general operation of a CCCryptor is: initialize it with raw key data and other optional fields with CCCryptorCreate(); process input data via one or more calls to CCCryptorUpdate(), each of which may result in output data being written to caller-supplied memory; and obtain possible remaining output data with CCCryptorFinal(). The CCCryptor is disposed of via CCCryptorRelease(), or it can be reused (with the same key data as provided to CCCryptorCreate()) by calling CCCryptorReset(). CCCryptors can be dynamically allocated by this module, or their memory can be allocated by the caller. See discussion for CCCryptorCreate() and CCCryptorCreateFromData() for information on CCCryptor allocation. One option for block ciphers is padding, as defined in PKCS7; when padding is enabled, the total amount of data encrypted does not have to be an even multiple of the block size, and the actual length of plaintext is calculated during decryption. Another option for block ciphers is Cipher Block Chaining, known as CBC mode. When using CBC mode, an Initialization Vector (IV) is provided along with the key when starting an encrypt or decrypt operation. If CBC mode is selected and no IV is provided, an IV of all zeroes will be used. CCCryptor also implements block bufferring, so that individual calls to CCCryptorUpdate() do not have to provide data whose length is aligned to the block size. (If padding is disabled, encrypting with block ciphers does require that the *total* length of data input to CCCryptorUpdate() call(s) be aligned to the block size.) A given CCCryptor can only be used by one thread at a time; multiple threads can use safely different CCCryptors at the same time. */ #ifndef _CC_COMMON_CRYPTOR_ #define _CC_COMMON_CRYPTOR_ #include <stdbool.h> #include <stdint.h> #ifndef KERNEL #include <stddef.h> #endif /* KERNEL */ #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /*! @typedef CCCryptorRef @abstract Opaque reference to a CCCryptor object. */ typedef struct _CCCryptor *CCCryptorRef; /*! @enum CCCryptorStatus @abstract Return values from CommonCryptor operations. @constant kCCSuccess Operation completed normally. @constant kCCParamError Illegal parameter value. @constant kCCBufferTooSmall Insufficent buffer provided for specified operation. @constant kCCMemoryFailure Memory allocation failure. @constant kCCAlignmentError Input size was not aligned properly. @constant kCCDecodeError Input data did not decode or decrypt properly. @constant kCCUnimplemented Function not implemented for the current algorithm. */ enum { kCCSuccess = 0, kCCParamError = -4300, kCCBufferTooSmall = -4301, kCCMemoryFailure = -4302, kCCAlignmentError = -4303, kCCDecodeError = -4304, kCCUnimplemented = -4305, kCCOverflow = -4306 }; typedef int32_t CCCryptorStatus; /*! @enum CCOperation @abstract Operations that an CCCryptor can perform. @constant kCCEncrypt Symmetric encryption. @constant kCCDecrypt Symmetric decryption. */ enum { kCCEncrypt = 0, kCCDecrypt, }; typedef uint32_t CCOperation; /*! @enum CCAlgorithm @abstract Encryption algorithms implemented by this module. @constant kCCAlgorithmAES128 Advanced Encryption Standard, 128-bit block @constant kCCAlgorithmDES Data Encryption Standard @constant kCCAlgorithm3DES Triple-DES, three key, EDE configuration @constant kCCAlgorithmCAST CAST @constant kCCAlgorithmRC4 RC4 stream cipher @constant kCCAlgorithmBlowfish Blowfish block cipher */ enum { kCCAlgorithmAES128 = 0, kCCAlgorithmDES, kCCAlgorithm3DES, kCCAlgorithmCAST, kCCAlgorithmRC4, kCCAlgorithmRC2, kCCAlgorithmBlowfish }; typedef uint32_t CCAlgorithm; /*! @enum CCOptions @abstract Options flags, passed to CCCryptorCreate(). @constant kCCOptionPKCS7Padding Perform PKCS7 padding. @constant kCCOptionECBMode Electronic Code Book Mode. Default is CBC. */ enum { /* options for block ciphers */ kCCOptionPKCS7Padding = 0x0001, kCCOptionECBMode = 0x0002 /* stream ciphers currently have no options */ }; typedef uint32_t CCOptions; /*! @enum Key sizes @discussion Key sizes, in bytes, for supported algorithms. @constant kCCKeySizeAES128 128 bit AES key size. @constant kCCKeySizeAES192 192 bit AES key size. @constant kCCKeySizeAES256 256 bit AES key size. @constant kCCKeySizeDES DES key size. @constant kCCKeySize3DES Triple DES key size. @constant kCCKeySizeMinCAST CAST minimum key size. @constant kCCKeySizeMaxCAST CAST maximum key size. @constant kCCKeySizeMinRC4 RC4 minimum key size. @constant kCCKeySizeMaxRC4 RC4 maximum key size. @discussion DES and TripleDES have fixed key sizes. AES has three discrete key sizes. CAST and RC4 have variable key sizes. */ enum { kCCKeySizeAES128 = 16, kCCKeySizeAES192 = 24, kCCKeySizeAES256 = 32, kCCKeySizeDES = 8, kCCKeySize3DES = 24, kCCKeySizeMinCAST = 5, kCCKeySizeMaxCAST = 16, kCCKeySizeMinRC4 = 1, kCCKeySizeMaxRC4 = 512, kCCKeySizeMinRC2 = 1, kCCKeySizeMaxRC2 = 128, kCCKeySizeMinBlowfish = 8, kCCKeySizeMaxBlowfish = 56, }; /*! @enum Block sizes @discussion Block sizes, in bytes, for supported algorithms. @constant kCCBlockSizeAES128 AES block size (currently, only 128-bit blocks are supported). @constant kCCBlockSizeDES DES block size. @constant kCCBlockSize3DES Triple DES block size. @constant kCCBlockSizeCAST CAST block size. */ enum { /* AES */ kCCBlockSizeAES128 = 16, /* DES */ kCCBlockSizeDES = 8, /* 3DES */ kCCBlockSize3DES = 8, /* CAST */ kCCBlockSizeCAST = 8, kCCBlockSizeRC2 = 8, kCCBlockSizeBlowfish = 8, }; /*! @enum Minimum context sizes @discussion Minimum context sizes, for caller-allocated CCCryptorRefs. To minimize dynamic allocation memory, a caller can create a CCCryptorRef by passing caller-supplied memory to the CCCryptorCreateFromData() function. These constants define the minimum amount of memory, in bytes, needed for CCCryptorRefs for each supported algorithm. Note: these constants are valid for the current version of this library; they may change in subsequent releases, so applications wishing to allocate their own memory for use in creating CCCryptorRefs must be prepared to deal with a kCCBufferTooSmall return from CCCryptorCreateFromData(). See discussion for the CCCryptorCreateFromData() function. @constant kCCContextSizeAES128 - Minimum context size for kCCAlgorithmAES128. @constant kCCContextSizeDES - Minimum context size for kCCAlgorithmDES. @constant kCCContextSize3DES - Minimum context size for kCCAlgorithm3DES. @constant kCCContextSizeCAST - Minimum context size for kCCAlgorithmCAST. @constant kCCContextSizeRC4 - Minimum context size for kCCAlgorithmRC4. */ enum { kCCContextSizeAES128 = 404, kCCContextSizeDES = 240, kCCContextSize3DES = 496, kCCContextSizeCAST = 240, kCCContextSizeRC4 = 1072 }; /*! @function CCCryptorCreate @abstract Create a cryptographic context. @param op Defines the basic operation: kCCEncrypt or kCCDecrypt. @param alg Defines the algorithm. @param options A word of flags defining options. See discussion for the CCOptions type. @param key Raw key material, length keyLength bytes. @param keyLength Length of key material. Must be appropriate for the selected operation and algorithm. Some algorithms provide for varying key lengths. @param iv Initialization vector, optional. Used by block ciphers when Cipher Block Chaining (CBC) mode is enabled. If present, must be the same length as the selected algorithm's block size. If CBC mode is selected (by the absence of the kCCOptionECBMode bit in the options flags) and no IV is present, a NULL (all zeroes) IV will be used. This parameter is ignored if ECB mode is used or if a stream cipher algorithm is selected. @param cryptorRef A (required) pointer to the returned CCCryptorRef. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCCryptorCreate( CCOperation op, /* kCCEncrypt, etc. */ CCAlgorithm alg, /* kCCAlgorithmDES, etc. */ CCOptions options, /* kCCOptionPKCS7Padding, etc. */ const void *key, /* raw key material */ size_t keyLength, const void *iv, /* optional initialization vector */ CCCryptorRef *cryptorRef) /* RETURNED */ __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorCreateFromData @abstract Create a cryptographic context using caller-supplied memory. @param op Defines the basic operation: kCCEncrypt or kCCDecrypt. @param alg Defines the algorithm. @param options A word of flags defining options. See discussion for the CCOptions type. @param key Raw key material, length keyLength bytes. @param keyLength Length of key material. Must be appropriate for the selected operation and algorithm. Some algorithms provide for varying key lengths. @param iv Initialization vector, optional. Used by block ciphers when Cipher Block Chaining (CBC) mode is enabled. If present, must be the same length as the selected algorithm's block size. If CBC mode is selected (by the absence of the kCCOptionECBMode bit in the options flags) and no IV is present, a NULL (all zeroes) IV will be used. This parameter is ignored if ECB mode is used or if a stream cipher algorithm is selected. @param data A pointer to caller-supplied memory from which the CCCryptorRef will be created. @param dataLength The size of the caller-supplied memory in bytes. @param cryptorRef A (required) pointer to the returned CCCryptorRef. @param dataUsed Optional. If present, the actual number of bytes of the caller-supplied memory which was consumed by creation of the CCCryptorRef is returned here. Also, if the supplied memory is of insufficent size to create a CCCryptorRef, kCCBufferTooSmall is returned, and the minimum required buffer size is returned via this parameter if present. @result Possible error returns are kCCParamError and kCCBufferTooSmall. @discussion The CCCryptorRef created by this function *may* be disposed of via CCCRyptorRelease; that call is not strictly necessary, but if it's not performed, good security practice dictates that the caller should zero the memory provided to create the CCCryptorRef when the caller is finished using the CCCryptorRef. */ CCCryptorStatus CCCryptorCreateFromData( CCOperation op, /* kCCEncrypt, etc. */ CCAlgorithm alg, /* kCCAlgorithmDES, etc. */ CCOptions options, /* kCCOptionPKCS7Padding, etc. */ const void *key, /* raw key material */ size_t keyLength, const void *iv, /* optional initialization vector */ const void *data, /* caller-supplied memory */ size_t dataLength, /* length of data in bytes */ CCCryptorRef *cryptorRef, /* RETURNED */ size_t *dataUsed) /* optional, RETURNED */ __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorRelease @abstract Free a context created by CCCryptorCreate or CCCryptorCreateFromData(). @param cryptorRef The CCCryptorRef to release. @result The only possible error return is kCCParamError resulting from passing in a null CCCryptorRef. */ CCCryptorStatus CCCryptorRelease( CCCryptorRef cryptorRef) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorUpdate @abstract Process (encrypt, decrypt) some data. The result, if any, is written to a caller-provided buffer. @param cryptorRef A CCCryptorRef created via CCCryptorCreate() or CCCryptorCreateFromData(). @param dataIn Data to process, length dataInLength bytes. @param dataInLength Length of data to process. @param dataOut Result is written here. Allocated by caller. Encryption and decryption can be performed "in-place", with the same buffer used for input and output. @param dataOutAvailable The size of the dataOut buffer in bytes. @param dataOutMoved On successful return, the number of bytes written to dataOut. @result kCCBufferTooSmall indicates insufficent space in the dataOut buffer. The caller can use CCCryptorGetOutputLength() to determine the required output buffer size in this case. The operation can be retried; no state is lost when this is returned. @discussion This routine can be called multiple times. The caller does not need to align input data lengths to block sizes; input is bufferred as necessary for block ciphers. When performing symmetric encryption with block ciphers, and padding is enabled via kCCOptionPKCS7Padding, the total number of bytes provided by all the calls to this function when encrypting can be arbitrary (i.e., the total number of bytes does not have to be block aligned). However if padding is disabled, or when decrypting, the total number of bytes does have to be aligned to the block size; otherwise CCCryptFinal() will return kCCAlignmentError. A general rule for the size of the output buffer which must be provided by the caller is that for block ciphers, the output length is never larger than the input length plus the block size. For stream ciphers, the output length is always exactly the same as the input length. See the discussion for CCCryptorGetOutputLength() for more information on this topic. Generally, when all data has been processed, call CCCryptorFinal(). In the following cases, the CCCryptorFinal() is superfluous as it will not yield any data nor return an error: 1. Encrypting or decrypting with a block cipher with padding disabled, when the total amount of data provided to CCCryptorUpdate() is an integral multiple of the block size. 2. Encrypting or decrypting with a stream cipher. */ CCCryptorStatus CCCryptorUpdate( CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut, /* data RETURNED here */ size_t dataOutAvailable, size_t *dataOutMoved) /* number of bytes written */ __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorFinal @abstract Finish an encrypt or decrypt operation, and obtain the (possible) final data output. @param cryptorRef A CCCryptorRef created via CCCryptorCreate() or CCCryptorCreateFromData(). @param dataOut Result is written here. Allocated by caller. @param dataOutAvailable The size of the dataOut buffer in bytes. @param dataOutMoved On successful return, the number of bytes written to dataOut. @result kCCBufferTooSmall indicates insufficent space in the dataOut buffer. The caller can use CCCryptorGetOutputLength() to determine the required output buffer size in this case. The operation can be retried; no state is lost when this is returned. kCCAlignmentError When decrypting, or when encrypting with a block cipher with padding disabled, kCCAlignmentError will be returned if the total number of bytes provided to CCCryptUpdate() is not an integral multiple of the current algorithm's block size. kCCDecodeError Indicates garbled ciphertext or the wrong key during decryption. This can only be returned while decrypting with padding enabled. @discussion Except when kCCBufferTooSmall is returned, the CCCryptorRef can no longer be used for subsequent operations unless CCCryptorReset() is called on it. It is not necessary to call CCCryptorFinal() when performing symmetric encryption or decryption if padding is disabled, or when using a stream cipher. It is not necessary to call CCCryptorFinal() prior to CCCryptorRelease() when aborting an operation. */ CCCryptorStatus CCCryptorFinal( CCCryptorRef cryptorRef, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved) /* number of bytes written */ __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorGetOutputLength @abstract Determine output buffer size required to process a given input size. @param cryptorRef A CCCryptorRef created via CCCryptorCreate() or CCCryptorCreateFromData(). @param inputLength The length of data which will be provided to CCCryptorUpdate(). @param final If false, the returned value will indicate the output buffer space needed when 'inputLength' bytes are provided to CCCryptorUpdate(). When 'final' is true, the returned value will indicate the total combined buffer space needed when 'inputLength' bytes are provided to CCCryptorUpdate() and then CCCryptorFinal() is called. @result The maximum buffer space need to perform CCCryptorUpdate() and optionally CCCryptorFinal(). @discussion Some general rules apply that allow clients of this module to know a priori how much output buffer space will be required in a given situation. For stream ciphers, the output size is always equal to the input size, and CCCryptorFinal() never produces any data. For block ciphers, the output size will always be less than or equal to the input size plus the size of one block. For block ciphers, if the input size provided to each call to CCCryptorUpdate() is is an integral multiple of the block size, then the output size for each call to CCCryptorUpdate() is less than or equal to the input size for that call to CCCryptorUpdate(). CCCryptorFinal() only produces output when using a block cipher with padding enabled. */ size_t CCCryptorGetOutputLength( CCCryptorRef cryptorRef, size_t inputLength, bool final) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCryptorReset @abstract Reinitializes an existing CCCryptorRef with a (possibly) new initialization vector. The CCCryptorRef's key is unchanged. Not implemented for stream ciphers. @param cryptorRef A CCCryptorRef created via CCCryptorCreate() or CCCryptorCreateFromData(). @param iv Optional initialization vector; if present, must be the same size as the current algorithm's block size. @result The the only possible errors are kCCParamError and kCCUnimplemented. @discussion This can be called on a CCCryptorRef with data pending (i.e. in a padded mode operation before CCCryptFinal is called); however any pending data will be lost in that case. */ CCCryptorStatus CCCryptorReset( CCCryptorRef cryptorRef, const void *iv) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @function CCCrypt @abstract Stateless, one-shot encrypt or decrypt operation. This basically performs a sequence of CCCrytorCreate(), CCCryptorUpdate(), CCCryptorFinal(), and CCCryptorRelease(). @param alg Defines the encryption algorithm. @param op Defines the basic operation: kCCEncrypt or kCCDecrypt. @param options A word of flags defining options. See discussion for the CCOptions type. @param key Raw key material, length keyLength bytes. @param keyLength Length of key material. Must be appropriate for the select algorithm. Some algorithms may provide for varying key lengths. @param iv Initialization vector, optional. Used for Cipher Block Chaining (CBC) mode. If present, must be the same length as the selected algorithm's block size. If CBC mode is selected (by the absence of any mode bits in the options flags) and no IV is present, a NULL (all zeroes) IV will be used. This is ignored if ECB mode is used or if a stream cipher algorithm is selected. @param dataIn Data to encrypt or decrypt, length dataInLength bytes. @param dataInLength Length of data to encrypt or decrypt. @param dataOut Result is written here. Allocated by caller. Encryption and decryption can be performed "in-place", with the same buffer used for input and output. @param dataOutAvailable The size of the dataOut buffer in bytes. @param dataOutMoved On successful return, the number of bytes written to dataOut. If kCCBufferTooSmall is returned as a result of insufficient buffer space being provided, the required buffer space is returned here. @result kCCBufferTooSmall indicates insufficent space in the dataOut buffer. In this case, the *dataOutMoved parameter will indicate the size of the buffer needed to complete the operation. The operation can be retried with minimal runtime penalty. kCCAlignmentError indicates that dataInLength was not properly aligned. This can only be returned for block ciphers, and then only when decrypting or when encrypting with block with padding disabled. kCCDecodeError Indicates improperly formatted ciphertext or a "wrong key" error; occurs only during decrypt operations. */ CCCryptorStatus CCCrypt( CCOperation op, /* kCCEncrypt, etc. */ CCAlgorithm alg, /* kCCAlgorithmAES128, etc. */ CCOptions options, /* kCCOptionPKCS7Padding, etc. */ const void *key, size_t keyLength, const void *iv, /* optional initialization vector */ const void *dataIn, /* optional per op and alg */ size_t dataInLength, void *dataOut, /* data RETURNED here */ size_t dataOutAvailable, size_t *dataOutMoved) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0); /*! @enum Cipher Modes @discussion These are the selections available for modes of operation for use with block ciphers. If RC4 is selected as the cipher (a stream cipher) the only correct mode is kCCModeRC4. @constant kCCModeECB - Electronic Code Book Mode. @constant kCCModeCBC - Cipher Block Chaining Mode. @constant kCCModeCFB - Cipher Feedback Mode. @constant kCCModeOFB - Output Feedback Mode. @constant kCCModeXTS - XEX-based Tweaked CodeBook Mode. @constant kCCModeRC4 - RC4 as a streaming cipher is handled internally as a mode. @constant kCCModeCFB8 - Cipher Feedback Mode producing 8 bits per round. */ enum { kCCModeECB = 1, kCCModeCBC = 2, kCCModeCFB = 3, kCCModeCTR = 4, kCCModeF8 = 5, // Unimplemented for now (not included) kCCModeLRW = 6, // Unimplemented for now (not included) kCCModeOFB = 7, kCCModeXTS = 8, kCCModeRC4 = 9, kCCModeCFB8 = 10, }; typedef uint32_t CCMode; /*! @enum Padding for Block Ciphers @discussion These are the padding options available for block modes. @constant ccNoPadding - No padding. @constant ccPKCS7Padding - PKCS7 Padding. */ enum { ccNoPadding = 0, ccPKCS7Padding = 1, }; typedef uint32_t CCPadding; /*! @enum Mode options - so far only used for CTR mode @discussion Values used to specify options for modes. @constant kCCModeOptionCTR_LE - CTR Mode Little Endian. @constant kCCModeOptionCTR_BE - CTR Mode Big Endian. */ enum { kCCModeOptionCTR_LE = 0x0001, kCCModeOptionCTR_BE = 0x0002 }; typedef uint32_t CCModeOptions; /*! @function CCCryptorCreateWithMode @abstract Create a cryptographic context. @param op Defines the basic operation: kCCEncrypt or kCCDecrypt. @param mode Specifies the cipher mode to use for operations. @param alg Defines the algorithm. @param padding Specifies the padding to use. @param iv Initialization vector, optional. Used by block ciphers with the following modes: Cipher Block Chaining (CBC) Cipher Feedback (CFB and CFB8) Output Feedback (OFB) Counter (CTR) If present, must be the same length as the selected algorithm's block size. If no IV is present, a NULL (all zeroes) IV will be used. This parameter is ignored if ECB mode is used or if a stream cipher algorithm is selected. @param key Raw key material, length keyLength bytes. @param keyLength Length of key material. Must be appropriate for the selected operation and algorithm. Some algorithms provide for varying key lengths. @param tweak Raw key material, length keyLength bytes. Used for the tweak key in XEX-based Tweaked CodeBook (XTS) mode. @param tweakLength Length of tweak key material. Must be appropriate for the selected operation and algorithm. Some algorithms provide for varying key lengths. For XTS this is the same length as the encryption key. @param numRounds The number of rounds of the cipher to use. 0 uses the default. @param options A word of flags defining options. See discussion for the CCModeOptions type. @param cryptorRef A (required) pointer to the returned CCCryptorRef. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCCryptorCreateWithMode( CCOperation op, /* kCCEncrypt, kCCEncrypt */ CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, /* optional initialization vector */ const void *key, /* raw key material */ size_t keyLength, const void *tweak, /* raw tweak material */ size_t tweakLength, int numRounds, /* 0 == default */ CCModeOptions options, CCCryptorRef *cryptorRef) /* RETURNED */ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_COMMON_CRYPTOR_ */ |
Changes to CommonCrypto/CommonDigest.h.
︙ | ︙ | |||
21 22 23 24 25 26 27 | * @APPLE_LICENSE_HEADER_END@ */ /* * CommonDigest.h - common digest routines: MD2, MD4, MD5, SHA1. */ | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | * @APPLE_LICENSE_HEADER_END@ */ /* * CommonDigest.h - common digest routines: MD2, MD4, MD5, SHA1. */ #ifndef _CC_COMMON_DIGEST_H_ #define _CC_COMMON_DIGEST_H_ #include <stdint.h> #include <Availability.h> #ifdef __cplusplus extern "C" { |
︙ | ︙ | |||
47 48 49 50 51 52 53 | * calculation and place the result in the caller-supplied buffer * indicated by the md parameter. They return the md parameter. * Unlike the opensssl counterparts, these one-shot functions require * a non-NULL md pointer. Passing in NULL for the md parameter * results in a NULL return and no digest calculation. */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | * calculation and place the result in the caller-supplied buffer * indicated by the md parameter. They return the md parameter. * Unlike the opensssl counterparts, these one-shot functions require * a non-NULL md pointer. Passing in NULL for the md parameter * results in a NULL return and no digest calculation. */ typedef uint32_t CC_LONG; /* 32 bit unsigned integer */ typedef uint64_t CC_LONG64; /* 64 bit unsigned integer */ /*** MD2 ***/ #define CC_MD2_DIGEST_LENGTH 16 /* digest length in bytes */ #define CC_MD2_BLOCK_BYTES 64 /* block size in bytes */ #define CC_MD2_BLOCK_LONG (CC_MD2_BLOCK_BYTES / sizeof(CC_LONG)) typedef struct CC_MD2state_st { int num; unsigned char data[CC_MD2_DIGEST_LENGTH]; CC_LONG cksm[CC_MD2_BLOCK_LONG]; CC_LONG state[CC_MD2_BLOCK_LONG]; } CC_MD2_CTX; extern int CC_MD2_Init(CC_MD2_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD2_Update(CC_MD2_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD2_Final(unsigned char *md, CC_MD2_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_MD2(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** MD4 ***/ #define CC_MD4_DIGEST_LENGTH 16 /* digest length in bytes */ #define CC_MD4_BLOCK_BYTES 64 /* block size in bytes */ #define CC_MD4_BLOCK_LONG (CC_MD4_BLOCK_BYTES / sizeof(CC_LONG)) typedef struct CC_MD4state_st { CC_LONG A,B,C,D; CC_LONG Nl,Nh; CC_LONG data[CC_MD4_BLOCK_LONG]; uint32_t num; } CC_MD4_CTX; extern int CC_MD4_Init(CC_MD4_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD4_Update(CC_MD4_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD4_Final(unsigned char *md, CC_MD4_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_MD4(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** MD5 ***/ #define CC_MD5_DIGEST_LENGTH 16 /* digest length in bytes */ #define CC_MD5_BLOCK_BYTES 64 /* block size in bytes */ #define CC_MD5_BLOCK_LONG (CC_MD5_BLOCK_BYTES / sizeof(CC_LONG)) typedef struct CC_MD5state_st { CC_LONG A,B,C,D; CC_LONG Nl,Nh; CC_LONG data[CC_MD5_BLOCK_LONG]; int num; } CC_MD5_CTX; extern int CC_MD5_Init(CC_MD5_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD5_Update(CC_MD5_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_MD5_Final(unsigned char *md, CC_MD5_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** SHA1 ***/ #define CC_SHA1_DIGEST_LENGTH 20 /* digest length in bytes */ #define CC_SHA1_BLOCK_BYTES 64 /* block size in bytes */ #define CC_SHA1_BLOCK_LONG (CC_SHA1_BLOCK_BYTES / sizeof(CC_LONG)) typedef struct CC_SHA1state_st { CC_LONG h0,h1,h2,h3,h4; CC_LONG Nl,Nh; CC_LONG data[CC_SHA1_BLOCK_LONG]; int num; } CC_SHA1_CTX; extern int CC_SHA1_Init(CC_SHA1_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA1_Update(CC_SHA1_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA1_Final(unsigned char *md, CC_SHA1_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_SHA1(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** SHA224 ***/ #define CC_SHA224_DIGEST_LENGTH 28 /* digest length in bytes */ #define CC_SHA224_BLOCK_BYTES 64 /* block size in bytes */ /* same context struct is used for SHA224 and SHA256 */ typedef struct CC_SHA256state_st { CC_LONG count[2]; CC_LONG hash[8]; CC_LONG wbuf[16]; } CC_SHA256_CTX; extern int CC_SHA224_Init(CC_SHA256_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA224_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA224_Final(unsigned char *md, CC_SHA256_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_SHA224(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** SHA256 ***/ #define CC_SHA256_DIGEST_LENGTH 32 /* digest length in bytes */ #define CC_SHA256_BLOCK_BYTES 64 /* block size in bytes */ extern int CC_SHA256_Init(CC_SHA256_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA256_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA256_Final(unsigned char *md, CC_SHA256_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_SHA256(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** SHA384 ***/ #define CC_SHA384_DIGEST_LENGTH 48 /* digest length in bytes */ #define CC_SHA384_BLOCK_BYTES 128 /* block size in bytes */ /* same context struct is used for SHA384 and SHA512 */ typedef struct CC_SHA512state_st { CC_LONG64 count[2]; CC_LONG64 hash[8]; CC_LONG64 wbuf[16]; } CC_SHA512_CTX; extern int CC_SHA384_Init(CC_SHA512_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA384_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA384_Final(unsigned char *md, CC_SHA512_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_SHA384(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*** SHA512 ***/ #define CC_SHA512_DIGEST_LENGTH 64 /* digest length in bytes */ #define CC_SHA512_BLOCK_BYTES 128 /* block size in bytes */ extern int CC_SHA512_Init(CC_SHA512_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA512_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern int CC_SHA512_Final(unsigned char *md, CC_SHA512_CTX *c) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); extern unsigned char *CC_SHA512(const void *data, CC_LONG len, unsigned char *md) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /* * To use the above digest functions with existing code which uses * the corresponding openssl functions, #define the symbol * COMMON_DIGEST_FOR_OPENSSL in your client code (BEFORE including * this file), and simply link against libSystem (or System.framework) * instead of libcrypto. * * You can *NOT* mix and match functions operating on a given data * type from the two implementations; i.e., if you do a CC_MD5_Init() * on a CC_MD5_CTX object, do not assume that you can do an openssl-style * MD5_Update() on that same context. */ #ifdef COMMON_DIGEST_FOR_OPENSSL #define MD2_DIGEST_LENGTH CC_MD2_DIGEST_LENGTH #define MD2_CTX CC_MD2_CTX #define MD2_Init CC_MD2_Init #define MD2_Update CC_MD2_Update #define MD2_Final CC_MD2_Final #define MD4_DIGEST_LENGTH CC_MD4_DIGEST_LENGTH #define MD4_CTX CC_MD4_CTX #define MD4_Init CC_MD4_Init #define MD4_Update CC_MD4_Update #define MD4_Final CC_MD4_Final #define MD5_DIGEST_LENGTH CC_MD5_DIGEST_LENGTH #define MD5_CTX CC_MD5_CTX #define MD5_Init CC_MD5_Init #define MD5_Update CC_MD5_Update #define MD5_Final CC_MD5_Final #define SHA_DIGEST_LENGTH CC_SHA1_DIGEST_LENGTH #define SHA_CTX CC_SHA1_CTX #define SHA1_Init CC_SHA1_Init #define SHA1_Update CC_SHA1_Update #define SHA1_Final CC_SHA1_Final #define SHA224_DIGEST_LENGTH CC_SHA224_DIGEST_LENGTH #define SHA256_CTX CC_SHA256_CTX #define SHA224_Init CC_SHA224_Init #define SHA224_Update CC_SHA224_Update #define SHA224_Final CC_SHA224_Final #define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH #define SHA256_Init CC_SHA256_Init #define SHA256_Update CC_SHA256_Update #define SHA256_Final CC_SHA256_Final #define SHA384_DIGEST_LENGTH CC_SHA384_DIGEST_LENGTH #define SHA512_CTX CC_SHA512_CTX #define SHA384_Init CC_SHA384_Init #define SHA384_Update CC_SHA384_Update #define SHA384_Final CC_SHA384_Final #define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH #define SHA512_Init CC_SHA512_Init #define SHA512_Update CC_SHA512_Update #define SHA512_Final CC_SHA512_Final #endif /* COMMON_DIGEST_FOR_OPENSSL */ /* * In a manner similar to that described above for openssl * compatibility, these macros can be used to provide compatiblity * with legacy implementations of MD5 using the interface defined * in RFC 1321. */ #ifdef COMMON_DIGEST_FOR_RFC_1321 #define MD5_CTX CC_MD5_CTX #define MD5Init CC_MD5_Init #define MD5Update CC_MD5_Update void MD5Final (unsigned char [16], MD5_CTX *) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); #endif /* COMMON_DIGEST_FOR_RFC_1321 */ #ifdef __cplusplus } #endif #endif /* _CC_COMMON_DIGEST_H_ */ |
Changes to CommonCrypto/CommonHMAC.h.
︙ | ︙ | |||
18 19 20 21 22 23 24 | * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /*! | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /*! @header CommonHMAC.h @abstract Keyed Message Authentication Code (HMAC) functions. */ #ifndef _CC_COMMON_HMAC_H_ #define _CC_COMMON_HMAC_H_ #include <CommonCrypto/CommonDigest.h> #include <sys/types.h> #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /*! @enum CCHmacAlgorithm @abstract Algorithms implemented in this module. @constant kCCHmacAlgSHA1 HMAC with SHA1 digest @constant kCCHmacAlgMD5 HMAC with MD5 digest @constant kCCHmacAlgSHA256 HMAC with SHA256 digest @constant kCCHmacAlgSHA384 HMAC with SHA384 digest @constant kCCHmacAlgSHA512 HMAC with SHA512 digest @constant kCCHmacAlgSHA224 HMAC with SHA224 digest */ enum { kCCHmacAlgSHA1, kCCHmacAlgMD5, kCCHmacAlgSHA256, kCCHmacAlgSHA384, kCCHmacAlgSHA512, kCCHmacAlgSHA224 }; typedef uint32_t CCHmacAlgorithm; /*! @typedef CCHmacContext @abstract HMAC context. */ #define CC_HMAC_CONTEXT_SIZE 96 typedef struct { uint32_t ctx[CC_HMAC_CONTEXT_SIZE]; } CCHmacContext; /*! @function CCHmacInit @abstract Initialize an CCHmacContext with provided raw key bytes. @param ctx An HMAC context. @param algorithm HMAC algorithm to perform. @param key Raw key bytes. @param keyLength Length of raw key bytes; can be any length including zero. */ void CCHmacInit( CCHmacContext *ctx, CCHmacAlgorithm algorithm, const void *key, size_t keyLength) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*! @function CCHmacUpdate @abstract Process some data. @param ctx An HMAC context. @param data Data to process. @param dataLength Length of data to process, in bytes. @discussion This can be called multiple times. */ void CCHmacUpdate( CCHmacContext *ctx, const void *data, size_t dataLength) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /*! @function CCHmacFinal @abstract Obtain the final Message Authentication Code. @param ctx An HMAC context. @param macOut Destination of MAC; allocated by caller. @discussion The length of the MAC written to *macOut is the same as the digest length associated with the HMAC algorithm: kCCHmacSHA1 : CC_SHA1_DIGEST_LENGTH kCCHmacMD5 : CC_MD5_DIGEST_LENGTH */ void CCHmacFinal( CCHmacContext *ctx, void *macOut) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); /* * Stateless, one-shot HMAC function. * Output is written to caller-supplied buffer, as in CCHmacFinal(). */ void CCHmac( CCHmacAlgorithm algorithm, /* kCCHmacSHA1, kCCHmacMD5 */ const void *key, size_t keyLength, /* length of key in bytes */ const void *data, size_t dataLength, /* length of data in bytes */ void *macOut) /* MAC written here */ __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_COMMON_HMAC_H_ */ |
Changes to CommonCrypto/CommonKeyDerivation.h.
︙ | ︙ | |||
20 21 22 23 24 25 26 | * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_PBKDF_H_ #define _CC_PBKDF_H_ | | | | > | > | < < | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_PBKDF_H_ #define _CC_PBKDF_H_ #include <sys/param.h> #include <string.h> #include <Availability.h> #ifdef KERNEL #include <machine/limits.h> #else #include <limits.h> #include <stdlib.h> #endif /* KERNEL */ #include <CommonCrypto/CommonDigest.h> #include <CommonCrypto/CommonHMAC.h> #ifdef __cplusplus extern "C" { #endif |
︙ | ︙ | |||
88 89 90 91 92 93 94 | * kCCPRFHmacAlgSHA1 * kCCPRFHmacAlgSHA224 * kCCPRFHmacAlgSHA256 * kCCPRFHmacAlgSHA384 * kCCPRFHmacAlgSHA512 | | | > | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | * kCCPRFHmacAlgSHA1 * kCCPRFHmacAlgSHA224 * kCCPRFHmacAlgSHA256 * kCCPRFHmacAlgSHA384 * kCCPRFHmacAlgSHA512 @result kCCParamError can result from bad values for the password, salt, and unwrapped key pointers as well as a bad value for the prf function. */ int CCKeyDerivationPBKDF( CCPBKDFAlgorithm algorithm, const char *password, size_t passwordLen, const uint8_t *salt, size_t saltLen, CCPseudoRandomAlgorithm prf, uint rounds, uint8_t *derivedKey, size_t derivedKeyLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* * All lengths are in bytes - not bits. */ /* |
︙ | ︙ | |||
125 126 127 128 129 130 131 | @result the number of iterations to use for the desired processing time. */ uint CCCalibratePBKDF(CCPBKDFAlgorithm algorithm, size_t passwordLen, size_t saltLen, CCPseudoRandomAlgorithm prf, size_t derivedKeyLen, uint32_t msec) | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | @result the number of iterations to use for the desired processing time. */ uint CCCalibratePBKDF(CCPBKDFAlgorithm algorithm, size_t passwordLen, size_t saltLen, CCPseudoRandomAlgorithm prf, size_t derivedKeyLen, uint32_t msec) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_PBKDF_H_ */ |
Changes to CommonCrypto/CommonSymmetricKeywrap.h.
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #define _CC_SYMKEYWRAP_H_ #include <sys/types.h> #include <sys/param.h> #include <stdint.h> #include <string.h> #include <limits.h> #include <stdlib.h> #include <Availability.h> #ifdef __cplusplus extern "C" { #endif enum { kCCWRAPAES = 1, }; | > > > > | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #define _CC_SYMKEYWRAP_H_ #include <sys/types.h> #include <sys/param.h> #include <stdint.h> #include <string.h> #ifdef KERNEL #include <machine/limits.h> #else #include <limits.h> #include <stdlib.h> #endif /* KERNEL */ #include <Availability.h> #ifdef __cplusplus extern "C" { #endif enum { kCCWRAPAES = 1, }; extern const uint8_t *CCrfc3394_iv __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0); extern const size_t CCrfc3394_ivLen __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0); typedef uint32_t CCWrappingAlgorithm; /*! @function CCSymmetricKeyWrap @abstract Wrap a symmetric key with a Key Encryption Key (KEK). |
︙ | ︙ | |||
78 79 80 81 82 83 84 | int CCSymmetricKeyWrap( CCWrappingAlgorithm algorithm, const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *rawKey, size_t rawKeyLen, uint8_t *wrappedKey, size_t *wrappedKeyLen) | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | int CCSymmetricKeyWrap( CCWrappingAlgorithm algorithm, const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *rawKey, size_t rawKeyLen, uint8_t *wrappedKey, size_t *wrappedKeyLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCSymmetricKeyUnwrap @abstract Unwrap a symmetric key with a Key Encryption Key (KEK). @param algorithm Currently only AES Keywrapping (rfc3394) is available via kCCWRAPAES |
︙ | ︙ | |||
114 115 116 117 118 119 120 | int CCSymmetricKeyUnwrap( CCWrappingAlgorithm algorithm, const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *wrappedKey, size_t wrappedKeyLen, uint8_t *rawKey, size_t *rawKeyLen) | | | | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | int CCSymmetricKeyUnwrap( CCWrappingAlgorithm algorithm, const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *wrappedKey, size_t wrappedKeyLen, uint8_t *rawKey, size_t *rawKeyLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCSymmetricWrappedSize @abstract Determine the buffer size required to hold a key wrapped with CCAESKeyWrap(). @param algorithm Currently only AES Keywrapping (rfc3394) is available via kCCWRAPAES @param rawKeyLen The length of the key in bytes. @result The length of the resulting wrapped key. */ size_t CCSymmetricWrappedSize( CCWrappingAlgorithm algorithm, size_t rawKeyLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCSymmetricUnwrappedSize @abstract Determine the buffer size required to hold a key unwrapped with CCAESKeyUnwrap(). @param algorithm Currently only AES Keywrapping (rfc3394) is available via kCCWRAPAES @param wrappedKeyLen The length of the wrapped key in bytes. @result The length of the resulting raw key. */ size_t CCSymmetricUnwrappedSize( CCWrappingAlgorithm algorithm, size_t wrappedKeyLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_SYMKEYWRAP_H_ */ |
Deleted Configurations/CommonCrypto_base.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_deployment.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_development.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_dynamic.xcconfig.
|
| < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_dynamic_deployment.xcconfig.
|
| < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_dynamic_development.xcconfig.
|
| < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_localtest.xcconfig.
|
| < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_static.xcconfig.
|
| < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_static_deployment.xcconfig.
|
| < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_static_development.xcconfig.
|
| < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_umbrellaMember.xcconfig.
|
| < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_umbrellaMember_deployment.xcconfig.
|
| < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_umbrellaMember_development.xcconfig.
|
| < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unitTest_dynamic_development.xcconfig.
|
| < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_base.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_deployment.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_development.xcconfig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_dynamic_deployment.xcconfig.
|
| < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_static_deployment.xcconfig.
|
| < < < < < < < < < < < |
Deleted Configurations/CommonCrypto_unittest_static_development.xcconfig.
|
| < < < < < < < < < < < |
Added Configurations/components/CC_base.xcconfig.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | // // CommonCrypto_base.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the shared settings for all targets of the // CommonCrypto XCode Project // ************************************************************************** // * Begin Project Section // ************************************************************************** ARCHS = $(NATIVE_ARCH) $(ARCHS_STANDARD_64_BIT) arm // Minimum OS version MACOSX_DEPLOYMENT_TARGET = BUILD_VARIANTS = normal profile debug // // Directory Names // CC_PATH_BASE = $(PROJECT_DIR) CC_PATH_XCCONFIGS = $(CC_PATH_BASE)/Configurations CC_PATH_PUBLIC_HEADERS = $(CC_PATH_BASE)/CommonCrypto CC_PATH_SOURCE = $(CC_PATH_BASE)/Source // This REALLY should come from an include from a truly global XCCONFIG file // This can easily be retrofitted when we have more projects using this // system CONFIGURATION_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION) PUBLIC_HEADERS_FOLDER_PATH = /usr/include/CommonCrypto PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/CommonCrypto HEADER_SEARCH_PATHS = // USER_HEADER_SEARCH_PATHS = $(CC_PATH_SOURCE) // Include user path in header search ALWAYS_SEARCH_USER_PATHS = YES // Deal with "installation" This may not be necessary but it will not hurt either INSTALL_PATH = /usr/lib/system INSTALL_OWNER = root INSTALL_GROUP = wheel // Deal with project versioning MYVERSION = 50000 CURRENT_PROJECT_VERSION = $(MYVERSION) VERSIONING_SYSTEM = apple-generic VERSION_INFO_BUILDER = $(USER) DYLIB_COMPATIBILITY_VERSION = 1 DYLIB_CURRENT_VERSION = $(MYVERSION) EXECUTABLE_PREFIX = lib // ************************************************************************** // * End Project Section // ************************************************************************** // ************************************************************************** // * Begin Code Signing Section // ************************************************************************** CODE_SIGN_IDENTITY = CODE_SIGN_RESOURCE_RULES_PATH = OTHER_CODE_SIGN_FLAGS = // ************************************************************************** // * End Code Signing Section // ************************************************************************** // ************************************************************************** // * Begin Compiler Section // ************************************************************************** // Compiler version: Unset - setting this can cause problems between build // trains. GCC_VERSION = com.apple.compilers.llvm.clang.1_0 // Debugging information. DEBUG_INFORMATION_FORMAT = dwarf-with-dsym // Tuning GCC_MODEL_TUNING = G4 // GCC Flags GCC_AUTO_VECTORIZATION = NO // Ensure position independent code generation GCC_DYNAMIC_NO_PIC = NO GCC_ENABLE_FIX_AND_CONTINUE = NO GCC_ENABLE_KERNEL_DEVELOPMENT = NO GCC_ENABLE_SSE3_EXTENSIONS = NO GCC_ENABLE_SSE41_EXTENSIONS = NO GCC_ENABLE_SSE42_EXTENSIONS = NO GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = NO GCC_ENABLE_SYMBOL_SEPARATION = NO GCC_FAST_MATH = NO // Test Coverage GCC_GENERATE_TEST_COVERAGE_FILES = NO GCC_INLINES_ARE_PRIVATE_EXTERN = NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO GCC_MODEL_PPC64 = NO GCC_NO_COMMON_BLOCKS = NO // Objective-C++ destructors GCC_OBJC_CALL_CXX_CDTORS = NO GCC_STRICT_ALIASING = NO GCC_SYMBOLS_PRIVATE_EXTERN = YES GCC_UNROLL_LOOPS = NO GCC_FEEDBACK_DIRECTED_OPTIMIZATION = off GCC_FAST_OBJC_DISPATCH = YES GCC_GENERATE_DEBUGGING_SYMBOLS = YES GCC_REUSE_STRINGS = YES GCC_THREADSAFE_STATICS = YES GCC_DEBUGGING_SYMBOLS = default // Garbage collection GCC_ENABLE_OBJC_GC = unsupported // Language Flags // Prefix file Should we have one of these? GCC_PRECOMPILE_PREFIX_HEADER = NO GCC_PREFIX_HEADER = GCC_ALTIVEC_EXTENSIONS = NO GCC_CHAR_IS_UNSIGNED_CHAR = NO GCC_CHECK_RETURN_VALUE_OF_OPERATOR_NEW = NO GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO GCC_ENABLE_TRIGRAPHS = NO GCC_FORCE_CPU_SUBTYPE_ALL = NO GCC_INCREASE_PRECOMPILED_HEADER_SHARING = NO GCC_ONE_BYTE_BOOL = NO GCC_SHORT_ENUMS = NO GCC_USE_INDIRECT_FUNCTION_CALLS = NO GCC_USE_REGISTER_FUNCTION_CALLS = NO GCC_CW_ASM_SYNTAX = YES GCC_ENABLE_ASM_KEYWORD = YES GCC_ENABLE_BUILTIN_FUNCTIONS = YES GCC_ENABLE_CPP_EXCEPTIONS = YES GCC_ENABLE_CPP_RTTI = YES GCC_ENABLE_OBJC_EXCEPTIONS = YES GCC_ENABLE_PASCAL_STRINGS = YES GCC_LINK_WITH_DYNAMIC_LIBRARIES = YES GCC_USE_STANDARD_INCLUDE_SEARCHING = YES // WARNINGS // // I am including most warnings in this list, If problems occur they can // be commented out or changed to be NO WARNING_CFLAGS = -Wall GCC_TREAT_WARNINGS_AS_ERRORS = YES // Should any of these be YES? GCC_WARN_PEDANTIC = NO GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES GCC_WARN_64_TO_32_BIT_CONVERSION = YES GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES GCC_WARN_ABOUT_MISSING_NEWLINE = YES GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES GCC_WARN_INHIBIT_ALL_WARNINGS = YES GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES GCC_WARN_MISSING_PARENTHESES = YES GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES GCC_WARN_PROTOTYPE_CONVERSION = YES GCC_WARN_SHADOW = YES GCC_WARN_SIGN_COMPARE = YES GCC_WARN_STRICT_SELECTOR_MATCH = YES GCC_WARN_UNDECLARED_SELECTOR = YES GCC_WARN_UNKNOWN_PRAGMAS = YES GCC_WARN_UNUSED_PARAMETER = YES GCC_WARN_UNUSED_VARIABLE = YES GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES GCC_WARN_ABOUT_RETURN_TYPE = YES GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES GCC_WARN_CHECK_SWITCH_STATEMENTS = YES GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES GCC_WARN_UNINITIALIZED_AUTOS = YES GCC_WARN_UNUSED_FUNCTION = YES GCC_WARN_UNUSED_LABEL = YES GCC_PREPROCESSOR_DEFINITIONS = _FORTIFY_SOURCE=2 // ************************************************************************** // * End Compiler Section // ************************************************************************** // ************************************************************************** // * Begin Linker Section // ************************************************************************** // OTHER_LDFLAGS // Set up a three tiered set of variables for linker flags // This will allow for adding linker flags and not run into // the XCCONFIG "bug" of not being able to set FOO = $(FOO) bar DEAD_CODE_STRIPPING = YES GENERATE_MASTER_OBJECT_FILE = NO KEEP_PRIVATE_EXTERNS = NO // Should this be yes? LD_GENERATE_MAP_FILE = NO LINKER_DISPLAYS_MANGLED_NAMES = NO PRESERVE_DEAD_CODE_INITS_AND_TERMS = NO SEPARATE_SYMBOL_EDIT = NO LINK_WITH_STANDARD_LIBRARIES = YES PREBINDING = NO // ************************************************************************** // * End Linker Section // ************************************************************************** |
Added Configurations/components/CC_deployment.xcconfig.
> > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // // CommonCrypto_deployment.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the deployment settings for all targets #include "CC_base.xcconfig" // Debug build set optimization level to s GCC_OPTIMIZATION_LEVEL = s GCC_PREPROCESSOR_DEFINITIONS_PROJECT = NDEBUG COPY_PHASE_STRIP = YES WARNING_CFLAGS = -Wall |
Added Configurations/components/CC_development.xcconfig.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // // CommonCrypto_debug.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the development settings for all targets #include "CC_base.xcconfig" // Debug build set optimization level to 1 GCC_OPTIMIZATION_LEVEL = 0 // This was at odds with the base defining GCC_PREPROCESSOR_DEFINITIONS - it got // overidden by it. I copied the base value (_FORTIFY_SOURCE=2) and added DEBUG // to create a debug level override for GCC_PREPROCESSOR_DEFINITIONS // GCC_PREPROCESSOR_DEFINITIONS_PROJECT = DEBUG GCC_PREPROCESSOR_DEFINITIONS = _FORTIFY_SOURCE=2 DEBUG COPY_PHASE_STRIP = NO WARNING_CFLAGS = -Wall |
Added Configurations/components/CC_dynamic.xcconfig.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // // CommonCrypto_dynamic.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file defines settings that specific for dynamic libraries STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = Dynamic EXECUTABLE_EXTENSION = dylib LIBRARY_STYLE = Dynamic |
Added Configurations/components/CC_dynamic_deployment.xcconfig.
> > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | // // CC_dynamic_deployment.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the deployment version of the dynamic CommonCrypto Library #include "CC_deployment.xcconfig" #include "CC_dynamic.xcconfig" |
Added Configurations/components/CC_dynamic_development.xcconfig.
> > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | // // CC_dynamic_development.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the development version of the dynamic CommonCrypto Library #include "CC_development.xcconfig" #include "CC_dynamic.xcconfig" |
Added Configurations/components/CC_kernel.xcconfig.
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // // CC_kernel_development.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the settings for kernel kext targets GCC_ENABLE_KERNEL_DEVELOPMENT = YES KERNEL_MODULE = YES WRAPPER_EXTENSION = kext // GCC_WARN_PEDANTIC is a problem for non-ISO compliant kernel headers GCC_WARN_PEDANTIC = NO DEAD_CODE_STRIPPING = NO // Standard paths for kexts INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Extensions" PRIVATE_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/PrivateHeaders/$(KEXT_FAMILY_NAME)" PUBLIC_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/Headers/$(KEXT_FAMILY_NAME)" |
Added Configurations/components/CC_kernel_deployment.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CC_kernel_deployment.xcconfig // CommonCrypto // // Created by Stacey Son on 10/20/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the deployment version of the kernel CommonCrypto kext. #include "CC_deployment.xcconfig" #include "CC_kernel.xcconfig" |
Added Configurations/components/CC_kernel_development.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CC_kernel_development.xcconfig // CommonCrypto // // Created by Stacey Son on 10/20/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the development version of the kernel CommonCrypto kext. #include "CC_development.xcconfig" #include "CC_kernel.xcconfig" |
Added Configurations/components/CC_static.xcconfig.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // // CC_static.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file defines settings that specific for static libraries STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = Dynamic EXECUTABLE_EXTENSION = a LIBRARY_STYLE = Static |
Added Configurations/components/CC_static_deployment.xcconfig.
> > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | // // CC_static_deployment.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the deployment version of the static CommonCrypto Library #include "CC_deployment.xcconfig" #include "CC_static.xcconfig" |
Added Configurations/components/CC_static_development.xcconfig.
> > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | // // CC_static_development.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/11/10. // Copyright 2010 Apple. All rights reserved. // // This XCCONFIG file is for the development version of the static CommonCrypto Library #include "CC_development.xcconfig" #include "CC_static.xcconfig" |
Added Configurations/components/CC_umbrellaMember.xcconfig.
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // // CC_umbrellaMember.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines settings that specific for umbrella member libraries OTHER_LDFLAGS = -Wl -umbrella System -allowable_client otest -allowable_client CommonCryptoUnitTest -allowable_client XTSTest -allowable_client CBCTest -allowable_client tcCryptoTool -allowable_client bigcbc STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = Dynamic EXECUTABLE_EXTENSION = dylib LIBRARY_STYLE = Dynamic |
Added Configurations/platforms/CC_MacOSXClient.xcconfig.
> > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 | // // MacOSXClient.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. SDKROOT = macosx10.6 OTHER_CFLAGS = -fstack-protector-all -Wstack-protector -DSHA256_USE_ASSEMBLY=1 -DCC_MACOSX PRODUCT_NAME = commonCrypto |
Added Configurations/platforms/CC_iOSClient.xcconfig.
> > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 | // // MacOSXClient.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. SDKROOT = iphoneos5.0.internal OTHER_CFLAGS = -fstack-protector-all -Wstack-protector -DSHA256_USE_ASSEMBLY=1 -DCC_iOS PRODUCT_NAME = commonCrypto |
Added Configurations/platforms/CC_iOSClientSim.xcconfig.
> > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | // // MacOSXClient.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. //SDKROOT = iphonesimulator5.0 OTHER_CFLAGS = -fstack-protector-all -Wstack-protector -DSHA256_USE_ASSEMBLY=1 -DCC_iOS_SIM PRODUCT_NAME = commonCrypto_sim PRIVATE_HEADERS_FOLDER_PATH = $(SDKROOT)/usr/local/include/CommonCrypto PUBLIC_HEADERS_FOLDER_PATH = $(SDKROOT)/usr/include/CommonCrypto |
Added Configurations/targets/CC_MacOSXClient_deployment.xcconfig.
> > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // // CommonCrypto_MacOSXClient_deployment.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the deployment version of the CommonCrypto umbrella member for System CommonCrypto Library for MacOSX #include "../components/CC_deployment.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_MacOSXClient.xcconfig" |
Added Configurations/targets/CC_MacOSXClient_development.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CommonCrypto_MacOSXClient_development.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the development version of the CommonCrypto umbrella member for System CommonCrypto Library for MacOSX #include "../components/CC_development.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_MacOSXClient.xcconfig" |
Added Configurations/targets/CC_iOSClient_deployment.xcconfig.
> > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // // CommonCrypto_MacOSXClient_deployment.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the deployment version of the umbrella member for System CommonCrypto Library #include "../components/CC_deployment.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_iOSClient.xcconfig" |
Added Configurations/targets/CC_iOSClient_development.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CC_MacOSXClient_development.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the development version of the CommonCrypto umbrella member for System CommonCrypto Library for MacOSX #include "../components/CC_development.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_iOSClient.xcconfig" |
Added Configurations/targets/CC_iOSSim_deployment.xcconfig.
> > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // // CC_MacOSXClient_deployment.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the deployment version of the umbrella member for System CommonCrypto Library #include "../components/CC_deployment.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_iOSClientSim.xcconfig" |
Added Configurations/targets/CC_iOSSim_development.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CC_MacOSXClient_development.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file is for the development version of the CommonCrypto umbrella member for System CommonCrypto Library for MacOSX #include "../components/CC_development.xcconfig" #include "../components/CC_umbrellaMember.xcconfig" #include "../platforms/CC_iOSClientSim.xcconfig" |
Added Configurations/tests/CC_localtest.xcconfig.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // // CommonCrypto_unittest_base.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // ARCHS = $(NATIVE_ARCH) $(ARCHS_STANDARD_64_BIT) arm GCC_OPTIMIZATION_LEVEL = 0 GCC_PREPROCESSOR_DEFINITIONS = _FORTIFY_SOURCE=2 DEBUG COPY_PHASE_STRIP = NO WARNING_CFLAGS = -Wall |
Added Configurations/tests/CC_unitTest_dynamic_development.xcconfig.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | // // CommonCrypto_unitTest_dynamic_development.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/13/10. // Copyright 2010 Apple. All rights reserved. // #include "CC_unittest_development.xcconfig" LIBRARY_STYLE = Dynamic |
Added Configurations/tests/CC_unittest_base.xcconfig.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // // CommonCrypto_unittest_base.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the shared settings for all unit test targets of the // CommonCrypto XCode Project // ************************************************************************** // * Begin Project Section // ************************************************************************** CC_PATH_BASE = $(PROJECT_DIR) CC_PATH_UNIT_TEST_SOURCE = $(CC_PATH_BASE)/UnitTestSource PRODUCT_NAME = CommonCryptoUnitTest ARCHS = $(NATIVE_ARCH) $(ARCHS_STANDARD_64_BIT) arm OTHER_LDFLAGS = -framework Cocoa -framework SenTestingKit WRAPPER_EXTENSION = octest FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_FRAMEWORKS_DIR) GCC_PREFIX_HEADER = $(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h INFOPLIST_FILE = $(CC_PATH_UNIT_TEST_SOURCE)/CommonCryptoUnitTests-Info.plist OBJC_DISABLE_GC = NO // ************************************************************************** // * End Project Section // ************************************************************************** |
Added Configurations/tests/CC_unittest_deployment.xcconfig.
> > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // // CommonCrypto_unittest_base.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the deployment setting for unit test targets of the // CommonCrypto XCode Project #include "CC_unittest_base.xcconfig" GCC_OPTIMIZATION_LEVEL = s GCC_PREPROCESSOR_DEFINITIONS_PROJECT = NDEBUG COPY_PHASE_STRIP = YES WARNING_CFLAGS = -Wall |
Added Configurations/tests/CC_unittest_development.xcconfig.
> > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // // CommonCrypto_unittest_base.xcconfig // CommonCrypto // // InfoSec Standard Configuration // Copyright 2010 Apple Inc. All rights reserved. // // This XCCONFIG file defines the development setting for unit test targets of the // CommonCrypto XCode Project #include "CC_unittest_base.xcconfig" GCC_OPTIMIZATION_LEVEL = 0 GCC_PREPROCESSOR_DEFINITIONS_PROJECT = DEBUG COPY_PHASE_STRIP = NO WARNING_CFLAGS = -Wall |
Added Configurations/tests/CC_unittest_dynamic_deployment.xcconfig.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | // // CommonCrypto_unittest_dynamic_deployment.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/13/10. // Copyright 2010 Apple. All rights reserved. // #include "CC_unittest_deployment.xcconfig" LIBRARY_STYLE = Dynamic |
Added Configurations/tests/CC_unittest_static_deployment.xcconfig.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | // // CommonCrypto_unittest_static_deployment.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/13/10. // Copyright 2010 Apple. All rights reserved. // #include "CC_unittest_deployment.xcconfig" LIBRARY_STYLE = Static |
Added Configurations/tests/CC_unittest_static_development.xcconfig.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | // // CommonCrypto_unittest_static_development.xcconfig // CommonCrypto // // Created by Jim Murphy on 1/13/10. // Copyright 2010 Apple. All rights reserved. // #include "CC_unittest_development.xcconfig" LIBRARY_STYLE = Static |
Deleted LocalTests/CBCTest/CBCTest.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/CBCTest/CBCTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/crypto.c.
|
| < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/hexString.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/hexString.h.
|
| < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/printByteBuffer.c.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/printByteBuffer.h.
|
| < < < < < < < < < < < < < < |
Deleted LocalTests/XTSTest/xtsTestVectors.c.
more than 10,000 changes
Deleted LocalTests/XTSTest/xtsTestVectors.h.
|
| < < < < < < < < < |
Deleted LocalTests/ccSymTest.cpp.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/testUtil/byteBuffer.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/testUtil/byteBuffer.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/Makefile.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/boxes-ref.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/bsafeUtils.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/bsafeUtils.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/common.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/common.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/commonCpp.cpp.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cputime.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cputime.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cspdlTesting.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cspwrap.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cspwrap.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/cssmErrorStrings.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/fileIo.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/fileIo.h.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/nssAppUtils.cpp.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/nssAppUtils.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/rijndael-alg-ref.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/rijndael-alg-ref.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/rijndaelApi.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/rijndaelApi.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/ssleayUtils.cpp.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/ssleayUtils.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LocalTests/utilLib/t_stdlib.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/AES.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/AESAssembly.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Data.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/AES.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/Data.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/DecryptCBC.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/EncryptCBC.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/EncryptDecrypt.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/ExpandKeyForDecryption.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/ExpandKeyForEncryption.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/Intel/ReadMe.txt.
|
| < < < < |
Deleted Source/AESedp/MakeData.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/ReadMe.txt.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/AESedp/makefile.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/API/CommonBigNum.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_BIGNUM_FUNCTIONS #include "CommonBigNum.h" #include "CommonBigNumPriv.h" #include "CommonRandomSPI.h" #include "ccMemory.h" #include "ccErrors.h" #include "ccdebug.h" #include <corecrypto/ccz.h> #include <corecrypto/ccn.h> /* For ccn_sizeof(). */ #include <corecrypto/cc_priv.h> /* For CC_LOAD32_BE. */ static void * cc_alloc(void *ctx CC_UNUSED, size_t size) { return malloc(size); } static void cc_free(void *ctx CC_UNUSED, size_t oldsize, void *p) { cc_zero(oldsize, p); free(p); } static void * cc_realloc(void *ctx CC_UNUSED, size_t oldsize, void *p, size_t newsize) { void *r = malloc(newsize); memcpy(r, p, oldsize); cc_zero(oldsize, p); free(p); return r; } struct ccz_class ccz_c = { .ctx = 0, .ccz_alloc = cc_alloc, .ccz_realloc = cc_realloc, .ccz_free = cc_free }; CCBigNumRef CCCreateBigNum(CCStatus *status) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = malloc(ccz_size(&ccz_c)); if (status) *status = r ? kCCSuccess : kCCMemoryFailure; if (r) ccz_init(&ccz_c, r); if(!r) printf("Bad Create\n"); return (CCBigNumRef)r; } CCStatus CCBigNumClear(CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)bn; ccz_zero(r); return kCCSuccess; } void CCBigNumFree(CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)bn; ccz_free(r); free(r); } CCBigNumRef CCBigNumCopy(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; ccz *r = (ccz *)CCCreateBigNum(status); if (r) ccz_set(r, s); return (CCBigNumRef)r; } uint32_t CCBigNumBitCount(const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; return ccz_bitlen(s); } uint32_t CCBigNumZeroLSBCount(const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; return ccz_trailing_zeros(s); } uint32_t CCBigNumByteCount(const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; return ccz_write_uint_size(s); } CCBigNumRef CCBigNumFromData(CCStatus *status, const void *s, size_t len) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)CCCreateBigNum(status); if (r) { ccz_read_uint(r, len, s); } return (CCBigNumRef)r; } size_t CCBigNumToData(CCStatus *status, const CCBigNumRef bn, void *to) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; size_t to_size = ccz_write_uint_size(s); ccz_write_uint(s, to_size, to); return to_size; } CCBigNumRef CCBigNumFromHexString(CCStatus *status, const char *in) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)CCCreateBigNum(status); if (r) { if (ccz_read_radix(r, strlen(in), in, 16)) { ccz_zero(r); if (status) *status = kCCDecodeError; return NULL; } } return (CCBigNumRef)r; } char * CCBigNumToHexString(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (ccz *)bn; size_t to_size = ccz_write_radix_size(s, 16); char *to = malloc(to_size+1); ccz_write_radix(s, to_size, to, 16); to[to_size] = 0; return to; } int CCBigNumCompare(const CCBigNumRef bn1, const CCBigNumRef bn2) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (const ccz *)bn1; const ccz *t = (const ccz *)bn2; return ccz_cmp(s, t); } int CCBigNumCompareI(const CCBigNumRef bn1, const uint32_t num) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); const ccz *s = (const ccz *)bn1; return ccz_cmpi(s, num); } CCStatus CCBigNumSetNegative(CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)bn; ccz_neg(r); return kCCSuccess; } CCStatus CCBigNumSetI(CCBigNumRef bn, uint64_t num) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)bn; ccz_seti(r, num); return kCCSuccess; } uint32_t CCBigNumGetI(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); /* TODO: This could be done more efficiently if we pushed a ccz_readi and ccn_readi routine all the way down into corecrypto. */ ccz *s = (const ccz *)bn; uint32_t v = 0; if(ccz_write_int_size(s) > sizeof(v)) { *status = kCCOverflow; return 0; } uint8_t to[sizeof(v)]; ccz_write_uint(s, sizeof(v), to); CC_LOAD32_BE(v, to); if (status) *status = kCCSuccess; return v; } CCBigNumRef CCBigNumCreateRandom(CCStatus *status, int bits, int top, int bottom) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); struct ccrng_state *rng = ccDRBGGetRngState(); ccz *r = (ccz *)CCCreateBigNum(status); if (r && top > 0) { /* TODO: Use the #if 0'd code once CommonCrypto has a native ccrng handle to use. */ #if 1 do { ccz_random_bits(r, top, rng); } while(ccz_bitlen(r) - ccz_trailing_zeros(r) < bottom); #else size_t data_size = ccn_sizeof(top); uint8_t data[data_size]; CCStatus st; do { st = CCRandomCopyBytes(kCCRandomDefault, data, data_size); if (st) { break; } if (top & 7) data[0] &= 0xff >> 8 - (top & 7); ccz_read_uint(r, data_size, data); } while(ccz_bitlen(r) - ccz_trailing_zeros(r) < bottom); memset(data, 0, data_size); if (st) { if (status) *status = st; CCBigNumFree(r); r = NULL; } #endif } return (CCBigNumRef)r; } CCStatus CCBigNumAdd(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)res; ccz *s = (const ccz *)a; ccz *t = (const ccz *)b; ccz_add(r, s, t); return kCCSuccess; } CCStatus CCBigNumAddI(CCBigNumRef res, const CCBigNumRef a, const uint32_t b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)res; ccz *s = (const ccz *)a; ccz_addi(r, s, b); return kCCSuccess; } CCStatus CCBigNumSub(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)res; ccz *s = (const ccz *)a; ccz *t = (const ccz *)b; ccz_sub(r, s, t); return kCCSuccess; } CCStatus CCBigNumSubI(CCBigNumRef res, const CCBigNumRef a, const uint32_t b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz *r = (ccz *)res; ccz *s = (const ccz *)a; ccz_subi(r, s, b); return kCCSuccess; } CCStatus CCBigNumMul(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_mul(res, a, b); return kCCSuccess; } CCStatus CCBigNumMulI(CCBigNumRef res, const CCBigNumRef a, const uint32_t b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_muli(res, a, b); return kCCSuccess; } CCStatus CCBigNumDiv(CCBigNumRef quotient, CCBigNumRef remainder, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_divmod(quotient, remainder, a, b); return kCCSuccess; } CCStatus CCBigNumDiv2(CCBigNumRef res, const CCBigNumRef a) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_div2(res, a); return kCCSuccess; } CCStatus CCBigNumMod(CCBigNumRef res, CCBigNumRef dividend, CCBigNumRef modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_mod(res, dividend, modulus); return kCCSuccess; } CCStatus CCBigNumModI(uint32_t *res, CCBigNumRef dividend, uint32_t modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCStatus status = 0; CCBigNumRef r = CCCreateBigNum(&status); if(!r) goto err; CCBigNumRef mod = CCCreateBigNum(&status); if(!mod) goto err; status = CCBigNumSetI(mod, modulus); ccz_mod(r, dividend, mod); *res = CCBigNumGetI(&status, r); err: if(r) CCBigNumFree(r); if(mod) CCBigNumFree(mod); return status; } CCStatus CCBigNumSquare(CCBigNumRef res, const CCBigNumRef a) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_sqr(res, a); return kCCSuccess; } CCStatus CCBigNumGCD(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_gcd(res, a, b); return kCCSuccess; } CCStatus CCBigNumLCM(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_lcm(res, a, b); return kCCSuccess; } CCStatus CCBigNumMulMod(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef b, const CCBigNumRef modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_mulmod(res, a, b, modulus); return kCCSuccess; } CCStatus CCBigNumSquareMod(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_sqrmod(res, a, modulus); return kCCSuccess; } CCStatus CCBigNumInverseMod(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_invmod(res, a, modulus); return kCCSuccess; } CCStatus CCBigNumModExp(CCBigNumRef res, const CCBigNumRef a, const CCBigNumRef power, const CCBigNumRef modulus) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_expmod(res, a, power, modulus); return kCCSuccess; } CCStatus CCBigNumLeftShift(CCBigNumRef res, const CCBigNumRef a, const uint32_t digits) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_lsl(res, a, digits); return kCCSuccess; } CCStatus CCBigNumRightShift(CCBigNumRef res, const CCBigNumRef a, const uint32_t digits) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccz_lsr(res, a, digits); return kCCSuccess; } CCStatus CCBigNumMontgomerySetup(CCBigNumRef num, uint32_t *rho) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return kCCUnimplemented; // ccLTCErr(mp_montgomery_setup(num, rho)); } CCStatus CCBigNumMontgomeryNormalization(CCBigNumRef a, CCBigNumRef b) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return kCCUnimplemented; // ccLTCErr(mp_montgomery_normalization(a, b)); } CCStatus CCBigNumMontgomeryReduce(CCBigNumRef x, CCBigNumRef n, uint32_t rho) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return kCCUnimplemented; // ccLTCErr(mp_montgomery_reduce(x, n, rho)); } bool CCBigNumIsPrime(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if (status) *status = kCCSuccess; /* TODO: Figure out right number of rounds (or depth). */ return ccz_is_prime(bn, 16); } bool CCBigNumIsOdd(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if (status) *status = kCCSuccess; return ccz_is_odd(bn); } bool CCBigNumIsZero(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if (status) *status = kCCSuccess; return ccz_is_zero(bn); } bool CCBigNumIsNegative(CCStatus *status, const CCBigNumRef bn) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if (status) *status = kCCSuccess; return ccz_is_negative(bn); } |
Added Source/API/CommonBigNumPriv.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_BIGNUM_PRIV_H_ #define _CC_BIGNUM_PRIV_H_ #include <stdint.h> /* Uses the tomcrypt math structure to harness math libraries */ /* we probably want to convert this to a CCRandomRef later */ typedef void prng_state; #define LTC_SOURCE // #include "tomcrypt_math.h" typedef void ccBigNum; typedef ccBigNum *CCBigNumber; #endif /* _CC_BIGNUM_PRIV_H_ */ |
Changes to Source/API/CommonCMAC.c.
︙ | ︙ | |||
17 18 19 20 21 22 23 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ | | | | | | | | > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_CMAC_FUNCTIONS #include "CommonCMACSPI.h" #include "CommonCryptorPriv.h" #include <corecrypto/ccaes.h> #include "ccdebug.h" /* Internal functions to support one-shot */ const uint8_t const_Rb[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87 }; void leftshift_onebit(uint8_t *input, uint8_t *output) { int i; uint8_t overflow = 0; for ( i=15; i>=0; i-- ) { |
︙ | ︙ | |||
52 53 54 55 56 57 58 | void xor_128(const uint8_t *a, const uint8_t *b, uint8_t *out) { int i; for (i=0;i<16; i++) out[i] = a[i] ^ b[i]; } | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | void xor_128(const uint8_t *a, const uint8_t *b, uint8_t *out) { int i; for (i=0;i<16; i++) out[i] = a[i] ^ b[i]; } void ccGenAESSubKey(struct ccmode_ecb *aesmode, ccecb_ctx *ctx, void *key1, void *key2) { uint8_t L[16]; uint8_t Z[16]; uint8_t tmp[16]; size_t moved = 0; memset(Z, 0, 16); aesmode->ecb(ctx, 1, Z, L); if ( (L[0] & 0x80) == 0 ) { /* If MSB(L) = 0, then K1 = L << 1 */ leftshift_onebit(L, key1); } else { /* Else K1 = ( L << 1 ) (+) Rb */ leftshift_onebit(L, tmp); xor_128(tmp,const_Rb, key1); } |
︙ | ︙ | |||
102 103 104 105 106 107 108 | size_t dataLength, /* length of data in bytes */ void *macOut) /* MAC written here */ { uint8_t X[16],Y[16], M_last[16], padded[16]; uint8_t K1[16], K2[16]; int n, i, flag; size_t moved = 0; | > > | > > > > | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | size_t dataLength, /* length of data in bytes */ void *macOut) /* MAC written here */ { uint8_t X[16],Y[16], M_last[16], padded[16]; uint8_t K1[16], K2[16]; int n, i, flag; size_t moved = 0; struct ccmode_ecb *aesmode = getCipherMode(kCCAlgorithmAES128, kCCModeECB, kCCEncrypt).ecb; ccecb_ctx_decl(aesmode->size, ctx); CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); // CMacInit aesmode->init(aesmode, &ctx, 16, key); aesmode->ecb(&ctx, 1, Y, X); ccGenAESSubKey(aesmode, &ctx, K1, K2); // CMacUpdates (all in this case) n = (dataLength+15) / 16; /* n is number of rounds */ if ( 0 == n ) { n = 1; |
︙ | ︙ | |||
129 130 131 132 133 134 135 | ccAESCMacPadding(&data[16*(n-1)],padded,dataLength%16); xor_128(padded,K2,M_last); } memset(X, 0, 16); for ( i=0; i<n-1; i++ ) { xor_128(X,&data[16*i],Y); /* Y := Mi (+) X */ | | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | ccAESCMacPadding(&data[16*(n-1)],padded,dataLength%16); xor_128(padded,K2,M_last); } memset(X, 0, 16); for ( i=0; i<n-1; i++ ) { xor_128(X,&data[16*i],Y); /* Y := Mi (+) X */ aesmode->ecb(&ctx, 1, Y, X); } // CMacFinal xor_128(X,M_last,Y); aesmode->ecb(&ctx, 1, Y, X); memcpy(macOut, X, 16); } |
Added Source/API/CommonCryptoAESShoefly.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CommonCryptoAESShoefly.c * CommonCrypto * * Shim for Diskimages to bridge to a non-hw based aes-cbc * */ // #define COMMON_AESSHOEFLY_FUNCTIONS #define CC_Building #include "aes.h" #include "ccdebug.h" void aes_encrypt_key128(const unsigned char *in_key, aes_encrypt_ctx cx[1]) { CCCryptorRef encCryptorRef; aes_encrypt_ctx *ctx = cx; size_t dataUsed; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorCreateFromDataWithMode(kCCEncrypt, kCCModeCBC, kCCAlgorithmAES128NoHardware, ccNoPadding, NULL, in_key, 16, NULL, 0, 0, 0, &ctx->ctx, kCCContextSizeGENERIC, &ctx->cref, &dataUsed); } void aes_encrypt_key256(const unsigned char *in_key, aes_encrypt_ctx cx[1]) { CCCryptorRef encCryptorRef; aes_encrypt_ctx *ctx = cx; size_t dataUsed; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorCreateFromDataWithMode(kCCEncrypt, kCCModeCBC, kCCAlgorithmAES128NoHardware, ccNoPadding, NULL, in_key, 32, NULL, 0, 0, 0, &ctx->ctx, kCCContextSizeGENERIC, &ctx->cref, &dataUsed); } void aes_decrypt_key128(const unsigned char *in_key, aes_decrypt_ctx cx[1]) { CCCryptorRef encCryptorRef; aes_encrypt_ctx *ctx = cx; size_t dataUsed; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorCreateFromDataWithMode(kCCDecrypt, kCCModeCBC, kCCAlgorithmAES128NoHardware, ccNoPadding, NULL, in_key, 16, NULL, 0, 0, 0, &ctx->ctx, kCCContextSizeGENERIC, &ctx->cref, &dataUsed); } void aes_decrypt_key256(const unsigned char *in_key, aes_decrypt_ctx cx[1]) { CCCryptorRef encCryptorRef; aes_encrypt_ctx *ctx = cx; size_t dataUsed; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorCreateFromDataWithMode(kCCDecrypt, kCCModeCBC, kCCAlgorithmAES128NoHardware, ccNoPadding, NULL, in_key, 32, NULL, 0, 0, 0, &ctx->ctx, kCCContextSizeGENERIC, &ctx->cref, &dataUsed); } void aes_encrypt_cbc(const unsigned char *in_blk, const unsigned char *in_iv, unsigned int num_blk, unsigned char *out_blk, aes_encrypt_ctx cx[1]) { aes_encrypt_ctx *ctx = cx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorEncryptDataBlock(ctx->cref, in_iv, in_blk, num_blk * AES_BLOCK_SIZE, out_blk); } void aes_decrypt_cbc(const unsigned char *in_blk, const unsigned char *in_iv, unsigned int num_blk, unsigned char *out_blk, aes_decrypt_ctx cx[1]) { aes_encrypt_ctx *ctx = cx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorDecryptDataBlock(ctx->cref, in_iv, in_blk, num_blk * AES_BLOCK_SIZE, out_blk); } |
Added Source/API/CommonCryptoCASTShoefly.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_CASTSHOEFLY_FUNCTIONS #include <stdio.h> #include "lionCompat.h" #include "CommonCryptorSPI.h" #define DIAGNOSTIC #include "ccdebug.h" void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) { CCCryptorRef *encCryptorRef; size_t dataUsed; encCryptorRef = key->cref; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CCCryptorCreateWithMode(kCCBoth, kCCModeECB, kCCAlgorithmCAST, ccNoPadding, NULL, data, len, NULL, 0, 0, 0, encCryptorRef); } void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out, CAST_KEY *key, int enc) { size_t moved; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Op: %d\n", enc); if(enc) CCCryptorEncryptDataBlock(key->cref, NULL, in, kCCBlockSizeCAST, out); else CCCryptorDecryptDataBlock(key->cref, NULL, in, kCCBlockSizeCAST, out); } |
Changes to Source/API/CommonCryptor.c.
|
| | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 | */ /* * CommonCryptor.c - common crypto context. * */ #include "CommonCryptor.h" #include "CommonCryptorSPI.h" #include "CommonCryptorPriv.h" | > > > > | < | < < < < < | > > > > > > > > > > > | < > | > > > > > > > > | < | > | | < > > > > > > > > > > > > > > > > > | < < < > | | < | | < | | < | | < < | < < < > | | | > > > > > > > > > > > > > > > > > > > > | > > > > > > | | > > > | > > > > > | | > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | > | > > > > | > | | > > | > > > | > | > | > > > | | > | > > | > > > > > > > > > | | | | > > | > > | | > > | > > | | > > | > > > > > > | > > > | | > > | > > > | > | | > | | | > > > > > > | > > > > > > > > > > > > | < > > | < > > | > > | > > > > > | < > | > > > | < > > > > > > > > > > > | > > > | > > > > > | | | | | | | | | | > > > > > > > > > > > > > | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | */ /* * CommonCryptor.c - common crypto context. * */ // #define COMMON_CRYPTOR_FUNCTIONS #include "ccMemory.h" #include "ccdebug.h" #include "CommonCryptor.h" #include "CommonCryptorSPI.h" #include "CommonCryptorPriv.h" #include <dispatch/dispatch.h> #include <dispatch/queue.h> /* * CommonCryptor's portion of a CCCryptorRef. */ typedef struct cipherMode_t { dispatch_once_t init; struct ccmode_ecb* ecb; struct ccmode_cbc* cbc; struct ccmode_cfb* cfb; struct ccmode_cfb8* cfb8; struct ccmode_ctr* ctr; struct ccmode_ofb* ofb; struct ccmode_xts* xts; struct ccmode_gcm* gcm; } cipherMode; static cipherMode cipherModeTab[7][2]; static inline size_t ccGetCipherBlockSize(CCCryptor *ref) { switch(ref->cipher) { case kCCAlgorithmAES128: return kCCBlockSizeAES128; case kCCAlgorithmDES: return kCCBlockSizeDES; case kCCAlgorithm3DES: return kCCBlockSize3DES; case kCCAlgorithmCAST: return kCCBlockSizeCAST; case kCCAlgorithmRC4: return 1; case kCCAlgorithmRC2: return kCCBlockSizeRC2; case kCCAlgorithmBlowfish: return kCCBlockSizeBlowfish; default: return kCCBlockSizeAES128; } } corecryptoMode getCipherMode(CCAlgorithm cipher, CCMode mode, CCOperation direction) { for(int i = 0; i<2; i++) { dispatch_once(&(cipherModeTab[cipher][i].init), ^{ cipherModeTab[cipher][i].ecb = ccmodeList[cipher][i].ecb(); cipherModeTab[cipher][i].cbc = ccmodeList[cipher][i].cbc(); cipherModeTab[cipher][i].cfb = ccmodeList[cipher][i].cfb(); cipherModeTab[cipher][i].cfb8 = ccmodeList[cipher][i].cfb8(); cipherModeTab[cipher][i].ctr = ccmodeList[cipher][i].ctr(); cipherModeTab[cipher][i].ofb = ccmodeList[cipher][i].ofb(); #if defined(__i386__) || defined(__x86_64__) cipherModeTab[cipher][i].xts = ccmodeList[cipher][i].xts(); #else cipherModeTab[cipher][i].xts = NULL; #endif cipherModeTab[cipher][i].gcm = ccmodeList[cipher][i].gcm(); }); } // printf("%lu Size %lu Blocksize\n\n", cipherModeTab[cipher][direction].ecb->size, cipherModeTab[cipher][direction].ecb->block_size); switch(mode) { case kCCModeECB: return (corecryptoMode) cipherModeTab[cipher][direction].ecb; case kCCModeCBC: return (corecryptoMode) cipherModeTab[cipher][direction].cbc; case kCCModeCFB: return (corecryptoMode) cipherModeTab[cipher][direction].cfb; case kCCModeCFB8: return (corecryptoMode) cipherModeTab[cipher][direction].cfb8; case kCCModeCTR: return (corecryptoMode) cipherModeTab[cipher][direction].ctr; case kCCModeOFB: return (corecryptoMode) cipherModeTab[cipher][direction].ofb; case kCCModeXTS: return (corecryptoMode) cipherModeTab[cipher][direction].xts; case kCCModeGCM: return (corecryptoMode) cipherModeTab[cipher][direction].gcm; } return (corecryptoMode) (struct ccmode_ecb*) NULL; } static CCCryptorStatus setCryptorCipherMode(CCCryptor *ref, CCAlgorithm cipher, CCMode mode, CCOperation direction) { switch(mode) { case kCCModeECB: if((ref->symMode[direction].ecb = getCipherMode(cipher, mode, direction).ecb) == NULL) return kCCUnimplemented; ref->modeDesc = &ccecb_mode; break; case kCCModeCBC: if((ref->symMode[direction].cbc = getCipherMode(cipher, mode, direction).cbc) == NULL) return kCCUnimplemented; ref->modeDesc = &cccbc_mode; break; case kCCModeCFB: if((ref->symMode[direction].cfb = getCipherMode(cipher, mode, direction).cfb) == NULL) return kCCUnimplemented; ref->modeDesc = &cccfb_mode; break; case kCCModeCFB8: if((ref->symMode[direction].cfb8 = getCipherMode(cipher, mode, direction).cfb8) == NULL) return kCCUnimplemented; ref->modeDesc = &cccfb8_mode; break; case kCCModeCTR: if((ref->symMode[direction].ctr = getCipherMode(cipher, mode, direction).ctr) == NULL) return kCCUnimplemented; ref->modeDesc = &ccctr_mode; break; case kCCModeOFB: if((ref->symMode[direction].ofb = getCipherMode(cipher, mode, direction).ofb) == NULL) return kCCUnimplemented; ref->modeDesc = &ccofb_mode; break; case kCCModeXTS: if((ref->symMode[direction].xts = getCipherMode(cipher, mode, direction).xts) == NULL) return kCCUnimplemented; ref->modeDesc = &ccxts_mode; break; case kCCModeGCM: if((ref->symMode[direction].gcm = getCipherMode(cipher, mode, direction).gcm) == NULL) return kCCUnimplemented; ref->modeDesc = &ccgcm_mode; break; default: return kCCParamError; } return kCCSuccess; } static inline CCCryptorStatus ccSetupCryptor(CCCryptor *ref, CCAlgorithm cipher, CCMode mode, CCOperation direction, CCPadding padding) { CCCryptorStatus retval; if(cipher > 6) return kCCParamError; if(direction > kCCBoth) return kCCParamError; if(cipher == kCCAlgorithmRC4) mode = kCCModeOFB; ref->mode = mode; CCOperation op = direction; if(ref->mode == kCCModeXTS || ref->mode == kCCModeECB || ref->mode == kCCModeCBC) op = kCCBoth; // printf("Cryptor setup - cipher %d mode %d direction %d padding %d\n", cipher, mode, direction, padding); switch(op) { case kCCEncrypt: case kCCDecrypt: if((retval = setCryptorCipherMode(ref, cipher, mode, op)) != kCCSuccess) return retval; if((ref->ctx[op].data = CC_XMALLOC(ref->modeDesc->mode_get_ctx_size(ref->symMode[op]))) == NULL) return kCCMemoryFailure; break; case kCCBoth: if((retval = setCryptorCipherMode(ref, cipher, mode, kCCEncrypt)) != kCCSuccess) return retval; if((ref->ctx[kCCEncrypt].data = CC_XMALLOC(ref->modeDesc->mode_get_ctx_size(ref->symMode[kCCEncrypt]))) == NULL) return kCCMemoryFailure; if((retval = setCryptorCipherMode(ref, cipher, mode, kCCDecrypt)) != kCCSuccess) return retval; if((ref->ctx[kCCDecrypt].data = CC_XMALLOC(ref->modeDesc->mode_get_ctx_size(ref->symMode[kCCDecrypt]))) == NULL) return kCCMemoryFailure; break; } switch(padding) { case ccNoPadding: ref->padptr = &ccnopad_pad; break; case ccPKCS7Padding: if(mode == kCCModeCBC) ref->padptr = &ccpkcs7_pad; else ref->padptr = &ccpkcs7_ecb_pad; break; case ccCBCCTS1: ref->padptr = &cccts1_pad; break; case ccCBCCTS2: ref->padptr = &cccts2_pad; break; case ccCBCCTS3: ref->padptr = &cccts3_pad; break; default: ref->padptr = &ccnopad_pad; } ref->cipher = cipher; ref->cipherBlocksize = ccGetCipherBlockSize(ref); ref->op = direction; ref->bufferPos = 0; ref->bytesProcessed = 0; return kCCSuccess; } #define OP4INFO(X) (((X)->op == 3) ? 0: (X)->op) static inline size_t ccGetBlockSize(CCCryptor *ref) { return ref->modeDesc->mode_get_block_size(ref->symMode[OP4INFO(ref)]); } static inline bool ccIsStreaming(CCCryptor *ref) { return ref->modeDesc->mode_get_block_size(ref->symMode[ref->op]) == 1; } static inline CCCryptorStatus ccInitCryptor(CCCryptor *ref, const void *key, unsigned long key_len, const void *tweak_key, const void *iv) { size_t blocksize = ccGetCipherBlockSize(ref); if(!ref->modeDesc) return kCCParamError; uint8_t defaultIV[blocksize]; if(iv == NULL) { CC_XZEROMEM(defaultIV, blocksize); iv = defaultIV; } CCOperation op = ref->op; // This will create both sides of the context/mode pairs for now. if(ref->mode == kCCModeXTS || ref->mode == kCCModeECB || ref->mode == kCCModeCBC) op = kCCBoth; switch(op) { case kCCEncrypt: case kCCDecrypt: ref->modeDesc->mode_setup(ref->symMode[ref->op], iv, key, key_len, tweak_key, 0, 0, ref->ctx[ref->op]); break; case kCCBoth: ref->modeDesc->mode_setup(ref->symMode[kCCEncrypt], iv, key, key_len, tweak_key, 0, 0, ref->ctx[kCCEncrypt]); ref->modeDesc->mode_setup(ref->symMode[kCCDecrypt], iv, key, key_len, tweak_key, 0, 0, ref->ctx[kCCDecrypt]); break; } return kCCSuccess; } static inline CCCryptorStatus ccDoEnCrypt(CCCryptor *ref, const void *dataIn, size_t dataInLength, void *dataOut) { if(!ref->modeDesc->mode_encrypt) return kCCParamError; ref->modeDesc->mode_encrypt(ref->symMode[kCCEncrypt], dataIn, dataOut, dataInLength, ref->ctx[kCCEncrypt]); return kCCSuccess; } static inline CCCryptorStatus ccDoDeCrypt(CCCryptor *ref, const void *dataIn, size_t dataInLength, void *dataOut) { if(!ref->modeDesc->mode_decrypt) return kCCParamError; ref->modeDesc->mode_decrypt(ref->symMode[kCCDecrypt], dataIn, dataOut, dataInLength, ref->ctx[kCCDecrypt]); return kCCSuccess; } static inline CCCryptorStatus ccDoEnCryptTweaked(CCCryptor *ref, const void *dataIn, size_t dataInLength, void *dataOut, const void *tweak) { if(!ref->modeDesc->mode_encrypt_tweaked) return kCCParamError; ref->modeDesc->mode_encrypt_tweaked(ref->symMode[kCCEncrypt], dataIn, dataOut, dataInLength, tweak, ref->ctx[kCCEncrypt]); return kCCSuccess; } static inline CCCryptorStatus ccDoDeCryptTweaked(CCCryptor *ref, const void *dataIn, size_t dataInLength, void *dataOut, const void *tweak) { if(!ref->modeDesc->mode_decrypt_tweaked) return kCCParamError; ref->modeDesc->mode_decrypt_tweaked(ref->symMode[kCCDecrypt], dataIn, dataOut, dataInLength, tweak, ref->ctx[kCCDecrypt]); return kCCSuccess; } static inline CCCryptorStatus ccGetIV(CCCryptor *ref, void *iv, size_t *ivLen) { if(ref->modeDesc->mode_getiv == NULL) return kCCParamError; if(ref->modeDesc->mode_getiv(ref->symMode[OP4INFO(ref)], iv, ivLen, ref->ctx[OP4INFO(ref)]) != 0) return kCCMemoryFailure; return kCCSuccess; } static inline CCCryptorStatus ccSetIV(CCCryptor *ref, void *iv, size_t ivLen) { if(ref->modeDesc->mode_setiv == NULL) return kCCParamError; if(ref->modeDesc->mode_setiv(ref->symMode[OP4INFO(ref)], iv, ivLen, ref->ctx[OP4INFO(ref)]) != 0) return kCCMemoryFailure; return kCCSuccess; } static inline void ccClearCryptor(CCCryptor *ref) { CC_XZEROMEM(ref->buffptr, sizeof(ref->buffptr)); CCOperation op = ref->op; // This will clear both sides of the context/mode pairs for now. if(ref->mode == kCCModeXTS || ref->mode == kCCModeECB || ref->mode == kCCModeCBC) op = kCCBoth; switch(op) { case kCCEncrypt: case kCCDecrypt: CC_XZEROMEM(ref->ctx[ref->op].data, ref->modeDesc->mode_get_ctx_size(ref->symMode[ref->op])); CC_XFREE(ref->ctx[ref->op].data, ref->modeDesc->mode_get_ctx_size(ref->symMode[ref->op])); break; case kCCBoth: for(int i = 0; i<2; i++) { CC_XZEROMEM(ref->ctx[i].data, ref->modeDesc->mode_get_ctx_size(ref->symMode[i])); CC_XFREE(ref->ctx[i].data, ref->modeDesc->mode_get_ctx_size(ref->symMode[i])); } break; } ref->cipher = 0; ref->mode = 0; ref->op = 0; ref->bufferPos = 0; ref->bytesProcessed = 0; } static inline CCCryptorStatus ccEncryptPad(CCCryptor *cryptor, void *buf, size_t *moved) { if(cryptor->padptr->encrypt_pad(cryptor->ctx[cryptor->op], cryptor->modeDesc, cryptor->symMode[cryptor->op], cryptor->buffptr, cryptor->bufferPos, buf, moved)) return kCCDecodeError; return kCCSuccess; } static inline CCCryptorStatus ccDecryptPad(CCCryptor *cryptor, void *buf, size_t *moved) { if(cryptor->padptr->decrypt_pad(cryptor->ctx[cryptor->op], cryptor->modeDesc, cryptor->symMode[cryptor->op], cryptor->buffptr, cryptor->bufferPos, buf, moved)) return kCCDecodeError; return kCCSuccess; } static inline size_t ccGetReserve(CCCryptor *cryptor) { return cryptor->padptr->padreserve(cryptor->op == kCCEncrypt, cryptor->modeDesc, cryptor->symMode[cryptor->op]); } static inline size_t ccGetPadlen(CCCryptor *cryptor) { return cryptor->padptr->padlen(cryptor->op == kCCEncrypt, cryptor->modeDesc, cryptor->symMode[cryptor->op], cryptor->buffptr); } static uint8_t * ccGetBytesAligned64(uint8_t *fromptr, uint32_t *bytesused) { uint8_t *retval; retval = fromptr; if((uintptr_t) fromptr % 8) retval = (uint8_t *)(((uintptr_t) fromptr / 8) * 8 + 8); *bytesused = retval - fromptr; return retval; } static int ccAddBuff(CCCryptor *cryptor, const void *dataIn, size_t dataInLength) { CC_XMEMCPY((char *) cryptor->buffptr + cryptor->bufferPos, dataIn, dataInLength); cryptor->bufferPos += dataInLength; return dataInLength; } CCCryptorStatus CCCryptorCreate( CCOperation op, /* kCCEncrypt, etc. */ CCAlgorithm alg, /* kCCAlgorithmDES, etc. */ CCOptions options, /* kCCOptionPKCS7Padding, etc. */ const void *key, /* raw key material */ size_t keyLength, const void *iv, /* optional initialization vector */ CCCryptorRef *cryptorRef) /* RETURNED */ { CCCryptorStatus err; CCCompatCryptor *compat_cryptor = NULL; size_t dataUsed = 0; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if((compat_cryptor = (CCCompatCryptor *)CC_XMALLOC(sizeof(CCCompatCryptor))) == NULL) return kCCMemoryFailure; err = CCCryptorCreateFromData( op, alg, options, key, keyLength, iv, compat_cryptor, sizeof(CCCompatCryptor), cryptorRef, &dataUsed); if(err != kCCSuccess) CC_XFREE(compat_cryptor, sizeof(CCCompatCryptor)); else compat_cryptor->weMallocd = true; return err; } CCCryptorStatus CCCryptorCreateFromData( CCOperation op, /* kCCEncrypt, etc. */ CCAlgorithm alg, /* kCCAlgorithmDES, etc. */ |
︙ | ︙ | |||
184 185 186 187 188 189 190 191 | CCMode mode; CCPadding padding; const void *tweak; size_t tweakLength; int numRounds; CCModeOptions modeOptions; /* Determine mode from options - old call only supported ECB and CBC | > | | | < < > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > | > > > > | > > > > | | | | | | | < | > | | > | < > | > > | | < < < | < < < < | > > > | < < | | < < | | | > | | < < < < > | | < < | < < > > | > > > > > | < > | < > > > | < > | < | | | > > | | < < | < | | > | < > | | < > > | | | > > | | > > > > > | > > | < < | | | > > > > > > | | | > > | > > > > > | > | > | | | < < | | | < < < | < < < < < < > > | | | < | | > > | < > | < | | > > > > > > > > > > | | | | | | < < < < < | | | < < > | > > > | | < | | | | < < | | | | | > | > | | < < < > | < | | | | | > > > | > > > | | < < < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < | < < < | | < < < < < | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | CCMode mode; CCPadding padding; const void *tweak; size_t tweakLength; int numRounds; CCModeOptions modeOptions; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); /* Determine mode from options - old call only supported ECB and CBC we treat RC4 as a "mode" in that it's the only streaming cipher currently supported */ if(alg == kCCAlgorithmRC4) mode = kCCModeRC4; else if(options & kCCOptionECBMode) mode = kCCModeECB; else mode = kCCModeCBC; /* Determine padding from options - only PKCS7 was available */ padding = ccNoPadding; if(options & kCCOptionPKCS7Padding) padding = ccPKCS7Padding; /* No tweak was ever used */ tweak = NULL; tweakLength = 0; /* default rounds */ numRounds = 0; /* No mode options needed */ modeOptions = 0; return CCCryptorCreateFromDataWithMode(op, mode, alg, padding, iv, key, keyLength, tweak, tweakLength, numRounds, modeOptions, data, dataLength, cryptorRef, dataUsed); } /* This version mallocs the CCCryptorRef */ CCCryptorStatus CCCryptorCreateWithMode( CCOperation op, /* kCCEncrypt, kCCEncrypt, kCCBoth (default for BlockMode) */ CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, /* optional initialization vector */ const void *key, /* raw key material */ size_t keyLength, const void *tweak, /* raw tweak material */ size_t tweakLength, int numRounds, /* 0 == default */ CCModeOptions options, CCCryptorRef *cryptorRef) /* RETURNED */ { CCCryptorStatus err; CCCompatCryptor *compat_cryptor = NULL; size_t dataUsed = 0; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if((compat_cryptor = (CCCompatCryptor *)CC_XMALLOC(sizeof(CCCompatCryptor))) == NULL) return kCCMemoryFailure; err = CCCryptorCreateFromDataWithMode( op, mode, alg, padding, iv, key, keyLength, tweak, tweakLength, numRounds, options, compat_cryptor, DEFAULT_CRYPTOR_MALLOC, cryptorRef, &dataUsed); if(err != kCCSuccess) CC_XFREE(compat_cryptor, sizeof(CCCompatCryptor)); else compat_cryptor->weMallocd = true; return err; } #define KEYALIGNMENT (sizeof(int)-1) CCCryptorStatus CCCryptorCreateFromDataWithMode( CCOperation op, /* kCCEncrypt, kCCEncrypt, kCCBoth (default for BlockMode) */ CCMode mode, CCAlgorithm alg, CCPadding padding, const void *iv, /* optional initialization vector */ const void *key, /* raw key material */ size_t keyLength, const void *tweak, /* raw tweak material */ size_t tweakLength, int numRounds, CCModeOptions options, const void *data, /* caller-supplied memory */ size_t dataLength, /* length of data in bytes */ CCCryptorRef *cryptorRef, /* RETURNED */ size_t *dataUsed) /* optional, RETURNED */ { CCCryptorStatus retval = kCCSuccess; CCCryptor *cryptor = NULL; CCCompatCryptor *compat_cryptor = NULL; int needed, needed2aligncryptor; uint8_t *alignedKey = NULL; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Op: %d Mode: %d Cipher: %d Padding: %d\n", op, mode, alg, padding); // For now we're mapping these two AES selectors to the stock one. if(alg == kCCAlgorithmAES128NoHardware || alg == kCCAlgorithmAES128WithHardware) alg = kCCAlgorithmAES128; /* corecrypto only implements CTR_BE. No use of CTR_LE was found so we're marking this as unimplemented for now. Also in Lion this was defined in reverse order. See <rdar://problem/10306112> */ if(mode == kCCModeCTR && options != kCCModeOptionCTR_BE) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Mode is CTR, but options isn't BE\n", op, mode, alg, padding); return kCCUnimplemented; } // validate pointers if((data == NULL) || (cryptorRef == NULL) || (key == NULL)) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "bad arguments\n", 0); return kCCParamError; } /* * Some implementations are sensitive to keys not being 4 byte aligned. * We'll move the key into an aligned buffer for the call to setup * the key schedule. */ if((intptr_t) key & KEYALIGNMENT) { if((alignedKey = CC_XMALLOC(keyLength)) == NULL) { return kCCMemoryFailure; } CC_XMEMCPY(alignedKey, key, keyLength); key = alignedKey; } /* Get Space for Cryptor Structure */ compat_cryptor = (CCCompatCryptor *) ccGetBytesAligned64((uint8_t *)data, &needed2aligncryptor); needed = needed2aligncryptor + sizeof(CCCompatCryptor); if(dataUsed != NULL) *dataUsed = needed; if (needed > dataLength) { if(dataUsed != NULL) *dataUsed += 16; /* in case it's not on a doubleword boundary */ CC_DEBUG_LOG(ASL_LEVEL_ERR, "Needed %d Have %d\n", needed, dataLength); retval = kCCBufferTooSmall; goto out; } compat_cryptor->weMallocd = false; if((cryptor = (CCCryptor *)CC_XMALLOC(DEFAULT_CRYPTOR_MALLOC)) == NULL) { retval = kCCMemoryFailure; goto out; } compat_cryptor->cryptor = cryptor; *cryptorRef = compat_cryptor; if((retval = ccSetupCryptor(cryptor, alg, mode, op, padding)) != kCCSuccess) { printf("Failed to setup Cryptor struct with alg/mode %d\n", retval); goto out; } if((retval = ccInitCryptor(cryptor, key, keyLength, tweak, iv)) != kCCSuccess) { printf("Failed to init Cryptor %d\n", retval); goto out; } out: // Things to destroy if setup failed if(retval) { *cryptorRef = NULL; if(compat_cryptor) compat_cryptor->cryptor = NULL; if(cryptor) { CC_XZEROMEM(cryptor, DEFAULT_CRYPTOR_MALLOC); CC_XFREE(cryptor, DEFAULT_CRYPTOR_MALLOC); } } else { // printf("Blocksize = %d mode = %d pad = %d\n", ccGetBlockSize(cryptor), cryptor->mode, padding); } // Things to destroy all the time if(alignedKey) { CC_XZEROMEM(alignedKey, keyLength); CC_XFREE(alignedKey, keyLength); } return retval; } CCCryptorStatus CCCryptorRelease( CCCryptorRef cryptorRef) { uint32_t err; CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; uint32_t weMallocd; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(cryptorRef == NULL) return kCCSuccess; cryptor = compat_cryptor->cryptor; weMallocd = compat_cryptor->weMallocd; ccClearCryptor(cryptor); CC_XMEMSET(cryptor, 0, CCCRYPTOR_SIZE); CC_XFREE(cryptor, DEFAULT_CRYPTOR_MALLOC); if(weMallocd) CC_XFREE(compat_cryptor, sizeof(CCCompatCryptor)); return kCCSuccess; } #define FULLBLOCKSIZE(X,BLOCKSIZE) (((X)/(BLOCKSIZE))*BLOCKSIZE) #define FULLBLOCKREMAINDER(X,BLOCKSIZE) ((X)%(BLOCKSIZE)) static CCCryptorStatus ccSimpleUpdate(CCCryptor *cryptor, const void *dataIn, size_t dataInLength, void **dataOut, size_t *dataOutAvailable, size_t *dataOutMoved) { CCCryptorStatus retval; if(dataOutAvailable < dataInLength) return kCCBufferTooSmall; if(cryptor->op == kCCEncrypt) { if((retval = ccDoEnCrypt(cryptor, dataIn, dataInLength, *dataOut)) != kCCSuccess) return retval; } else { if((retval = ccDoDeCrypt(cryptor, dataIn, dataInLength, *dataOut)) != kCCSuccess) return retval; } cryptor->bytesProcessed += dataInLength; if(dataOutMoved) *dataOutMoved += dataInLength; *dataOut += dataInLength; *dataOutAvailable -= dataInLength; return kCCSuccess; } static CCCryptorStatus ccBlockUpdate(CCCryptor *cryptor, const void *dataIn, size_t dataInLength, void *dataOut, size_t *dataOutAvailable, size_t *dataOutMoved) { CCCryptorStatus retval; uint32_t encrypting = (cryptor->op == kCCEncrypt); size_t blocksize = ccGetCipherBlockSize(cryptor); size_t reserve = ccGetReserve(cryptor); size_t buffsize = (reserve) ? reserve: blocksize; /* minimum buffering is a block */ size_t dataCount = cryptor->bufferPos + dataInLength; /* Total amount of data we have "in hand" to process now. */ size_t dataCountToHold, dataCountToProcess; size_t remainder, movecnt; /* This is a simple optimization */ if(reserve == 0 && cryptor->bufferPos == 0 && (dataInLength % blocksize) == 0) { // No Padding, not buffering, even blocks // printf("simple processing\n"); return ccSimpleUpdate(cryptor, dataIn, dataInLength, &dataOut, &dataOutAvailable, dataOutMoved); } /* From this point on we're dealing with a Block Cipher with Block oriented I/O We always fallback to buffering once we're processing non-block aligned data. If the data inputs result in data becoming block aligned once again we can move back to block aligned I/O - even if it's only for partial processing of the data supplied to this routine. */ if(dataCount <= reserve) { dataCountToHold = dataCount; } else { remainder = FULLBLOCKREMAINDER(dataCount, blocksize); dataCountToHold = buffsize - blocksize + remainder; dataCountToHold = (remainder) ? dataCountToHold: reserve; } dataCountToProcess = dataCount - dataCountToHold; // printf("DataCount %d Processing %d Holding %d\n", dataCount, dataCountToProcess, dataCountToHold); if(dataCountToProcess > 0) { if(cryptor->bufferPos == 0) { // printf("CCCryptorUpdate checkpoint 0\n"); /* nothing to do yet */ } else if(cryptor->bufferPos < dataCountToProcess) { // printf("CCCryptorUpdate checkpoint 1\n"); movecnt = blocksize - (cryptor->bufferPos % blocksize); ccAddBuff(cryptor, dataIn, movecnt); dataIn += movecnt; dataInLength -= movecnt; // printf("CCCryptorUpdate checkpoint 1.1 bufpos = %d\n", (int) cryptor->bufferPos); if((retval = ccSimpleUpdate(cryptor, cryptor->buffptr, cryptor->bufferPos, &dataOut, &dataOutAvailable, dataOutMoved)) != kCCSuccess) { return retval; } // printf("CCCryptorUpdate checkpoint 1.2\n"); dataCountToProcess -= cryptor->bufferPos; cryptor->bufferPos = 0; } else if(cryptor->bufferPos == dataCountToProcess) { // printf("CCCryptorUpdate checkpoint 2\n"); if((retval = ccSimpleUpdate(cryptor, cryptor->buffptr, cryptor->bufferPos, &dataOut, &dataOutAvailable, dataOutMoved)) != kCCSuccess) { return retval; } dataCountToProcess -= cryptor->bufferPos; cryptor->bufferPos = 0; } else /* (cryptor->bufferPos > dataCountToProcess) */ { // printf("CCCryptorUpdate checkpoint 3\n"); if(dataCountToHold) { // printf("CCCryptorUpdate bad calculation 1\n"); return kCCDecodeError; } if((retval = ccSimpleUpdate(cryptor, cryptor->buffptr, dataCountToProcess, &dataOut, &dataOutAvailable, dataOutMoved)) != kCCSuccess) { return retval; } cryptor->bufferPos = reserve - dataCountToProcess; memmove(cryptor->buffptr, ((uint8_t *) cryptor->buffptr)+ dataCountToProcess, cryptor->bufferPos); return kCCSuccess; } if(dataCountToProcess > 0) { // printf("CCCryptorUpdate checkpoint 4\n"); movecnt = FULLBLOCKREMAINDER(dataCountToProcess, blocksize); if(movecnt) { // printf("CCCryptorUpdate bad calculation 2\n"); return kCCDecodeError; } if((retval = ccSimpleUpdate(cryptor, dataIn, dataCountToProcess, &dataOut, &dataOutAvailable, dataOutMoved)) != kCCSuccess) return retval; dataIn += dataCountToProcess; dataInLength -= dataCountToProcess; } } if(dataCountToHold) { // printf("CCCryptorUpdate checkpoint 1\n"); movecnt = dataCountToHold - cryptor->bufferPos; if(movecnt) { if(movecnt != dataInLength) { // printf("CCCryptorUpdate bad calculation 3\n"); return kCCDecodeError; } ccAddBuff(cryptor, dataIn, movecnt); dataIn += movecnt; dataInLength -= movecnt; } } if(dataInLength) { // printf("CCCryptorUpdate bad calculation 4\n"); return kCCDecodeError; } return kCCSuccess; } CCCryptorStatus CCCryptorUpdate(CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut, size_t dataOutAvailable, size_t *dataOutMoved) { CCCryptorStatus retval; CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(dataOutMoved) *dataOutMoved = 0; if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(dataInLength == 0) return kCCSuccess; if(ccIsStreaming(cryptor)) { return ccSimpleUpdate(cryptor, dataIn, dataInLength, &dataOut, &dataOutAvailable, dataOutMoved); } retval = ccBlockUpdate(cryptor, dataIn, dataInLength, dataOut, dataOutAvailable, dataOutMoved); return retval; } CCCryptorStatus CCCryptorFinal( CCCryptorRef cryptorRef, void *dataOut, /* data RETURNED here */ size_t dataOutAvailable, size_t *dataOutMoved) /* number of bytes written */ { CCCompatCryptor *compat_cryptor = cryptorRef; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; CCCryptor *cryptor = compat_cryptor->cryptor; if(cryptor == NULL) return kCCSuccess; // Some old behavior .. CDSA? has zapped the Cryptor. CCCryptorStatus retval; int encrypting = (cryptor->op == kCCEncrypt); uint8_t *bufp = cryptor->buffptr; uint32_t blocksize = ccGetCipherBlockSize(cryptor); size_t moved; uint8_t padval; char tmpbuf[blocksize*2]; if(dataOutMoved) *dataOutMoved = 0; if(ccIsStreaming(cryptor)) return kCCSuccess; if(encrypting) { retval = ccEncryptPad(cryptor, tmpbuf, &moved); if(retval != kCCSuccess) return retval; if(dataOutAvailable < moved) { return kCCBufferTooSmall; } if(dataOut) { CC_XMEMCPY(dataOut, tmpbuf, moved); if(dataOutMoved) *dataOutMoved = moved; } cryptor->bufferPos = 0; } else { if(ccGetReserve(cryptor) != 0) { retval = ccDecryptPad(cryptor, tmpbuf, &moved); if(retval != kCCSuccess) return retval; if(dataOutAvailable < moved) { return kCCBufferTooSmall; } if(dataOut) { CC_XMEMCPY(dataOut, tmpbuf, moved); if(dataOutMoved) *dataOutMoved = moved; } cryptor->bytesProcessed += *dataOutMoved; cryptor->bufferPos = 0; } } return kCCSuccess; } size_t CCCryptorGetOutputLength( CCCryptorRef cryptorRef, size_t inputLength, bool final) { size_t retval; CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; retval = cryptor->bufferPos + inputLength; if(ccIsStreaming(cryptor)) return retval; if(cryptor->op == kCCEncrypt) { retval = FULLBLOCKSIZE(retval, ccGetCipherBlockSize(cryptor)); if(final) retval += ccGetPadlen(cryptor); return retval; } else { if(final) return retval; else return FULLBLOCKSIZE(retval, ccGetCipherBlockSize(cryptor)); } } CCCryptorStatus CCCryptorReset( CCCryptorRef cryptorRef, const void *iv) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CCCryptorStatus retval; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; /* This routine resets all buffering and sets or clears the IV. It is documented to throw away any in-flight buffer data. */ cryptor->bytesProcessed = cryptor->bufferPos = 0; /* Call the common routine to reset the IV - this will copy in the new value. There is now always space for an IV in the cryptor. */ if(iv) { retval = ccSetIV(cryptor, iv, ccGetCipherBlockSize(cryptor)); } else { uint8_t ivzero[ccGetCipherBlockSize(cryptor)]; CC_XZEROMEM(ivzero, ccGetCipherBlockSize(cryptor)); retval = ccSetIV(cryptor, ivzero, ccGetCipherBlockSize(cryptor)); } if(retval == kCCParamError) return kCCSuccess; return retval; } CCCryptorStatus CCCryptorGetIV(CCCryptorRef cryptorRef, void *iv) { uint32_t blocklen; CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(ccIsStreaming(cryptor)) return kCCParamError; return ccGetIV(cryptor, iv, ccGetCipherBlockSize(cryptor)); } /* * One-shot is mostly service provider independent, except for the * dataOutLength check. */ CCCryptorStatus CCCrypt( |
︙ | ︙ | |||
481 482 483 484 485 486 487 | size_t dataInLength, void *dataOut, /* data RETURNED here */ size_t dataOutAvailable, size_t *dataOutMoved) { CCCryptorRef cryptor = NULL; CCCryptorStatus retval; | < | > | | | < < | | > | | > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | < < | < < < < > | | > > | | | > | > > > | > > > > > | > > | > > > | > > | > | > > > > > > > > > > > > > > > > > > > > > > > > | 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | size_t dataInLength, void *dataOut, /* data RETURNED here */ size_t dataOutAvailable, size_t *dataOutMoved) { CCCryptorRef cryptor = NULL; CCCryptorStatus retval; size_t outputSize; size_t used = 0; size_t moved; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(retval = CCCryptorCreate(op, alg, options, key, keyLength, iv, &cryptor)) { return retval; } if((outputSize = CCCryptorGetOutputLength(cryptor, dataInLength, true)) > dataOutAvailable) { CCCryptorRelease(cryptor); if(dataOutMoved != NULL) *dataOutMoved = outputSize; return kCCBufferTooSmall; } if(retval = CCCryptorUpdate(cryptor, dataIn, dataInLength, dataOut, dataOutAvailable, &moved)) { CCCryptorRelease(cryptor); return retval; } dataOut += moved; used += moved; dataOutAvailable -= moved; if(retval = CCCryptorFinal(cryptor, dataOut, dataOutAvailable, &moved)) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Final Error\n", 0); // printf("Failing on final\n"); } else { used += moved; if(dataOutMoved != NULL) *dataOutMoved = used; } CCCryptorRelease(cryptor); return retval; } CCCryptorStatus CCCryptorEncryptDataBlock( CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(ccIsStreaming(cryptor)) return kCCParamError; if(!iv) return ccDoEnCrypt(cryptor, dataIn, dataInLength, dataOut); return ccDoEnCryptTweaked(cryptor, dataIn, dataInLength, dataOut, iv); } CCCryptorStatus CCCryptorDecryptDataBlock( CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(ccIsStreaming(cryptor)) return kCCParamError; if(!iv) return ccDoDeCrypt(cryptor, dataIn, dataInLength, dataOut); return ccDoDeCryptTweaked(cryptor, dataIn, dataInLength, dataOut, iv); } CCCryptorStatus CCDesIsWeakKey( void *key, size_t length) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return ccdes_key_is_weak(key, length); } void CCDesSetOddParity(void *key, size_t Length) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccdes_key_set_odd_parity(key, Length); } uint32_t CCDesCBCCksum(void *in, void *out, size_t length, void *key, size_t keylen, void *ivec) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return ccdes_cbc_cksum(in, out, length, key, keylen, ivec); } // Legacy SPI #include <corecrypto/ccrc4.h> typedef struct current_rc4_key_st { uint32_t x,y; uint32_t data[256]; } RC4_KEY; #ifndef NDEBUG #define ASSERT(s) #else #define ASSERT(s) assert(s) #endif void CC_RC4_set_key(void *ctx, int len, const unsigned char *data) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ASSERT(sizeof(RC4_KEY) == ccrc4_eay.size); ccrc4_eay.init(ctx, len, data); } void CC_RC4(void *ctx, unsigned long len, const unsigned char *indata, unsigned char *outdata) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccrc4_eay.crypt(ctx, len, indata, outdata); } |
Changes to Source/API/CommonCryptorPriv.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2006-2010 Apple, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
19 20 21 22 23 24 25 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CommonCryptorPriv.h - interface between CommonCryptor and operation- and | | | | | | < | < < < < < < | | > > | | < < | | < > > > | > > | | | | < < < < < < < < | > < | | > > | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * CommonCryptorPriv.h - interface between CommonCryptor and operation- and * algorithm-specific service providers. */ #ifndef _CC_COMMON_CRYPTOR_PRIV_ #define _CC_COMMON_CRYPTOR_PRIV_ #include "CommonCryptor.h" #include "CommonCryptorSPI.h" #include <dispatch/dispatch.h> #include "corecryptoSymmetricBridge.h" #ifdef __cplusplus extern "C" { #endif /* Byte-Size Constants */ #define CCMAXBUFFERSIZE 128 /* RC2/RC5 Max blocksize */ #define DEFAULT_CRYPTOR_MALLOC 4096 #define CC_STREAMKEYSCHED 2048 #define CC_MODEKEYSCHED 2048 #define CC_MAXBLOCKSIZE 128 typedef struct _CCCryptor { uint8_t buffptr[32]; uint32_t bufferPos; uint32_t bytesProcessed; uint32_t cipherBlocksize; CCAlgorithm cipher; CCMode mode; CCOperation op; /* kCCEncrypt, kCCDecrypt, or kCCBoth */ corecryptoMode symMode[2]; cc2CCModeDescriptor *modeDesc; modeCtx ctx[2]; cc2CCPaddingDescriptor *padptr; } CCCryptor; typedef struct _CCCompat { uint32_t weMallocd; CCCryptor *cryptor; } CCCompatCryptor; #define CCCRYPTOR_SIZE sizeof(struct _CCCryptor) #define kCCContextSizeGENERIC (sizeof(CCCompatCryptor)) corecryptoMode getCipherMode(CCAlgorithm cipher, CCMode mode, CCOperation direction); #ifdef __cplusplus } #endif #endif /* _CC_COMMON_CRYPTOR_PRIV_ */ |
Added Source/API/CommonDH.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_DH_FUNCTIONS #include "CommonDH.h" #include "CommonRandomSPI.h" #include <dispatch/dispatch.h> #include <dispatch/queue.h> #include <corecrypto/ccn.h> #include <corecrypto/ccdh.h> #include <corecrypto/ccdh_gp.h> #include "ccMemory.h" #include "ccErrors.h" #include "ccdebug.h" typedef struct CCDHParameters_s { ccdh_const_gp_t gp; size_t malloced; } CCDHParmSetstruct, *CCDHParmSet; typedef struct DH_ { CCDHParmSet parms; ccdh_full_ctx_t ctx; } CCDHstruct, *CCDH; static struct CCDHParameters_s gp2; static struct CCDHParameters_s gp5; CCDHParameters kCCDHRFC2409Group2 = &gp2; CCDHParameters kCCDHRFC3526Group5 = &gp5; // = ccdh_gp_rfc3526group05(void); static void ccdhInitGPs() { static dispatch_once_t dhgpinit; dispatch_once(&dhgpinit, ^{ kCCDHRFC3526Group5->malloced = 0; kCCDHRFC3526Group5->gp = ccdh_gp_rfc3526group05(); }); } CCDHRef CCDHCreate(CCDHParameters dhParameter) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_NONULLPARM(dhParameter); if(dhParameter == kCCDHRFC2409Group2) return NULL; // no corecrypto group yet for this. ccdhInitGPs(); CCDHParmSet CCDHParm = (CCDHParmSet) dhParameter; CCDH retval = CC_XMALLOC(sizeof(CCDHstruct)); if(retval == NULL) return retval; retval->ctx._full = CC_XMALLOC(ccdh_full_ctx_size(ccdh_ccn_size(CCDHParm->gp))); if(retval->ctx._full == NULL) { CC_XFREE(retval, sizeof(CCDHstruct)); return NULL; } ccdh_ctx_init(CCDHParm->gp, retval->ctx); retval->parms = CCDHParm; return retval; } void CCDHRelease(CCDHRef ref) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(ref == NULL) return; CCDH keyref = (CCDH) ref; if(keyref->ctx._full) CC_XFREE(keyref->ctx._full, ccdh_full_ctx_size(ccdh_ccn_size(keyref->parms->gp))); keyref->ctx._full = keyref->parms = NULL; CC_XFREE(keyref, sizeof(CCDHstruct)); } int CCDHGenerateKey(CCDHRef ref, void *output, size_t *outputLength) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_NONULLPARM(ref); CC_NONULLPARM(output); CC_NONULLPARM(outputLength); CCDH keyref = (CCDH) ref; if(ccdh_generate_key(keyref->parms->gp, ccDRBGGetRngState(), keyref->ctx.pub)) return -1; size_t size_needed = ccdh_export_pub_size(keyref->ctx); if(size_needed > *outputLength) { *outputLength = size_needed; return -1; } *outputLength = size_needed; ccdh_export_pub(keyref->ctx, output); return 0; } int CCDHComputeKey(unsigned char *sharedKey, size_t *sharedKeyLen, const void *peerPubKey, size_t peerPubKeyLen, CCDHRef ref) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_NONULLPARM(sharedKey); CC_NONULLPARM(sharedKeyLen); CC_NONULLPARM(peerPubKey); CC_NONULLPARM(ref); CCDH keyref = (CCDH) ref; ccdh_pub_ctx_decl_gp(keyref->parms->gp, peer_pub); cc_size n = ccdh_ctx_n(keyref->ctx); cc_unit skey[n]; if(ccdh_import_pub(keyref->parms->gp, peerPubKeyLen, peerPubKey, peer_pub)) return -1; if(ccdh_compute_key(keyref->ctx, peer_pub, skey)) return -1; size_t size_needed = ccn_write_uint_size(n, skey); if(size_needed > *sharedKeyLen) { *sharedKeyLen = size_needed; return -1; } *sharedKeyLen = size_needed; (void) ccn_write_uint_padded(n, skey, *sharedKeyLen, sharedKey); return 0; } CCDHParameters CCDHParametersCreateFromData(const void *p, size_t pLen, const void *g, size_t gLen, size_t l) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_NONULLPARM(p); CC_NONULLPARM(g); cc_size psize = ccn_nof_size(pLen); cc_size gsize = ccn_nof_size(gLen); cc_size n = (psize > gsize) ? psize: gsize; cc_unit pval[n], gval[n]; CCDHParmSet retval = CC_XMALLOC(sizeof(CCDHParmSetstruct)); if(retval == NULL) return NULL; retval->malloced = ccdh_gp_size(n); retval->gp.gp = (ccdh_gp *) CC_XMALLOC(retval->malloced); if(retval->gp.gp == NULL) { retval->malloced = 0; CC_XFREE(retval, sizeof(CCDHParmSetstruct)); return NULL; } if(ccdh_init_gp(retval->gp._ncgp, n, pval, gval, (cc_size) l)) return NULL; return retval; } void CCDHParametersRelease(CCDHParameters parameters) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(parameters == NULL) return; if(parameters == kCCDHRFC2409Group2) return; if(parameters == kCCDHRFC3526Group5) return; CCDHParmSet CCDHParm = (CCDHParmSet) parameters; if(CCDHParm->malloced) CC_XFREE(CCDHParm->gp.gp, retval->malloced); CCDHParm->malloced = 0; CCDHParm->gp.gp = NULL; CC_XFREE(CCDHParm, sizeof(CCDHParmSetstruct)); } // TODO - needs PKCS3 in/out CCDHParameters CCDHParametersCreateFromPKCS3(const void *data, size_t len) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_NONULLPARM(data); return NULL; } size_t CCDHParametersPKCS3EncodeLength(CCDHParameters parms) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return 0; } size_t CCDHParametersPKCS3Encode(CCDHParameters parms, void *data, size_t dataAvailable) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return 0; } |
Changes to Source/API/CommonDigest.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include "CommonDigest.h" #include "CommonDigestPriv.h" #include "CommonDigestSPI.h" | > > > | | > > > > > > > > > > | | > | | > | < | > | < > > | > | > > > > | | | | | | | | | | | | | | > | | | | < < < < > > | > > | | > > > > | | > > > > > > > | > > > > > > | > > > > | | > > | > > | | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > > > > > | | > > > > > > | | > > > > > | | | > | | < > | < < | < < < < < < < < < > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | < < | | < < < | < < < < | < < < < < < | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_DIGEST_FUNCTIONS #define COMMON_DIGEST_FOR_RFC_1321 #include "CommonDigest.h" #include "CommonDigestPriv.h" #include "CommonDigestSPI.h" #include "ccErrors.h" #include "ccMemory.h" #include "ccdebug.h" #include <stdio.h> #include <dispatch/dispatch.h> #include <dispatch/queue.h> #include <corecrypto/ccmd2.h> #include <corecrypto/ccmd4.h> #include <corecrypto/ccmd5.h> #include <corecrypto/ccripemd.h> #include <corecrypto/ccsha1.h> #include <corecrypto/ccsha2.h> #define NDEBUG #ifndef NDEBUG #define ASSERT(s) #else #define ASSERT(s) assert(s) #endif static const size_t diMax = kCCDigestSkein512+1; static struct ccdigest_info *di[diMax]; // This returns a pointer to the corecrypto "di" structure for a digest. // It's used for all functions that need a di (HMac, Key Derivation, etc). struct ccdigest_info * CCDigestGetDigestInfo(CCDigestAlgorithm algorithm) { static dispatch_once_t di_init; dispatch_once(&di_init, ^{ di[kCCDigestNone] = NULL; di[kCCDigestMD2] = &ccmd2_di; di[kCCDigestMD4] = &ccmd4_di; di[kCCDigestMD5] = ccmd5_di(); di[kCCDigestRMD128] = &ccrmd128_di; di[kCCDigestRMD160] = &ccrmd160_di; di[kCCDigestRMD256] = &ccrmd256_di; di[kCCDigestRMD320] = &ccrmd320_di; di[kCCDigestSHA1] = ccsha1_di(); di[kCCDigestSHA224] = ccsha224_di(); di[kCCDigestSHA256] = ccsha256_di(); di[kCCDigestSHA384] = ccsha384_di(); di[kCCDigestSHA512] = ccsha512_di(); di[kCCDigestSkein128] = NULL; di[kCCDigestSkein160] = NULL; di[15] = NULL; // gap di[kCCDigestSkein224] = NULL; di[kCCDigestSkein256] = NULL; di[kCCDigestSkein384] = NULL; di[kCCDigestSkein512] = NULL; }); return di[algorithm]; } int CCDigestInit(CCDigestAlgorithm alg, CCDigestRef c) { if(alg == 0 || alg >= diMax) return kCCParamError; if(!c) return kCCParamError; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", alg); CCDigestCtxPtr p = (CCDigestCtxPtr) c; if(p->di = CCDigestGetDigestInfo(alg)) { ccdigest_init(p->di, (struct ccdigest_ctx *) p->md); return 0; } else { return kCCUnimplemented; } } int CCDigestUpdate(CCDigestRef c, const void *data, size_t len) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(c == NULL) return kCCParamError; if(len == 0) return kCCSuccess; if(data == NULL) return kCCParamError; /* this is only a problem if len > 0 */ CCDigestCtxPtr p = (CCDigestCtxPtr) c; if(p->di) { ccdigest_update(p->di, (struct ccdigest_ctx *) p->md, len, data); return kCCSuccess; } return kCCUnimplemented; } int CCDigestFinal(CCDigestRef c, uint8_t *out) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(c == NULL || out == NULL) return kCCParamError; CCDigestCtxPtr p = (CCDigestCtxPtr) c; if(p->di) { ccdigest_final(p->di, (struct ccdigest_ctx *) p->md, out); return 0; } return kCCUnimplemented; } int CCDigest(CCDigestAlgorithm alg, const uint8_t *data, size_t len, uint8_t *out) { CCDigestCtx_t c; int retval; struct ccdigest_info *di; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", alg); if(di = CCDigestGetDigestInfo(alg)) { ccdigest(di, len, data, out); return 0; } return kCCUnimplemented; } size_t CCDigestGetBlockSize(CCDigestAlgorithm algorithm) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", algorithm); struct ccdigest_info *di = CCDigestGetDigestInfo(algorithm); if(di) return di->block_size; return kCCUnimplemented; } size_t CCDigestGetOutputSize(CCDigestAlgorithm algorithm) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", algorithm); struct ccdigest_info *di = CCDigestGetDigestInfo(algorithm); if(di) return di->output_size; return kCCUnimplemented; } size_t CCDigestGetBlockSizeFromRef(CCDigestRef ctx) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCDigestCtxPtr p = (CCDigestCtxPtr) ctx; if(p->di) return p->di->block_size; return kCCUnimplemented; } size_t CCDigestBlockSize(CCDigestRef ctx) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CCDigestGetBlockSizeFromRef(ctx); } size_t CCDigestOutputSize(CCDigestRef ctx) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CCDigestGetOutputSizeFromRef(ctx); } size_t CCDigestGetOutputSizeFromRef(CCDigestRef ctx) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCDigestCtxPtr p = (CCDigestCtxPtr) ctx; if(p->di) return p->di->output_size; return kCCUnimplemented; } CCDigestRef CCDigestCreate(CCDigestAlgorithm alg) { CCDigestCtxPtr retval = CC_XMALLOC(sizeof(CCDigestCtx_t)); // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!retval) return NULL; if(CCDigestInit(alg, retval)) { CC_XFREE(retval, sizeof(CCDigestCtx_t)); return NULL; } return retval; } uint8_t * CCDigestOID(CCDigestRef ctx) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCDigestCtxPtr p = (CCDigestCtxPtr) ctx; return p->di->oid; } size_t CCDigestOIDLen(CCDigestRef ctx) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCDigestCtxPtr p = (CCDigestCtxPtr) ctx; return p->di->oid_size; } CCDigestRef CCDigestCreateByOID(uint8_t *OID, size_t OIDlen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); for(int i=kCCDigestMD2; i<diMax; i++) { struct ccdigest_info *di = CCDigestGetDigestInfo(i); if(di && (OIDlen == di->oid_size) && (CC_XMEMCMP(OID, di->oid, OIDlen) == 0)) return CCDigestCreate(i); } return NULL; } void CCDigestReset(CCDigestRef ctx) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CCDigestCtxPtr p = (CCDigestCtxPtr) ctx; if(p->di) ccdigest_init(p->di, (struct ccdigest_ctx *) p->md); } void CCDigestDestroy(CCDigestRef ctx) { // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(ctx) { CC_XZEROMEM(ctx, sizeof(CCDigestCtx_t)); CC_XFREE(ctx, sizeof(CCDigestCtx_t)); } } /* * Legacy CommonDigest API shims. */ #define CC_COMPAT_DIGEST_RETURN 1 #define DIGEST_SHIMS(_name_,_constant_) \ \ static size_t CC_##_name_##_Len = 0; \ static size_t CC_##_name_##_Ctr = 0; \ \ int CC_##_name_##_Init(CC_##_name_##_CTX *c) { \ struct ccdigest_info *di = CCDigestGetDigestInfo(_constant_); \ ASSERT(sizeof(CC_##_name_##_CTX) <= ccdigest_di_size(di)); \ ccdigest_init(CCDigestGetDigestInfo(_constant_), (struct ccdigest_ctx *) c); \ return 1; \ } \ \ int \ CC_##_name_##_Update(CC_##_name_##_CTX *c, const void *data, CC_LONG len) \ { \ CC_##_name_##_Len += len; \ ccdigest_update(CCDigestGetDigestInfo(_constant_), (struct ccdigest_ctx *) c, len, data); \ return 1; \ } \ \ int \ CC_##_name_##_Final(unsigned char *md, CC_##_name_##_CTX *c) \ { \ if(((++CC_##_name_##_Ctr) % 50) == 0) CC_DEBUG_LOG(ASL_LEVEL_ERR, "Len = %lu\n", CC_##_name_##_Len); \ ccdigest_final(CCDigestGetDigestInfo(_constant_), (struct ccdigest_ctx *) c, md); \ return 1; \ } \ \ unsigned char * \ CC_##_name_ (const void *data, CC_LONG len, unsigned char *md) \ { \ (void) CCDigest(_constant_, data, len, md); \ return md; \ } #define DIGEST_FINAL_SHIMS(_name_,_constant_) \ unsigned char * \ CC_##_name_ (const void *data, CC_LONG len, unsigned char *md) \ { \ (void) CCDigest(_constant_, data, len, md); \ return md; \ } DIGEST_FINAL_SHIMS(MD2, kCCDigestMD2) DIGEST_SHIMS(MD4, kCCDigestMD4) DIGEST_SHIMS(MD5, kCCDigestMD5) DIGEST_SHIMS(SHA1, kCCDigestSHA1) DIGEST_FINAL_SHIMS(SHA224, kCCDigestSHA224) DIGEST_FINAL_SHIMS(SHA256, kCCDigestSHA256) DIGEST_FINAL_SHIMS(SHA384, kCCDigestSHA384) DIGEST_FINAL_SHIMS(SHA512, kCCDigestSHA512) #define MD5_CTX CC_MD5_CTX void MD5Final(unsigned char md[16], MD5_CTX *c) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); (void) CC_MD5_Final(md, c); } static void ccdigest_process(struct ccdigest_info *di, uint8_t *bufptr, ccdigest_state_t state, uint64_t curlen, size_t len, uint8_t *data) { while(len) { if (curlen == 0 && len >= di->block_size) { uint64_t fullblocks = len / di->block_size; di->compress(state, fullblocks, data); uint64_t nbytes = fullblocks * di->block_size; len -= nbytes; data += nbytes; } else { uint64_t n = CC_XMIN(len, (di->block_size - curlen)); CC_XMEMCPY(bufptr + curlen, data, n); curlen += n; len -= n; data += n; if (curlen == di->block_size) { di->compress(state, 1, bufptr); curlen = 0; } } } } static void ccdigest_finalize(struct ccdigest_info *di, uint8_t *bufptr, ccdigest_state_t state, uint64_t curlen, uint64_t totalLen) { bufptr[curlen++] = (unsigned char)0x80; int reserve = 8; if(di->block_size == 128) reserve = 16; // SHA384/512 reserves 16 bytes below. /* if the length is currently above block_size - reserve bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (curlen > (di->block_size - reserve)) { while (curlen < di->block_size) bufptr[curlen++] = (unsigned char)0; di->compress(state, 1, bufptr); curlen = 0; } /* pad out with zeros, but store length in last 8 bytes (sizeof uint64_t) */ while (curlen < (di->block_size - 8)) bufptr[curlen++] = (unsigned char)0; totalLen *= 8; // size in bits CC_XSTORE64H(totalLen, bufptr+(di->block_size - 8)); di->compress(state, 1, bufptr); } /* #define CC_MD2_DIGEST_LENGTH 16 #define CC_MD2_BLOCK_BYTES 64 #define CC_MD2_BLOCK_LONG (CC_MD2_BLOCK_BYTES / sizeof(CC_LONG)) typedef struct CC_MD2state_st { int num; unsigned char data[CC_MD2_DIGEST_LENGTH]; CC_LONG cksm[CC_MD2_BLOCK_LONG]; CC_LONG state[CC_MD2_BLOCK_LONG]; } CC_MD2_CTX; */ static inline void md2in(struct ccdigest_info *di, ccdigest_ctx_t ctx, CC_MD2_CTX *c) { CC_XMEMCPY(ccdigest_state_u8(di, ctx)+48, c->cksm, CC_MD2_BLOCK_LONG); CC_XMEMCPY(ccdigest_state_u8(di, ctx), c->state, CC_MD2_BLOCK_LONG); CC_XMEMCPY(ccdigest_data(di, ctx), c->data, CC_MD2_DIGEST_LENGTH); ccdigest_num(di, ctx) = c->num; } static inline void md2out(struct ccdigest_info *di, CC_MD2_CTX *c, ccdigest_ctx_t ctx) { CC_XMEMCPY(c->cksm, ccdigest_state_u8(di, ctx)+48, CC_MD2_BLOCK_LONG); CC_XMEMCPY(c->state, ccdigest_state_u8(di, ctx), CC_MD2_BLOCK_LONG); CC_XMEMCPY(c->data, ccdigest_data(di, ctx), CC_MD2_DIGEST_LENGTH); c->num = (int) ccdigest_num(di, ctx); } int CC_MD2_Init(CC_MD2_CTX *c) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestMD2); ccdigest_di_decl(di, ctx); ccdigest_init(di, ctx); md2out(di, c, ctx); return CC_COMPAT_DIGEST_RETURN; } int CC_MD2_Update(CC_MD2_CTX *c, const void *data, CC_LONG len) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestMD2); ccdigest_di_decl(di, ctx); md2in(di, ctx, c); ccdigest_update(di, ctx, len, data); md2out(di, c, ctx); return CC_COMPAT_DIGEST_RETURN; } extern int CC_MD2_Final(unsigned char *md, CC_MD2_CTX *c) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestMD2); ccdigest_di_decl(di, ctx); md2in(di, ctx, c); ccdigest_final(di, ctx, md); md2out(di, c, ctx); return CC_COMPAT_DIGEST_RETURN; } /* typedef struct CC_SHA256state_st { CC_LONG count[2]; CC_LONG hash[8]; CC_LONG wbuf[16]; } CC_SHA256_CTX; */ typedef struct CC_SHA256state_x { uint64_t count; uint32_t hash[8]; uint32_t wbuf[16]; } CC_SHA256_CTX_X; int CC_SHA256_Init(CC_SHA256_CTX *x) { CC_SHA256_CTX_X *c = (CC_SHA256_CTX_X *) x; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ASSERT(sizeof(CC_SHA256_CTX) == sizeof(CC_SHA256_CTX_X)); struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA256); ASSERT(di->state_size == CC_SHA256_DIGEST_LENGTH); CC_XZEROMEM(c->hash, CC_SHA256_DIGEST_LENGTH); ASSERT(di->block_size == CC_SHA256_BLOCK_BYTES); CC_XZEROMEM(c->wbuf, CC_SHA256_BLOCK_BYTES); c->count = 0; CC_XMEMCPY(c->hash, di->initial_state, di->state_size); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA256_Update(CC_SHA256_CTX *x, const void *data, CC_LONG len) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA256); CC_SHA256_CTX_X *c = (CC_SHA256_CTX_X *) x; uint64_t totalLen = c->count; uint64_t curlen = totalLen % di->block_size; uint8_t *bufptr = (uint8_t *) c->wbuf; struct ccdigest_state *state = c->hash; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!len || !data) return CC_COMPAT_DIGEST_RETURN; c->count += len; ccdigest_process(di, bufptr, state, curlen, len, data); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA256_Final(unsigned char *md, CC_SHA256_CTX *x) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA256); CC_SHA256_CTX_X *c = (CC_SHA256_CTX_X *) x; uint64_t totalLen = c->count; uint64_t curlen = totalLen % di->block_size; uint8_t *bufptr = (uint8_t *) c->wbuf; struct ccdigest_state *state = c->hash; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!md) return CC_COMPAT_DIGEST_RETURN; ccdigest_finalize(di, bufptr, state, curlen, totalLen); /* copy output */ for (int i = 0; i < 8; i++) CC_XSTORE32H(c->hash[i], md+(4*i)); return CC_COMPAT_DIGEST_RETURN; } /* typedef struct CC_SHA512state_st { CC_LONG64 count[2]; CC_LONG64 hash[8]; CC_LONG64 wbuf[16]; } CC_SHA512_CTX; */ typedef struct CC_SHA512state_x { uint64_t count; uint64_t countx; uint64_t hash[8]; uint64_t wbuf[16]; } CC_SHA512_CTX_X; int CC_SHA512_Init(CC_SHA512_CTX *x) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA512); CC_SHA512_CTX_X *c = (CC_SHA512_CTX_X *) x; ASSERT(di->state_size == CC_SHA512_DIGEST_LENGTH); CC_XZEROMEM(c->hash, CC_SHA512_DIGEST_LENGTH); ASSERT(di->block_size == CC_SHA512_BLOCK_BYTES); CC_XZEROMEM(c->wbuf, CC_SHA512_BLOCK_BYTES); c->count = 0; CC_XMEMCPY(c->hash, di->initial_state, di->state_size); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA512_Update(CC_SHA512_CTX *x, const void *data, CC_LONG len) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA512); CC_SHA512_CTX_X *c = (CC_SHA512_CTX_X *) x; uint64_t totalLen = c->count; uint64_t curlen = totalLen % di->block_size; uint8_t *bufptr = (uint8_t *) c->wbuf; struct ccdigest_state *state = c->hash; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!len || !data) return CC_COMPAT_DIGEST_RETURN; c->count += len; ccdigest_process(di, bufptr, state, curlen, len, data); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA512_Final(unsigned char *md, CC_SHA512_CTX *x) { struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA512); CC_SHA512_CTX_X *c = (CC_SHA512_CTX_X *) x; uint64_t totalLen = c->count; uint64_t curlen = totalLen % di->block_size; uint8_t *bufptr = (uint8_t *) c->wbuf; struct ccdigest_state *state = c->hash; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!md) return CC_COMPAT_DIGEST_RETURN; ccdigest_finalize(di, bufptr, state, curlen, totalLen); /* copy output */ for (int i = 0; i < di->output_size/8; i++) CC_XSTORE64H(c->hash[i], md+(8*i)); return CC_COMPAT_DIGEST_RETURN; } /* * Dependent sets of routines (SHA224 and SHA384) */ int CC_SHA224_Init(CC_SHA256_CTX *c) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA224); ASSERT(di->state_size == CC_SHA256_DIGEST_LENGTH); CC_XZEROMEM(c->hash, CC_SHA256_DIGEST_LENGTH); ASSERT(di->block_size == CC_SHA256_BLOCK_BYTES); CC_XZEROMEM(c->wbuf, CC_SHA256_BLOCK_BYTES); c->count[0] = c->count[1] = 0; CC_XMEMCPY(c->hash, di->initial_state, di->state_size); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA224_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CC_SHA256_Update(c, data, len); } int CC_SHA224_Final(unsigned char *md, CC_SHA256_CTX *c) { uint32_t buf[CC_SHA256_DIGEST_LENGTH/4]; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_SHA256_Final(buf, c); CC_XMEMCPY(md, buf, CC_SHA224_DIGEST_LENGTH); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA384_Init(CC_SHA512_CTX *c) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); struct ccdigest_info *di = CCDigestGetDigestInfo(kCCDigestSHA384); ASSERT(di->state_size == CC_SHA512_DIGEST_LENGTH); CC_XZEROMEM(c->hash, CC_SHA512_DIGEST_LENGTH); ASSERT(di->block_size == CC_SHA512_BLOCK_BYTES); CC_XZEROMEM(c->wbuf, CC_SHA512_BLOCK_BYTES); c->count[0] = c->count[1] = 0; CC_XMEMCPY(c->hash, di->initial_state, di->state_size); return CC_COMPAT_DIGEST_RETURN; } int CC_SHA384_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CC_SHA512_Update(c, data, len); } int CC_SHA384_Final(unsigned char *md, CC_SHA512_CTX *c) { uint64_t buf[CC_SHA512_DIGEST_LENGTH/8]; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); CC_SHA512_Final(buf, c); CC_XMEMCPY(md, buf, CC_SHA384_DIGEST_LENGTH); return CC_COMPAT_DIGEST_RETURN; } |
Changes to Source/API/CommonDigestPriv.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2004-2010 Apple, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
24 25 26 27 28 29 30 | /* * CommonDigestPriv.h - private typedefs and defines for ComonCrypto digest routines */ #ifndef _COMMON_DIGEST_PRIV_H_ #define _COMMON_DIGEST_PRIV_H_ | | | < < | < < < < | < | < < < < < < | < | < < < < < < < < < < < < < | < < < < < < < < < < < < < < | < | < < | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * CommonDigestPriv.h - private typedefs and defines for ComonCrypto digest routines */ #ifndef _COMMON_DIGEST_PRIV_H_ #define _COMMON_DIGEST_PRIV_H_ #include <CommonCrypto/CommonDigest.h> #include <CommonCrypto/CommonDigestSPI.h> // This has to fit in 1032 bytes for static context clients - until we move them. typedef struct ccDigest_s { struct ccdigest_info *di; uint8_t md[512]; } CCDigestCtx_t, *CCDigestCtxPtr; // This should remain internal only. This bridges the CommonCrypto->corecrypto structures struct ccdigest_info * CCDigestGetDigestInfo(CCDigestAlgorithm algorithm); #endif /* _COMMON_DIGEST_PRIV_H_ */ |
Added Source/API/CommonECCryptor.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_EC_FUNCTIONS #include "CommonECCryptor.h" #include "CommonDigest.h" #include "CommonDigestPriv.h" #include "CommonRandomSPI.h" #include "ccMemory.h" #import <corecrypto/ccec.h> #include <AssertMacros.h> #include "ccdebug.h" #pragma mark Internal Structures and Functions typedef struct _CCECCryptor { union { ccec_full_ctx *private; ccec_pub_ctx *public; uint8_t *bytes; } ecKey; size_t keySize; CCECKeyType keyType; } CCECCryptor; static CCECCryptor * ccMallocECCryptor(size_t nbits, CCECKeyType keyType) { CCECCryptor *retval; size_t ctxSize = 0; if(!ccec_keysize_is_supported(nbits)) return kCCParamError; ccec_const_cp_t cp = ccec_get_cp(nbits); size_t len = ccec_cp_prime_size(cp); if((retval = CC_XMALLOC(sizeof(CCECCryptor))) == NULL) return NULL; retval->keySize = nbits; retval->ecKey.bytes = NULL; switch(keyType) { case ccECKeyPublic: retval->keyType = ccECBlankPublicKey; ctxSize = ccec_pub_ctx_size(len); break; case ccECKeyPrivate: retval->keyType = ccECBlankPrivateKey; ctxSize = ccec_full_ctx_size(len); break; default: retval = kCCParamError; goto errOut; } if((retval->ecKey.bytes = CC_XMALLOC(ctxSize)) == NULL) goto errOut; ccec_ctx_init(cp, retval->ecKey.public); return retval; errOut: if(retval) { CC_XFREE(retval, sizeof(CCECCryptor)); } return retval; } static void ccECCryptorClear(CCECCryptor *theKey) { size_t nbits = theKey->keySize; size_t ctxSize = 0; if(!ccec_keysize_is_supported(nbits)) return ; //kCCParamError; ccec_const_cp_t cp = ccec_get_cp(nbits); size_t len = ccec_cp_prime_size(cp); CCECCryptor *key = (CCECCryptor *) theKey; if(!key) return; switch(key->keyType) { case ccECKeyPublic: case ccECBlankPublicKey: ctxSize = ccec_pub_ctx_size(len); break; case ccECKeyPrivate: case ccECBlankPrivateKey: ctxSize = ccec_full_ctx_size(len); break; default: break; } if(ctxSize && key->ecKey.bytes) { CC_XZEROMEM(key->ecKey.bytes, ctxSize); CC_XFREE(key->ecKey.bytes, ctxSize); } errOut: CC_XZEROMEM(key, sizeof(CCECCryptor)); CC_XFREE(key, sizeof(CCECCryptor)); } static bool ccECpairwiseConsistencyCheck(CCECCryptorRef privateKey, CCECCryptorRef publicKey) { CCCryptorStatus status = kCCSuccess; uint8_t digestBuffer[CC_SHA1_DIGEST_LENGTH]; size_t signedDataLen = 4096; uint8_t signedData[4096]; uint32_t isValid = 0; CC_XMEMSET(digestBuffer, 0x0a, CC_SHA1_DIGEST_LENGTH); status = CCECCryptorSignHash(privateKey, digestBuffer, CC_SHA1_DIGEST_LENGTH, signedData, &signedDataLen); if (kCCSuccess != status) return false; status = CCECCryptorVerifyHash(publicKey, digestBuffer, CC_SHA1_DIGEST_LENGTH, signedData, signedDataLen, &isValid); if (kCCSuccess != status || isValid != 1) return false; return true; } #pragma mark API (SPI for now) CCCryptorStatus CCECCryptorGeneratePair(size_t nbits, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey) { CCCryptorStatus retval; CCECCryptor *privateCryptor = NULL; CCECCryptor *publicCryptor = NULL; struct ccrng_state *theRng = ccDRBGGetRngState(); CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!ccec_keysize_is_supported(nbits)) return kCCParamError; ccec_const_cp_t cp = ccec_get_cp(nbits); cc_size n = ccec_cp_n(cp); __Require_Action((privateCryptor = ccMallocECCryptor(nbits, ccECKeyPrivate)) != NULL, errOut, retval = kCCMemoryFailure); privateCryptor->keySize = nbits; __Require_Action((ccec_generate_key(cp, theRng, privateCryptor->ecKey.private) == 0), errOut, retval = kCCDecodeError); privateCryptor->keyType = ccECKeyPrivate; __Require_Action((publicCryptor = CCECCryptorGetPublicKeyFromPrivateKey(privateCryptor)) != NULL, errOut, retval = kCCMemoryFailure); __Require_Action(ccECpairwiseConsistencyCheck(privateCryptor, publicCryptor) == true, errOut, retval = kCCDecodeError); *publicKey = publicCryptor; *privateKey = privateCryptor; return kCCSuccess; errOut: if(privateCryptor) ccECCryptorClear(privateCryptor); if(publicCryptor) ccECCryptorClear(publicCryptor); *publicKey = *privateKey = NULL; return kCCDecodeError; } CCECCryptorRef CCECCryptorGetPublicKeyFromPrivateKey(CCECCryptorRef privateKey) { CCECCryptor *publicCryptor = NULL; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); __Require((publicCryptor = ccMallocECCryptor(privateKey->keySize, ccECKeyPublic)) != NULL, errOut); if(!ccec_keysize_is_supported(privateKey->keySize)) return kCCParamError; ccec_const_cp_t cp = ccec_get_cp(privateKey->keySize); size_t ctx_size = ccec_pub_ctx_size(ccec_cp_prime_size(cp)); CC_XMEMCPY(publicCryptor->ecKey.public, privateKey->ecKey.public, ctx_size); publicCryptor->keySize = privateKey->keySize; publicCryptor->keyType = ccECKeyPublic; if(ccECpairwiseConsistencyCheck(privateKey, publicCryptor) == false) goto errOut; return publicCryptor; errOut: if(publicCryptor) ccECCryptorClear(publicCryptor); return NULL; } CCCryptorStatus CCECCryptorGetKeyComponents(CCECCryptorRef ecKey, size_t *keySize, uint8_t *qX, size_t *qXLength, uint8_t *qY, size_t *qYLength, uint8_t *d, size_t *dLength) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); switch(ecKey->keyType) { case ccECKeyPublic: if(ccec_get_pubkey_components(ecKey->ecKey.public, keySize, qX, qXLength, qY, qYLength)) return kCCMemoryFailure; break; case ccECKeyPrivate: if(ccec_get_fullkey_components(ecKey->ecKey.private, keySize, qX, qXLength, qY, qYLength, d, dLength)) return kCCMemoryFailure; break; default: return kCCParamError; } return kCCSuccess; } CCCryptorStatus CCECCryptorCreateFromData(size_t nbits, uint8_t *qX, size_t qXLength, uint8_t *qY, size_t qYLength, CCECCryptorRef *ref) { CCECCryptor *publicCryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); *ref = NULL; if((publicCryptor = ccMallocECCryptor(nbits, ccECKeyPublic)) == NULL) return kCCMemoryFailure; if(ccec_make_pub(nbits, qXLength, qX, qYLength, qY, publicCryptor->ecKey.public)) { ccECCryptorClear(publicCryptor); return kCCDecodeError; } publicCryptor->keyType = ccECKeyPublic; *ref = publicCryptor; return kCCSuccess; } CCECKeyType CCECGetKeyType(CCECCryptorRef key) { CCECCryptor *cryptor = key; CCECKeyType retval; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return ccECBlankPublicKey; retval = cryptor->keyType; if(retval != ccECKeyPublic && retval != ccECKeyPrivate) return ccECBadKey; return retval; } int CCECGetKeySize(CCECCryptorRef key) { CCECCryptor *cryptor = key; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return kCCParamError; return key->keySize; } void CCECCryptorRelease(CCECCryptorRef key) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccECCryptorClear(key); } CCCryptorStatus CCECCryptorImportPublicKey(void *keyPackage, size_t keyPackageLen, CCECCryptorRef *key) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CCECCryptorImportKey(kCCImportKeyBinary, keyPackage, keyPackageLen, ccECKeyPublic, key); } CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key) { CCECCryptor *cryptor = NULL; CCCryptorStatus retval = kCCSuccess; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(keyPackage == NULL) return kCCParamError; switch(format) { case kCCImportKeyBinary: if(keyType == ccECKeyPrivate) { size_t nbits = ccec_x963_import_priv_size(keyPackageLen); if((cryptor = ccMallocECCryptor(nbits, ccECKeyPrivate)) == NULL) return kCCMemoryFailure; ccec_const_cp_t cp = ccec_get_cp(nbits); __Require_Action(ccec_x963_import_priv(cp, keyPackageLen, keyPackage, cryptor->ecKey.private) == 0, errOut, retval = kCCDecodeError); cryptor->keySize = nbits; } else if(keyType == ccECKeyPublic) { size_t nbits = ccec_x963_import_pub_size(keyPackageLen); if((cryptor = ccMallocECCryptor(nbits, ccECKeyPublic)) == NULL) return kCCMemoryFailure; ccec_const_cp_t cp = ccec_get_cp(nbits); __Require_Action(ccec_x963_import_pub(cp, keyPackageLen, keyPackage, cryptor->ecKey.public) == 0, errOut, retval = kCCDecodeError); cryptor->keySize = nbits; } else return kCCParamError; cryptor->keyType = keyType; *key = cryptor; break; case kCCImportKeyDER: retval = kCCUnimplemented; break; default: retval = kCCParamError; break; } errOut: if(retval) { *key = NULL; if(cryptor) ccECCryptorClear(cryptor); } return retval; } CCCryptorStatus CCECCryptorExportPublicKey(CCECCryptorRef key, void *out, size_t *outLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return kCCParamError; if(out == NULL) return kCCParamError; return CCECCryptorExportKey(kCCImportKeyBinary, out, outLen, ccECKeyPublic, key); } CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key) { CCCryptorStatus retval = kCCSuccess; unsigned long len = *keyPackageLen; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return kCCParamError; if(keyPackage == NULL) return kCCParamError; switch(format) { case kCCImportKeyBinary: { CCECCryptorRef tmpkey; size_t len = ccec_x963_export_size(keyType == ccECKeyPrivate, key->ecKey.private); if(len > *keyPackageLen) { *keyPackageLen = len; return kCCMemoryFailure; } *keyPackageLen = len; ccec_x963_export(keyType == ccECKeyPrivate, keyPackage, key->ecKey.private); break; } case kCCImportKeyDER: retval = kCCUnimplemented; break; default: retval = kCCParamError; break; } return retval; } CCCryptorStatus CCECCryptorSignHash(CCECCryptorRef privateKey, const void *hashToSign, size_t hashSignLen, void *signedData, size_t *signedDataLen) { CCCryptorStatus retval = kCCSuccess; CCECCryptor *privateCryptor = privateKey; // CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(privateKey == NULL || hashToSign == NULL || signedData == NULL || signedDataLen == NULL) return kCCParamError; struct ccrng_state *therng = ccDRBGGetRngState(); if(ccec_sign(privateKey->ecKey.private, hashSignLen, hashToSign, signedDataLen, signedData, therng) != 0) retval = kCCDecodeError; return retval; } CCCryptorStatus CCECCryptorVerifyHash(CCECCryptorRef publicKey, const void *hash, size_t hashLen, const void *signedData, size_t signedDataLen, uint32_t *valid) { CCCryptorStatus retval = kCCSuccess; bool stat = 0; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(publicKey == NULL || hash == NULL || signedData == NULL) return kCCParamError; if(ccec_verify(publicKey->ecKey.public, hashLen, hash, signedDataLen, signedData, &stat)) retval = kCCDecodeError; *valid = stat; return retval; } #pragma mark API for ECDH - needs corecrypto key import / export capability (SPI for now) CCCryptorStatus CCECCryptorWrapKey(CCECCryptorRef publicKey, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, CCDigestAlg digestType) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return kCCUnimplemented; } CCCryptorStatus CCECCryptorUnwrapKey(CCECCryptorRef privateKey, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return kCCUnimplemented; } CCCryptorStatus CCECCryptorComputeSharedSecret(CCECCryptorRef privateKey, CCECCryptorRef publicKey, void *out, size_t *outLen) { CCCryptorStatus retval = kCCSuccess; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(privateKey == NULL || publicKey == NULL) return kCCParamError; if(out == NULL) return kCCParamError; if(ccec_compute_key(privateKey->ecKey.private, publicKey->ecKey.public, outLen, out)) return kCCDecodeError; return retval; } |
Added Source/API/CommonGCMCryptor.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_GCM_FUNCTIONS #include "ccMemory.h" #include "ccdebug.h" #include "CommonCryptor.h" #include "CommonCryptorSPI.h" #include "CommonCryptorPriv.h" #include <corecrypto/ccmode_factory.h> CCCryptorStatus CCCryptorGCMAddIV(CCCryptorRef cryptorRef, const void *iv, size_t ivLen) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; ccmode_gcm_set_iv(cryptor->ctx[cryptor->op].gcm, ivLen, iv); return kCCSuccess; } CCCryptorStatus CCCryptorGCMAddAAD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; ccmode_gcm_gmac(cryptor->ctx[cryptor->op].gcm, aDataLen, aData); return kCCSuccess; } // This is for old iOS5 clients CCCryptorStatus CCCryptorGCMAddADD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) { return CCCryptorGCMAddAAD(cryptorRef, aData, aDataLen); } // This was a temp mistake in MacOSX8 CCCryptorStatus CCCryptorGCMaddAAD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) { return CCCryptorGCMAddAAD(cryptorRef, aData, aDataLen); } CCCryptorStatus CCCryptorGCMEncrypt( CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(dataIn == NULL || dataOut == NULL) return kCCParamError; ccmode_gcm_encrypt(cryptor->ctx[cryptor->op].gcm, dataInLength, dataIn, dataOut); return kCCSuccess; } CCCryptorStatus CCCryptorGCMDecrypt( CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(dataIn == NULL || dataOut == NULL) return kCCParamError; ccmode_gcm_decrypt(cryptor->ctx[cryptor->op].gcm, dataInLength, dataIn, dataOut); return kCCSuccess; } CCCryptorStatus CCCryptorGCMFinal( CCCryptorRef cryptorRef, const void *tag, size_t *tagLength) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; if(tag == NULL || tagLength == NULL) return kCCParamError; ccmode_gcm_finalize(cryptor->ctx[cryptor->op].gcm, tagLength, tag); return kCCSuccess; } CCCryptorStatus CCCryptorGCMReset( CCCryptorRef cryptorRef) { CCCompatCryptor *compat_cryptor = cryptorRef; CCCryptor *cryptor; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(compat_cryptor == NULL) return kCCParamError; cryptor = compat_cryptor->cryptor; ccmode_gcm_reset(cryptor->ctx[cryptor->op].gcm); return kCCSuccess; } CCCryptorStatus CCCryptorGCM( CCOperation op, /* kCCEncrypt, kCCDecrypt */ CCAlgorithm alg, const void *key, /* raw key material */ size_t keyLength, const void *iv, size_t ivLen, const void *aData, size_t aDataLen, const void *dataIn, size_t dataInLength, void *dataOut, const void *tag, size_t *tagLength) { CCCryptorRef cryptorRef; CCCryptorStatus retval; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Op: %d Cipher: %d\n", op, alg); retval = CCCryptorCreateWithMode(op, kCCModeGCM, alg, 0, NULL, key, keyLength, NULL, 0, 0, 0, &cryptorRef); if(retval) return retval; // IV is optional if(ivLen) { retval = CCCryptorGCMAddIV(cryptorRef, iv, ivLen); if(retval) return retval; } // This must always be called - even with no aData. retval = CCCryptorGCMaddAAD(cryptorRef, aData, aDataLen); if(retval) return retval; if(op == kCCEncrypt) retval = CCCryptorGCMEncrypt(cryptorRef, dataIn, dataInLength, dataOut); else if(op == kCCDecrypt) retval = CCCryptorGCMDecrypt(cryptorRef, dataIn, dataInLength, dataOut); else return kCCParamError; if(retval) return retval; retval = CCCryptorGCMFinal(cryptorRef, tag, tagLength); CCCryptorRelease(cryptorRef); return retval; } |
Changes to Source/API/CommonHMAC.c.
|
| | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
17 18 19 20 21 22 23 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ | | | < < < | | | > | > | < < < < < < < < < | | > > | > > | | > > > > > | | > > > > | > | | | > | | > > > | > > | > > > | | | | | | | | > > > | > | > | > | | < > > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | | < < < | < < < < < | < < < < < < < < < < < < < < | | < < | < | | | | | > > | | | | > > > | > > > > > > | | > > > > > > > | | > > > > > > | | | | | | | > > > > > > | > | > > > > > > > | > > > | > | > > > | > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_HMAC_FUNCTIONS #include "CommonHMAC.h" #include "CommonHmacSPI.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" #include "CommonDigestPriv.h" #include <corecrypto/cchmac.h> #include "ccMemory.h" #include "ccdebug.h" #ifndef NDEBUG #define ASSERT(s) #else #define ASSERT(s) assert(s) #endif #define HMAC_MAX_BLOCK_SIZE CC_SHA512_BLOCK_BYTES #define HMAC_MAX_DIGEST_SIZE CC_SHA512_DIGEST_LENGTH /* * This is what a CCHmacContext actually points to. * we have 384 bytes to work with */ typedef struct { struct ccdigest_info *di; cchmac_ctx_decl(HMAC_MAX_BLOCK_SIZE, HMAC_MAX_DIGEST_SIZE, ctx); } _NewHmacContext; typedef struct { CCHmacAlgorithm ccHmacValue; CCDigestAlgorithm ccDigestAlg; const char *ccDigestName; } ccHmac2DigestConversion; const ccHmac2DigestConversion ccconversionTable[] = { { kCCHmacAlgSHA1, kCCDigestSHA1, "sha1" }, { kCCHmacAlgMD5, kCCDigestMD5, "md5" }, { kCCHmacAlgSHA224, kCCDigestSHA224, "sha224" }, { kCCHmacAlgSHA256, kCCDigestSHA256, "sha256" }, { kCCHmacAlgSHA384, kCCDigestSHA384, "sha384" }, { kCCHmacAlgSHA512, kCCDigestSHA512, "sha512" }, }; const static int ccHmacConversionTableLength = sizeof(ccconversionTable) / sizeof(ccHmac2DigestConversion); static struct ccdigest_info * convertccHmacSelector(CCHmacAlgorithm oldSelector) { int i; for(i=0; i<ccHmacConversionTableLength; i++) if(oldSelector == ccconversionTable[i].ccHmacValue) { return CCDigestGetDigestInfo(ccconversionTable[i].ccDigestAlg); } return NULL; } void CCHmacInit( CCHmacContext *ctx, CCHmacAlgorithm algorithm, /* kCCHmacSHA1, kCCHmacMD5 */ const void *key, size_t keyLength) /* length of key in bytes */ { _NewHmacContext *hmacCtx = (_NewHmacContext *)ctx; uint8_t tk[HMAC_MAX_DIGEST_SIZE]; const uint8_t *keyP; uint32_t byte; uint8_t k_ipad[HMAC_MAX_BLOCK_SIZE]; size_t digestLen; size_t blockLen; // CCDigestCtxPtr digestCtx = &hmacCtx->digestCtx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", algorithm); ASSERT(sizeof(_NewHmacContext) < sizeof(CCHmacContext)); if(hmacCtx == NULL) { CC_DEBUG_LOG(CC_DEBUG, "NULL Context passed in\n"); return; } if(key == NULL) { CC_DEBUG_LOG(CC_DEBUG, "NULL Context passed in\n"); return; } CC_XZEROMEM(hmacCtx, sizeof(_NewHmacContext)); if((hmacCtx->di = convertccHmacSelector(algorithm)) == NULL) { CC_DEBUG_LOG(CC_DEBUG, "CCHMac Unknown Digest %d\n", algorithm); return; } cchmac_init(hmacCtx->di, hmacCtx->ctx, keyLength, key); } void CCHmacUpdate( CCHmacContext *ctx, const void *dataIn, size_t dataInLength) /* length of data in bytes */ { _NewHmacContext *hmacCtx = (_NewHmacContext *)ctx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); cchmac_update(hmacCtx->di, hmacCtx->ctx, dataInLength, dataIn); } void CCHmacFinal( CCHmacContext *ctx, void *macOut) { _NewHmacContext *hmacCtx = (_NewHmacContext *)ctx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); cchmac_final(hmacCtx->di, hmacCtx->ctx, macOut); } void CCHmacDestroy(CCHmacContextRef ctx) { CC_XZEROMEM(ctx, sizeof(_NewHmacContext)); CC_XFREE(ctx, sizeof(_NewHmacContext)); } size_t CCHmacOutputSizeFromRef(CCHmacContextRef ctx) { _NewHmacContext *hmacCtx = (_NewHmacContext *)ctx; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return hmacCtx->di->output_size; } size_t CCHmacOutputSize(CCDigestAlg alg) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return CCDigestGetOutputSize(alg); } /* * Stateless, one-shot HMAC function. * Output is written to caller-supplied buffer, as in CCHmacFinal(). */ void CCHmac( CCHmacAlgorithm algorithm, /* kCCHmacSHA1, kCCHmacMD5 */ const void *key, size_t keyLength, /* length of key in bytes */ const void *data, size_t dataLength, /* length of data in bytes */ void *macOut) /* MAC written here */ { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering Algorithm: %d\n", algorithm); cchmac(convertccHmacSelector(algorithm), keyLength, key, dataLength, data, macOut); } CCHmacContextRef CCHmacCreate(CCDigestAlg alg, const void *key, size_t keyLength) { _NewHmacContext *hmacCtx; uint8_t tk[HMAC_MAX_DIGEST_SIZE]; const uint8_t *keyP; uint32_t byte; uint8_t k_ipad[HMAC_MAX_BLOCK_SIZE]; size_t digestLen = CCDigestGetOutputSize(alg); size_t blockLen = CCDigestGetBlockSize(alg); CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); /* if this fails, it's time to adjust CC_HMAC_CONTEXT_SIZE */ if((hmacCtx = CC_XMALLOC(sizeof(_NewHmacContext))) == NULL) return NULL; CC_XZEROMEM(hmacCtx, sizeof(_NewHmacContext)); if((hmacCtx->di = CCDigestGetDigestInfo(alg)) == NULL) { CC_DEBUG_LOG(CC_DEBUG, "CCHMac Unknown Digest %d\n"); return NULL; } cchmac_init(hmacCtx->di, hmacCtx->ctx, keyLength, key); return hmacCtx; } |
Changes to Source/API/CommonKeyDerivation.c.
|
| < < < < | < < | < < < > | < < < < < < < < | < < < | < < < > > > > | < < | | | | | | < < | < < < < < < < < < | < < | < | < < < < < < < < < < < < < < < < < | < | < < < | < < < < < | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < | > | | < < < | < < < < | < | < < < < | < < < | < < < < | < < | < < < | < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < > > > > > > | | > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_KEYDERIVATION_FUNCTIONS #include "CommonKeyDerivation.h" #include <corecrypto/ccpbkdf2.h> #include "CommonDigestPriv.h" #include "CommonDigestSPI.h" #include "ccdebug.h" int CCKeyDerivationPBKDF( CCPBKDFAlgorithm algorithm, const char *password, size_t passwordLen, const uint8_t *salt, size_t saltLen, CCPseudoRandomAlgorithm prf, uint rounds, uint8_t *derivedKey, size_t derivedKeyLen) { const struct ccdigest_info *di; CC_DEBUG_LOG(ASL_LEVEL_ERR, "PasswordLen %lu SaltLen %lU PRF %d Rounds %u DKLen %lu\n", passwordLen, saltLen, prf, rounds, derivedKeyLen); if(algorithm != kCCPBKDF2) return -1; switch(prf) { case kCCPRFHmacAlgSHA1: di = CCDigestGetDigestInfo(kCCDigestSHA1); break; case kCCPRFHmacAlgSHA224: di = CCDigestGetDigestInfo(kCCDigestSHA224); break; case kCCPRFHmacAlgSHA256: di = CCDigestGetDigestInfo(kCCDigestSHA256); break; case kCCPRFHmacAlgSHA384: di = CCDigestGetDigestInfo(kCCDigestSHA384); break; case kCCPRFHmacAlgSHA512: di = CCDigestGetDigestInfo(kCCDigestSHA512); break; default: return -1; } if(!password || !salt || !derivedKey || (derivedKeyLen == 0) || (rounds == 0)) return -1; ccpbkdf2_hmac(di, passwordLen, password, saltLen, salt, rounds, derivedKeyLen, derivedKey); return 0; } #include <mach/mach.h> #include <mach/mach_time.h> #define ROUNDMEASURE 100000 // This is for the scratchspace - it's twice the size of the max PRF buffer + 4 to work within the pbkdf2 code we currently // have. #define CC_MAX_PRF_WORKSPACE 128+4 static uint64_t timer() { static mach_timebase_info_data_t sTimebaseInfo; uint64_t timeNano; if ( sTimebaseInfo.denom == 0 ) { (void) mach_timebase_info(&sTimebaseInfo); } timeNano = mach_absolute_time(); return (uint64_t) (timeNano * sTimebaseInfo.numer) / (sTimebaseInfo.denom * 1000000); } uint CCCalibratePBKDF(CCPBKDFAlgorithm algorithm, size_t passwordLen, size_t saltLen, CCPseudoRandomAlgorithm prf, size_t derivedKeyLen, uint32_t msec) { char *password; uint8_t *salt; uint64_t startTime, endTime, elapsedTime; uint8_t *derivedKey; int i; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if (derivedKeyLen == 0) return -1; // bad parameters if (saltLen == 0 || saltLen > CC_MAX_PRF_WORKSPACE) return -1; // out of bounds parameters if (passwordLen == 0 ) passwordLen = 1; if(algorithm != kCCPBKDF2) return -1; if((password = malloc(passwordLen)) == NULL) return -1; for(i=0; i<passwordLen; i++) password[i] = 'a'; if((salt = malloc(saltLen)) == NULL) return -1; for(i=0; i<saltLen; i++) salt[i] = i%256; if((derivedKey = malloc(derivedKeyLen)) == NULL) return -1; for(elapsedTime = 0, i=0; i < 5 && elapsedTime == 0; i++) { startTime = timer(); if(CCKeyDerivationPBKDF(algorithm, password, passwordLen, salt, saltLen, prf, ROUNDMEASURE, derivedKey, derivedKeyLen)) return -2; endTime = timer(); elapsedTime = endTime - startTime; } if(elapsedTime == 0) return 123456; // arbitrary, but something is seriously wrong free(password); free(salt); free(derivedKey); return (msec * ROUNDMEASURE)/elapsedTime; } |
Deleted Source/API/CommonKeyDerivationPriv.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/API/CommonRSACryptor.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_RSA_FUNCTIONS #include "CommonRSACryptor.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" #include "CommonDigestPriv.h" #include "CommonRandomSPI.h" #include <corecrypto/ccrsa.h> #include <corecrypto/ccrsa_priv.h> #include <corecrypto/ccasn1.h> #include "asn1Types.h" #include "DER_Keys.h" #include "DER_Encode.h" #include "ccErrors.h" #include "ccMemory.h" // #include "ccCoreCryptoInterface.h" #include "ccdebug.h" #include <AssertMacros.h> #pragma mark internal #define kCCMaximumRSAKeyBits 4096 #define kCCMaximumRSAKeyBytes ccn_sizeof(kCCMaximumRSAKeyBits) #define kCCRSAKeyContextSize ccrsa_full_ctx_size(kCCMaximumRSAKeyBytes) #define RSA_PKCS1_PAD_ENCRYPT 0x02 typedef struct _CCRSACryptor { union { ccrsa_full_ctx *full; ccrsa_priv_ctx *private; ccrsa_pub_ctx *public; uint8_t *bytes; } rsaKey; size_t keySize; size_t ctxSize; CCRSAKeyType keyType; } CCRSACryptor; static CCRSACryptor * ccMallocRSACryptor(size_t nbits, CCRSAKeyType keyType) { CCRSACryptor *retval; size_t ctxSize = 0; cc_size n = ccn_nof(nbits); if((retval = CC_XMALLOC(sizeof(CCRSACryptor))) == NULL) return NULL; retval->keySize = nbits; retval->rsaKey.bytes = NULL; switch(keyType) { case ccRSAKeyPublic: retval->keyType = ccRSABlankPublicKey; retval->ctxSize = ccrsa_pub_ctx_size(ccn_sizeof(nbits)); break; case ccRSAKeyPrivate: retval->keyType = ccRSABlankPrivateKey; retval->ctxSize = ccrsa_full_ctx_size(ccn_sizeof(nbits)); break; default: retval = kCCParamError; goto errOut; } if((retval->rsaKey.bytes = CC_XMALLOC(retval->ctxSize)) == NULL) goto errOut; ccrsa_ctx_n(retval->rsaKey.full) = n; return retval; errOut: if(retval) { CC_XFREE(retval, sizeof(CCRSACryptor)); } return retval; } static void ccRSACryptorClear(CCRSACryptorRef theKey) { size_t nbits; size_t ctxSize = 0; CCRSACryptor *key = (CCRSACryptor *) theKey; if(!key) return; if(ctxSize && key->rsaKey.bytes) { CC_XZEROMEM(key->rsaKey.bytes, key->ctxSize); CC_XFREE(key->rsaKey.bytes, key->ctxSize); } CC_XZEROMEM(key, sizeof(CCRSACryptor)); CC_XFREE(key, sizeof(CCRSACryptor)); } /* This is done for FIPS. Basically we make sure that the two keys will work to encrypt/decrypt each other's data. This will test up to 4K bit keys. */ #define MAXKEYTEST 512 static bool ccRSApairwiseConsistencyCheck(CCRSACryptorRef privateKey, CCRSACryptorRef publicKey) { CCCryptorStatus status = kCCSuccess; uint8_t digestBuffer[CC_SHA1_DIGEST_LENGTH]; size_t theDataLen = MAXKEYTEST, resultLen, recoveryLen; uint8_t theData[MAXKEYTEST]; uint8_t theResult[MAXKEYTEST]; uint8_t theRecovered[MAXKEYTEST]; /* the RSA keysize had better be equal - we convert keysizes to bytes since we need to work with the appropriate size data buffers for tests. */ theDataLen = CCRSAGetKeySize(privateKey) / 8; if(theDataLen > MAXKEYTEST || theDataLen != (CCRSAGetKeySize(publicKey) / 8)) { return false; } /* Fill the input buffer for the test */ CC_XMEMSET(theData, 0x0a, theDataLen); /* Encrypt the buffer with the private key then be sure the output isn't the same as the input */ resultLen = theDataLen; status = CCRSACryptorCrypt(privateKey, theData, theDataLen, theResult, &resultLen); if (kCCSuccess != status) { return false; } if(CC_XMEMCMP(theData, theResult, theDataLen) == 0) { return false; } /* Decrypt the buffer with the public key and be sure the output matches the original input */ recoveryLen = theDataLen; status = CCRSACryptorCrypt(publicKey, theResult, resultLen, theRecovered, &recoveryLen); if (kCCSuccess != status) { return false; } if(recoveryLen != theDataLen) { return false; } if(CC_XMEMCMP(theData, theRecovered, theDataLen) != 0) { return false; } /* Cleanup and leave */ CC_XZEROMEM(theData, MAXKEYTEST); CC_XZEROMEM(theResult, MAXKEYTEST); CC_XZEROMEM(theRecovered, MAXKEYTEST); return true; } #pragma mark APIDone CCCryptorStatus CCRSACryptorGeneratePair(size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey) { CCCryptorStatus retval; CCRSACryptor *privateCryptor = NULL; CCRSACryptor *publicCryptor = NULL; struct ccrng_state *theRng1 = ccDRBGGetRngState(); struct ccrng_state *theRng2 = ccDevRandomGetRngState(); CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); // ccrsa_generate_key() requires the exponent as length / pointer to bytes cc_unit cc_unit_e = (cc_unit) e; size_t eSize = ccn_write_int_size(1, &cc_unit_e); uint8_t eBytes[eSize]; ccn_write_int(1, &cc_unit_e, eSize, eBytes); *publicKey = *privateKey = NULL; __Require_Action((privateCryptor = ccMallocRSACryptor(keysize, ccRSAKeyPrivate)) != NULL, errOut, retval = kCCMemoryFailure); // __Require_Action((ccrsa_generate_key(keysize, privateCryptor->rsaKey.full, sizeof(e), &e, theRng) == 0), errOut, retval = kCCDecodeError); __Require_Action((ccrsa_generate_931_key(keysize, privateCryptor->rsaKey.full, eSize, eBytes, theRng1, theRng2) == 0), errOut, retval = kCCDecodeError); privateCryptor->keyType = ccRSAKeyPrivate; __Require_Action((publicCryptor = CCRSACryptorGetPublicKeyFromPrivateKey(privateCryptor)) != NULL, errOut, retval = kCCMemoryFailure); *publicKey = publicCryptor; *privateKey = privateCryptor; __Require_Action(ccRSApairwiseConsistencyCheck(*privateKey, *publicKey) == true, errOut, retval = kCCDecodeError); return kCCSuccess; errOut: if(privateCryptor) ccRSACryptorClear(privateCryptor); if(publicCryptor) ccRSACryptorClear(publicCryptor); *publicKey = *privateKey = NULL; return retval; } CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privateCryptorRef) { int tcReturn; CCRSACryptor *publicCryptor = NULL, *privateCryptor = privateCryptorRef; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if((publicCryptor = ccMallocRSACryptor(privateCryptor->keySize, ccRSAKeyPublic)) == NULL) return NULL; CC_XMEMCPY(publicCryptor->rsaKey.public, privateCryptor->rsaKey.private, ccrsa_pub_ctx_size(privateCryptor->keySize)); publicCryptor->keyType = ccRSAKeyPublic; return publicCryptor; } CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key) { CCRSACryptor *cryptor = key; CCRSAKeyType retval; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return ccRSABadKey; retval = cryptor->keyType; if(retval != ccRSAKeyPublic && retval != ccRSAKeyPrivate) return ccRSABadKey; return retval; } int CCRSAGetKeySize(CCRSACryptorRef key) { CCRSACryptor *cryptor = key; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(key == NULL) return kCCParamError; return cryptor->keySize; } void CCRSACryptorRelease(CCRSACryptorRef key) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccRSACryptorClear(key); } CCCryptorStatus CCRSACryptorImport(const void *keyPackage, size_t keyPackageLen, CCRSACryptorRef *key) { CCRSACryptor *cryptor = NULL; CCCryptorStatus retval; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!keyPackage || !key) return kCCParamError; DERItem keyItem = {(DERByte *)keyPackage, keyPackageLen}; DERRSAPubKeyPKCS1 decodedKey; if(DERParseSequence(&keyItem, DERNumRSAPubKeyPKCS1ItemSpecs, DERRSAPubKeyPKCS1ItemSpecs, &decodedKey, sizeof(decodedKey))) return kCCDecodeError; size_t n = ccn_nof_size(decodedKey.modulus.length); cc_unit m[n], e[n]; __Require_Action(ccn_read_uint(n, m, decodedKey.modulus.length, decodedKey.modulus.data) == 0, errOut, retval = kCCParamError); __Require_Action(ccn_read_uint(n, e, decodedKey.pubExponent.length, decodedKey.pubExponent.data) == 0, errOut, retval = kCCParamError); size_t nbits = ccn_bitlen(n, m); __Require_Action((cryptor = ccMallocRSACryptor(nbits, ccRSAKeyPublic)) != NULL, errOut, retval = kCCMemoryFailure); ccrsa_init_pub(cryptor->rsaKey.public, m, e); *key = cryptor; cryptor->keyType = ccRSAKeyPublic; return kCCSuccess; errOut: if(cryptor) ccRSACryptorClear(cryptor); *key = NULL; return retval; } CCCryptorStatus CCRSACryptorExport(CCRSACryptorRef key, void *out, size_t *outLen) { CCRSACryptor *cryptor = key; CCCryptorStatus retval = kCCSuccess; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!key || !out) return kCCParamError; __Require_Action(ccrsa_export_pub(key->rsaKey.public, outLen, out) == 0, errOut, retval = kCCDecodeError); errOut: return retval; } CCCryptorStatus CCRSACryptorEncrypt(CCRSACryptorRef publicKey, CCAsymetricPadding padding, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType) { CCCryptorStatus retval = kCCSuccess; ccrsa_pub_ctx_t pubkey; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!publicKey || !cipherText || !plainText || !cipherTextLen) return kCCParamError; pubkey.pub = publicKey->rsaKey.public; switch(padding) { case ccPKCS1Padding: if(ccrsa_encrypt_eme_pkcs1v15(pubkey, ccDRBGGetRngState(), cipherTextLen, cipherText, plainTextLen, plainText) != 0) retval = kCCDecodeError; break; case ccOAEPPadding: if(ccrsa_encrypt_oaep(pubkey, CCDigestGetDigestInfo(digestType), ccDRBGGetRngState(), cipherTextLen, cipherText, plainTextLen, plainText, tagDataLen, tagData) != 0) retval = kCCDecodeError; break; default: retval = kCCParamError; goto errOut; } errOut: return retval; } CCCryptorStatus CCRSACryptorDecrypt(CCRSACryptorRef privateKey, CCAsymetricPadding padding, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType) { CCCryptorStatus retval = kCCSuccess; ccrsa_full_ctx_t fullkey; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!privateKey || !cipherText || !plainText || !plainTextLen) return kCCParamError; fullkey.full = privateKey->rsaKey.private; switch (padding) { case ccPKCS1Padding: if(ccrsa_decrypt_eme_pkcs1v15(fullkey, plainTextLen, plainText, cipherTextLen, cipherText) != 0) retval = kCCDecodeError; break; case ccOAEPPadding: if(ccrsa_decrypt_oaep(fullkey, CCDigestGetDigestInfo(digestType), plainTextLen, plainText, cipherTextLen, cipherText, tagDataLen, tagData) != 0) retval = kCCDecodeError; break; default: goto errOut; } errOut: return retval; } CCCryptorStatus CCRSACryptorCrypt(CCRSACryptorRef rsaKey, const void *in, size_t inLen, void *out, size_t *outLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!rsaKey || !in || !out || !outLen) return kCCParamError; size_t keysizeBytes = rsaKey->keySize/8; if(inLen != keysizeBytes || *outLen < keysizeBytes) return kCCMemoryFailure; cc_size n = ccrsa_ctx_n(rsaKey->rsaKey.full); cc_unit buf[n]; ccn_read_uint(n, buf, inLen, in); switch(rsaKey->keyType) { case ccRSAKeyPublic: ccrsa_pub_crypt(rsaKey->rsaKey.public, buf, buf); break; case ccRSAKeyPrivate: ccrsa_priv_crypt(ccrsa_ctx_private(rsaKey->rsaKey.full), buf, buf); break; default: return kCCParamError; } *outLen = keysizeBytes; ccn_write_uint_padded(n, buf, *outLen, out); return kCCSuccess; } static inline cczp_read_uint(cczp_t r, size_t data_size, const uint8_t *data) { if(ccn_read_uint(ccn_nof_size(data_size), CCZP_PRIME(r), data_size, data) != 0) return -1; CCZP_N(r) = ccn_nof_size(data_size); cczp_init(r); return 0; } static inline CCCryptorStatus ccn_write_arg(size_t n, const cc_unit *source, uint8_t *dest, size_t *destLen) { size_t len; if((len = ccn_write_uint_size(n, source)) > *destLen) { return kCCMemoryFailure; } *destLen = len; ccn_write_uint(n, source, *destLen, dest); return kCCSuccess; } CCCryptorStatus CCRSACryptorCreatePairFromData(uint32_t e, uint8_t *xp1, size_t xp1Length, uint8_t *xp2, size_t xp2Length, uint8_t *xp, size_t xpLength, uint8_t *xq1, size_t xq1Length, uint8_t *xq2, size_t xq2Length, uint8_t *xq, size_t xqLength, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey, uint8_t *retp, size_t *retpLength, uint8_t *retq, size_t *retqLength, uint8_t *retm, size_t *retmLength, uint8_t *retd, size_t *retdLength) { CCCryptorStatus retval; CCRSACryptor *privateCryptor = NULL; CCRSACryptor *publicCryptor = NULL; cc_unit x_p1[ccn_nof_size(xp1Length)]; cc_unit x_p2[ccn_nof_size(xp2Length)]; cc_unit x_p[ccn_nof_size(xpLength)]; cc_unit x_q1[ccn_nof_size(xq1Length)]; cc_unit x_q2[ccn_nof_size(xq2Length)]; cc_unit x_q[ccn_nof_size(xqLength)]; cc_unit e_value[1]; size_t nbits = xpLength * 8 + xqLength * 8; // or we'll add this as a parameter. This appears to be correct for FIPS cc_size n = ccn_nof(nbits); cc_unit p[n], q[n], m[n], d[n]; cc_size np, nq, nm, nd; np = nq = nm = nd = n; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); e_value[0] = (cc_unit) e; __Require_Action((privateCryptor = ccMallocRSACryptor(nbits, ccRSAKeyPrivate)) != NULL, errOut, retval = kCCMemoryFailure); ccrsa_pub_ctx_t pubk = ccrsa_ctx_public(privateCryptor->rsaKey.full); ccrsa_priv_ctx_t privk = ccrsa_ctx_private(privateCryptor->rsaKey.full); __Require_Action(ccn_read_uint(ccn_nof_size(xp1Length), x_p1, xp1Length, xp1) == 0, errOut, kCCParamError); __Require_Action(ccn_read_uint(ccn_nof_size(xp2Length), x_p2, xp2Length, xp2)== 0, errOut, kCCParamError); __Require_Action(ccn_read_uint(ccn_nof_size(xpLength), x_p, xpLength, xp) == 0, errOut, kCCParamError); __Require_Action(ccn_read_uint(ccn_nof_size(xq1Length), x_q1, xq1Length, xq1) == 0, errOut, kCCParamError); __Require_Action(ccn_read_uint(ccn_nof_size(xq2Length), x_q2, xq2Length, xq2) == 0, errOut, kCCParamError); __Require_Action(ccn_read_uint(ccn_nof_size(xqLength), x_q, xqLength, xq) == 0, errOut, kCCParamError); __Require_Action(ccrsa_make_931_key(nbits, 1, e_value, ccn_nof_size(xp1Length), x_p1, ccn_nof_size(xp2Length), x_p2, ccn_nof_size(xpLength), x_p, ccn_nof_size(xq1Length), x_q1, ccn_nof_size(xq2Length), x_q2, ccn_nof_size(xqLength), x_q, privateCryptor->rsaKey.full, &np, p, &nq, q, &nm, m, &nd, d) == 0, errOut, retval = kCCDecodeError); privateCryptor->keyType = ccRSAKeyPrivate; __Require_Action((publicCryptor = CCRSACryptorGetPublicKeyFromPrivateKey(privateCryptor)) != NULL, errOut, retval = kCCMemoryFailure); *publicKey = publicCryptor; *privateKey = privateCryptor; ccn_write_arg(np, p, retp, retpLength); ccn_write_arg(nq, q, retq, retqLength); ccn_write_arg(nm, m, retm, retmLength); ccn_write_arg(nd, d, retd, retdLength); return kCCSuccess; errOut: if(privateCryptor) ccRSACryptorClear(privateCryptor); if(publicCryptor) ccRSACryptorClear(publicCryptor); // CLEAR the bits *publicKey = *privateKey = NULL; return retval; } CCCryptorStatus CCRSACryptorCreateFromData( CCRSAKeyType keyType, uint8_t *modulus, size_t modulusLength, uint8_t *exponent, size_t exponentLength, uint8_t *p, size_t pLength, uint8_t *q, size_t qLength, CCRSACryptorRef *ref) { CCCryptorStatus retval = kCCSuccess; CCRSACryptor *rsaKey = NULL; size_t n = ccn_nof_size(modulusLength); cc_unit m[n]; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); __Require_Action(ccn_read_uint(n, m, modulusLength, modulus), errOut, retval = kCCParamError); size_t nbits = ccn_bitlen(n, m); __Require_Action((rsaKey = ccMallocRSACryptor(nbits, keyType)) != NULL, errOut, retval = kCCMemoryFailure); __Require_Action(ccn_read_uint(n, ccrsa_ctx_m(rsaKey->rsaKey.public), modulusLength, modulus), errOut, retval = kCCParamError); __Require_Action(ccn_read_uint(n, ccrsa_ctx_e(rsaKey->rsaKey.public), exponentLength, exponent), errOut, retval = kCCParamError); cczp_init(ccrsa_ctx_zm(rsaKey->rsaKey.public)); rsaKey->keySize = ccn_bitlen(n, ccrsa_ctx_m(rsaKey->rsaKey.public)); switch(keyType) { case ccRSAKeyPublic: rsaKey->keyType = ccRSAKeyPublic; break; case ccRSAKeyPrivate: { ccrsa_full_ctx_t fk; fk.full = rsaKey->rsaKey.full; ccrsa_pub_ctx_t pubk = ccrsa_ctx_public(rsaKey->rsaKey.public); ccrsa_priv_ctx_t privk = ccrsa_ctx_private(rsaKey->rsaKey.full); size_t psize = ccn_nof_size(pLength); size_t qsize = ccn_nof_size(qLength); CCZP_N(ccrsa_ctx_private_zp(privk)) = psize; __Require_Action(ccn_read_uint(psize, CCZP_PRIME(ccrsa_ctx_private_zp(privk)), pLength, p), errOut, kCCParamError); CCZP_N(ccrsa_ctx_private_zq(privk)) = qsize; __Require_Action(ccn_read_uint(qsize, CCZP_PRIME(ccrsa_ctx_private_zq(privk)), qLength, q), errOut, kCCParamError); ccrsa_crt_makekey(ccrsa_ctx_zm(pubk), ccrsa_ctx_e(pubk), ccrsa_ctx_d(fk), ccrsa_ctx_private_zp(privk), ccrsa_ctx_private_dp(privk), ccrsa_ctx_private_qinv(privk), ccrsa_ctx_private_zq(privk), ccrsa_ctx_private_dq(privk)); rsaKey->keyType = ccRSAKeyPrivate; break; } default: retval = kCCParamError; goto errOut; } *ref = rsaKey; return kCCSuccess; errOut: if(rsaKey) ccRSACryptorClear(rsaKey); return retval; } CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength) { CCRSACryptor *rsa = rsaKey; ccrsa_pub_ctx *pubkey = rsaKey->rsaKey.public; const cc_size n = ccrsa_ctx_n(pubkey); CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); switch(rsa->keyType) { case ccRSAKeyPublic: { if(ccrsa_get_pubkey_components(pubkey, modulus, modulusLength, exponent, exponentLength)) return kCCParamError; break; } case ccRSAKeyPrivate: { ccrsa_full_ctx *key = rsaKey->rsaKey.private; if(ccrsa_get_fullkey_components(key, modulus, modulusLength, exponent, exponentLength, p, pLength, q, qLength)) return kCCParamError; break; } default: return kCCParamError; } return kCCSuccess; } CCCryptorStatus CCRSACryptorSign(CCRSACryptorRef privateKey, CCAsymetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!privateKey || !hashToSign || !signedData) return kCCParamError; switch(padding) { case ccPKCS1Padding: if(ccrsa_sign_pkcs1v15(privateKey->rsaKey.full, CCDigestGetDigestInfo(digestType)->oid, hashSignLen, hashToSign, signedDataLen, signedData) != 0) return kCCDecodeError; break; case ccOAEPPadding: if(ccrsa_sign_oaep(privateKey->rsaKey.full, CCDigestGetDigestInfo(digestType), ccDRBGGetRngState(), hashSignLen, hashToSign, signedDataLen, signedData) != 0) return kCCDecodeError; break; case ccX931Padding: case ccPKCS1PaddingRaw: case ccPaddingNone: default: return kCCParamError; break; } return kCCSuccess; } CCCryptorStatus CCRSACryptorVerify(CCRSACryptorRef publicKey, CCAsymetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen) { bool valid; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(!publicKey || !hash || !signedData) return kCCParamError; switch(padding) { case ccPKCS1Padding: if(ccrsa_verify_pkcs1v15(publicKey->rsaKey.public, CCDigestGetDigestInfo(digestType)->oid, hashLen, hash, signedDataLen, signedData, &valid) != 0) return kCCDecodeError; if(!valid) return kCCDecodeError; break; case ccOAEPPadding: if(ccrsa_verify_oaep(publicKey->rsaKey.public, CCDigestGetDigestInfo(digestType), hashLen, hash, signedDataLen, signedData, &valid) != 0) return kCCDecodeError; if(!valid) return kCCDecodeError; break; case ccX931Padding: case ccPKCS1PaddingRaw: case ccPaddingNone: default: return kCCParamError; break; } return kCCSuccess; } #pragma mark APINotDone #ifdef NEVER // This was only here for FIPS. If we move FIPS to the corecrypto layer it will need to be there. CCCryptorStatus CCRSACryptorDecodePayloadPKCS1( CCRSACryptorRef publicKey, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen) { int tcReturn; int stat = 0; CCRSACryptor *publicCryptor = publicKey; uint8_t *message; unsigned long messageLen, modulusLen; CCCryptorStatus retval = kCCSuccess; modulusLen = CCRSAGetKeySize(publicKey); messageLen = modulusLen / 8; if((message = CC_XMALLOC(messageLen)) == NULL) return kCCMemoryFailure; tcReturn = rsa_exptmod(cipherText, cipherTextLen, message, messageLen, publicCryptor->keyType, &publicCryptor->key); if(tcReturn) { retval = kCCDecodeError; goto out; } tcReturn = pkcs_1_v1_5_decode(message, messageLen, LTC_PKCS_1_EME, modulusLen, plainText, plainTextLen, &stat); if(tcReturn) { retval = kCCDecodeError; goto out; } if(!stat) { retval = kCCDecodeError; goto out; } out: CC_XZEROMEM(message, messageLen); CC_XFREE(message, messageLen); return retval; } #endif |
Changes to Source/API/CommonRandom.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
17 18 19 20 21 22 23 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ | > > > > > > > > > > > > | > > > | > > > > > > > > > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < > > > | | | < < < < > | > | > > > > > > > > | > | | > | | | > > > > > > > > > | | > > | > > > | > > > > > > > > > > > > | | > | < > > | > > > > > | | | > > > | > | | | | > > > | | > > > | > > > > > > > > > > > > | < < | | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_RANDOM_FUNCTIONS #include "CommonRandomSPI.h" #include <dispatch/dispatch.h> #include <dispatch/queue.h> #include <corecrypto/ccaes.h> #include <corecrypto/ccdrbg.h> #include <corecrypto/ccrng_CommonCrypto.h> #include <corecrypto/ccrng_system.h> #include "ccMemory.h" #include "ccdebug.h" /* This is an internal structure used to represent the two types of random number generators we're using. */ typedef struct __CCRandom { uint32_t rngtype; union { struct ccrng_system_state *devrandom; struct ccrng_CommonCrypto_state *drbg; } state; union { uint8_t *bytes; struct ccdrbg_info *drbg; } info; struct ccdrbg_state *drbg_state; } ccInternalRandom, *ccInternalRandomRef; /* The types of refs including "undefined" and "user created". */ static const uint32_t rng_undefined = 0; static const uint32_t rng_default = 1; static const uint32_t rng_devrandom = 2; static const uint32_t rng_created = 99; /* These are the two internal structures for a DRBG and /dev/random based accessor. */ ccInternalRandom ccRandomDefaultStruct = { .rngtype = rng_default, }; ccInternalRandom ccRandomDevRandomStruct = { .rngtype = rng_devrandom, }; CCRandomRef kCCRandomDefault = &ccRandomDefaultStruct; CCRandomRef kCCRandomDevRandom = &ccRandomDevRandomStruct; /* Initialize (if necessary) and return the ccrng_state pointer for the /dev/random rng. */ struct ccrng_state * ccDevRandomGetRngState() { static dispatch_once_t rnginit; dispatch_once(&rnginit, ^{ kCCRandomDevRandom->state.devrandom = (struct ccrng_state *) CC_XMALLOC(sizeof(struct ccrng_system_state)); ccrng_system_init(kCCRandomDevRandom->state.devrandom); }); return kCCRandomDevRandom->state.devrandom; } /* Read bytes from /dev/random */ int ccDevRandomReadBytes(void *ptr, size_t length) { for(int retries = 5; retries && ccrng_generate(kCCRandomDevRandom->state.devrandom, length, ptr); retries--) if(retries == 0) return -1; return 0; } /* Initialize (if necessary) and return the ccrng_state pointer for the DRBG. */ static int ccInitDRBG(ccInternalRandomRef drbg, struct ccdrbg_nistctr_custom *options, int function_options) { CCRNGStatus retval = kCCSuccess; //uint8_t entropy[64]; //struct timeval now; //gettimeofday(&now, NULL); // ccDevRandomGetRngState(); // if(ccDevRandomReadBytes(entropy, sizeof(entropy))) return kCCDecodeError; retval = kCCMemoryFailure; // errors following will be memory failures. if((drbg->info.drbg = CC_XMALLOC(sizeof(struct ccdrbg_info))) == NULL) goto errOut; ccdrbg_factory_nistctr(drbg->info.drbg, options); if((drbg->drbg_state = CC_XMALLOC(drbg->info.drbg->size)) == NULL) goto errOut; if((drbg->state.drbg = CC_XMALLOC(sizeof(struct ccrng_CommonCrypto_state))) == NULL) goto errOut; if(ccrng_CommonCrypto_init(drbg->state.drbg, drbg->info.drbg, drbg->drbg_state, function_options)) { retval = kCCDecodeError; goto errOut; } return 0; errOut: if(drbg->info.drbg) { if(drbg->state.drbg) CC_XFREE(drbg->state.drbg, sizeof(struct ccrng_CommonCrypto_state)); if(drbg->drbg_state) CC_XFREE(drbg->drbg_state, drbg->info.drbg->size); CC_XFREE(drbg->info.drbg, sizeof(struct ccdrbg_info)); } return retval; } #ifndef NDEBUG #define ASSERT(s) #else #define ASSERT(s) assert(s) #endif /* Default DRGB setup */ static const struct ccdrbg_nistctr_custom CCDRGBcustom = { .ecb = &ccaes_ltc_ecb_encrypt_mode, .keylen = 16, .strictFIPS = 1, .use_df = 1 }; static struct ccdrbg_info CCDRGBinfo; #define KNOWN_DRGB_STATE_SIZE 1160 static uint8_t CCDRGBstate[KNOWN_DRGB_STATE_SIZE]; struct ccrng_CommonCrypto_state CCDRGBrngstate; struct ccrng_state * ccDRBGGetRngState() { static dispatch_once_t rnginit; dispatch_once(&rnginit, ^{ kCCRandomDefault->info.drbg = &CCDRGBinfo; ccdrbg_factory_nistctr(kCCRandomDefault->info.drbg, &CCDRGBcustom); ASSERT(kCCRandomDefault->info.drbg->size <= sizeof(CCDRGBstate)); kCCRandomDefault->drbg_state = CCDRGBstate; kCCRandomDefault->state.drbg = &CCDRGBrngstate; if(ccrng_CommonCrypto_init(&CCDRGBrngstate, &CCDRGBinfo, CCDRGBstate, 0)) { kCCRandomDefault = NULL; } }); ASSERT(kCCRandomDefault != NULL); if(kCCRandomDefault == NULL) return NULL; return kCCRandomDefault->state.drbg; } /* Read bytes from the DRBG */ int ccDRBGReadBytes(struct ccrng_CommonCrypto_state *state, void *ptr, size_t length) { ccrng_generate(state, length, ptr); return 0; } CCRNGStatus CCRNGCreate(uint32_t options, CCRandomRef *rngRef) { CCRNGStatus retval; ccInternalRandomRef ref; struct ccdrbg_nistctr_custom custom_options; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ref = CC_XMALLOC(sizeof(ccInternalRandom)); if(NULL == ref) return kCCMemoryFailure; ref->rngtype = rng_created; // defaults custom_options.ecb = &ccaes_ltc_ecb_encrypt_mode; custom_options.keylen = 16; custom_options.strictFIPS = 1; custom_options.use_df = 1; if(retval = ccInitDRBG(ref, &custom_options, options)) return retval; *rngRef = ref; return kCCSuccess; } CCRNGStatus CCRNGRelease(CCRandomRef rng) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); if(rng->rngtype == rng_created) { ccrng_CommonCrypto_done(rng->state.drbg); CC_XFREE(rng, sizeof(ccInternalRandom)); } return kCCSuccess; } int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count) { struct ccrng_state *rng; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering rnd(NULL) = %s\n", (rnd == NULL) ? "TRUE": "FALSE"); if(NULL == bytes) return -1; if(0 == count) return 0; if(NULL == rnd) { rng = ccDRBGGetRngState(); return ccDRBGReadBytes(rng, bytes, count); } switch(rnd->rngtype) { case rng_default: rng = ccDRBGGetRngState(); return ccDRBGReadBytes(rng, bytes, count); break; case rng_devrandom: rng = ccDevRandomGetRngState(); return ccDevRandomReadBytes(bytes, count); break; case rng_created: return ccDRBGReadBytes(rnd->state.drbg, bytes, count); break; default: // we can get bytes from the DRBG rng = ccDRBGGetRngState(); return ccDRBGReadBytes(rng, bytes, count); break; } } |
Changes to Source/API/CommonSymmetricKeywrap.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include "CommonSymmetricKeywrap.h" #include <AssertMacros.h> | > > > | < | > | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ // #define COMMON_SYMMETRIC_KEYWRAP_FUNCTIONS #include "CommonSymmetricKeywrap.h" #include "CommonCryptor.h" #include "CommonCryptorPriv.h" #include <AssertMacros.h> #include "ccdebug.h" static const uint8_t rfc3394_iv_data[] = { 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6 }; const uint8_t* CCrfc3394_iv = rfc3394_iv_data; const size_t CCrfc3394_ivLen = sizeof(rfc3394_iv_data); static uint64_t pack64(const uint8_t *iv, size_t ivLen) { uint64_t retval; int i; for(i=0, retval=0; i<8; i++) retval = (retval<<8) + iv[i]; return retval; } /* 1) Initialize variables. Set A = IV, an initial value (see 2.2.3) For i = 1 to n R[i] = P[i] |
︙ | ︙ | |||
143 144 145 146 147 148 149 | const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *rawKey, size_t rawKeyLen, uint8_t *wrappedKey, size_t *wrappedKeyLen) { uint32_t n = rawKeyLen / 8; /* key size in 64 bit blocks */ uint64_t (*R)[2]; /* R is a two-dimensional array, with n rows of 2 columns */ | | > | < > > | | > > > | > > | > | | > > > | | | | | > | | > > | | > > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *rawKey, size_t rawKeyLen, uint8_t *wrappedKey, size_t *wrappedKeyLen) { uint32_t n = rawKeyLen / 8; /* key size in 64 bit blocks */ uint64_t (*R)[2]; /* R is a two-dimensional array, with n rows of 2 columns */ int i, j, err = 0; struct ccmode_ecb *ccmode = getCipherMode(kCCAlgorithmAES128, kCCModeECB, kCCEncrypt).ecb; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccecb_ctx_decl(ccmode->size, ctx); R = calloc(n, sizeof(uint64_t[2])); // don't wrap with something smaller // require_action(rawKeyLen <= kekLen, out, err = -1); // kek multiple of 64 bits: 128, 192, 256 require_action(kekLen == 16 || kekLen == 24 || kekLen == 32, out, err = -1); // wrapped_key_len 64 bits larger than key_len require_action(wrappedKeyLen && (*wrappedKeyLen >= rawKeyLen + 64/8), out, err = -1); // R[0][1] = P[0] ... R[1][n-1] = P[n-1] for (i = 0; i < n; i++) memcpy(&R[i][1], rawKey + (64/8) * i, (64/8)); uint64_t kek_iv = pack64(iv, ivLen); R[0][0] = kek_iv; ccmode->init(ccmode, &ctx, kekLen, kek); for (j = 0; j < 6; j++) { for (i = 0; i < n; i++) { ccmode->ecb(&ctx, 1, (uint8_t*)&R[i][0], (uint8_t*)&R[i][0]); R[(i + 1) % n][0] = R[i][0] ^ _OSSwapInt64((n*j)+i+1); } } // write output memcpy(wrappedKey, &R[0][0], 8); for (i = 0; i < n; i++) memcpy(wrappedKey + 8 + i * 8, &R[i][1], 8); for(i=0; i<n; i++) for(j=0; j<2; j++) R[i][j] = 0; out: if (R) free(R); return err; } int CCSymmetricKeyUnwrap( CCWrappingAlgorithm algorithm, const uint8_t *iv, const size_t ivLen, const uint8_t *kek, size_t kekLen, const uint8_t *wrappedKey, size_t wrappedKeyLen, uint8_t *rawKey, size_t *rawKeyLen) { uint32_t n = wrappedKeyLen/8 - 1; /* raw key size in 64 bit blocks */ uint64_t (*R)[2]; /* R is a two-dimensional array, with n rows of 2 columns */ int i, j, err = 0; struct ccmode_ecb *ccmode = getCipherMode(kCCAlgorithmAES128, kCCModeECB, kCCDecrypt).ecb; CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); ccecb_ctx_decl(ccmode->size, ctx); R = calloc(n, sizeof(uint64_t[2])); // kek multiple of 64 bits: 128, 192, 256 require_action(kekLen == 16 || kekLen == 24 || kekLen == 32, out, err = -1); // wrapped_key_len 64 bits larger than key_len // require_action(rawKeyLen && (*rawKeyLen <= wrappedKeyLen - 64/8), out, err = -1); // R[0][1] = C[0] ... R[1][n-1] = C[n-1] memcpy(&R[0][0], wrappedKey, 64/8); for (i = 0; i < n; i++) memcpy(&R[i][1], wrappedKey + (64/8) * (i+1), 64/8); ccmode->init(ccmode, &ctx, kekLen, kek); for (j = 5; j >= 0; j--) { for (i = n - 1; i >= 0; i--) { R[i][0] = R[(i + 1) % n][0] ^ _OSSwapInt64((n*j)+i+1); ccmode->ecb(&ctx, 1, (uint8_t*)&R[i][0], (uint8_t*)&R[i][0]); } } uint64_t kek_iv = pack64(iv, ivLen); // R[0][0] == iv? require_action(R[0][0] == kek_iv, out, err = -1); // write output for (i = 0; i < n; i++) memcpy(rawKey + i * 8, &R[i][1], 8); // clean all stack variables for(i=0; i<n; i++) for(j=0; j<2; j++) R[i][j] = 0; out: if (R) free(R); return err; } size_t CCSymmetricWrappedSize( CCWrappingAlgorithm algorithm, size_t rawKeyLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return (rawKeyLen + 8); } size_t CCSymmetricUnwrappedSize( CCWrappingAlgorithm algorithm, size_t wrappedKeyLen) { CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); return (wrappedKeyLen - 8); } |
Deleted Source/CAST/c_ecb.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CAST/c_enc.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CAST/c_skey.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CAST/cast_lcl.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CAST/cast_s.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CAST/ccCast.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CommonCrypto.exp.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/CommonCryptoSPI/CommonBigNum.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 | /* * Copyright (c) 2011 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_BIGNUM_H_ #define _CC_BIGNUM_H_ #include <Availability.h> #include <stdint.h> #include <CommonCrypto/CommonCryptor.h> #ifdef __cplusplus extern "C" { #endif /* * This is an SPI - it isn't intended to be generally used. If you * intend to use this we strongly urge you to talk to someone in the * Information Security Group to see if there isn't an alternative * set of functions to implement your cryptographic needs. */ /* * This shares the error status of CommonCryptor.h */ typedef CCCryptorStatus CCStatus; typedef struct _CCBigNumRef *CCBigNumRef; /*! @function CCCreateBigNum @abstract Creates a BigNum - must be freed later with CCBigNumFree. @param status A pointer to a CCStatus for return codes. @result On success this returns a newly allocated BigNum (must be freed with CCBigNumFree). Returns NULL on failure. */ CCBigNumRef CCCreateBigNum(CCStatus *status) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumClear @abstract Zeroes (clears) a BigNum. @param bn The BigNum to clear. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumClear(CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumFree @abstract Frees and clears a BigNum. @param bn The BigNum to free. */ void CCBigNumFree(CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumCopy @abstract Copies a BigNum. @param status A pointer to a CCStatus for return codes. @param bn The BigNum to copy. @result On success this returns a newly allocated BigNum (must be freed with CCBigNumFree). Returns NULL on failure. */ CCBigNumRef CCBigNumCopy(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumBitCount @abstract Returns the number of significant bits in a BigNum. @param bn The BigNum. @result Returns number of bits. */ uint32_t CCBigNumBitCount(const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumZeroLSBCount @abstract Returns the number of zero bits before the least significant 1 bit. @param bn The BigNum. @result Returns number of bits. */ uint32_t CCBigNumZeroLSBCount(const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumByteCount @abstract Returns the number of bytes if converted to binary data. @param bn The BigNum. @result Returns number of bytes. */ uint32_t CCBigNumByteCount(const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumFromData @abstract Creates a BigNum from binary data. @param status A pointer to a CCStatus for return codes. @param s - the data pointer. The data is expected to be an array of octets in big endian format. @param len - the length of the data. @result On success this returns a newly allocated BigNum (must be freed with CCBigNumFree). Returns NULL on failure. */ CCBigNumRef CCBigNumFromData(CCStatus *status, const void *s, size_t len) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumToData @abstract Dumps a BigNum into binary data. @param status A pointer to a CCStatus for return codes. @param bn The BigNum. @param s - the pointer to the data area. You can use CCBigNumByteCount() to determine the size of the data area to provide. @result Returns the length of the data area. */ size_t CCBigNumToData(CCStatus *status, const CCBigNumRef bn, void *to) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumFromHexString @abstract Creates a BigNum from a hexadecimal string. @param status A pointer to a CCStatus for return codes. @param in - a null terminated hexadecimal string. @result On success this returns a newly allocated BigNum (must be freed with CCBigNumFree). Returns NULL on failure. */ CCBigNumRef CCBigNumFromHexString(CCStatus *status, const char *in) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumToHexString @abstract Dumps a BigNum into binary data. @param status A pointer to a CCStatus for return codes. @param bn The BigNum. @result Returns a hexadecimal string representation of the BigNum. This must be freed by the caller. Returns NULL on failure. */ char * CCBigNumToHexString(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumByteCount @abstract Returns the number of bytes that will result from converting a BigNum to octets. @param bn The BigNum. @result The number of bytes. */ uint32_t CCBigNumByteCount(const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumCompare @abstract Compares two BigNums. @param bn1 - a BigNum. @param bn2 - a BigNum. @result Returns -1 if bn1 is less than bn2. Returns 0 if bn1 and bn2 are equal. Returns 1 if bn1 is greater than bn2. */ int CCBigNumCompare(const CCBigNumRef bn1, const CCBigNumRef bn2) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumCompareI @abstract Compares a BigNum and a 32 bit integer. @param bn1 - a BigNum. @param num - an integer. @result Returns -1 if bn1 is less than num. Returns 0 if bn1 and num are equal. Returns 1 if bn1 is greater than num. */ int CCBigNumCompareI(const CCBigNumRef bn1, const uint32_t num) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSetNegative @abstract Negates a BigNum. @param bn - a BigNum. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSetNegative(CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSetI @abstract Sets a BigNum value using an unsigned integer. @param bn The BigNum. @param num The value to set. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSetI(CCBigNumRef bn, uint64_t num) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumGetI @abstract Get an unsigned integer representation of the BigNum. This assumes the BigNum can actually fit within the unsigned integer representation. @param status A pointer to a CCStatus for return codes. @param bn The BigNum. @result returns the unsigned integer value. */ uint32_t CCBigNumGetI(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumAdd @abstract Adds two BigNums. @param result A bigNum in which to place the result. @param a The first BigNum to add. @param b The second BigNum to add. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumAdd(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumAddI @abstract Adds a BigNum and an unsigned integer. @param result A bigNum in which to place the result. @param a The first BigNum to add. @param b The unsigned integer to add. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumAddI(CCBigNumRef result, const CCBigNumRef a, const uint32_t b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSub @abstract Subtracts a BigNum from a BigNum. @param result A bigNum in which to place the result. @param a The BigNum. @param b The BigNum to subtract. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSub(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSubI @abstract Subtracts an unsigned integer from a BigNum. @param result A bigNum in which to place the result. @param a The BigNum. @param b The unsigned integer to subtract. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSubI(CCBigNumRef result, const CCBigNumRef a, const uint32_t b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMul @abstract Multiplies two BigNums. @param result A bigNum in which to place the result. @param a The first BigNum to multiply. @param b The second BigNum to multiply. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMul(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMulI @abstract Multiplies a BigNum and an unsigned integer. @param result A bigNum in which to place the result. @param a The first BigNum to multiply. @param b The unsigned integer to multiply. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMulI(CCBigNumRef result, const CCBigNumRef a, const uint32_t b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumDiv @abstract Divides a BigNum (a) by another Bignum (b). @param quotient A bigNum in which to place the quotient (a div b). @param remainder A bigNum in which to place the remainder (a mod b). @param a The BigNum to divide. @param b The BigNum used to divide a. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumDiv(CCBigNumRef quotient, CCBigNumRef remainder, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumDiv2 @abstract Divides a BigNum (a) by 2. @param result A bigNum in which to place the result. @param a The BigNum to divide. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumDiv2(CCBigNumRef result, const CCBigNumRef a) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMod @abstract Find the remainder of a BigNum for a given modulus. @param result A bigNum in which to place the result. @param dividend The BigNum to divide. @param modulus The BigNum used to divide a and produce the mod value. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMod(CCBigNumRef result, CCBigNumRef dividend, CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumModI @abstract Find the remainder of a BigNum for a given modulus (unsigned integer version). @param result A pointer to an unsigned integer in which to place the result. @param dividend The BigNum to divide. @param modulus The BigNum used to divide a and produce the mod value. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumModI(uint32_t *result, CCBigNumRef dividend, uint32_t modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSquare @abstract Find the square of a BigNum. @param result A bigNum in which to place the result. @param a The BigNum to square. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSquare(CCBigNumRef result, const CCBigNumRef a) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumGCD @abstract Find the Greatest Common Denominator of two BigNums. @param result A bigNum in which to place the result. @param a A BigNum. @param b A BigNum. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumGCD(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumLCM @abstract Find the Least Common Multiple of two BigNums. @param result A bigNum in which to place the result. @param a A BigNum. @param b A BigNum. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumLCM(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMulMod @abstract Perform Modular Multiplication. @param result A bigNum in which to place the result. @param a A BigNum. @param b A BigNum. @param modulus The Modulus. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMulMod(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef b, const CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumSquareMod @abstract Perform Modular Squaring. @param result A bigNum in which to place the result. @param a A BigNum. @param modulus The Modulus. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumSquareMod(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumInverseMod @abstract Perform Modular Inversion. @param result A bigNum in which to place the result. @param a A BigNum. @param modulus The Modulus. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumInverseMod(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumModExp @abstract Perform Modular Exponentiation. @param result A bigNum in which to place the result. @param a The base integer. @param power The power integer. @param modulus The Modulus. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumModExp(CCBigNumRef result, const CCBigNumRef a, const CCBigNumRef power, const CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumLeftShift @abstract Shift a BigNum left @param result A bigNum in which to place the result. @param a The BigNum. @param digits How many bit places to shift left. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumLeftShift(CCBigNumRef result, const CCBigNumRef a, const uint32_t digits) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumRightShift @abstract Shift a BigNum right @param result A bigNum in which to place the result. @param a The BigNum. @param digits How many bit places to shift right. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumRightShift(CCBigNumRef result, const CCBigNumRef a, const uint32_t digits) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMontgomerySetup @abstract Setup Montgomery @param num The modulus. @param rho The destination for the reduction digit. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMontgomerySetup(CCBigNumRef num, uint32_t *rho) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMontgomeryNormalization @abstract Get the normalization value. @param result A bigNum in which to place the result. @param modulus The modulus. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMontgomeryNormalization(CCBigNumRef result, CCBigNumRef modulus) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumMontgomeryReduce @abstract Reduce a number @param x The BigNum to reduce - the result will be stored back into this BigNum. @param modulus The modulus. @param rho The reduction digit. @result returns a CCStatus (See CommonCryptor.h for values). */ CCStatus CCBigNumMontgomeryReduce(CCBigNumRef x, CCBigNumRef modulus, uint32_t rho) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumCreateRandom @abstract Creates a BigNum with a random value. ZZZZZ @param status A pointer to a CCStatus for return codes. @result On success this returns a newly allocated BigNum (must be freed with CCBigNumFree). Returns NULL on failure. */ CCBigNumRef CCBigNumCreateRandom(CCStatus *status, int bits, int top, int bottom) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumIsPrime @abstract Determines if a BigNum is prime. @param status A pointer to a CCStatus for return codes. @param bn - a BigNum. @result Returns true or false. */ bool CCBigNumIsPrime(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumIsOdd @abstract Determines if a BigNum is odd. @param status A pointer to a CCStatus for return codes. @param bn - a BigNum. @result Returns true or false. */ bool CCBigNumIsOdd(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumIsZero @abstract Determines if a BigNum is zero. @param status A pointer to a CCStatus for return codes. @param bn - a BigNum. @result Returns true or false. */ bool CCBigNumIsZero(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCBigNumIsNegative @abstract Determines if a BigNum is negative. @param status A pointer to a CCStatus for return codes. @param bn - a BigNum. @result Returns true or false. */ bool CCBigNumIsNegative(CCStatus *status, const CCBigNumRef bn) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_BIGNUM_H_ */ |
Changes to Source/CommonCryptoSPI/CommonCMACSPI.h.
︙ | ︙ | |||
45 46 47 48 49 50 51 | @param macOut The digest bytes (space provided by the caller). Output is written to caller-supplied buffer. */ void CCAESCmac(const void *key, const uint8_t *data, size_t dataLength, void *macOut) | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | @param macOut The digest bytes (space provided by the caller). Output is written to caller-supplied buffer. */ void CCAESCmac(const void *key, const uint8_t *data, size_t dataLength, void *macOut) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_6_0); #ifdef __cplusplus } #endif #endif /* _CC_CMACSPI_H_ */ |
Changes to Source/CommonCryptoSPI/CommonCryptoPriv.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2006-2012 Apple, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
21 22 23 24 25 26 27 | * @APPLE_LICENSE_HEADER_END@ */ /* * CommonCryptoPriv.h - private typedefs and defines for ComonCrypto */ | | | | > > > > > > > > > | > | | < > > | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | * @APPLE_LICENSE_HEADER_END@ */ /* * CommonCryptoPriv.h - private typedefs and defines for ComonCrypto */ #ifndef __COMMONCRYPTO_PRIVATE__ #define __COMMONCRYPTO_PRIVATE__ #include <CommonCrypto/CommonCryptorSPI.h> #include <CommonCrypto/CommonDigestSPI.h> #include <CommonCrypto/CommonECCryptor.h> #include <CommonCrypto/CommonRSACryptor.h> #include <CommonCrypto/CommonBigNum.h> #include <CommonCrypto/CommonDH.h> #include <CommonCrypto/CommonHMacSPI.h> #include <CommonCrypto/CommonCMACSPI.h> #include <CommonCrypto/CommonRandomSPI.h> #include <CommonCrypto/CommonSelfTest.h> // The following headers will be jettisoned once all internal projects // are weaned from them. #include <CommonCrypto/aes.h> #include <CommonCrypto/lionCompat.h> #endif /* __COMMONCRYPTO_PRIVATE__ */ |
Changes to Source/CommonCryptoSPI/CommonCryptorSPI.h.
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #define _CC_CryptorSPI_H_ #include <sys/types.h> #include <sys/param.h> #include <stdint.h> #include <string.h> #include <limits.h> #include <stdlib.h> #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /* This is an SPI header. It includes some work in progress implementation notes that will be removed when this is promoted to an API set. */ /* | > > > > | | > > > > | > | | > | < < | < < < < | | > > > > > > | | < < > < < > | < < < > | > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #define _CC_CryptorSPI_H_ #include <sys/types.h> #include <sys/param.h> #include <stdint.h> #include <string.h> #ifdef KERNEL #include <machine/limits.h> #else #include <limits.h> #include <stdlib.h> #endif /* KERNEL */ #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /* This is an SPI header. It includes some work in progress implementation notes that will be removed when this is promoted to an API set. */ /* Private Ciphers */ /* Lion SPI name for no padding. Defining for compatibility. Is now ccNoPadding in CommonCryptor.h */ enum { ccDefaultPadding = 0, }; enum { kCCAlgorithmAES128NoHardware = 20, kCCAlgorithmAES128WithHardware = 21 }; /* Private Modes */ enum { kCCModeGCM = 11, }; /* Private Paddings */ enum { ccCBCCTS1 = 10, ccCBCCTS2 = 11, ccCBCCTS3 = 12, }; /* Private Cryptor direction (op) */ enum { kCCBoth = 3, }; /* Supports a mode call of int mode_setup(int cipher, const unsigned char *IV, const unsigned char *key, int keylen, const unsigned char *tweak, int tweaklen, int num_rounds, int options, mode_context *ctx); */ |
︙ | ︙ | |||
103 104 105 106 107 108 109 | size_t tweakLength, int numRounds, CCModeOptions options, const void *data, /* caller-supplied memory */ size_t dataLength, /* length of data in bytes */ CCCryptorRef *cryptorRef, /* RETURNED */ size_t *dataUsed) /* optional, RETURNED */ | | < < < < < < < < < < < < < < < < | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | size_t tweakLength, int numRounds, CCModeOptions options, const void *data, /* caller-supplied memory */ size_t dataLength, /* length of data in bytes */ CCCryptorRef *cryptorRef, /* RETURNED */ size_t *dataUsed) /* optional, RETURNED */ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* Assuming we can use existing CCCryptorCreateFromData for all modes serviced by these: int mode_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, mode_context *ctx); int mode_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, mode_context *ctx); */ /* Block mode encrypt and decrypt interfaces for IV tweaked blocks (XTS and CBC) int mode_encrypt_tweaked(const unsigned char *pt, unsigned long len, unsigned char *ct, const unsigned char *tweak, mode_context *ctx); int mode_decrypt_tweaked(const unsigned char *ct, unsigned long len, unsigned char *pt, const unsigned char *tweak, mode_context *ctx); */ CCCryptorStatus CCCryptorEncryptDataBlock( CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); CCCryptorStatus CCCryptorDecryptDataBlock( CCCryptorRef cryptorRef, const void *iv, const void *dataIn, size_t dataInLength, void *dataOut) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* Assuming we can use the existing CCCryptorRelease() interface for int mode_done(mode_context *ctx); */ /* Not surfacing these other than with CCCryptorReset() int mode_setiv(const unsigned char *IV, unsigned long len, mode_context *ctx); int mode_getiv(const unsigned char *IV, unsigned long *len, mode_context *ctx); */ /* DES key utilities */ CCCryptorStatus CCDesIsWeakKey( void *key, size_t Length) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); void CCDesSetOddParity( void *key, size_t Length) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); uint32_t CCDesCBCCksum(void *input, void *output, size_t length, void *key, size_t keylen, void *ivec) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* * returns a cipher blocksize length iv in the provided iv buffer. */ CCCryptorStatus CCCryptorGetIV(CCCryptorRef cryptorRef, void *iv) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* GCM Support Interfaces Use CCCryptorCreateWithMode() with the kCCModeGCM selector to initialize a CryptoRef. Only kCCAlgorithmAES128 can be used with GCM and these functions. IV Setting etc will be ignored from CCCryptorCreateWithMode(). Use the CCCryptorGCMAddIV() routine below for IV setup. */ /* This adds the initial vector octets from iv of length ivLen to the GCM CCCryptorRef. You can call this function as many times as required to process the entire IV. */ CCCryptorStatus CCCryptorGCMAddIV(CCCryptorRef cryptorRef, const void *iv, size_t ivLen) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /* Additional Authentication Data After the entire IV has been processed, the additional authentication data can be processed. Unlike the IV, a packet/session does not require additional authentication data (AAD) for security. The AAD is meant to be used as side–channel data you want to be authenticated with the packet. Note: once you begin adding AAD to the GCM CCCryptorRef you cannot return to adding IV data until the state has been reset. */ CCCryptorStatus CCCryptorGCMAddAAD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); // Maintain the old symbol with incorrect camel-case for now. CCCryptorStatus CCCryptorGCMaddAAD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); // This is for old iOS5 clients CCCryptorStatus CCCryptorGCMAddADD(CCCryptorRef cryptorRef, const void *aData, size_t aDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); CCCryptorStatus CCCryptorGCMEncrypt( CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); CCCryptorStatus CCCryptorGCMDecrypt( CCCryptorRef cryptorRef, const void *dataIn, size_t dataInLength, void *dataOut) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /* This terminates the GCM state gcm and stores the tag in tag of length taglen octets. */ CCCryptorStatus CCCryptorGCMFinal( CCCryptorRef cryptorRef, const void *tag, size_t *tagLength) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /* This will reset the GCM CCCryptorRef to the state that CCCryptorCreateWithMode() left it. The user would then call CCCryptorGCMAddIV(), CCCryptorGCMaddAAD(), etc. */ CCCryptorStatus CCCryptorGCMReset( CCCryptorRef cryptorRef) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /* This will initialize the GCM state with the given key, IV and AAD value then proceed to encrypt or decrypt the message text and store the final message tag. The definition of the variables is the same as it is for all the manual functions. If you are processing many packets under the same key you shouldn’t use this function as it invokes the pre–computation with each call. */ CCCryptorStatus CCCryptorGCM( CCOperation op, /* kCCEncrypt, kCCDecrypt */ CCAlgorithm alg, const void *key, /* raw key material */ size_t keyLength, const void *iv, size_t ivLen, const void *aData, size_t aDataLen, const void *dataIn, size_t dataInLength, void *dataOut, const void *tag, size_t *tagLength) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); void CC_RC4_set_key(void *ctx, int len, const unsigned char *data) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); void CC_RC4(void *ctx, unsigned long len, const unsigned char *indata, unsigned char *outdata) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_CryptorSPI_H_ */ |
Added Source/CommonCryptoSPI/CommonDH.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_DH_H_ #define _CC_DH_H_ #include <Availability.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif typedef struct CCDHRef_s *CCDHRef; typedef struct CCDHParameters_s *CCDHParameters; extern CCDHParameters kCCDHRFC2409Group2 __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); extern CCDHParameters kCCDHRFC3526Group5 __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCDHCreate @abstract Creates a Diffie-Hellman context. @param dhParameter The Diffie-Hellman Group to use (provides p and g). The only appropriate values are kCCDHGenerator2 or kCCDHGenerator5, defined above. @result If unable to allocate memory this returns NULL. */ CCDHRef CCDHCreate(CCDHParameters dhParameter) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCDHRelease @abstract Releases a Diffie-Hellman context. @param ref The Diffie-Hellman context to clear and deallocate. */ void CCDHRelease(CCDHRef ref) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCDHGenerateKey @abstract Generate the public key for use in a Diffie-Hellman handshake. This value is returned as a byte string. @param ref The Diffie-Hellman context. @result returns -1 on failure. */ int CCDHGenerateKey(CCDHRef ref, void *output, size_t *outputLength) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /*! @function CCDHComputeKey @abstract Compute the shared Diffie-Hellman key using the peer's public key. @param sharedKey Shared key computed from the peer public key, p, g, and the private key. @param peerPubKey Public key received from the peer. @param peerPubKeyLen Length of peer public key. @param ref The Diffie-Hellman context to clear and deallocate. @param returns the length of the shared key. */ int CCDHComputeKey(unsigned char *sharedKey, size_t *sharedKeyLen, const void *peerPubKey, size_t peerPubKeyLen, CCDHRef ref) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); CCDHParameters CCDHParametersCreateFromData(const void *p, size_t pLen, const void *g, size_t gLen, size_t l) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); CCDHParameters CCDHParametersCreateFromPKCS3(const void *data, size_t len) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); size_t CCDHParametersPKCS3EncodeLength(CCDHParameters parms) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); size_t CCDHParametersPKCS3Encode(CCDHParameters parms, void *data, size_t dataAvailable) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); void CCDHParametersRelease(CCDHParameters parameters) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_DH_H_ */ |
Changes to Source/CommonCryptoSPI/CommonDigestSPI.h.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_DigestSPI_H_ #define _CC_DigestSPI_H_ #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /*! | > > > > | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_DigestSPI_H_ #define _CC_DigestSPI_H_ #include <stdint.h> #include <sys/types.h> #include <Availability.h> #ifdef __cplusplus extern "C" { #endif /*! @enum CCDigestAlgorithm @abstract Algorithms implemented in this module. @constant kCCDigestNone Digest Selector for "no digest" @constant kCCDigestMD2 MD2 digest @constant kCCDigestMD4 MD4 digest @constant kCCDigestMD5 MD5 digest @constant kCCDigestRMD128 RMD 128 bit digest @constant kCCDigestRMD160 RMD 160 bit digest @constant kCCDigestRMD256 RMD 256 bit digest @constant kCCDigestRMD320 RMD 320 bit digest |
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | @constant kCCDigestSkein224 Skein 224 bit digest @constant kCCDigestSkein256 Skein 256 bit digest @constant kCCDigestSkein384 Skein 384 bit digest @constant kCCDigestSkein512 Skein 512 bit digest */ enum { kCCDigestMD2 = 1, kCCDigestMD4 = 2, kCCDigestMD5 = 3, kCCDigestRMD128 = 4, kCCDigestRMD160 = 5, kCCDigestRMD256 = 6, kCCDigestRMD320 = 7, kCCDigestSHA1 = 8, kCCDigestSHA224 = 9, kCCDigestSHA256 = 10, kCCDigestSHA384 = 11, kCCDigestSHA512 = 12, kCCDigestSkein128 = 13, kCCDigestSkein160 = 14, kCCDigestSkein224 = 16, kCCDigestSkein256 = 17, kCCDigestSkein384 = 18, kCCDigestSkein512 = 19, }; | > | > > > > > > > > > > > > > > > > > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | @constant kCCDigestSkein224 Skein 224 bit digest @constant kCCDigestSkein256 Skein 256 bit digest @constant kCCDigestSkein384 Skein 384 bit digest @constant kCCDigestSkein512 Skein 512 bit digest */ enum { kCCDigestNone = 0, kCCDigestMD2 = 1, kCCDigestMD4 = 2, kCCDigestMD5 = 3, kCCDigestRMD128 = 4, kCCDigestRMD160 = 5, kCCDigestRMD256 = 6, kCCDigestRMD320 = 7, kCCDigestSHA1 = 8, kCCDigestSHA224 = 9, kCCDigestSHA256 = 10, kCCDigestSHA384 = 11, kCCDigestSHA512 = 12, kCCDigestSkein128 = 13, kCCDigestSkein160 = 14, kCCDigestSkein224 = 16, kCCDigestSkein256 = 17, kCCDigestSkein384 = 18, kCCDigestSkein512 = 19, }; typedef uint32_t CCDigestAlgorithm; // Hold this until Heimdal has changed. #define CCDigestAlg CCDigestAlgorithm /*! @typedef CCDigestCtx @abstract Digest context. */ #define CC_DIGEST_SIZE 1032 typedef struct CCDigestCtx_t { uint8_t context[CC_DIGEST_SIZE]; } CCDigestCtx, *CCDigestRef; #define CC_RMD128_DIGEST_LENGTH 16 /* digest length in bytes */ #define CC_RMD128_BLOCK_BYTES 64 /* block size in bytes */ #define CC_RMD128_BLOCK_LONG (CC_RMD128_BLOCK_BYTES / sizeof(CC_LONG)) #define CC_RMD160_DIGEST_LENGTH 20 /* digest length in bytes */ #define CC_RMD160_BLOCK_BYTES 64 /* block size in bytes */ #define CC_RMD160_BLOCK_LONG (CC_RMD160_BLOCK_BYTES / sizeof(CC_LONG)) #define CC_RMD256_DIGEST_LENGTH 32 /* digest length in bytes */ #define CC_RMD256_BLOCK_BYTES 64 /* block size in bytes */ #define CC_RMD256_BLOCK_LONG (CC_RMD256_BLOCK_BYTES / sizeof(CC_LONG)) #define CC_RMD320_DIGEST_LENGTH 40 /* digest length in bytes */ #define CC_RMD320_BLOCK_BYTES 64 /* block size in bytes */ #define CC_RMD320_BLOCK_LONG (CC_RMD320_BLOCK_BYTES / sizeof(CC_LONG)) /**************************************************************************/ /* SPI Only */ /**************************************************************************/ /* * This information will remain SPI - internal functions available * to callers not needing a stable ABI that have a need to provide |
︙ | ︙ | |||
104 105 106 107 108 109 110 | @param algorithm Digest algorithm to perform. @param ctx A digest context. returns 0 on success. */ int | | | > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | @param algorithm Digest algorithm to perform. @param ctx A digest context. returns 0 on success. */ int CCDigestInit(CCDigestAlgorithm algorithm, CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /**************************************************************************/ /* Future API */ /**************************************************************************/ /* |
︙ | ︙ | |||
130 131 132 133 134 135 136 | @param length The length of the data to digest. @param output The digest bytes (space provided by the caller). Output is written to caller-supplied buffer, as in CCDigestFinal(). */ int | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > | > > > > > > > > > > > > > > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | @param length The length of the data to digest. @param output The digest bytes (space provided by the caller). Output is written to caller-supplied buffer, as in CCDigestFinal(). */ int CCDigest(CCDigestAlgorithm algorithm, const uint8_t *data, size_t length, uint8_t *output) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestCreate @abstract Allocate and initialize a CCDigestCtx for a digest. @param algorithm Digest algorithm to setup. returns a pointer to a digestRef on success. */ CCDigestRef CCDigestCreate(CCDigestAlgorithm alg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestUpdate @abstract Continue to digest data. @param ctx A digest context. @param data The data to digest. @param length The length of the data to digest. returns 0 on success. */ int CCDigestUpdate(CCDigestRef ctx, const void *data, size_t length) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestFinal @abstract Conclude digest operations and produce the digest output. @param ctx A digest context. @param output The digest bytes (space provided by the caller). returns 0 on success. */ int CCDigestFinal(CCDigestRef ctx, uint8_t *output) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestDestroy @abstract Clear and free a CCDigestCtx @param ctx A digest context. */ void CCDigestDestroy(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestReset @abstract Clear and re-initialize a CCDigestCtx for the same algorithm. @param ctx A digest context. */ void CCDigestReset(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestRefGetDigest @abstract Produce the digest output result for the bytes currently processed. @param ctx A digest context. @param output The digest bytes (space provided by the caller). returns 0 on success. */ int CCDigestGetDigest(CCDigestRef ctx, uint8_t *output) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestGetBlockSize @abstract Provides the block size of the digest algorithm @param algorithm A digest algorithm selector. returns 0 on failure or the block size on success. */ size_t CCDigestGetBlockSize(CCDigestAlgorithm algorithm) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestGetOutputSize @abstract Provides the digest output size of the digest algorithm @param algorithm A digest algorithm selector. returns 0 on failure or the digest output size on success. */ size_t CCDigestGetOutputSize(CCDigestAlgorithm algorithm) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCDigestGetBlockSizeFromRef @abstract Provides the block size of the digest algorithm @param ctx A digest context. returns 0 on failure or the block size on success. */ size_t CCDigestGetBlockSizeFromRef(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); // Until Heimdal Changes // #define CCDigestBlockSize CCDigestGetBlockSizeFromRef size_t CCDigestBlockSize(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA); /*! @function CCDigestGetOutputSizeFromRef @abstract Provides the digest output size of the digest algorithm @param ctx A digest context. returns 0 on failure or the digest output size on success. */ size_t CCDigestGetOutputSizeFromRef(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); // Until Heimdal Changes // #define CCDigestOutputSize CCDigestGetOutputSizeFromRef size_t CCDigestOutputSize(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); uint8_t * CCDigestOID(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); size_t CCDigestOIDLen(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); CCDigestRef CCDigestCreateByOID(uint8_t *OID, size_t OIDlen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_DigestSPI_H_ */ |
Added Source/CommonCryptoSPI/CommonECCryptor.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_ECCRYPTOR_H_ #define _CC_ECCRYPTOR_H_ #include <Availability.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonDigestSPI.h> #include "CommonRSACryptor.h" #ifdef __cplusplus extern "C" { #endif /*! @typedef CCECCryptorRef @abstract Opaque reference to a CCECCryptor object. */ typedef struct _CCECCryptor *CCECCryptorRef; /* EC Key Types */ enum { ccECKeyPublic = 0, ccECKeyPrivate = 1, ccECBlankPublicKey = 97, ccECBlankPrivateKey = 98, ccECBadKey = 99, }; typedef uint32_t CCECKeyType; /* EC Key Import/Export Formats */ enum { kCCImportKeyBinary = 0, kCCImportKeyDER = 1, }; typedef uint32_t CCECKeyExternalFormat; /*! @discussion Key sizes for this set of interfaces must be between 128 and 384 bits. The key size must also be evenly divisible by 8 */ /*! @function CCECCryptorGeneratePair @abstract Generate an EC public and private key. A curve will be chosen from ECC-256 or ECC-384. @param keysize Must be between 192 and 521 (inclusive) @param publicKey A (required) pointer for the returned public CCECCryptorRef. @param privateKey A (required) pointer for the returned private CCECCryptorRef. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCECCryptorGeneratePair( size_t keysize, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorGetPublicKeyFromPrivateKey @abstract Grab the parts from a private key to make a public key. @param privateKey A pointer to a private CCECCryptorRef. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCECCryptorRef CCECCryptorGetPublicKeyFromPrivateKey(CCECCryptorRef privateKey) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorImportPublicKey @abstract Import an Elliptic Curve public key from data. This imports public keys in ANSI X.9.63 format. @param keyPackage The data package containing the encoded key. @param keyPackageLen The length of the encoded key package. @param key A CCECCryptorRef of the decoded key. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCECCryptorImportPublicKey( void *keyPackage, size_t keyPackageLen, CCECCryptorRef *key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorImportKey @abstract Import an Elliptic Curve public key from data. @param format The format in which the key is encoded. @param keyPackage The data package containing the encoded key. @param keyPackageLen The length of the encoded key package. @param keyType The type of key to be imported (public or private). @param key A CCECCryptorRef of the decoded key. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorExportPublicKey @abstract Export an Elliptic Curve public key from data. This exports public keys in ANSI X.9.63 format. @param key The CCECCryptorRef of the key to encode. @param out The destination for the encoded key. @param outLen A pointer to the length of the encoded key. This is an in/out parameter. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCECCryptorExportPublicKey( CCECCryptorRef key, void *out, size_t *outLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); // We'll remove the CCECCryptorExportPublicKey later - we like this better. CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECGetKeyType @abstract Determine whether a CCECCryptorRef is public or private @param key The CCECCryptorRef. @result Return values are ccECKeyPublic, ccECKeyPrivate, or ccECBadKey */ CCECKeyType CCECGetKeyType(CCECCryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECGetKeySize @abstract Return the key size @param key The CCECCryptorRef. @result Returns the keysize in bits or kCCParamError. */ int CCECGetKeySize(CCECCryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorRelease @abstract Clear and release a CCECCryptorRef. @param key The CCECCryptorRef of the key to release. */ void CCECCryptorRelease(CCECCryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorSignHash @abstract Compute a signature for a hash with an EC private key. @param privateKey A pointer to a private CCECCryptorRef. @param hashToSign A pointer to the bytes of the value to be signed. @param hashSignLen Length of data to be signed. @param signedData The signature bytes. @param signedDataLen A pointer to the length of signature material. This is an in/out parameter value. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCECCryptorSignHash( CCECCryptorRef privateKey, const void *hashToSign, size_t hashSignLen, void *signedData, size_t *signedDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorVerifyHash @abstract Verify a signature for data with an EC private key. @param publicKey A pointer to a public CCECCryptorRef. @param hash A pointer to the bytes of the hash of the data. @param hashLen Length of hash. @param signedData The bytes of the signature to be verified. @param signedDataLen Length of data associated with the signature. @param valid An indicator whether the signature was valid @result Possible error returns are kCCParamError, kCCMemoryFailure or kCCNotVerified. */ CCCryptorStatus CCECCryptorVerifyHash( CCECCryptorRef publicKey, const void *hash, size_t hashLen, const void *signedData, size_t signedDataLen, uint32_t *valid) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorWrapKey @abstract Encrypt data (wrap a symmetric key) with an EC public key. @param publicKey A pointer to a public CCECCryptorRef. @param plainText A pointer to the data to be encrypted. @param plainTextLen Length of data to be encrypted. @param cipherText The encrypted byte result. @param cipherTextLen Length of encrypted bytes. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @result Possible error returns are kCCParamError. */ CCCryptorStatus CCECCryptorWrapKey(CCECCryptorRef publicKey, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, CCDigestAlg digestType) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorUnwrapKey @abstract Decrypt data (unwrap a symmetric key) with an EC private key. @param privateKey A pointer to a private CCECCryptorRef. @param cipherText The encrypted bytes. @param cipherTextLen Length of encrypted bytes. @param plainText The decrypted data bytes. @param plainTextLen A pointer to the length of data decrypted. This is an in/out parameter. @result Possible error returns are kCCParamError. */ CCCryptorStatus CCECCryptorUnwrapKey(CCECCryptorRef privateKey, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorComputeSharedSecret @abstract Construct a Diffie-Hellman shared secret with a private and public ECC key. @param privateKey A pointer to a private CCECCryptorRef. @param publicKey A pointer to a public CCECCryptorRef (usually obtained from the other party in the session.) @param out The output data buffer. @param outLen The output data buffer size. This is an in-out parameter. When the function returns this is set to the length of the result. @result Possible error returns are kCCParamError, kCCDecodeError or kCCBufferTooSmall. */ CCCryptorStatus CCECCryptorComputeSharedSecret( CCECCryptorRef privateKey, CCECCryptorRef publicKey, void *out, size_t *outLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*======================================================================================*/ /* Only for FIPS Testing */ /*======================================================================================*/ /*! @function CCECCryptorGetKeyComponents @abstract Get EC Public Key Parameters for FIPS tests @param ecKey The EC Key to deconstruct @param keySize The EC Keysize. @param qX, qXLength The pointer and length(return) for the X Parameter. @param qY, qYLength The pointer and length(return) for the Y Parameter. @param d, dLength The pointer and length(return) for the D (Private Key Only) Parameter. @result If the function is successful (kCCSuccess) the X and Y parameters contain the discreet public key point coordinate values. If the key passed in is a Private Key the D parameter will contain the private key. All other errors result in kCCParamError. */ CCCryptorStatus CCECCryptorGetKeyComponents(CCECCryptorRef ecKey, size_t *keySize, uint8_t *qX, size_t *qXLength, uint8_t *qY, size_t *qYLength, uint8_t *d, size_t *dLength) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECCryptorCreateFromData @abstract For FIPS CAVS testing we need the ability to create an EC key from an X and Y parameter set. @param keySize The EC Keysize. @param qX, qXLength The pointer and length for the X Parameter. @param qY, qYLength The pointer and length for the Y Parameter. @param ref A pointer to the CCECCryptorRef to contain the result. @result If the function is successful (kCCSuccess) a CCECCryptorRef is returned in the ref parameter. All other errors result in kCCParamError. */ CCCryptorStatus CCECCryptorCreateFromData(size_t keySize, uint8_t *qX, size_t qXLength, uint8_t *qY, size_t qYLength, CCECCryptorRef *ref) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECSignatureDecode @abstract For FIPS CAVS testing we need the ability to get the binary S and R values from the DER signature blob. @param SignedData, signedDataLen The pointer and length of the DER formatted signature @param r, rLength The pointer and length for the R component (return value). @param s, sLength The pointer and length for the S component (return value). @result If the function is successful (kCCSuccess) the r and s parameters have the individual values from the signature. */ CCCryptorStatus CCECSignatureDecode(const void *signedData, size_t signedDataLen, uint8_t *r, size_t *rLength, uint8_t *s, size_t *sLength) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCECSignatureEncode @abstract For FIPS CAVS testing we need the ability to produce a DER formatted signature from discreet R and S components. @param r, rLength The pointer and length for the R component. @param s, sLength The pointer and length for the S component. @param signedData, signedDataLen The pointer and length of the DER formatted signature ( return value) @result If the function is successful (kCCSuccess) the signature is returned as a DER-formatted blob. */ CCCryptorStatus CCECSignatureEncode(uint8_t *r, size_t rLength, uint8_t *s, size_t sLength, void *signedData, size_t *signedDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_ECCRYPTOR_H_ */ |
Added Source/CommonCryptoSPI/CommonHMacSPI.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_HmacSPI_H_ #define _CC_HmacSPI_H_ #include <CommonCrypto/CommonHMAC.h> #include <CommonCrypto/CommonDigest.h> #include <CommonCrypto/CommonDigestSPI.h> #include <stdint.h> #include <sys/types.h> #include <Availability.h> #ifdef __cplusplus extern "C" { #endif typedef struct CCHmacContext * CCHmacContextRef; CCHmacContextRef CCHmacCreate(CCDigestAlg alg, const void *key, size_t keyLength) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* Update and Final are reused from existing api, type changed from struct CCHmacContext * to CCHmacContextRef though */ void CCHmacDestroy(CCHmacContextRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); size_t CCHmacOutputSizeFromRef(CCHmacContextRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); size_t CCHmacOutputSize(CCDigestAlg alg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); #ifdef __cplusplus } #endif #endif /* _CC_HmacSPI_H_ */ |
Added Source/CommonCryptoSPI/CommonRSACryptor.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _CC_RSACRYPTOR_H_ #define _CC_RSACRYPTOR_H_ #include <Availability.h> #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonDigestSPI.h> #ifdef __cplusplus extern "C" { #endif /*! @typedef CCRSACryptorRef @abstract Opaque reference to a CCRSACryptor object. */ typedef struct _CCRSACryptor *CCRSACryptorRef; /* RSA Key Types */ enum { ccRSAKeyPublic = 0, ccRSAKeyPrivate = 1, ccRSABlankPublicKey = 97, ccRSABlankPrivateKey = 98, ccRSABadKey = 99, }; typedef uint32_t CCRSAKeyType; /* Padding for Asymmetric ciphers */ enum { ccPaddingNone = 1000, ccPKCS1Padding = 1001, ccOAEPPadding = 1002, ccX931Padding = 1003, // Work in Progress - don't use. ccPKCS1PaddingRaw = 1004, }; typedef uint32_t CCAsymetricPadding; /* Additional CCCryptorStatus for signature verification failure. */ enum { kCCNotVerified = -4306 }; /*! @discussion Key sizes for this set of interfaces must be between 1024 and 4096 bits. The key size must also be evenly divisible by 32. */ /*! @function CCRSACryptorGeneratePair @abstract Generate an RSA public and private key. @param keysize Example sizes for RSA keys are: 512, 768, 1024, 2048. @param e The "e" value (public key). Must be odd; 65537 or larger @param publicKey A (required) pointer for the returned public CCRSACryptorRef. @param privateKey A (required) pointer for the returned private CCRSACryptorRef. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCRSACryptorGeneratePair( size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorGetPublicKeyFromPrivateKey @abstract Create an RSA public key from a full private key. @param privateKey A pointer to a private CCRSACryptorRef. @result returns either a valid public key CCRSACryptorRef or NULL. */ CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privkey) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorImport @abstract Import an RSA key from data. This imports public or private keys in PKCS#1 format. @param keyPackage The data package containing the encoded key. @param keyPackageLen The length of the encoded key package. @param key A CCRSACryptorRef of the decoded key. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCRSACryptorImport( const void *keyPackage, size_t keyPackageLen, CCRSACryptorRef *key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorExport @abstract Import an RSA key from data. This exports public or private keys in PKCS#1 format. @param key The CCRSACryptorRef of the key to encode. @param keyPackage The data package in which to put the encoded key. @param keyPackageLen A pointer to the length of the encoded key package. This is an in/out parameter. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCRSACryptorExport( CCRSACryptorRef key, void *out, size_t *outLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSAGetKeyType @abstract Determine whether a CCRSACryptorRef is public or private @param key The CCRSACryptorRef. @result Return values are ccRSAKeyPublic, ccRSAKeyPrivate, or ccRSABadKey */ CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSAGetKeySize @abstract Return the key size @param key The CCRSACryptorRef. @result Returns the keysize in bits or kCCParamError. */ int CCRSAGetKeySize(CCRSACryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorRelease @abstract Clear and release a CCRSACryptorRef. @param key The CCRSACryptorRef of the key to release. */ void CCRSACryptorRelease(CCRSACryptorRef key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorSign @abstract Compute a signature for data with an RSA private key. @param privateKey A pointer to a private CCRSACryptorRef. @param padding A selector for the padding to be used. @param hashToSign A pointer to the bytes of the value to be signed. @param hashSignLen Length of data to be signed. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @param saltLen Length of salt to use for the signature. @param sig The signature bytes. @param sigLen A pointer to the length of signature material. This is an in/out parameter value. @result Possible error returns are kCCParamError and kCCMemoryFailure. */ CCCryptorStatus CCRSACryptorSign( CCRSACryptorRef privateKey, CCAsymetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorVerify @abstract Verify a signature for data with an RSA private key. @param publicKey A pointer to a public CCRSACryptorRef. @param padding A selector for the padding to be used. @param hash A pointer to the bytes of the hash of the data. @param hashLen Length of hash. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @param saltLen Length of salt to use for the signature. @param signedData The bytes of the signature to be verified. @param signedDataLen Length of data associated with the signature. @result Possible error returns are kCCParamError, kCCMemoryFailure or kCCNotVerified. */ CCCryptorStatus CCRSACryptorVerify( CCRSACryptorRef publicKey, CCAsymetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorEncrypt @abstract Encrypt data with an RSA public key. @param publicKey A pointer to a public CCRSACryptorRef. @param padding A selector for the padding to be used. @param plainText A pointer to the data to be encrypted. @param plainTextLen Length of data to be encrypted. @param cipherText The encrypted byte result. @param cipherTextLen Length of encrypted bytes. @param tagData tag to be included in the encryption. @param tagDataLen Length of tag bytes. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @result Possible error returns are kCCParamError. */ CCCryptorStatus CCRSACryptorEncrypt( CCRSACryptorRef publicKey, CCAsymetricPadding padding, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorDecrypt @abstract Decrypt data with an RSA private key. @param privateKey A pointer to a private CCRSACryptorRef. @param padding A selector for the padding to be used. @param cipherText The encrypted bytes. @param cipherTextLen Length of encrypted bytes. @param plainText The decrypted data bytes. @param plainTextLen A pointer to the length of data decrypted. This is an in/out parameter. @param tagData tag to be included in the encryption. @param tagDataLen Length of tag bytes. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @result Possible error returns are kCCParamError. */ CCCryptorStatus CCRSACryptorDecrypt( CCRSACryptorRef privateKey, CCAsymetricPadding padding, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorDecodePayloadPKCS1 @abstract Decrypt data with an RSA public key, strip off PKCS1 padding and return the payload. @param publicKey A pointer to a public CCRSACryptorRef. @param cipherText The encrypted bytes. @param cipherTextLen Length of encrypted bytes. @param plainText The decrypted data bytes. @param plainTextLen A pointer to the length of data decrypted. This is an in/out parameter. @param digestType The digest algorithm to use (See CommonDigestSPI.h). @result Possible error returns are kCCParamError. */ CCCryptorStatus CCRSACryptorDecodePayloadPKCS1( CCRSACryptorRef publicKey, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0); /*! @function CCRSACryptorCrypt @abstract En/Decrypt data with an RSA key. @param rsaKey A pointer to a CCRSACryptorRef. @param in The input data. @param inLen The input data length. @param out The output data buffer. @param outLen The output data buffer size. This is an in-out parameter. When the function returns this is set to the length of the result. @result Possible error returns are kCCParamError, kCCDecodeError or kCCBufferTooSmall. */ CCCryptorStatus CCRSACryptorCrypt( CCRSACryptorRef rsaKey, const void *in, size_t inLen, void *out, size_t *outLen) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSAGetKeyComponents @abstract En/Decrypt data with an RSA key. @param rsaKey A pointer to a CCRSACryptorRef. @param modulus The modulus in MSB format. @param modulusLength The modulus data length. (in/out parameter) @param exponent The raw data bytes of the exponent. @param exponentLength The exponent data length. (in/out parameter) @param p The raw data bytes of the modulus factor P. (ccRSAKeyPrivate only) @param pLength The P data length. (in/out parameter) @param q The raw data bytes of the modulus factor Q. (ccRSAKeyPrivate only) @param qLength The Q data length. (in/out parameter) @result If the function is successful (kCCSuccess) */ CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRSACryptorCreateFromData @abstract For FIPS CAVS testing we need the ability to create an RSA key from an exponent and Modulus. @param keyType The type of key to create - ccRSAKeyPublic or ccRSAKeyPrivate. @param modulus The modulus in MSB format. @param modulusLength The modulus data length. @param exponent The raw data bytes of the exponent. @param exponentLength The exponent data length. @param p The raw data bytes of the modulus factor P. (ccRSAKeyPrivate only) @param pLength The P data length. @param q The raw data bytes of the modulus factor Q. (ccRSAKeyPrivate only) @param qLength The Q data length. @result If the function is successful (kCCSuccess) a RSACryptoRef is returned in the ref parameter. All other errors result in kCCParamError. */ CCCryptorStatus CCRSACryptorCreateFromData( CCRSAKeyType keyType, uint8_t *modulus, size_t modulusLength, uint8_t *exponent, size_t exponentLength, uint8_t *p, size_t pLength, uint8_t *q, size_t qLength, CCRSACryptorRef *ref) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); CCCryptorStatus CCRSACryptorCreatePairFromData(uint32_t e, uint8_t *xp1, size_t xp1Length, uint8_t *xp2, size_t xp2Length, uint8_t *xp, size_t xpLength, uint8_t *xq1, size_t xq1Length, uint8_t *xq2, size_t xq2Length, uint8_t *xq, size_t xqLength, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey, uint8_t *retp, size_t *retpLength, uint8_t *retq, size_t *retqLength, uint8_t *retm, size_t *retmLength, uint8_t *retd, size_t *retdLength) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); #ifdef __cplusplus } #endif #endif /* _CC_RSACRYPTOR_H_ */ |
Changes to Source/CommonCryptoSPI/CommonRandomSPI.h.
1 | /* | > > > > > | | > > > > > > > > | | > > | > > | > > > > > > > > > | < < > > > > > > > > > > < > > > > > | | > > > > > > < < > > > | < | > > | | > | > > > | > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > | > | > > | > > > > > > > | > > > > > > | > > > | > > > | > > > > | | > > > | > > > > > > > > > | > > > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | #ifndef COMMONRANDOM_H #define COMMONRANDOM_H 1 /* * CommonRandom.h * * Copyright © 2010-2011 by Apple, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * */ #include <dispatch/dispatch.h> #include <dispatch/queue.h> #include <Availability.h> #include <stdint.h> #include <sys/types.h> #include <CommonCrypto/CommonCryptor.h> /*! @header CommonRNG.h @abstract An interface to a system random number generator. This module provides a managed way either to get random numbers from a NIST-approved random number generator or /dev/random. The NIST random number generator gets its entropy from /dev/random, but operates 9x-10x faster than it. @discussion It is inconvenient to call system random number generators directly. In the simple case of calling /dev/random, the caller has to open the device and close it in addition to managing it while it's open. This module has as its immediate raison d'tre the inconvenience of doing this. It manages a file descriptor to /dev/random including the exception processing of what happens in a fork() and exec(). Call CCRandomCopyBytes() and all the fiddly bits are managed for you. Just get on with whatever you were really trying to do. More importantly, though, it also manages a FIPS 140-compliant way to get random numbers. NIST created in their document SP 800-90 a new type of AES-based "Deterministic Random Bit Generator" (DRBG) (what is often called a PRNG) and guidelines on how to use it. There are two reasons to prefer it over directly calling /dev/random. It's a standard and immediately compliant with FIPS 140, and it is dramatically faster per-byte. For complete disclosure, this implements an AES-CTR DRBG with derivation function using AES-128 as the cipher and prediction resistance. Thus, we provide two RNGs to call, kCCRandomDefault (the NIST one) and kCCRandomDevRandom (a managed wrapper around /dev/random). If you are doing anything involving security, call the default one. You'll be glad you did, because it does much security-related housekeeping for you and you don't have to think about it. Really. In implementation details, the first time you call CCRandomCopyBytes(), it will open up /dev/random and seed the RNG with 64 bytes. After each call, there is a reseed operation that happens on an async GCD queue that reseeds with 32 bytes and a nonce from mach_absolute_time(). All access to the internal DRBG is serialized through a GCD queue and is therefore thread safe. Should you need to create your own RNG context or have a secondary RNG context, CCRNGCreate() and CCRNGRelease() will let you create an RNG yourself and then call CCRandomCopyBytes() with that context. */ #if defined(__cplusplus) extern "C" { #endif typedef CCCryptorStatus CCRNGStatus; /*! @typedef CCRandomRef @abstract Abstract Reference to a random number generator. */ #ifndef COMMONRANDOMPRIV_H // Check for the private header typedef struct __CCRandom *CCRandomRef; #endif /*! @function CCRandomCopyBytes @abstract Return random bytes in a buffer allocated by the caller. @discussion The default PRNG returns cryptographically strong random bits suitable for use as cryptographic keys, IVs, nonces etc. @param rnd The random number generator to use. Pre-defined values: kCCRandomDefault, the NIST AES-based one and kCCRandomDevRandom, /dev/random itself. Alternately, you can create one with CCRNGCreate(). @param bytes Pointer to the return buffer. @param count Number of random bytes to return. @result Return kCCSuccess on success. Other values are ... */ int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); extern CCRandomRef kCCRandomDefault __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); extern CCRandomRef kCCRandomDevRandom __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRNGCreate @abstract Create an RNG context. @discussion This creates a CCRandomRef that you can then pass into CCRandomCopyBytes(). Only call this if you need to create your own context. You can call CCRandomCopyBytes() with this context. Remember to release it. @param options Option flags. See below. Unless you have a very good reason, just use kCCRNGOptionCryptoRNG. @param rngRef A pointer to a CCRandomRef. @result Returns kCCSuccess on success. */ CCRNGStatus CCRNGCreate(uint32_t options, CCRandomRef *rngRef) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /*! @function CCRNGRelease @abstract Release an RNG context. @discussion This releases and deallocates a context. @param rng A CCRandomRef. @result Returns kCCSuccess on success. */ CCRNGStatus CCRNGRelease(CCRandomRef rng) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0); /* Options flags The option flags are not exposed through the default use of CCRandomGetBytes(). They are only exposed through direct use of a CCRandomRef. The polarity is reversed here for two reasons. One is that I want people to think before they make a non-FIPS, predictable RNG. If you're doing any sort of crypto, you want FIPS and you want prediction resistance. Prediction resistance reseeds after every query which is slightly slower, but more secure. Non-FIPS is about 20% faster for very large reads, where very large means well over a MB per get, which you will probably never do. If you pull under 500 bytes from the RNG, there is *NO* change in performance for non-FIPS. Non-FIPS makes two changes. First, it increments the counter in machine-natural order, which on little-endian machines makes a very small performance improvement. It saves you two byte-swaps for every 32-bit increment of the counter, for every int that has to be incremented, which is admittedly not much. It is so much not much that this is a compile-time option in the DRBG, and likely to be turned off. But something that makes a difference is that it reads from the DRBG in one lump sum, instead of in 500 byte chunks, as FIPS demands. On a 50MB test, runs about 20% faster, but obviously for 500 bytes would run the same. Arguably, we should remove the non-FIPS thing because in most circumstances it matters naught. Also, as we've said before, if you're interested in security, you shouldn't be worrying about a small performance tweaks. Prediction resistance re-seeds the DRBG after every request with 32 bytes from /dev/random and a timestamp from mach_absolute_time(). This is a legitimate thing you might want and a difference between a "random" and a "urandom" variant. */ enum { kCCRNGOptionIgnoreFIPS = 0x00000001, kCCRNGOptionNoPredictionResistance = 0x00000002, kCCRNGOptionCryptoRNG = 0x00000000, }; // Accessor functions to get the rng "states" for internal Security Framework // use. #include <corecrypto/ccdrbg.h> #include <corecrypto/ccrng_system.h> struct ccrng_state *ccDevRandomGetRngState() __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); struct ccrng_state *ccDRBGGetRngState() __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); #if defined(__cplusplus) } #endif #endif /* COMMONRANDOM_H */ |
Changes to Source/CommonCryptoSPI/aes.h.
1 | /* | < < | < | < < | < < | < < < | < < | < < < < < < < < < < < < | | | | | | | | | | | < < | < < | < < < | | | < < | < < < < | < > | > | < < < < < | < < < < < < | < | < < < | < < < < < | < < < < < < | < < | < < < < < < < < < < < | < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < | | | | < | | > | < | < | | | < < > > | | | | > | < < < > | < < < < | < > < | | < | < < < < < < | | < < > | < > | < < > > | | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /* * aes.h * * Copyright © 2010 by Apple, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * */ /* * aes.h * CommonCrypto shoefly for compatability with older versions * */ #ifdef CC_Building #include "CommonCryptor.h" #include "CommonCryptorSPI.h" #include "CommonCryptorPriv.h" #else #include <CommonCrypto/CommonCryptor.h> #include <CommonCrypto/CommonCryptorSPI.h> #endif /* CC_Building */ #if !defined( _CC_AES_H_ ) #define _CC_AES_H_ #if defined(__cplusplus) extern "C" { #endif #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ typedef struct { CCCryptorRef cref; uint32_t ctx[kCCContextSizeAES128/4]; } aes_encrypt_ctx; typedef struct { CCCryptorRef cref; uint32_t ctx[kCCContextSizeAES128/4]; } aes_decrypt_ctx; void aes_encrypt_key128(const unsigned char *in_key, aes_encrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_encrypt_key256(const unsigned char *in_key, aes_encrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_encrypt_cbc(const unsigned char *in_blk, const unsigned char *in_iv, unsigned int num_blk, unsigned char *out_blk, aes_encrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_decrypt_key128(const unsigned char *in_key, aes_decrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_decrypt_key256(const unsigned char *in_key, aes_decrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); void aes_decrypt_cbc(const unsigned char *in_blk, const unsigned char *in_iv, unsigned int num_blk, unsigned char *out_blk, aes_decrypt_ctx cx[1]) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_5_0, __IPHONE_5_0); #if defined(__cplusplus) } #endif #endif /* _CC_AES_H_ */ |
Deleted Source/CommonCryptoSPI/aesopt.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CommonCryptoSPI/cast.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CommonCryptoSPI/ccCast.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CommonCryptoSPI/ccRC2.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/CommonCryptoSPI/lionCompat.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /* * Copyright © 2011 by Apple, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * */ #if !defined( _COMMON_CRYPTO_LION_COMPAT_ ) #define _COMMON_CRYPTO_LION_COMPAT_ #include <Availability.h> #include <CommonCrypto/CommonDigestSPI.h> #include <CommonCrypto/CommonCryptor.h> typedef struct { CCCryptorRef cref; } CAST_KEY; size_t CCDigestBlockSize(CCDigestRef ctx) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA); // might be needed. void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out, CAST_KEY *key, int enc) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_NA, __IPHONE_NA); // might be needed. void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_NA, __IPHONE_NA); #endif /* _COMMON_CRYPTO_LION_COMPAT_ */ |
Deleted Source/CommonCryptoSPI/opensslDES.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/CommonCryptoSPI/rc2.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md2_dgst.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md32_common.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md4_dgst.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md4_locl.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md5_dgst.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/md5_locl.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha1.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha1edp.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha1edpBigEndian.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha1edpLittleEndian.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha256.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha256_nossse3.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha2Priv.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/Digest/sha_locl.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/Exports/CommonCrypto.exp.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | _CCAESCmac _CCBigNumAdd _CCBigNumAddI _CCBigNumBitCount _CCBigNumByteCount _CCBigNumByteCount _CCBigNumClear _CCBigNumCompare _CCBigNumCompareI _CCBigNumCopy _CCBigNumCreateRandom _CCBigNumDiv _CCBigNumDiv2 _CCBigNumFree _CCBigNumFromData _CCBigNumFromHexString _CCBigNumGCD _CCBigNumGetI _CCBigNumInverseMod _CCBigNumIsNegative _CCBigNumIsOdd _CCBigNumIsPrime _CCBigNumIsZero _CCBigNumLCM _CCBigNumLeftShift _CCBigNumMod _CCBigNumModExp _CCBigNumModI _CCBigNumMontgomeryNormalization _CCBigNumMontgomeryReduce _CCBigNumMontgomerySetup _CCBigNumMul _CCBigNumMulI _CCBigNumMulMod _CCBigNumRightShift _CCBigNumSetI _CCBigNumSetNegative _CCBigNumSquare _CCBigNumSquareMod _CCBigNumSub _CCBigNumSubI _CCBigNumToData _CCBigNumToHexString _CCBigNumZeroLSBCount _CCCalibratePBKDF _CCCreateBigNum _CCCrypt _CCCryptorCreate _CCCryptorCreateFromData _CCCryptorCreateFromDataWithMode _CCCryptorCreateWithMode _CCCryptorDecryptDataBlock _CCCryptorEncryptDataBlock _CCCryptorFinal _CCCryptorGCM _CCCryptorGCMaddAAD _CCCryptorGCMAddAAD _CCCryptorGCMAddADD _CCCryptorGCMAddIV _CCCryptorGCMDecrypt _CCCryptorGCMEncrypt _CCCryptorGCMFinal _CCCryptorGCMReset _CCCryptorGetIV _CCCryptorGetOutputLength _CCCryptorRelease _CCCryptorReset _CCCryptorUpdate _CCDHComputeKey _CCDHCreate _CCDHGenerateKey _CCDHParametersCreateFromData _CCDHParametersCreateFromPKCS3 _CCDHParametersPKCS3EncodeLength _CCDHParametersPKCS3Encode _CCDHParametersRelease _CCDHRelease _CCDesCBCCksum _CCDesIsWeakKey _CCDesSetOddParity _CCDigest _CCDigestCreate _CCDigestCreateByOID _CCDigestDestroy _CCDigestFinal _CCDigestGetBlockSize _CCDigestGetBlockSizeFromRef _CCDigestGetOutputSize _CCDigestOutputSize _CCDigestGetOutputSizeFromRef _CCDigestInit _CCDigestOID _CCDigestOIDLen _CCDigestReset _CCDigestUpdate _CCECCryptorComputeSharedSecret _CCECCryptorCreateFromData _CCECCryptorExportKey _CCECCryptorExportPublicKey _CCECCryptorGeneratePair _CCECCryptorGetKeyComponents _CCECCryptorImportKey _CCECCryptorImportPublicKey _CCECCryptorRelease _CCECCryptorSignHash _CCECCryptorUnwrapKey _CCECCryptorVerifyHash _CCECCryptorWrapKey _CCECGetKeySize _CCECGetKeyType _CCHmac _CCHmacCreate _CCHmacDestroy _CCHmacFinal _CCHmacInit _CCHmacOutputSize _CCHmacOutputSizeFromRef _CCHmacUpdate _CCKeyDerivationPBKDF _CCRNGCreate _CCRNGRelease _CCRSACryptorCreateFromData _CCRSACryptorCreatePairFromData _CCRSACryptorCrypt _CCRSACryptorDecrypt _CCRSACryptorEncrypt _CCRSACryptorExport _CCRSACryptorGeneratePair _CCRSACryptorImport _CCRSACryptorRelease _CCRSACryptorSign _CCRSACryptorVerify _CCRSAGetKeyComponents _CCRSAGetKeySize _CCRSAGetKeyType _CCRandomCopyBytes _CCSymmetricKeyUnwrap _CCSymmetricKeyWrap _CCSymmetricUnwrappedSize _CCSymmetricWrappedSize _CC_MD2 _CC_MD2_Final _CC_MD2_Init _CC_MD2_Update _CC_MD4 _CC_MD4_Final _CC_MD4_Init _CC_MD4_Update _CC_MD5 _CC_MD5_Final _CC_MD5_Init _CC_MD5_Update _CC_RC4 _CC_RC4_set_key _CC_SHA1 _CC_SHA1_Final _CC_SHA1_Init _CC_SHA1_Update _CC_SHA224 _CC_SHA224_Final _CC_SHA224_Init _CC_SHA224_Update _CC_SHA256 _CC_SHA256_Final _CC_SHA256_Init _CC_SHA256_Update _CC_SHA384 _CC_SHA384_Final _CC_SHA384_Init _CC_SHA384_Update _CC_SHA512 _CC_SHA512_Final _CC_SHA512_Init _CC_SHA512_Update _CCrfc3394_iv _CCrfc3394_ivLen _aes_decrypt_cbc _aes_decrypt_key128 _aes_decrypt_key256 _aes_encrypt_cbc _aes_encrypt_key128 _aes_encrypt_key256 _ccDRBGGetRngState _ccDevRandomGetRngState _kCCRandomDefault _kCCRandomDevRandom _kCCDHRFC2409Group2 _kCCDHRFC3526Group5 _CCDigestBlockSize _CAST_ecb_encrypt _CAST_set_key _MD5Final |
Added Source/Exports/CommonCryptoIOS5.exp.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | _CCAESCmac _CCBigNumAdd _CCBigNumAddI _CCBigNumBitCount _CCBigNumByteCount _CCBigNumByteCount _CCBigNumClear _CCBigNumCompare _CCBigNumCompareI _CCBigNumCopy _CCBigNumCreateRandom _CCBigNumDiv _CCBigNumDiv2 _CCBigNumFree _CCBigNumFromData _CCBigNumFromHexString _CCBigNumGCD _CCBigNumGetI _CCBigNumInverseMod _CCBigNumIsNegative _CCBigNumIsOdd _CCBigNumIsPrime _CCBigNumIsZero _CCBigNumLCM _CCBigNumLeftShift _CCBigNumMod _CCBigNumModExp _CCBigNumModI _CCBigNumMontgomeryNormalization _CCBigNumMontgomeryReduce _CCBigNumMontgomerySetup _CCBigNumMul _CCBigNumMulI _CCBigNumMulMod _CCBigNumRightShift _CCBigNumSetI _CCBigNumSetNegative _CCBigNumSquare _CCBigNumSquareMod _CCBigNumSub _CCBigNumSubI _CCBigNumToData _CCBigNumToHexString _CCBigNumZeroLSBCount _CCCalibratePBKDF _CCCreateBigNum _CCCrypt _CCCryptorCreate _CCCryptorCreateFromData _CCCryptorCreateFromDataWithMode _CCCryptorCreateWithMode _CCCryptorDecryptDataBlock _CCCryptorEncryptDataBlock _CCCryptorFinal _CCCryptorGCM _CCCryptorGCMaddAAD _CCCryptorGCMAddAAD _CCCryptorGCMAddADD _CCCryptorGCMAddIV _CCCryptorGCMDecrypt _CCCryptorGCMEncrypt _CCCryptorGCMFinal _CCCryptorGCMReset _CCCryptorGetIV _CCCryptorGetOutputLength _CCCryptorRelease _CCCryptorReset _CCCryptorUpdate _CCDHComputeKey _CCDHCreate _CCDHGenerateKey _CCDHParametersCreateFromData _CCDHParametersCreateFromPKCS3 _CCDHParametersPKCS3EncodeLength _CCDHParametersPKCS3Encode _CCDHParametersRelease _CCDHRelease _CCDesCBCCksum _CCDesIsWeakKey _CCDesSetOddParity _CCDigest _CCDigestCreate _CCDigestCreateByOID _CCDigestDestroy _CCDigestFinal _CCDigestGetBlockSize _CCDigestGetBlockSizeFromRef _CCDigestGetOutputSize _CCDigestOutputSize _CCDigestGetOutputSizeFromRef _CCDigestInit _CCDigestOID _CCDigestOIDLen _CCDigestReset _CCDigestUpdate _CCECCryptorComputeSharedSecret _CCECCryptorCreateFromData _CCECCryptorExportKey _CCECCryptorExportPublicKey _CCECCryptorGeneratePair _CCECCryptorGetKeyComponents _CCECCryptorImportKey _CCECCryptorImportPublicKey _CCECCryptorRelease _CCECCryptorSignHash _CCECCryptorUnwrapKey _CCECCryptorVerifyHash _CCECCryptorWrapKey _CCECGetKeySize _CCECGetKeyType _CCHmac _CCHmacCreate _CCHmacDestroy _CCHmacFinal _CCHmacInit _CCHmacOutputSize _CCHmacOutputSizeFromRef _CCHmacUpdate _CCKeyDerivationPBKDF _CCRNGCreate _CCRNGRelease _CCRSACryptorCreateFromData _CCRSACryptorCreatePairFromData _CCRSACryptorCrypt _CCRSACryptorDecrypt _CCRSACryptorEncrypt _CCRSACryptorExport _CCRSACryptorGeneratePair _CCRSACryptorImport _CCRSACryptorRelease _CCRSACryptorSign _CCRSACryptorVerify _CCRSAGetKeyComponents _CCRSAGetKeySize _CCRSAGetKeyType _CCRandomCopyBytes _CCSymmetricKeyUnwrap _CCSymmetricKeyWrap _CCSymmetricUnwrappedSize _CCSymmetricWrappedSize _CC_MD2 _CC_MD2_Final _CC_MD2_Init _CC_MD2_Update _CC_MD4 _CC_MD4_Final _CC_MD4_Init _CC_MD4_Update _CC_MD5 _CC_MD5_Final _CC_MD5_Init _CC_MD5_Update _CC_RC4 _CC_RC4_set_key _CC_SHA1 _CC_SHA1_Final _CC_SHA1_Init _CC_SHA1_Update _CC_SHA224 _CC_SHA224_Final _CC_SHA224_Init _CC_SHA224_Update _CC_SHA256 _CC_SHA256_Final _CC_SHA256_Init _CC_SHA256_Update _CC_SHA384 _CC_SHA384_Final _CC_SHA384_Init _CC_SHA384_Update _CC_SHA512 _CC_SHA512_Final _CC_SHA512_Init _CC_SHA512_Update _CCrfc3394_iv _CCrfc3394_ivLen _aes_decrypt_cbc _aes_decrypt_key128 _aes_decrypt_key256 _aes_encrypt_cbc _aes_encrypt_key128 _aes_encrypt_key256 _ccDRBGGetRngState _ccDevRandomGetRngState _kCCRandomDefault _kCCRandomDevRandom _kCCDHRFC2409Group2 _kCCDHRFC3526Group5 _CCDigestBlockSize _MD5Final |
Deleted Source/GladmanAES/README.
|
| < < < < < < |
Deleted Source/GladmanAES/aescrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/GladmanAES/aeskey.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/GladmanAES/aestab.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/GladmanAES/aestab.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/GladmanAES/ccNewGladman.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/RC2/ccRC2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/RC2/rc2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/des.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/des_enc.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/des_locl.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/e_os2.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/opensslDES.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/opensslconf.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/set_key.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/ccOpenssl/spr.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added Source/ccUtilities/byteBuffer.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | /* * Copyright (c) 2011 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * printByteBuffer.c * byteutils */ #include "ccMemory.h" #include "byteBuffer.h" void printBytes(uint8_t *buff, size_t len, char *name) { int i; printf("Dumping %d bytes from %s\n", (int) len, name); for(i=0; i<len; i++) { if(i > 0 && !(i%8)) putchar(' '); if(i > 0 && !(i%64)) putchar('\n'); printf("%02x", buff[i]); } putchar('\n'); } void printByteBuffer(byteBuffer bb, char *name) { printBytes(bb->bytes, bb->len, name); } byteBuffer mallocByteBuffer(size_t len) { byteBuffer retval; if((retval = (byteBuffer) CC_XMALLOC(sizeof(byteBufferStruct) + len + 1)) == NULL) return NULL; retval->len = len; retval->size = sizeof(byteBufferStruct) + len + 1; retval->bytes = (uint8_t *) (retval + 1) ; /* just past the byteBuffer in malloc'ed space */ return retval; } void freeByteBuffer(byteBuffer b) { CC_XFREE(b, b->size); } /* utility function to convert hex character representation to their nibble (4 bit) values */ static uint8_t nibbleFromChar(char c) { if(c >= '0' && c <= '9') return c - '0'; if(c >= 'a' && c <= 'f') return c - 'a' + 10; if(c >= 'A' && c <= 'F') return c - 'A' + 10; return 255; } /* Convert a string of characters representing a hex buffer into a series of bytes of that real value */ byteBuffer hexStringToBytes(char *inhex) { byteBuffer retval; uint8_t *p; int len, i; len = (int) strlen(inhex) / 2; if((retval = mallocByteBuffer(len)) == NULL) return NULL; for(i=0, p = (uint8_t *) inhex; i<len; i++) { retval->bytes[i] = (nibbleFromChar(*p) << 4) | nibbleFromChar(*(p+1)); p += 2; } retval->bytes[len] = 0; return retval; } byteBuffer bytesToBytes(void *bytes, size_t len) { byteBuffer retval = mallocByteBuffer(len); CC_XMEMCPY(retval->bytes, bytes, len); return retval; } int bytesAreEqual(byteBuffer b1, byteBuffer b2) { if(b1->len != b2->len) return 0; return (CC_XMEMCMP(b1->bytes, b2->bytes, b1->len) == 0); } static char byteMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; static int byteMapLen = sizeof(byteMap); /* Utility function to convert nibbles (4 bit values) into a hex character representation */ static char nibbleToChar(uint8_t nibble) { if(nibble < byteMapLen) return byteMap[nibble]; return '*'; } /* Convert a buffer of binary values into a hex string representation */ char *bytesToHexString(byteBuffer bb) { char *retval; int i; retval = CC_XMALLOC(bb->len*2 + 1); for(i=0; i<bb->len; i++) { retval[i*2] = nibbleToChar(bb->bytes[i] >> 4); retval[i*2+1] = nibbleToChar(bb->bytes[i] & 0x0f); } retval[bb->len*2] = 0; return retval; } |
Added Source/ccUtilities/byteBuffer.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2011 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * printByteBuffer.h * byteutils * */ #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #ifndef _BYTEBUFFER_H_ #define _BYTEBUFFER_H_ typedef struct byte_buf { size_t len; size_t size; uint8_t *bytes; } byteBufferStruct, *byteBuffer; void printByteBuffer(byteBuffer bb, char *name); void printBytes(uint8_t *buff, size_t len, char *name); byteBuffer mallocByteBuffer(size_t len); void freeByteBuffer(byteBuffer b); byteBuffer hexStringToBytes(char *inhex); byteBuffer bytesToBytes(void *bytes, size_t len); int bytesAreEqual(byteBuffer b1, byteBuffer b2); char *bytesToHexString(byteBuffer bytes); #endif /* _BYTEBUFFER_H_ */ |
Added Source/ccUtilities/ccErrors.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccErrors.h * CommonCrypto */ #include "CommonCryptor.h" #ifndef CCERRORS_H #define CCERRORS_H #define CONTEXT_SIZE_CHK(CCCTX,DIGESTDI) (sizeof(CCCTX) < ccdigest_di_size(DIGESTDI)) #define CC_NONULLPARM(X) if(NULL==(X)) return kCCParamError #endif /* CCERRORS_H */ |
Added Source/ccUtilities/ccMemory.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccMemory.h * CommonCrypto */ #ifndef CCMEMORY_H #define CCMEMORY_H #ifdef KERNEL #define CC_XMALLOC(s) OSMalloc((s), CC_OSMallocTag) #define CC_XFREE(p, s) OSFree((p), (s), CC_OSMallocTag) #else /* KERNEL */ #include <stdlib.h> #include <string.h> #define CC_XMALLOC(s) malloc(s) #define CC_XCALLOC(c, s) calloc((c), (s)) #define CC_XREALLOC(p, s) realloc((p), (s)) #define CC_XFREE(p, s) free(p) #define CC_XMEMCPY(s1, s2, n) memcpy((s1), (s2), (n)) #define CC_XMEMCMP(s1, s2, n) memcmp((s1), (s2), (n)) #define CC_XMEMSET(s1, s2, n) memset((s1), (s2), (n)) #define CC_XZEROMEM(p, n) memset((p), 0, (n)) #define CC_XSTRCMP(s1, s2) strcmp((s1), (s2)) #define CC_XSTORE32H(x, y) do { \ (y)[0] = (unsigned char)(((x)>>24)&255); \ (y)[1] = (unsigned char)(((x)>>16)&255); \ (y)[2] = (unsigned char)(((x)>>8)&255); \ (y)[3] = (unsigned char)((x)&255); \ } while(0) #define CC_XSTORE64H(x, y) \ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } #define CC_XQSORT(base, nelement, width, comparfunc) qsort((base), (nelement), (width), (comparfunc)) #define CC_XALIGNED(PTR,NBYTE) (!(((size_t)(PTR))%(NBYTE))) #define CC_XMIN(X,Y) (((X) < (Y)) ? (X): (Y)) #endif #endif /* CCMEMORY_H */ |
Changes to Source/ccUtilities/ccdebug.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccdebug.c - CommonCrypto debug macros | < > > > > | | > > | | | | < | | > > | | | < > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccdebug.c - CommonCrypto debug macros * */ #include "ccdebug.h" #include <stdlib.h> #include <asl.h> #include <stdarg.h> #include <string.h> #include <stdio.h> #include <dispatch/dispatch.h> #include <dispatch/queue.h> static char *std_log_prefix = "###CommonCrypto : %s - %s"; static const char *std_ident = "CommonCrypto"; static const char *std_facility = "CipherSuite"; static uint32_t std_options = 0; static aslclient aslhandle = NULL; static aslmsg msgptr = NULL; static void ccdebug_init() { static dispatch_once_t init; dispatch_once(&init, ^{ char *ccEnvStdErr = getenv("CC_STDERR"); if(ccEnvStdErr != NULL && strncmp(ccEnvStdErr, "yes", 3) == 0) std_options |= ASL_OPT_STDERR; aslhandle = asl_open(std_ident, std_facility, std_options); msgptr = asl_new(ASL_TYPE_MSG); asl_set(msgptr, ASL_KEY_FACILITY, "com.apple.platformsec"); }); } #define LINESIZE 256 void ccdebug_imp(int level, char *funcname, char *format, ...) { va_list argp; char fmtbuffer[LINESIZE]; ccdebug_init(); va_start(argp, format); snprintf(fmtbuffer, LINESIZE, std_log_prefix, funcname, format); asl_vlog(aslhandle, msgptr, level, fmtbuffer, argp); va_end(argp); } |
Changes to Source/ccUtilities/ccdebug.h.
|
| | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at |
︙ | ︙ | |||
19 20 21 22 23 24 25 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccdebug.h - CommonCrypto debug macros | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > | > | > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ccdebug.h - CommonCrypto debug macros * */ #if defined(COMMON_DIGEST_FUNCTIONS) || defined(COMMON_CMAC_FUNCTIONS) || defined(COMMON_GCM_FUNCTIONS) \ || defined (COMMON_AESSHOEFLY_FUNCTIONS) || defined(COMMON_CASTSHOEFLY_FUNCTIONS) \ || defined (COMMON_CRYPTOR_FUNCTIONS) || defined(COMMON_HMAC_FUNCTIONS) \ || defined(COMMON_KEYDERIVATION_FUNCTIONS) || defined(COMMON_SYMMETRIC_KEYWRAP_FUNCTIONS) \ || defined(COMMON_RSA_FUNCTIONS) || defined(COMMON_EC_FUNCTIONS) || defined(COMMON_DH_FUNCTIONS) \ || defined(COMMON_BIGNUM_FUNCTIONS) || defined(COMMON_RANDOM_FUNCTIONS) #define DIAGNOSTIC #endif #ifdef KERNEL #include <stdarg.h> #define CC_DEBUG 1 #define CC_DEBUG_BUG 2 #define CC_DEBUG_FAILURE 3 #if DIAGNOSTIC #define CC_DEBUG_LOG(lvl, fmt, ...) do { \ const char *lvl_type[] = { "INVALID", "DEBUG", "ERROR", "FAILURE" }; \ char fmtbuffer[256]; \ int l = lvl; \ \ if (l < 0 || l > 3) l = 0; \ snprintf(fmtbuffer, sizeof(fmtbuffer), \ "CommonCrypto Function: %s:%d (%s) - %s", __FILE__, __LINE__, \ lvl_type[l], fmt); \ printf(fmtbuffer, __VA_ARGS__); \ } while (0) #else #define CC_DEBUG_LOG(lvl,fmt,...) {} #endif /* DIAGNOSTIC */ #else #include <asl.h> #include <stdarg.h> #define CC_DEBUG_FAILURE ASL_LEVEL_EMERG #define CC_DEBUG_BUG ASL_LEVEL_ERR #define CC_DEBUG ASL_LEVEL_ERR void ccdebug_imp(int level, char *funcname, char *format, ...); #ifdef DIAGNOSTIC #define CC_DEBUG_LOG(lvl,...) ccdebug_imp(lvl, __FUNCTION__, __VA_ARGS__) #else #define CC_DEBUG_LOG(lvl,...) {} #endif /* DEBUG */ #endif /* KERNEL */ |
Added Source/descriptors/corecryptoSymmetricBridge.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include "corecryptoSymmetricBridge.h" #include "ccMemory.h" #include <corecrypto/ccrc4.h> static void *noMode(void) { return NULL; } // RC4 as a mode trick ... void rc4ModeInit(const struct ccmode_ofb *ofb, void *ctx, unsigned long key_len, const void *key, const void *iv) { ccrc4_eay.init(ctx, key_len, key); } void rc4crypt(void *ctx, unsigned long nbytes, const void *in, void *out) { ccrc4_eay.crypt(ctx, nbytes, in, out); } typedef struct eay_rc4_key_st { uint32_t x,y; uint32_t data[256]; } eay_RC4_KEY; struct ccmode_ofb rc4mode = { .size = sizeof(eay_RC4_KEY), .block_size = 1, .init = rc4ModeInit, .ofb = rc4crypt, }; struct ccmode_ofb *cc_rc4_crypt_mode(void) { return &rc4mode; } // 2 dimensional array of various mode/cipher contexts // encrypt/decrypt x algorithm matching the list in CommonCryptor.h modeList ccmodeList[7][2] = { { // AES { ccaes_ecb_encrypt_mode, ccaes_cbc_encrypt_mode, ccaes_cfb_encrypt_mode, ccaes_cfb8_encrypt_mode, ccaes_ctr_crypt_mode, ccaes_ofb_crypt_mode, ccaes_xts_encrypt_mode, ccaes_gcm_encrypt_mode }, { ccaes_ecb_decrypt_mode, ccaes_cbc_decrypt_mode, ccaes_cfb_decrypt_mode, ccaes_cfb8_decrypt_mode, ccaes_ctr_crypt_mode, ccaes_ofb_crypt_mode, ccaes_xts_decrypt_mode, ccaes_gcm_decrypt_mode } }, { // DES { ccdes_ecb_encrypt_mode, ccdes_cbc_encrypt_mode, ccdes_cfb_encrypt_mode, ccdes_cfb8_encrypt_mode, ccdes_ctr_crypt_mode, ccdes_ofb_crypt_mode, noMode, noMode }, { ccdes_ecb_decrypt_mode, ccdes_cbc_decrypt_mode, ccdes_cfb_decrypt_mode, ccdes_cfb8_decrypt_mode, ccdes_ctr_crypt_mode, ccdes_ofb_crypt_mode, noMode, noMode } }, { // DES3 { ccdes3_ecb_encrypt_mode, ccdes3_cbc_encrypt_mode, ccdes3_cfb_encrypt_mode, ccdes3_cfb8_encrypt_mode, ccdes3_ctr_crypt_mode, ccdes3_ofb_crypt_mode, noMode, noMode }, { ccdes3_ecb_decrypt_mode, ccdes3_cbc_decrypt_mode, ccdes3_cfb_decrypt_mode, ccdes3_cfb8_decrypt_mode, ccdes3_ctr_crypt_mode, ccdes3_ofb_crypt_mode, noMode, noMode } }, { // CAST { cccast_ecb_encrypt_mode, cccast_cbc_encrypt_mode, cccast_cfb_encrypt_mode, cccast_cfb8_encrypt_mode, cccast_ctr_crypt_mode, cccast_ofb_crypt_mode, noMode, noMode }, { cccast_ecb_decrypt_mode, cccast_cbc_decrypt_mode, cccast_cfb_decrypt_mode, cccast_cfb8_decrypt_mode, cccast_ctr_crypt_mode, cccast_ofb_crypt_mode, noMode, noMode } }, { // RC4 - hijack OFB to put in streaming cipher descriptor { noMode, noMode, noMode, noMode, noMode, cc_rc4_crypt_mode, noMode, noMode }, { noMode, noMode, noMode, noMode, noMode, cc_rc4_crypt_mode, noMode, noMode } }, { // RC2 { ccrc2_ecb_encrypt_mode, ccrc2_cbc_encrypt_mode, ccrc2_cfb_encrypt_mode, ccrc2_cfb8_encrypt_mode, ccrc2_ctr_crypt_mode, ccrc2_ofb_crypt_mode, noMode, noMode }, { ccrc2_ecb_decrypt_mode, ccrc2_cbc_decrypt_mode, ccrc2_cfb_decrypt_mode, ccrc2_cfb8_decrypt_mode, ccrc2_ctr_crypt_mode, ccrc2_ofb_crypt_mode, noMode, noMode } }, { // Blowfish { ccblowfish_ecb_encrypt_mode, ccblowfish_cbc_encrypt_mode, ccblowfish_cfb_encrypt_mode, ccblowfish_cfb8_encrypt_mode, ccblowfish_ctr_crypt_mode, ccblowfish_ofb_crypt_mode, noMode, noMode }, { ccblowfish_ecb_decrypt_mode, ccblowfish_cbc_decrypt_mode, ccblowfish_cfb_decrypt_mode, ccblowfish_cfb8_decrypt_mode, ccblowfish_ctr_crypt_mode, ccblowfish_ofb_crypt_mode, noMode, noMode } }, }; // Thunks //ECB static size_t ccecb_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.ecb->size; } static size_t ccecb_mode_get_block_size(corecryptoMode modeObject) { return modeObject.ecb->block_size; } static void ccecb_mode_setup(corecryptoMode modeObj, const void *IV, const void *key, size_t keylen, const void *tweak, int tweaklen, int options, modeCtx ctx) { modeObj.ecb->init(modeObj.ecb, ctx.ecb, keylen, key); } static void ccecb_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.ecb->ecb(ctx.ecb, len / ccecb_mode_get_block_size(modeObj), in, out); } cc2CCModeDescriptor ccecb_mode = { .mode_get_ctx_size = ccecb_mode_get_ctx_size, .mode_get_block_size = ccecb_mode_get_block_size, .mode_setup = ccecb_mode_setup, .mode_encrypt = ccecb_mode_crypt, .mode_decrypt = ccecb_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // CBC static size_t cccbc_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.cbc->size + 16; } static size_t cccbc_mode_get_block_size(corecryptoMode modeObject) { return modeObject.cbc->block_size; } static void cccbc_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { CC_XMEMCPY(ctx.cbc->iv, iv, modeObj.cbc->block_size); modeObj.cbc->init(modeObj.cbc, &ctx.cbc->cbc, keylen, key); } static void cccbc_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.cbc->cbc(&ctx.cbc->cbc, ctx.cbc->iv, len / cccbc_mode_get_block_size(modeObj), in, out); } static int cccbc_getiv(corecryptoMode modeObj, void *iv, uint32_t *len, modeCtx ctx) { if(*len < cccbc_mode_get_block_size(modeObj)) { *len = cccbc_mode_get_block_size(modeObj); return -1; } uint8_t tmp[cccbc_mode_get_block_size(modeObj)]; CC_XMEMCPY(iv, ctx.cbc->iv, *len = cccbc_mode_get_block_size(modeObj)); return 0; } static int cccbc_setiv(corecryptoMode modeObj, const void *iv, uint32_t len, modeCtx ctx) { uint8_t tmp[cccbc_mode_get_block_size(modeObj)]; if(len != cccbc_mode_get_block_size(modeObj)) return -1; CC_XMEMCPY(ctx.cbc->iv, iv, cccbc_mode_get_block_size(modeObj)); return 0; } cc2CCModeDescriptor cccbc_mode = { .mode_get_ctx_size = cccbc_mode_get_ctx_size, .mode_get_block_size = cccbc_mode_get_block_size, .mode_setup = cccbc_mode_setup, .mode_encrypt = cccbc_mode_crypt, .mode_decrypt = cccbc_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = cccbc_setiv, .mode_getiv = cccbc_getiv }; // CFB static size_t cccfb_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.cfb->size; } static size_t cccfb_mode_get_block_size(corecryptoMode modeObject) { return modeObject.cfb->block_size; } static void cccfb_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.cfb->init(modeObj.cfb, ctx.cfb, keylen, key, iv); } static void cccfb_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.cfb->cfb(ctx.cfb, len / cccfb_mode_get_block_size(modeObj), in, out); } cc2CCModeDescriptor cccfb_mode = { .mode_get_ctx_size = cccfb_mode_get_ctx_size, .mode_get_block_size = cccfb_mode_get_block_size, .mode_setup = cccfb_mode_setup, .mode_encrypt = cccfb_mode_crypt, .mode_decrypt = cccfb_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // CFB8 static size_t cccfb8_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.cfb8->size; } static size_t cccfb8_mode_get_block_size(corecryptoMode modeObject) { return modeObject.cfb8->block_size; } static void cccfb8_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.cfb8->init(modeObj.cfb8, ctx.cfb8, keylen, key, iv); } static void cccfb8_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.cfb8->cfb8(ctx.cfb8, len / cccfb8_mode_get_block_size(modeObj), in, out); } cc2CCModeDescriptor cccfb8_mode = { .mode_get_ctx_size = cccfb8_mode_get_ctx_size, .mode_get_block_size = cccfb8_mode_get_block_size, .mode_setup = cccfb8_mode_setup, .mode_encrypt = cccfb8_mode_crypt, .mode_decrypt = cccfb8_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // CTR static size_t ccctr_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.ctr->size; } static size_t ccctr_mode_get_block_size(corecryptoMode modeObject) { return modeObject.ctr->block_size; } static void ccctr_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.ctr->init(modeObj.ctr, ctx.ctr, keylen, key, iv); } static void ccctr_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.ctr->ctr(ctx.ctr, len / ccctr_mode_get_block_size(modeObj), in, out); } cc2CCModeDescriptor ccctr_mode = { .mode_get_ctx_size = ccctr_mode_get_ctx_size, .mode_get_block_size = ccctr_mode_get_block_size, .mode_setup = ccctr_mode_setup, .mode_encrypt = ccctr_mode_crypt, .mode_decrypt = ccctr_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // OFB static size_t ccofb_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.ofb->size; } static size_t ccofb_mode_get_block_size(corecryptoMode modeObject) { return modeObject.ofb->block_size; } static void ccofb_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.ofb->init(modeObj.ofb, ctx.ofb, keylen, key, iv); } static void ccofb_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.ofb->ofb(ctx.ofb, len / ccofb_mode_get_block_size(modeObj), in, out); } cc2CCModeDescriptor ccofb_mode = { .mode_get_ctx_size = ccofb_mode_get_ctx_size, .mode_get_block_size = ccofb_mode_get_block_size, .mode_setup = ccofb_mode_setup, .mode_encrypt = ccofb_mode_crypt, .mode_decrypt = ccofb_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // XTS /* For now we always schedule both encrypt and decrypt contexts for AES-XTS. Original CommonCrypto support * allowed a "both" (kCCEncrypt and kCCDecrypt) capability used for AES-XTS block I/O. The initialization * and correct mode objext and context passing are done at the CommonCryptor layer. */ static size_t ccxts_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.xts->size; } static size_t ccxts_mode_get_block_size(corecryptoMode modeObject) { return modeObject.xts->block_size; } static void ccxts_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.xts->init(modeObj.xts, ctx.xts, keylen, key, tweak); } #ifdef UNUSED_INTERFACE static void ccxts_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.xts->xts(ctx.xts, len / ccxts_mode_get_block_size(modeObj), in, out); } static int ccxts_setiv(corecryptoMode modeObj, const void *iv, uint32_t len, modeCtx ctx) { if(len != modeObj.xts->block_size) return -1; modeObj.xts->set_tweak(ctx.xts, iv); return 0; } static int ccxts_getiv(corecryptoMode modeObj, void *iv, uint32_t *len, modeCtx ctx) { if(*len < modeObj.xts->block_size) { *len = modeObj.xts->block_size; return -1; } CC_XMEMCPY(iv, modeObj.xts->xts(ctx.xts, 0, NULL, NULL), *len = modeObj.xts->block_size); return 0; } #endif /* * These match what we had in libtomcrypt - they really are "this is a logical block" routines, so need * to handle partial blocks - so we use corecrypto's xts pad routines in every case. */ static void ccxts_mode_encrypt_tweak(corecryptoMode modeObj, const void *in, void *out, size_t len, const void *iv, modeCtx ctx) { ccxts_tweak_decl(ccxts_context_size(modeObj.xts), tweak); modeObj.xts->set_tweak(ctx.xts, tweak, iv); ccpad_xts_encrypt(modeObj.xts, ctx.xts, tweak, len, in, out); } static void ccxts_mode_decrypt_tweak(corecryptoMode modeObj, const void *in, void *out, size_t len, const void *iv, modeCtx ctx) { ccxts_tweak_decl(ccxts_context_size(modeObj.xts), tweak); modeObj.xts->set_tweak(ctx.xts, tweak, iv); ccpad_xts_decrypt(modeObj.xts, ctx.xts, tweak, len, in, out); } cc2CCModeDescriptor ccxts_mode = { .mode_get_ctx_size = ccxts_mode_get_ctx_size, .mode_get_block_size = ccxts_mode_get_block_size, .mode_setup = ccxts_mode_setup, .mode_encrypt = NULL, .mode_decrypt = NULL, .mode_encrypt_tweaked = ccxts_mode_encrypt_tweak, .mode_decrypt_tweaked = ccxts_mode_decrypt_tweak, .mode_done = NULL, .mode_setiv = NULL, .mode_getiv = NULL }; // GCM static size_t ccgcm_mode_get_ctx_size(corecryptoMode modeObject) { return modeObject.gcm->size; } static size_t ccgcm_mode_get_block_size(corecryptoMode modeObject) { return modeObject.gcm->block_size; } static void ccgcm_mode_setup(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx) { modeObj.gcm->init(modeObj.gcm, ctx.gcm, keylen, key); } static void ccgcm_mode_crypt(corecryptoMode modeObj, const void *in, void *out, size_t len, modeCtx ctx) { modeObj.gcm->gcm(ctx.gcm, len, in, out); } static int ccgcm_setiv(corecryptoMode modeObj, const void *iv, uint32_t len, modeCtx ctx) { modeObj.gcm->set_iv(ctx.gcm, len, iv); return 0; } cc2CCModeDescriptor ccgcm_mode = { .mode_get_ctx_size = ccgcm_mode_get_ctx_size, .mode_get_block_size = ccgcm_mode_get_block_size, .mode_setup = ccgcm_mode_setup, .mode_encrypt = ccgcm_mode_crypt, .mode_decrypt = ccgcm_mode_crypt, .mode_encrypt_tweaked = NULL, .mode_decrypt_tweaked = NULL, .mode_done = NULL, .mode_setiv = ccgcm_setiv, .mode_getiv = NULL }; // Padding static int ccpkcs7_encrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { ccpad_pkcs7_encrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, cipherText); *moved = modeptr->mode_get_block_size(modeObj); return 0; } static int ccpkcs7_decrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { *moved = ccpad_pkcs7_decrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, plainText); return 0; } static int ccpkcs7_encrypt_ecb_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { ccpad_pkcs7_ecb_encrypt(modeObj.ecb, ctx.ecb, len, buff, cipherText); *moved = modeptr->mode_get_block_size(modeObj); return 0; } static int ccpkcs7_decrypt_ecb_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { *moved = ccpad_pkcs7_ecb_decrypt(modeObj.ecb, ctx.ecb, len, buff, plainText); return 0; } /* * Maximum space needed for padding. */ #define MAXBLOCKSIZE_PKCS7 128 static size_t ccpkcs7_padlen(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, char *buffp) { int retval = 0; size_t blocksize = modeptr->mode_get_block_size(modeObj); /* We're going to return blocksize for unpad as a "maximum needed". Otherwise we're going to have to decrypt the last block to get the number */ return blocksize; } /* * How many bytes to reserve to enable padding - this is pre-encrypt/decrypt bytes. */ static size_t ccpkcs7_reserve(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj) { if(encrypt) { return 0; } else { return modeptr->mode_get_block_size(modeObj); } } cc2CCPaddingDescriptor ccpkcs7_pad = { .encrypt_pad = ccpkcs7_encrypt_pad, .decrypt_pad = ccpkcs7_decrypt_pad, .padlen = ccpkcs7_padlen, .padreserve = ccpkcs7_reserve, }; cc2CCPaddingDescriptor ccpkcs7_ecb_pad = { .encrypt_pad = ccpkcs7_encrypt_ecb_pad, .decrypt_pad = ccpkcs7_decrypt_ecb_pad, .padlen = ccpkcs7_padlen, .padreserve = ccpkcs7_reserve, }; static int cccts1_encrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { ccpad_cts1_encrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, cipherText); *moved = len; return 0; } static int cccts1_decrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { ccpad_cts1_decrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, plainText); *moved = len; return 0; } static int cccts2_encrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { ccpad_cts2_encrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, cipherText); *moved = len; return 0; } static int cccts2_decrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { ccpad_cts2_decrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, plainText); *moved = len; return 0; } static int cccts3_encrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { ccpad_cts3_encrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, cipherText); *moved = len; return 0; } static int cccts3_decrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { ccpad_cts3_decrypt(modeObj.cbc, &ctx.cbc->cbc, ctx.cbc->iv, len, buff, plainText); *moved = len; return 0; } /* * Maximum space needed for padding. */ #define MAXBLOCKSIZE_PKCS7 128 static size_t ccctsX_padlen(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, char *buffp) { return 0; } /* * How many bytes to reserve to enable padding - this is pre-encrypt/decrypt bytes. */ static size_t ccctsX_reserve(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj) { return modeptr->mode_get_block_size(modeObj) * 2; } cc2CCPaddingDescriptor cccts1_pad = { .encrypt_pad = cccts1_encrypt_pad, .decrypt_pad = cccts1_decrypt_pad, .padlen = ccctsX_padlen, .padreserve = ccctsX_reserve, }; cc2CCPaddingDescriptor cccts2_pad = { .encrypt_pad = cccts2_encrypt_pad, .decrypt_pad = cccts2_decrypt_pad, .padlen = ccctsX_padlen, .padreserve = ccctsX_reserve, }; cc2CCPaddingDescriptor cccts3_pad = { .encrypt_pad = cccts3_encrypt_pad, .decrypt_pad = cccts3_decrypt_pad, .padlen = ccctsX_padlen, .padreserve = ccctsX_reserve, }; static int ccnopad_encrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *cipherText, size_t *moved) { *moved = 0; return 0; } static int ccnopad_decrypt_pad(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, size_t len, void *plainText, size_t *moved) { *moved = 0; return 0; } /* * Maximum space needed for padding. */ static size_t ccnopad_padlen(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, char *buffp) { return 0; } /* * How many bytes to reserve to enable padding - this is pre-encrypt/decrypt bytes. */ static size_t ccnopad_reserve(int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj) { return 0; } cc2CCPaddingDescriptor ccnopad_pad = { .encrypt_pad = ccnopad_encrypt_pad, .decrypt_pad = ccnopad_decrypt_pad, .padlen = ccnopad_padlen, .padreserve = ccnopad_reserve, }; |
Added Source/descriptors/corecryptoSymmetricBridge.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /* * Copyright (c) 2012 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef CommonCrypto_corecryptoSymmetricBridge_h #define CommonCrypto_corecryptoSymmetricBridge_h #include <stdbool.h> #include <corecrypto/ccmode.h> #include <corecrypto/ccmode_impl.h> #include <corecrypto/ccaes.h> #include <corecrypto/ccdes.h> #include <corecrypto/cccast.h> #include <corecrypto/ccrc2.h> #include <corecrypto/ccblowfish.h> #include <corecrypto/ccpad.h> typedef union { struct ccmode_ecb *ecb; struct ccmode_cbc *cbc; struct ccmode_cfb *cfb; struct ccmode_cfb8 *cfb8; struct ccmode_ctr *ctr; struct ccmode_ofb *ofb; struct ccmode_xts *xts; struct ccmode_gcm *gcm; } corecryptoMode; typedef struct ccmode_ecb* (*ecb_p) (void); typedef struct ccmode_cbc* (*cbc_p) (void); typedef struct ccmode_cfb* (*cfb_p) (void); typedef struct ccmode_cfb8* (*cfb8_p) (void); typedef struct ccmode_ctr* (*ctr_p) (void); typedef struct ccmode_ofb* (*ofb_p) (void); typedef struct ccmode_xts* (*xts_p) (void); typedef struct ccmode_gcm* (*gcm_p) (void); typedef struct modes_t { ecb_p ecb; cbc_p cbc; cfb_p cfb; cfb8_p cfb8; ctr_p ctr; ofb_p ofb; xts_p xts; gcm_p gcm; } modeList; modeList ccmodeList[7][2]; typedef struct cbc_with_iv_t { uint8_t iv[16]; cccbc_ctx cbc; } cbc_iv_ctx; typedef union { void *data; ccecb_ctx *ecb; cbc_iv_ctx *cbc; cccfb_ctx *cfb; cccfb8_ctx *cfb8; ccctr_ctx *ctr; ccofb_ctx *ofb; ccxts_ctx *xts; ccgcm_ctx *gcm; } modeCtx; #pragma mark Modes /** Setup the mode @param cipher The index of the LTC Cipher - must be registered @param IV The initial vector @param key The input symmetric key @param keylen The length of the input key (octets) @param tweak The input tweak or salt @param tweaklen The length of the tweak or salt (if variable) (octets) @param options Mask for any mode options @param ctx [out] The destination of the mode context */ typedef void (*ccmode_setup_p)(corecryptoMode modeObj, const void *iv, const void *key, size_t keylen, const void *tweak, size_t tweaklen, int options, modeCtx ctx); /** Encrypt a block @param pt The plaintext @param ct [out] The ciphertext @param len the length of data (in == out) octets @param ctx The mode context @return # bytes encrypted */ typedef void (*ccmode_encrypt_p)(corecryptoMode modeObj, const void *pt, void *ct, size_t len, modeCtx ctx); /** Decrypt a block @param ct The ciphertext @param pt [out] The plaintext @param len the length of data (in == out) octets @param ctx The mode context @return # bytes encrypted */ typedef void (*ccmode_decrypt_p)(corecryptoMode modeObj, const void *ct, void *pt, size_t len, modeCtx ctx); /** Encrypt a block with a tweak (XTS mode currently) @param pt The plaintext @param ct [out] The ciphertext @param len the length of data (in == out) octets @param tweak The 128--bit encryption tweak (e.g. sector number) @param ctx The mode context @return # bytes encrypted */ typedef void (*ccmode_encrypt_tweaked_p)(corecryptoMode modeObj, const void *pt, size_t len, void *ct, const void *tweak, modeCtx ctx); /** Decrypt a block with a tweak (XTS mode currently) @param ct The ciphertext @param pt [out] The plaintext @param len the length of data (in == out) octets @param ctx The mode context @return # bytes encrypted */ typedef void (*ccmode_decrypt_tweaked_p)(corecryptoMode modeObj, const void *ct, size_t len, void *pt, const void *tweak, modeCtx ctx); /** Terminate the mode @param ctx [out] The mode context */ typedef int (*ccmode_done_p)(corecryptoMode modeObj, modeCtx ctx); /** Set an Initial Vector @param IV The initial vector @param len The length of the initial vector @param ctx The mode context */ typedef int (*ccmode_setiv_p)(corecryptoMode modeObj, const void *iv, uint32_t len, modeCtx ctx); /** Get an Initial Vector @param IV [out] The initial vector @param len The length of the initial vector @param ctx The mode context */ typedef int (*ccmode_getiv_p)(corecryptoMode modeObj, void *iv, uint32_t *len, modeCtx ctx); /** Get the mode context size @param modeObj a pointer to the mode object. @return the size of the context */ typedef size_t (*ccmode_get_ctx_size)(corecryptoMode modeObj); /** Get the mode block size @param modeObj a pointer to the mode object. @return the size of the block */ typedef size_t (*ccmode_get_block_size)(corecryptoMode modeObj); typedef struct cc2CCModeDescriptor_t { // ccBufStrat bufStrat; ccmode_get_ctx_size mode_get_ctx_size; ccmode_get_block_size mode_get_block_size; ccmode_setup_p mode_setup; ccmode_encrypt_p mode_encrypt; ccmode_decrypt_p mode_decrypt; ccmode_encrypt_tweaked_p mode_encrypt_tweaked; ccmode_decrypt_tweaked_p mode_decrypt_tweaked; ccmode_done_p mode_done; ccmode_setiv_p mode_setiv; ccmode_getiv_p mode_getiv; } cc2CCModeDescriptor, *cc2CCModeDescriptorPtr; cc2CCModeDescriptor ccecb_mode; cc2CCModeDescriptor cccbc_mode; cc2CCModeDescriptor cccfb_mode; cc2CCModeDescriptor cccfb8_mode; cc2CCModeDescriptor ccctr_mode; cc2CCModeDescriptor ccofb_mode; cc2CCModeDescriptor ccxts_mode; cc2CCModeDescriptor ccgcm_mode; // Buffer and Padding Handling /* * Fill out the padding for a buffer. The blocksize and starting points are * used to determine how much needs to be padded. If startpoint is 0 * then a full new buffer is added. Blocksize cannot be greater than 256. */ typedef int (*cc_encrypt_pad_p)(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, uint32_t startpoint, void *cipherText, size_t *moved); typedef int (*cc_decrypt_pad_p)(modeCtx ctx, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, void *buff, uint32_t startpoint, void *plainText, size_t *moved); /* * Maximum space needed for padding. */ typedef size_t (*ccpadlen_p) (int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj, char *buffp); /* * How many bytes to reserve to enable padding - this is pre-encrypt/decrypt bytes. */ typedef size_t (*ccreserve_p) (int encrypt, cc2CCModeDescriptorPtr modeptr, corecryptoMode modeObj); typedef struct cc2CCPaddingDescriptor_t { cc_encrypt_pad_p encrypt_pad; cc_decrypt_pad_p decrypt_pad; ccpadlen_p padlen; ccreserve_p padreserve; } cc2CCPaddingDescriptor, *cc2CCPaddingDescriptorPtr; cc2CCPaddingDescriptor ccnopad_pad; cc2CCPaddingDescriptor cccts1_pad; cc2CCPaddingDescriptor cccts2_pad; cc2CCPaddingDescriptor cccts3_pad; cc2CCPaddingDescriptor ccpkcs7_pad; cc2CCPaddingDescriptor ccpkcs7_ecb_pad; #endif |
Added Source/descriptors/digestDescriptors/ccDigestDescriptors.h.
> > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 | #include "ccDescriptors.h" #ifndef _CC_DIGESTDESCRIPTORS_H #define _CC_DIGESTDESCRIPTORS_H #define CCCTX_SIZE(DI) ((DI)->state_size + sizeof(uint64_t) + (DI)->block_size + sizeof(int)) #endif /* _CC_DIGESTDESCRIPTORS_H */ |
Added Source/descriptors/digestDescriptors/ccvngneonsha1Descriptor/ccvngneonsha1Desc.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #if defined(__ARM_ARCH_7A__) #include "ccvngneonsha1Desc.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "CommonDigest.h" const ccDescriptor cc_vngneonsha1_desc = { .implementation_info = &cc_sha1_impinfo, .dtype.digest.hashsize = CC_SHA1_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA1_BLOCK_BYTES, .dtype.digest.digest_info = &cc_vngneonsha1_di, .dtype.digest.init = &cc_vngneon_sha1_init, .dtype.digest.process = &cc_vngneon_sha1_process, .dtype.digest.done = &cc_vngneon_sha1_done, }; int cc_vngneon_sha1_init(cc_sha1_ctx *md_ctx) { ccdigest_init(cc_vngneonsha1_di, md_ctx); return CRYPT_OK; } int cc_vngneon_sha1_process(cc_sha1_ctx *md_ctx, const unsigned char *in, unsigned long inlen) { ccdigest_update(cc_vngneonsha1_di, md_ctx, inlen, in); return CRYPT_OK; } int cc_vngneon_sha1_done(cc_sha1_ctx *md_ctx, unsigned char *hash) { ccdigest_final(cc_vngneonsha1_di, md_ctx, hash); return CRYPT_OK; } #endif |
Added Source/descriptors/digestDescriptors/ccvngneonsha1Descriptor/ccvngneonsha1Desc.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #if defined(__ARM_ARCH_7A__) #define CCSHA1_VNG_ARMV7NEON #include <corecrypto/ccsha1.h> static const struct ccdigest_info *cc_vngneonsha1_di=&ccsha1_vng_armv7neon_di; typedef void cc_sha1_ctx; int cc_vngneon_sha1_init(cc_sha1_ctx *md_ctx); int cc_vngneon_sha1_process(cc_sha1_ctx *md_ctx, const unsigned char *in, unsigned long inlen); int cc_vngneon_sha1_done(cc_sha1_ctx *md_ctx, unsigned char *hash); #endif |
Added Source/descriptors/digestDescriptors/ltc_hashcommon.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #ifndef LTC_HASHCOMMON_H_ #define LTC_HASHCOMMON_H_ /* a simple macro for making hash "process" functions */ #define LTC_HASH_PROCESS(func_name, compress_name, state_var, field, block_size) \ int func_name (state_var *ctx, const unsigned char *in, unsigned long inlen) \ { \ unsigned long n; \ int err; \ \ \ LTC_ARGCHK(ctx != NULL); \ LTC_ARGCHK(in != NULL); \ \ \ if (ctx->curlen > sizeof(ctx->buf)) { \ return CRYPT_INVALID_ARG; \ } \ if ((ctx->length + inlen) < ctx->length) { \ return CRYPT_HASH_OVERFLOW; \ } \ while (inlen > 0) { \ if (ctx->curlen == 0 && inlen >= block_size) { \ if ((err = compress_name (ctx, in)) != CRYPT_OK) { \ return err; \ } \ ctx->length += block_size * 8; \ in += block_size; \ inlen -= block_size; \ } else { \ n = MIN(inlen, (block_size - ctx->curlen)); \ memcpy(ctx->buf + ctx->curlen, in, (size_t)n); \ ctx->curlen += n; \ in += n; \ inlen -= n; \ if (ctx->curlen == block_size) { \ if ((err = compress_name (ctx, ctx->buf)) != CRYPT_OK) { \ return err; \ } \ ctx->length += 8*block_size; \ ctx->curlen = 0; \ } \ } \ } \ return CRYPT_OK; \ } #endif /* LTC_HASHCOMMON_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_md2_descriptor/ltc_md2.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_md2.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @param ltc_md2.c LTC_MD2 (RFC 1319) hash function implementation by Tom St Denis */ const ccDescriptor ltc_md2_desc = { .implementation_info = &cc_md2_impinfo, .dtype.digest.hashsize = CC_MD2_DIGEST_LENGTH, .dtype.digest.blocksize = CC_MD2_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_md2_init, .dtype.digest.process = <c_md2_process, .dtype.digest.done = <c_md2_done, }; static const unsigned char PI_SUBST[256] = { 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 }; /* adds 16 bytes to the checksum */ static void md2_update_chksum(ltc_md2_ctx *ctx) { int j; unsigned char L; LTC_ARGCHKVD(ctx != NULL); L = ctx->chksum[15]; for (j = 0; j < 16; j++) { /* caution, the RFC says its "C[j] = S[M[i*16+j] xor L]" but the * reference source code [and test vectors] say otherwise. */ L = (ctx->chksum[j] ^= PI_SUBST[(int)(ctx->buf[j] ^ L)] & 255); } } static void md2_compress(ltc_md2_ctx *ctx) { int j, k; unsigned char t; LTC_ARGCHKVD(ctx != NULL); /* copy block */ for (j = 0; j < 16; j++) { ctx->X[16+j] = ctx->buf[j]; ctx->X[32+j] = ctx->X[j] ^ ctx->X[16+j]; } t = (unsigned char)0; /* do 18 rounds */ for (j = 0; j < 18; j++) { for (k = 0; k < 48; k++) { t = (ctx->X[k] ^= PI_SUBST[(int)(t & 255)]); } t = (t + (unsigned char)j) & 255; } } /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_md2_init(ltc_md2_ctx *ctx) { LTC_ARGCHK(ctx != NULL); /* LTC_MD2 uses a zero'ed state... */ CC_XZEROMEM(ctx->X, sizeof(ctx->X)); CC_XZEROMEM(ctx->chksum, sizeof(ctx->chksum)); CC_XZEROMEM(ctx->buf, sizeof(ctx->buf)); ctx->curlen = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int ltc_md2_process(ltc_md2_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); if (ctx->curlen > sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } while (inlen > 0) { n = MIN(inlen, (16 - ctx->curlen)); CC_XMEMCPY(ctx->buf + ctx->curlen, in, (size_t)n); ctx->curlen += n; in += n; inlen -= n; /* is 16 bytes full? */ if (ctx->curlen == 16) { md2_compress(ctx); md2_update_chksum(ctx); ctx->curlen = 0; } } return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_md2_done(ltc_md2_ctx *ctx, unsigned char *out) { unsigned long i, k; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* pad the message */ k = 16 - ctx->curlen; for (i = ctx->curlen; i < 16; i++) { ctx->buf[i] = (unsigned char)k; } /* hash and update */ md2_compress(ctx); md2_update_chksum(ctx); /* hash checksum */ CC_XMEMCPY(ctx->buf, ctx->chksum, 16); md2_compress(ctx); /* output is lower 16 bytes of X */ CC_XMEMCPY(out, ctx->X, 16); #ifdef LTC_CLEAN_STACK CC_XZEROMEM(ctx, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_md2_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char md[16]; } tests[] = { { "", {0x83,0x50,0xe5,0xa3,0xe2,0x4c,0x15,0x3d, 0xf2,0x27,0x5c,0x9f,0x80,0x69,0x27,0x73 } }, { "a", {0x32,0xec,0x01,0xec,0x4a,0x6d,0xac,0x72, 0xc0,0xab,0x96,0xfb,0x34,0xc0,0xb5,0xd1 } }, { "message digest", {0xab,0x4f,0x49,0x6b,0xfb,0x2a,0x53,0x0b, 0x21,0x9f,0xf3,0x30,0x31,0xfe,0x06,0xb0 } }, { "abcdefghijklmnopqrstuvwxyz", {0x4e,0x8d,0xdf,0xf3,0x65,0x02,0x92,0xab, 0x5a,0x41,0x08,0xc3,0xaa,0x47,0x94,0x0b } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", {0xda,0x33,0xde,0xf2,0xa4,0x2d,0xf1,0x39, 0x75,0x35,0x28,0x46,0xc3,0x03,0x38,0xcd } }, { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", {0xd5,0x97,0x6f,0x79,0xd8,0x3d,0x3a,0x0d, 0xc9,0x80,0x6c,0x3c,0x66,0xf3,0xef,0xd8 } } }; int i; ltc_hash_state md; unsigned char buf[16]; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_md2_init(&md); ltc_md2_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_md2_done(&md, buf); if (LTC_XMEMCMP(buf, tests[i].md, 16) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif /* LTC_TEST */ } |
Added Source/descriptors/digestDescriptors/ltc_md2_descriptor/ltc_md2.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_md2.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #ifndef _LTC_MD2_H_ #define _LTC_MD2_H_ #define LTC_MD2_HASHSIZE 16 #define LTC_MD2_BLOCKSIZE 16 typedef struct ltc_md2_state { unsigned long curlen; unsigned char buf[LTC_MD2_BLOCKSIZE]; unsigned char chksum[16]; unsigned char X[48]; unsigned char paddingB[16]; } ltc_md2_ctx; int ltc_md2_init(ltc_md2_ctx *md); int ltc_md2_process(ltc_md2_ctx *md, const unsigned char *in, unsigned long inlen); int ltc_md2_done(ltc_md2_ctx *md, unsigned char *hash); int ltc_md2_test(void); #endif /* _LTC_MD2_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_md4_descriptor/ltc_md4.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_md4.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @param ltc_md4.c Submitted by Dobes Vandermeer (dobes@smartt.com) */ const ccDescriptor ltc_md4_desc = { .implementation_info = &cc_md4_impinfo, .dtype.digest.hashsize = CC_MD4_DIGEST_LENGTH, .dtype.digest.blocksize = CC_MD4_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_md4_init, .dtype.digest.process = <c_md4_process, .dtype.digest.done = <c_md4_done, }; #define S11 3 #define S12 7 #define S13 11 #define S14 19 #define S21 3 #define S22 5 #define S23 9 #define S24 13 #define S31 3 #define S32 9 #define S33 11 #define S34 15 /* F, G and H are basic LTC_MD4 functions. */ #define F(x, y, z) (z ^ (x & (y ^ z))) #define G(x, y, z) ((x & y) | (z & (x | y))) #define H(x, y, z) ((x) ^ (y) ^ (z)) /* ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) LTC_ROLc(x, n) /* FF, GG and HH are transformations for rounds 1, 2 and 3 */ /* Rotation is separate from addition to prevent recomputation */ #define FF(a, b, c, d, x, s) { \ (a) += F ((b), (c), (d)) + (x); \ (a) = ROTATE_LEFT ((a), (s)); \ } #define GG(a, b, c, d, x, s) { \ (a) += G ((b), (c), (d)) + (x) + 0x5a827999UL; \ (a) = ROTATE_LEFT ((a), (s)); \ } #define HH(a, b, c, d, x, s) { \ (a) += H ((b), (c), (d)) + (x) + 0x6ed9eba1UL; \ (a) = ROTATE_LEFT ((a), (s)); \ } #ifdef LTC_CLEAN_STACK static int _md4_compress(ltc_md4_ctx *ctx, const unsigned char *buf) #else static int md4_compress(ltc_md4_ctx *ctx, const unsigned char *buf) #endif { ulong32 x[16], a, b, c, d; int i; /* copy state */ a = ctx->state[0]; b = ctx->state[1]; c = ctx->state[2]; d = ctx->state[3]; /* copy the state into 512-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD32L(x[i], buf + (4*i)); } /* Round 1 */ FF (a, b, c, d, x[ 0], S11); /* 1 */ FF (d, a, b, c, x[ 1], S12); /* 2 */ FF (c, d, a, b, x[ 2], S13); /* 3 */ FF (b, c, d, a, x[ 3], S14); /* 4 */ FF (a, b, c, d, x[ 4], S11); /* 5 */ FF (d, a, b, c, x[ 5], S12); /* 6 */ FF (c, d, a, b, x[ 6], S13); /* 7 */ FF (b, c, d, a, x[ 7], S14); /* 8 */ FF (a, b, c, d, x[ 8], S11); /* 9 */ FF (d, a, b, c, x[ 9], S12); /* 10 */ FF (c, d, a, b, x[10], S13); /* 11 */ FF (b, c, d, a, x[11], S14); /* 12 */ FF (a, b, c, d, x[12], S11); /* 13 */ FF (d, a, b, c, x[13], S12); /* 14 */ FF (c, d, a, b, x[14], S13); /* 15 */ FF (b, c, d, a, x[15], S14); /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 0], S21); /* 17 */ GG (d, a, b, c, x[ 4], S22); /* 18 */ GG (c, d, a, b, x[ 8], S23); /* 19 */ GG (b, c, d, a, x[12], S24); /* 20 */ GG (a, b, c, d, x[ 1], S21); /* 21 */ GG (d, a, b, c, x[ 5], S22); /* 22 */ GG (c, d, a, b, x[ 9], S23); /* 23 */ GG (b, c, d, a, x[13], S24); /* 24 */ GG (a, b, c, d, x[ 2], S21); /* 25 */ GG (d, a, b, c, x[ 6], S22); /* 26 */ GG (c, d, a, b, x[10], S23); /* 27 */ GG (b, c, d, a, x[14], S24); /* 28 */ GG (a, b, c, d, x[ 3], S21); /* 29 */ GG (d, a, b, c, x[ 7], S22); /* 30 */ GG (c, d, a, b, x[11], S23); /* 31 */ GG (b, c, d, a, x[15], S24); /* 32 */ /* Round 3 */ HH (a, b, c, d, x[ 0], S31); /* 33 */ HH (d, a, b, c, x[ 8], S32); /* 34 */ HH (c, d, a, b, x[ 4], S33); /* 35 */ HH (b, c, d, a, x[12], S34); /* 36 */ HH (a, b, c, d, x[ 2], S31); /* 37 */ HH (d, a, b, c, x[10], S32); /* 38 */ HH (c, d, a, b, x[ 6], S33); /* 39 */ HH (b, c, d, a, x[14], S34); /* 40 */ HH (a, b, c, d, x[ 1], S31); /* 41 */ HH (d, a, b, c, x[ 9], S32); /* 42 */ HH (c, d, a, b, x[ 5], S33); /* 43 */ HH (b, c, d, a, x[13], S34); /* 44 */ HH (a, b, c, d, x[ 3], S31); /* 45 */ HH (d, a, b, c, x[11], S32); /* 46 */ HH (c, d, a, b, x[ 7], S33); /* 47 */ HH (b, c, d, a, x[15], S34); /* 48 */ /* Update our state */ ctx->state[0] = ctx->state[0] + a; ctx->state[1] = ctx->state[1] + b; ctx->state[2] = ctx->state[2] + c; ctx->state[3] = ctx->state[3] + d; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int md4_compress(ltc_md4_ctx *ctx, const unsigned char *buf) { int err; err = _md4_compress(ctx, buf); ltc_burn_stack(sizeof(ulong32) * 20 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_md4_init(ltc_md4_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->length = 0; ctx->curlen = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_md4_process, md4_compress, ltc_md4_ctx, md4, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_md4_done(ltc_md4_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } md4_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); md4_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 4; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(ltc_hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_md4_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct md4_test_case { const char *input; unsigned char digest[16]; } cases[] = { { "", {0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31, 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0} }, { "a", {0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46, 0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24} }, { "abc", {0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52, 0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d} }, { "message digest", {0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8, 0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b} }, { "abcdefghijklmnopqrstuvwxyz", {0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd, 0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9} }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", {0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35, 0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4} }, { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", {0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19, 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36} }, }; int i; ltc_hash_state md; unsigned char digest[16]; for(i = 0; i < (int)(sizeof(cases) / sizeof(cases[0])); i++) { ltc_md4_init(&md); ltc_md4_process(&md, (const unsigned char *)cases[i].input, (unsigned long)strlen(cases[i].input)); ltc_md4_done(&md, digest); if (LTC_XMEMCMP(digest, cases[i].digest, 16) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_md4_descriptor/ltc_md4.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_md4.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_MD4_H_ #define _LTC_MD4_H_ #define LTC_MD4_HASHSIZE 16 #define LTC_MD4_BLOCKSIZE 64 typedef struct ltc_md4_state { uint32_t state[4]; uint64_t length; unsigned char buf[LTC_MD4_BLOCKSIZE]; uint32_t curlen; } ltc_md4_ctx; int ltc_md4_init(ltc_md4_ctx *ctx); int ltc_md4_process(ltc_md4_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_md4_done(ltc_md4_ctx *ctx, unsigned char *hash); int ltc_md4_test(void); #endif /* _LTC_MD4_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_md5_descriptor/ltc_md5.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_md5.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file ltc_md5.c LTC_MD5 hash function by Tom St Denis */ const ccDescriptor ltc_md5_desc = { .implementation_info = &cc_md5_impinfo, .dtype.digest.hashsize = CC_MD5_DIGEST_LENGTH, .dtype.digest.blocksize = CC_MD5_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_md5_init, .dtype.digest.process = <c_md5_process, .dtype.digest.done = <c_md5_done, }; #define F(x,y,z) (z ^ (x & (y ^ z))) #define G(x,y,z) (y ^ (z & (y ^ x))) #define H(x,y,z) (x^y^z) #define I(x,y,z) (y^(x|(~z))) #ifdef LTC_SMALL_CODE #define FF(a,b,c,d,M,s,t) \ a = (a + F(b,c,d) + M + t); a = ROL(a, s) + b; #define GG(a,b,c,d,M,s,t) \ a = (a + G(b,c,d) + M + t); a = ROL(a, s) + b; #define HH(a,b,c,d,M,s,t) \ a = (a + H(b,c,d) + M + t); a = ROL(a, s) + b; #define II(a,b,c,d,M,s,t) \ a = (a + I(b,c,d) + M + t); a = ROL(a, s) + b; static const unsigned char Worder[64] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12, 5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2, 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 }; static const unsigned char Rorder[64] = { 7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22, 5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20, 4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23, 6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21 }; static const ulong32 Korder[64] = { 0xd76aa478UL, 0xe8c7b756UL, 0x242070dbUL, 0xc1bdceeeUL, 0xf57c0fafUL, 0x4787c62aUL, 0xa8304613UL, 0xfd469501UL, 0x698098d8UL, 0x8b44f7afUL, 0xffff5bb1UL, 0x895cd7beUL, 0x6b901122UL, 0xfd987193UL, 0xa679438eUL, 0x49b40821UL, 0xf61e2562UL, 0xc040b340UL, 0x265e5a51UL, 0xe9b6c7aaUL, 0xd62f105dUL, 0x02441453UL, 0xd8a1e681UL, 0xe7d3fbc8UL, 0x21e1cde6UL, 0xc33707d6UL, 0xf4d50d87UL, 0x455a14edUL, 0xa9e3e905UL, 0xfcefa3f8UL, 0x676f02d9UL, 0x8d2a4c8aUL, 0xfffa3942UL, 0x8771f681UL, 0x6d9d6122UL, 0xfde5380cUL, 0xa4beea44UL, 0x4bdecfa9UL, 0xf6bb4b60UL, 0xbebfbc70UL, 0x289b7ec6UL, 0xeaa127faUL, 0xd4ef3085UL, 0x04881d05UL, 0xd9d4d039UL, 0xe6db99e5UL, 0x1fa27cf8UL, 0xc4ac5665UL, 0xf4292244UL, 0x432aff97UL, 0xab9423a7UL, 0xfc93a039UL, 0x655b59c3UL, 0x8f0ccc92UL, 0xffeff47dUL, 0x85845dd1UL, 0x6fa87e4fUL, 0xfe2ce6e0UL, 0xa3014314UL, 0x4e0811a1UL, 0xf7537e82UL, 0xbd3af235UL, 0x2ad7d2bbUL, 0xeb86d391UL }; #else #define FF(a,b,c,d,M,s,t) \ a = (a + F(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define GG(a,b,c,d,M,s,t) \ a = (a + G(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define HH(a,b,c,d,M,s,t) \ a = (a + H(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define II(a,b,c,d,M,s,t) \ a = (a + I(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #endif #ifdef LTC_CLEAN_STACK static int _md5_compress(ltc_md5_ctx *ctx, const unsigned char *buf) #else static int md5_compress(ltc_md5_ctx *ctx, const unsigned char *buf) #endif { ulong32 i, W[16], a, b, c, d; #ifdef LTC_SMALL_CODE ulong32 t; #endif /* copy the state into 512-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD32L(W[i], buf + (4*i)); } /* copy state */ a = ctx->state[0]; b = ctx->state[1]; c = ctx->state[2]; d = ctx->state[3]; #ifdef LTC_SMALL_CODE for (i = 0; i < 16; ++i) { FF(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 32; ++i) { GG(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 48; ++i) { HH(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 64; ++i) { II(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } #else FF(a,b,c,d,W[0],7,0xd76aa478UL) FF(d,a,b,c,W[1],12,0xe8c7b756UL) FF(c,d,a,b,W[2],17,0x242070dbUL) FF(b,c,d,a,W[3],22,0xc1bdceeeUL) FF(a,b,c,d,W[4],7,0xf57c0fafUL) FF(d,a,b,c,W[5],12,0x4787c62aUL) FF(c,d,a,b,W[6],17,0xa8304613UL) FF(b,c,d,a,W[7],22,0xfd469501UL) FF(a,b,c,d,W[8],7,0x698098d8UL) FF(d,a,b,c,W[9],12,0x8b44f7afUL) FF(c,d,a,b,W[10],17,0xffff5bb1UL) FF(b,c,d,a,W[11],22,0x895cd7beUL) FF(a,b,c,d,W[12],7,0x6b901122UL) FF(d,a,b,c,W[13],12,0xfd987193UL) FF(c,d,a,b,W[14],17,0xa679438eUL) FF(b,c,d,a,W[15],22,0x49b40821UL) GG(a,b,c,d,W[1],5,0xf61e2562UL) GG(d,a,b,c,W[6],9,0xc040b340UL) GG(c,d,a,b,W[11],14,0x265e5a51UL) GG(b,c,d,a,W[0],20,0xe9b6c7aaUL) GG(a,b,c,d,W[5],5,0xd62f105dUL) GG(d,a,b,c,W[10],9,0x02441453UL) GG(c,d,a,b,W[15],14,0xd8a1e681UL) GG(b,c,d,a,W[4],20,0xe7d3fbc8UL) GG(a,b,c,d,W[9],5,0x21e1cde6UL) GG(d,a,b,c,W[14],9,0xc33707d6UL) GG(c,d,a,b,W[3],14,0xf4d50d87UL) GG(b,c,d,a,W[8],20,0x455a14edUL) GG(a,b,c,d,W[13],5,0xa9e3e905UL) GG(d,a,b,c,W[2],9,0xfcefa3f8UL) GG(c,d,a,b,W[7],14,0x676f02d9UL) GG(b,c,d,a,W[12],20,0x8d2a4c8aUL) HH(a,b,c,d,W[5],4,0xfffa3942UL) HH(d,a,b,c,W[8],11,0x8771f681UL) HH(c,d,a,b,W[11],16,0x6d9d6122UL) HH(b,c,d,a,W[14],23,0xfde5380cUL) HH(a,b,c,d,W[1],4,0xa4beea44UL) HH(d,a,b,c,W[4],11,0x4bdecfa9UL) HH(c,d,a,b,W[7],16,0xf6bb4b60UL) HH(b,c,d,a,W[10],23,0xbebfbc70UL) HH(a,b,c,d,W[13],4,0x289b7ec6UL) HH(d,a,b,c,W[0],11,0xeaa127faUL) HH(c,d,a,b,W[3],16,0xd4ef3085UL) HH(b,c,d,a,W[6],23,0x04881d05UL) HH(a,b,c,d,W[9],4,0xd9d4d039UL) HH(d,a,b,c,W[12],11,0xe6db99e5UL) HH(c,d,a,b,W[15],16,0x1fa27cf8UL) HH(b,c,d,a,W[2],23,0xc4ac5665UL) II(a,b,c,d,W[0],6,0xf4292244UL) II(d,a,b,c,W[7],10,0x432aff97UL) II(c,d,a,b,W[14],15,0xab9423a7UL) II(b,c,d,a,W[5],21,0xfc93a039UL) II(a,b,c,d,W[12],6,0x655b59c3UL) II(d,a,b,c,W[3],10,0x8f0ccc92UL) II(c,d,a,b,W[10],15,0xffeff47dUL) II(b,c,d,a,W[1],21,0x85845dd1UL) II(a,b,c,d,W[8],6,0x6fa87e4fUL) II(d,a,b,c,W[15],10,0xfe2ce6e0UL) II(c,d,a,b,W[6],15,0xa3014314UL) II(b,c,d,a,W[13],21,0x4e0811a1UL) II(a,b,c,d,W[4],6,0xf7537e82UL) II(d,a,b,c,W[11],10,0xbd3af235UL) II(c,d,a,b,W[2],15,0x2ad7d2bbUL) II(b,c,d,a,W[9],21,0xeb86d391UL) #endif ctx->state[0] = ctx->state[0] + a; ctx->state[1] = ctx->state[1] + b; ctx->state[2] = ctx->state[2] + c; ctx->state[3] = ctx->state[3] + d; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int md5_compress(ltc_md5_ctx *ctx, const unsigned char *buf) { int err; err = _md5_compress(ctx, buf); // ltc_burn_stack(sizeof(ulong32) * 21); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_md5_init(ltc_md5_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ // LTC_HASH_PROCESS(ltc_md5_process, md5_compress, ltc_md5_ctx, md5, 64) int ltc_md5_process(ltc_md5_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); if (ctx->curlen > sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (ctx->curlen == 0 && inlen >= LTC_MD5_BLOCKSIZE) { if ((err = md5_compress(ctx, in)) != CRYPT_OK) { return err; } ctx->length += LTC_MD5_BLOCKSIZE * 8; in += LTC_MD5_BLOCKSIZE; inlen -= LTC_MD5_BLOCKSIZE; } else { n = MIN(inlen, (LTC_MD5_BLOCKSIZE - ctx->curlen)); CC_XMEMCPY(ctx->buf + ctx->curlen, in, n); ctx->curlen += n; in += n; inlen -= n; if (ctx->curlen == LTC_MD5_BLOCKSIZE) { if ((err = md5_compress(ctx, ctx->buf)) != CRYPT_OK) { return err; } ctx->length += 8*LTC_MD5_BLOCKSIZE; ctx->curlen = 0; } } } return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_md5_done(ltc_md5_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } md5_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); md5_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 4; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } ctx->curlen = 0; return CRYPT_OK; } |
Added Source/descriptors/digestDescriptors/ltc_md5_descriptor/ltc_md5.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_md5.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_MD5_H_ #define _LTC_MD5_H_ #define LTC_MD5_HASHSIZE 16 #define LTC_MD5_BLOCKSIZE 64 typedef struct ltc_md5_state { uint32_t state[4]; uint64_t length; unsigned char buf[LTC_MD5_BLOCKSIZE]; uint32_t curlen; } ltc_md5_ctx; int ltc_md5_init(ltc_md5_ctx *ctx); int ltc_md5_process(ltc_md5_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_md5_done(ltc_md5_ctx *ctx, unsigned char *hash); int ltc_md5_test(void); #endif /* _LTC_MD5_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_md5_descriptor/ltc_md5/ltc_md5.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" /** @file ltc_md5.c LTC_MD5 hash function by Tom St Denis */ #ifdef LTC_MD5 cc_implementation_info ltc_md5_impinfo = { .suiteMask = CC_COMPATIBILITY_SUITE, .name = "md5", .classification_id = digest, .identifier = LTC_MD5_ID, }; const struct ltc_hash_descriptor ltc_md5_desc = { .implementation_info = <c_md5_impinfo, .hashsize = LTC_MD5_HASHSIZE, .blocksize = LTC_MD5_BLOCKSIZE, .OID = { 1, 2, 840, 113549, 2, 5, }, .OIDlen = 6, .init = <c_md5_init, .process = <c_md5_process, .done = <c_md5_done, .test = <c_md5_test, .hmac_block = NULL }; #define F(x,y,z) (z ^ (x & (y ^ z))) #define G(x,y,z) (y ^ (z & (y ^ x))) #define H(x,y,z) (x^y^z) #define I(x,y,z) (y^(x|(~z))) #ifdef LTC_SMALL_CODE #define FF(a,b,c,d,M,s,t) \ a = (a + F(b,c,d) + M + t); a = ROL(a, s) + b; #define GG(a,b,c,d,M,s,t) \ a = (a + G(b,c,d) + M + t); a = ROL(a, s) + b; #define HH(a,b,c,d,M,s,t) \ a = (a + H(b,c,d) + M + t); a = ROL(a, s) + b; #define II(a,b,c,d,M,s,t) \ a = (a + I(b,c,d) + M + t); a = ROL(a, s) + b; static const unsigned char Worder[64] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12, 5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2, 0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9 }; static const unsigned char Rorder[64] = { 7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22, 5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20, 4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23, 6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21 }; static const ulong32 Korder[64] = { 0xd76aa478UL, 0xe8c7b756UL, 0x242070dbUL, 0xc1bdceeeUL, 0xf57c0fafUL, 0x4787c62aUL, 0xa8304613UL, 0xfd469501UL, 0x698098d8UL, 0x8b44f7afUL, 0xffff5bb1UL, 0x895cd7beUL, 0x6b901122UL, 0xfd987193UL, 0xa679438eUL, 0x49b40821UL, 0xf61e2562UL, 0xc040b340UL, 0x265e5a51UL, 0xe9b6c7aaUL, 0xd62f105dUL, 0x02441453UL, 0xd8a1e681UL, 0xe7d3fbc8UL, 0x21e1cde6UL, 0xc33707d6UL, 0xf4d50d87UL, 0x455a14edUL, 0xa9e3e905UL, 0xfcefa3f8UL, 0x676f02d9UL, 0x8d2a4c8aUL, 0xfffa3942UL, 0x8771f681UL, 0x6d9d6122UL, 0xfde5380cUL, 0xa4beea44UL, 0x4bdecfa9UL, 0xf6bb4b60UL, 0xbebfbc70UL, 0x289b7ec6UL, 0xeaa127faUL, 0xd4ef3085UL, 0x04881d05UL, 0xd9d4d039UL, 0xe6db99e5UL, 0x1fa27cf8UL, 0xc4ac5665UL, 0xf4292244UL, 0x432aff97UL, 0xab9423a7UL, 0xfc93a039UL, 0x655b59c3UL, 0x8f0ccc92UL, 0xffeff47dUL, 0x85845dd1UL, 0x6fa87e4fUL, 0xfe2ce6e0UL, 0xa3014314UL, 0x4e0811a1UL, 0xf7537e82UL, 0xbd3af235UL, 0x2ad7d2bbUL, 0xeb86d391UL }; #else #define FF(a,b,c,d,M,s,t) \ a = (a + F(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define GG(a,b,c,d,M,s,t) \ a = (a + G(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define HH(a,b,c,d,M,s,t) \ a = (a + H(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #define II(a,b,c,d,M,s,t) \ a = (a + I(b,c,d) + M + t); a = LTC_ROLc(a, s) + b; #endif #ifdef LTC_CLEAN_STACK static int _md5_compress(ltc_hstate_ptr md, const unsigned char *buf) #else static int md5_compress(ltc_hstate_ptr md, const unsigned char *buf) #endif { ulong32 i, W[16], a, b, c, d; #ifdef LTC_SMALL_CODE ulong32 t; #endif ltc_md5_ctx *ctx; ctx = &md->md5; /* copy the state into 512-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD32L(W[i], buf + (4*i)); } /* copy state */ a = ctx->state[0]; b = ctx->state[1]; c = ctx->state[2]; d = ctx->state[3]; #ifdef LTC_SMALL_CODE for (i = 0; i < 16; ++i) { FF(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 32; ++i) { GG(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 48; ++i) { HH(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } for (; i < 64; ++i) { II(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); t = d; d = c; c = b; b = a; a = t; } #else FF(a,b,c,d,W[0],7,0xd76aa478UL) FF(d,a,b,c,W[1],12,0xe8c7b756UL) FF(c,d,a,b,W[2],17,0x242070dbUL) FF(b,c,d,a,W[3],22,0xc1bdceeeUL) FF(a,b,c,d,W[4],7,0xf57c0fafUL) FF(d,a,b,c,W[5],12,0x4787c62aUL) FF(c,d,a,b,W[6],17,0xa8304613UL) FF(b,c,d,a,W[7],22,0xfd469501UL) FF(a,b,c,d,W[8],7,0x698098d8UL) FF(d,a,b,c,W[9],12,0x8b44f7afUL) FF(c,d,a,b,W[10],17,0xffff5bb1UL) FF(b,c,d,a,W[11],22,0x895cd7beUL) FF(a,b,c,d,W[12],7,0x6b901122UL) FF(d,a,b,c,W[13],12,0xfd987193UL) FF(c,d,a,b,W[14],17,0xa679438eUL) FF(b,c,d,a,W[15],22,0x49b40821UL) GG(a,b,c,d,W[1],5,0xf61e2562UL) GG(d,a,b,c,W[6],9,0xc040b340UL) GG(c,d,a,b,W[11],14,0x265e5a51UL) GG(b,c,d,a,W[0],20,0xe9b6c7aaUL) GG(a,b,c,d,W[5],5,0xd62f105dUL) GG(d,a,b,c,W[10],9,0x02441453UL) GG(c,d,a,b,W[15],14,0xd8a1e681UL) GG(b,c,d,a,W[4],20,0xe7d3fbc8UL) GG(a,b,c,d,W[9],5,0x21e1cde6UL) GG(d,a,b,c,W[14],9,0xc33707d6UL) GG(c,d,a,b,W[3],14,0xf4d50d87UL) GG(b,c,d,a,W[8],20,0x455a14edUL) GG(a,b,c,d,W[13],5,0xa9e3e905UL) GG(d,a,b,c,W[2],9,0xfcefa3f8UL) GG(c,d,a,b,W[7],14,0x676f02d9UL) GG(b,c,d,a,W[12],20,0x8d2a4c8aUL) HH(a,b,c,d,W[5],4,0xfffa3942UL) HH(d,a,b,c,W[8],11,0x8771f681UL) HH(c,d,a,b,W[11],16,0x6d9d6122UL) HH(b,c,d,a,W[14],23,0xfde5380cUL) HH(a,b,c,d,W[1],4,0xa4beea44UL) HH(d,a,b,c,W[4],11,0x4bdecfa9UL) HH(c,d,a,b,W[7],16,0xf6bb4b60UL) HH(b,c,d,a,W[10],23,0xbebfbc70UL) HH(a,b,c,d,W[13],4,0x289b7ec6UL) HH(d,a,b,c,W[0],11,0xeaa127faUL) HH(c,d,a,b,W[3],16,0xd4ef3085UL) HH(b,c,d,a,W[6],23,0x04881d05UL) HH(a,b,c,d,W[9],4,0xd9d4d039UL) HH(d,a,b,c,W[12],11,0xe6db99e5UL) HH(c,d,a,b,W[15],16,0x1fa27cf8UL) HH(b,c,d,a,W[2],23,0xc4ac5665UL) II(a,b,c,d,W[0],6,0xf4292244UL) II(d,a,b,c,W[7],10,0x432aff97UL) II(c,d,a,b,W[14],15,0xab9423a7UL) II(b,c,d,a,W[5],21,0xfc93a039UL) II(a,b,c,d,W[12],6,0x655b59c3UL) II(d,a,b,c,W[3],10,0x8f0ccc92UL) II(c,d,a,b,W[10],15,0xffeff47dUL) II(b,c,d,a,W[1],21,0x85845dd1UL) II(a,b,c,d,W[8],6,0x6fa87e4fUL) II(d,a,b,c,W[15],10,0xfe2ce6e0UL) II(c,d,a,b,W[6],15,0xa3014314UL) II(b,c,d,a,W[13],21,0x4e0811a1UL) II(a,b,c,d,W[4],6,0xf7537e82UL) II(d,a,b,c,W[11],10,0xbd3af235UL) II(c,d,a,b,W[2],15,0x2ad7d2bbUL) II(b,c,d,a,W[9],21,0xeb86d391UL) #endif ctx->state[0] = ctx->state[0] + a; ctx->state[1] = ctx->state[1] + b; ctx->state[2] = ctx->state[2] + c; ctx->state[3] = ctx->state[3] + d; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int md5_compress(ltc_hstate_ptr md, const unsigned char *buf) { int err; err = _md5_compress(md, buf); ltc_burn_stack(sizeof(ulong32) * 21); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_md5_init(ltc_hstate_ptr md) { ltc_md5_ctx *ctx; LTC_ARGCHK(md != NULL); ctx = &md->md5; ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_md5_process, md5_compress, ltc_md5_ctx, md5, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_md5_done(ltc_hstate_ptr md, unsigned char *out) { int i; ltc_md5_ctx *ctx; LTC_ARGCHK(md != NULL); LTC_ARGCHK(out != NULL); ctx = &md->md5; if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } md5_compress(md, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); md5_compress(md, ctx->buf); /* copy output */ for (i = 0; i < 4; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_md5_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[16]; } tests[] = { { "", { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, { "a", {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, { "abc", { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, { "message digest", { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, { "abcdefghijklmnopqrstuvwxyz", { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, { NULL, { 0 } } }; int i; unsigned char tmp[16]; ltc_hash_state md; for (i = 0; tests[i].msg != NULL; i++) { ltc_md5_init(&md); ltc_md5_process(&md, (const unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_md5_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 16) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } #endif /* LTC_MD5 */ |
Added Source/descriptors/digestDescriptors/ltc_md5_descriptor/ltc_md5/ltc_md5.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_md5.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #ifndef _LTC_MD5_H_ #define _LTC_MD5_H_ #define LTC_MD5_HASHSIZE 16 #define LTC_MD5_BLOCKSIZE 64 typedef struct ltc_md5_state { ulong64 length; ulong32 state[4], curlen; unsigned char buf[LTC_MD5_BLOCKSIZE]; } ltc_md5_ctx; int ltc_md5_init(ltc_hstate_ptr md); int ltc_md5_process(ltc_hstate_ptr md, const unsigned char *in, unsigned long inlen); int ltc_md5_done(ltc_hstate_ptr md, unsigned char *hash); int ltc_md5_test(void); extern const struct ltc_hash_descriptor ltc_md5_desc; #endif /* _LTC_MD5_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd128.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_rmd128.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" /** @param ltc_rmd128.c RMD128 Hash function */ /* Implementation of LTC_RIPEMD-128 based on the source by Antoon Bosselaers, * ESAT-COSIC * * This source has been radically overhauled to be portable and work within * the LibTomCrypt API by Tom St Denis */ const ccDescriptor ltc_rmd128_desc = { .implementation_info = &cc_rmd128_impinfo, .dtype.digest.hashsize = CC_RMD128_DIGEST_LENGTH, .dtype.digest.blocksize = CC_RMD128_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_rmd128_init, .dtype.digest.process = <c_rmd128_process, .dtype.digest.done = <c_rmd128_done, }; /* the four basic functions F(), G() and H() */ #define F(x, y, z) ((x) ^ (y) ^ (z)) #define G(x, y, z) (((x) & (y)) | (~(x) & (z))) #define H(x, y, z) (((x) | ~(y)) ^ (z)) #define I(x, y, z) (((x) & (z)) | ((y) & ~(z))) /* the eight basic operations FF() through III() */ #define FF(a, b, c, d, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)); #define GG(a, b, c, d, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\ (a) = LTC_ROLc((a), (s)); #define HH(a, b, c, d, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\ (a) = LTC_ROLc((a), (s)); #define II(a, b, c, d, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\ (a) = LTC_ROLc((a), (s)); #define FFF(a, b, c, d, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)); #define GGG(a, b, c, d, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x6d703ef3UL;\ (a) = LTC_ROLc((a), (s)); #define HHH(a, b, c, d, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x5c4dd124UL;\ (a) = LTC_ROLc((a), (s)); #define III(a, b, c, d, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x50a28be6UL;\ (a) = LTC_ROLc((a), (s)); #ifdef LTC_CLEAN_STACK static int _rmd128_compress(ltc_rmd128_ctx *ctx, const unsigned char *buf) #else static int rmd128_compress(ltc_rmd128_ctx *ctx, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16]; int i; /* load words X */ for (i = 0; i < 16; i++){ LTC_LOAD32L(X[i], buf + (4 * i)); } /* load state */ aa = aaa = ctx->state[0]; bb = bbb = ctx->state[1]; cc = ccc = ctx->state[2]; dd = ddd = ctx->state[3]; /* round 1 */ FF(aa, bb, cc, dd, X[ 0], 11); FF(dd, aa, bb, cc, X[ 1], 14); FF(cc, dd, aa, bb, X[ 2], 15); FF(bb, cc, dd, aa, X[ 3], 12); FF(aa, bb, cc, dd, X[ 4], 5); FF(dd, aa, bb, cc, X[ 5], 8); FF(cc, dd, aa, bb, X[ 6], 7); FF(bb, cc, dd, aa, X[ 7], 9); FF(aa, bb, cc, dd, X[ 8], 11); FF(dd, aa, bb, cc, X[ 9], 13); FF(cc, dd, aa, bb, X[10], 14); FF(bb, cc, dd, aa, X[11], 15); FF(aa, bb, cc, dd, X[12], 6); FF(dd, aa, bb, cc, X[13], 7); FF(cc, dd, aa, bb, X[14], 9); FF(bb, cc, dd, aa, X[15], 8); /* round 2 */ GG(aa, bb, cc, dd, X[ 7], 7); GG(dd, aa, bb, cc, X[ 4], 6); GG(cc, dd, aa, bb, X[13], 8); GG(bb, cc, dd, aa, X[ 1], 13); GG(aa, bb, cc, dd, X[10], 11); GG(dd, aa, bb, cc, X[ 6], 9); GG(cc, dd, aa, bb, X[15], 7); GG(bb, cc, dd, aa, X[ 3], 15); GG(aa, bb, cc, dd, X[12], 7); GG(dd, aa, bb, cc, X[ 0], 12); GG(cc, dd, aa, bb, X[ 9], 15); GG(bb, cc, dd, aa, X[ 5], 9); GG(aa, bb, cc, dd, X[ 2], 11); GG(dd, aa, bb, cc, X[14], 7); GG(cc, dd, aa, bb, X[11], 13); GG(bb, cc, dd, aa, X[ 8], 12); /* round 3 */ HH(aa, bb, cc, dd, X[ 3], 11); HH(dd, aa, bb, cc, X[10], 13); HH(cc, dd, aa, bb, X[14], 6); HH(bb, cc, dd, aa, X[ 4], 7); HH(aa, bb, cc, dd, X[ 9], 14); HH(dd, aa, bb, cc, X[15], 9); HH(cc, dd, aa, bb, X[ 8], 13); HH(bb, cc, dd, aa, X[ 1], 15); HH(aa, bb, cc, dd, X[ 2], 14); HH(dd, aa, bb, cc, X[ 7], 8); HH(cc, dd, aa, bb, X[ 0], 13); HH(bb, cc, dd, aa, X[ 6], 6); HH(aa, bb, cc, dd, X[13], 5); HH(dd, aa, bb, cc, X[11], 12); HH(cc, dd, aa, bb, X[ 5], 7); HH(bb, cc, dd, aa, X[12], 5); /* round 4 */ II(aa, bb, cc, dd, X[ 1], 11); II(dd, aa, bb, cc, X[ 9], 12); II(cc, dd, aa, bb, X[11], 14); II(bb, cc, dd, aa, X[10], 15); II(aa, bb, cc, dd, X[ 0], 14); II(dd, aa, bb, cc, X[ 8], 15); II(cc, dd, aa, bb, X[12], 9); II(bb, cc, dd, aa, X[ 4], 8); II(aa, bb, cc, dd, X[13], 9); II(dd, aa, bb, cc, X[ 3], 14); II(cc, dd, aa, bb, X[ 7], 5); II(bb, cc, dd, aa, X[15], 6); II(aa, bb, cc, dd, X[14], 8); II(dd, aa, bb, cc, X[ 5], 6); II(cc, dd, aa, bb, X[ 6], 5); II(bb, cc, dd, aa, X[ 2], 12); /* parallel round 1 */ III(aaa, bbb, ccc, ddd, X[ 5], 8); III(ddd, aaa, bbb, ccc, X[14], 9); III(ccc, ddd, aaa, bbb, X[ 7], 9); III(bbb, ccc, ddd, aaa, X[ 0], 11); III(aaa, bbb, ccc, ddd, X[ 9], 13); III(ddd, aaa, bbb, ccc, X[ 2], 15); III(ccc, ddd, aaa, bbb, X[11], 15); III(bbb, ccc, ddd, aaa, X[ 4], 5); III(aaa, bbb, ccc, ddd, X[13], 7); III(ddd, aaa, bbb, ccc, X[ 6], 7); III(ccc, ddd, aaa, bbb, X[15], 8); III(bbb, ccc, ddd, aaa, X[ 8], 11); III(aaa, bbb, ccc, ddd, X[ 1], 14); III(ddd, aaa, bbb, ccc, X[10], 14); III(ccc, ddd, aaa, bbb, X[ 3], 12); III(bbb, ccc, ddd, aaa, X[12], 6); /* parallel round 2 */ HHH(aaa, bbb, ccc, ddd, X[ 6], 9); HHH(ddd, aaa, bbb, ccc, X[11], 13); HHH(ccc, ddd, aaa, bbb, X[ 3], 15); HHH(bbb, ccc, ddd, aaa, X[ 7], 7); HHH(aaa, bbb, ccc, ddd, X[ 0], 12); HHH(ddd, aaa, bbb, ccc, X[13], 8); HHH(ccc, ddd, aaa, bbb, X[ 5], 9); HHH(bbb, ccc, ddd, aaa, X[10], 11); HHH(aaa, bbb, ccc, ddd, X[14], 7); HHH(ddd, aaa, bbb, ccc, X[15], 7); HHH(ccc, ddd, aaa, bbb, X[ 8], 12); HHH(bbb, ccc, ddd, aaa, X[12], 7); HHH(aaa, bbb, ccc, ddd, X[ 4], 6); HHH(ddd, aaa, bbb, ccc, X[ 9], 15); HHH(ccc, ddd, aaa, bbb, X[ 1], 13); HHH(bbb, ccc, ddd, aaa, X[ 2], 11); /* parallel round 3 */ GGG(aaa, bbb, ccc, ddd, X[15], 9); GGG(ddd, aaa, bbb, ccc, X[ 5], 7); GGG(ccc, ddd, aaa, bbb, X[ 1], 15); GGG(bbb, ccc, ddd, aaa, X[ 3], 11); GGG(aaa, bbb, ccc, ddd, X[ 7], 8); GGG(ddd, aaa, bbb, ccc, X[14], 6); GGG(ccc, ddd, aaa, bbb, X[ 6], 6); GGG(bbb, ccc, ddd, aaa, X[ 9], 14); GGG(aaa, bbb, ccc, ddd, X[11], 12); GGG(ddd, aaa, bbb, ccc, X[ 8], 13); GGG(ccc, ddd, aaa, bbb, X[12], 5); GGG(bbb, ccc, ddd, aaa, X[ 2], 14); GGG(aaa, bbb, ccc, ddd, X[10], 13); GGG(ddd, aaa, bbb, ccc, X[ 0], 13); GGG(ccc, ddd, aaa, bbb, X[ 4], 7); GGG(bbb, ccc, ddd, aaa, X[13], 5); /* parallel round 4 */ FFF(aaa, bbb, ccc, ddd, X[ 8], 15); FFF(ddd, aaa, bbb, ccc, X[ 6], 5); FFF(ccc, ddd, aaa, bbb, X[ 4], 8); FFF(bbb, ccc, ddd, aaa, X[ 1], 11); FFF(aaa, bbb, ccc, ddd, X[ 3], 14); FFF(ddd, aaa, bbb, ccc, X[11], 14); FFF(ccc, ddd, aaa, bbb, X[15], 6); FFF(bbb, ccc, ddd, aaa, X[ 0], 14); FFF(aaa, bbb, ccc, ddd, X[ 5], 6); FFF(ddd, aaa, bbb, ccc, X[12], 9); FFF(ccc, ddd, aaa, bbb, X[ 2], 12); FFF(bbb, ccc, ddd, aaa, X[13], 9); FFF(aaa, bbb, ccc, ddd, X[ 9], 12); FFF(ddd, aaa, bbb, ccc, X[ 7], 5); FFF(ccc, ddd, aaa, bbb, X[10], 15); FFF(bbb, ccc, ddd, aaa, X[14], 8); /* combine results */ ddd += cc + ctx->state[1]; /* final result for MDbuf[0] */ ctx->state[1] = ctx->state[2] + dd + aaa; ctx->state[2] = ctx->state[3] + aa + bbb; ctx->state[3] = ctx->state[0] + bb + ccc; ctx->state[0] = ddd; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int rmd128_compress(ltc_rmd128_ctx *ctx, const unsigned char *buf) { int err; err = _rmd128_compress(md, buf); ltc_burn_stack(sizeof(ulong32) * 24 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_rmd128_init(ltc_rmd128_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_rmd128_process, rmd128_compress, ltc_rmd128_ctx, rmd128, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_rmd128_done(ltc_rmd128_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } rmd128_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); rmd128_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 4; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(ltc_hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_rmd128_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char md[16]; } tests[] = { { "", { 0xcd, 0xf2, 0x62, 0x13, 0xa1, 0x50, 0xdc, 0x3e, 0xcb, 0x61, 0x0f, 0x18, 0xf6, 0xb3, 0x8b, 0x46 } }, { "a", { 0x86, 0xbe, 0x7a, 0xfa, 0x33, 0x9d, 0x0f, 0xc7, 0xcf, 0xc7, 0x85, 0xe7, 0x2f, 0x57, 0x8d, 0x33 } }, { "abc", { 0xc1, 0x4a, 0x12, 0x19, 0x9c, 0x66, 0xe4, 0xba, 0x84, 0x63, 0x6b, 0x0f, 0x69, 0x14, 0x4c, 0x77 } }, { "message digest", { 0x9e, 0x32, 0x7b, 0x3d, 0x6e, 0x52, 0x30, 0x62, 0xaf, 0xc1, 0x13, 0x2d, 0x7d, 0xf9, 0xd1, 0xb8 } }, { "abcdefghijklmnopqrstuvwxyz", { 0xfd, 0x2a, 0xa6, 0x07, 0xf7, 0x1d, 0xc8, 0xf5, 0x10, 0x71, 0x49, 0x22, 0xb3, 0x71, 0x83, 0x4e } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", { 0xd1, 0xe9, 0x59, 0xeb, 0x17, 0x9c, 0x91, 0x1f, 0xae, 0xa4, 0x62, 0x4c, 0x60, 0xc5, 0xc7, 0x02 } } }; int x; unsigned char buf[16]; ltc_hash_state md; for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { ltc_rmd128_init(&md); ltc_rmd128_process(&md, (const unsigned char *)tests[x].msg, strlen(tests[x].msg)); ltc_rmd128_done(&md, buf); if (LTC_XMEMCMP(buf, tests[x].md, 16) != 0) { #if 0 printf("Failed test %d\n", x); #endif return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd128.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_rmd128.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_RMD128_H_ #define _LTC_RMD128_H_ #define LTC_RMD128_HASHSIZE 16 #define LTC_RMD128_BLOCKSIZE 64 typedef struct ltc_rmd128_state { uint64_t length; uint32_t state[4]; uint32_t curlen; unsigned char buf[LTC_RMD128_BLOCKSIZE]; } ltc_rmd128_ctx; int ltc_rmd128_init(ltc_rmd128_ctx *ctx); int ltc_rmd128_process(ltc_rmd128_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_rmd128_done(ltc_rmd128_ctx *ctx, unsigned char *hash); #endif /* _LTC_RMD128_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd160.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_rmd160.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" /** @file ltc_rmd160.c RMD160 hash function */ /* Implementation of LTC_RIPEMD-160 based on the source by Antoon Bosselaers, * ESAT-COSIC * * This source has been radically overhauled to be portable and work within * the LibTomCrypt API by Tom St Denis */ const ccDescriptor ltc_rmd160_desc = { .implementation_info = &cc_rmd160_impinfo, .dtype.digest.hashsize = CC_RMD160_DIGEST_LENGTH, .dtype.digest.blocksize = CC_RMD160_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_rmd160_init, .dtype.digest.process = <c_rmd160_process, .dtype.digest.done = <c_rmd160_done, }; /* the five basic functions F(), G() and H() */ #define F(x, y, z) ((x) ^ (y) ^ (z)) #define G(x, y, z) (((x) & (y)) | (~(x) & (z))) #define H(x, y, z) (((x) | ~(y)) ^ (z)) #define I(x, y, z) (((x) & (z)) | ((y) & ~(z))) #define J(x, y, z) ((x) ^ ((y) | ~(z))) /* the ten basic operations FF() through III() */ #define FF(a, b, c, d, e, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define GG(a, b, c, d, e, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define HH(a, b, c, d, e, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define II(a, b, c, d, e, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define JJ(a, b, c, d, e, x, s) \ (a) += J((b), (c), (d)) + (x) + 0xa953fd4eUL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define FFF(a, b, c, d, e, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define GGG(a, b, c, d, e, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define HHH(a, b, c, d, e, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6d703ef3UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define III(a, b, c, d, e, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x5c4dd124UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define JJJ(a, b, c, d, e, x, s) \ (a) += J((b), (c), (d)) + (x) + 0x50a28be6UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #ifdef LTC_CLEAN_STACK static int _rmd160_compress(ltc_rmd160_ctx *ctx, const unsigned char *buf) #else static int rmd160_compress(ltc_rmd160_ctx *ctx, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,X[16]; int i; /* load words X */ for (i = 0; i < 16; i++){ LTC_LOAD32L(X[i], buf + (4 * i)); } /* load state */ aa = aaa = ctx->state[0]; bb = bbb = ctx->state[1]; cc = ccc = ctx->state[2]; dd = ddd = ctx->state[3]; ee = eee = ctx->state[4]; /* round 1 */ FF(aa, bb, cc, dd, ee, X[ 0], 11); FF(ee, aa, bb, cc, dd, X[ 1], 14); FF(dd, ee, aa, bb, cc, X[ 2], 15); FF(cc, dd, ee, aa, bb, X[ 3], 12); FF(bb, cc, dd, ee, aa, X[ 4], 5); FF(aa, bb, cc, dd, ee, X[ 5], 8); FF(ee, aa, bb, cc, dd, X[ 6], 7); FF(dd, ee, aa, bb, cc, X[ 7], 9); FF(cc, dd, ee, aa, bb, X[ 8], 11); FF(bb, cc, dd, ee, aa, X[ 9], 13); FF(aa, bb, cc, dd, ee, X[10], 14); FF(ee, aa, bb, cc, dd, X[11], 15); FF(dd, ee, aa, bb, cc, X[12], 6); FF(cc, dd, ee, aa, bb, X[13], 7); FF(bb, cc, dd, ee, aa, X[14], 9); FF(aa, bb, cc, dd, ee, X[15], 8); /* round 2 */ GG(ee, aa, bb, cc, dd, X[ 7], 7); GG(dd, ee, aa, bb, cc, X[ 4], 6); GG(cc, dd, ee, aa, bb, X[13], 8); GG(bb, cc, dd, ee, aa, X[ 1], 13); GG(aa, bb, cc, dd, ee, X[10], 11); GG(ee, aa, bb, cc, dd, X[ 6], 9); GG(dd, ee, aa, bb, cc, X[15], 7); GG(cc, dd, ee, aa, bb, X[ 3], 15); GG(bb, cc, dd, ee, aa, X[12], 7); GG(aa, bb, cc, dd, ee, X[ 0], 12); GG(ee, aa, bb, cc, dd, X[ 9], 15); GG(dd, ee, aa, bb, cc, X[ 5], 9); GG(cc, dd, ee, aa, bb, X[ 2], 11); GG(bb, cc, dd, ee, aa, X[14], 7); GG(aa, bb, cc, dd, ee, X[11], 13); GG(ee, aa, bb, cc, dd, X[ 8], 12); /* round 3 */ HH(dd, ee, aa, bb, cc, X[ 3], 11); HH(cc, dd, ee, aa, bb, X[10], 13); HH(bb, cc, dd, ee, aa, X[14], 6); HH(aa, bb, cc, dd, ee, X[ 4], 7); HH(ee, aa, bb, cc, dd, X[ 9], 14); HH(dd, ee, aa, bb, cc, X[15], 9); HH(cc, dd, ee, aa, bb, X[ 8], 13); HH(bb, cc, dd, ee, aa, X[ 1], 15); HH(aa, bb, cc, dd, ee, X[ 2], 14); HH(ee, aa, bb, cc, dd, X[ 7], 8); HH(dd, ee, aa, bb, cc, X[ 0], 13); HH(cc, dd, ee, aa, bb, X[ 6], 6); HH(bb, cc, dd, ee, aa, X[13], 5); HH(aa, bb, cc, dd, ee, X[11], 12); HH(ee, aa, bb, cc, dd, X[ 5], 7); HH(dd, ee, aa, bb, cc, X[12], 5); /* round 4 */ II(cc, dd, ee, aa, bb, X[ 1], 11); II(bb, cc, dd, ee, aa, X[ 9], 12); II(aa, bb, cc, dd, ee, X[11], 14); II(ee, aa, bb, cc, dd, X[10], 15); II(dd, ee, aa, bb, cc, X[ 0], 14); II(cc, dd, ee, aa, bb, X[ 8], 15); II(bb, cc, dd, ee, aa, X[12], 9); II(aa, bb, cc, dd, ee, X[ 4], 8); II(ee, aa, bb, cc, dd, X[13], 9); II(dd, ee, aa, bb, cc, X[ 3], 14); II(cc, dd, ee, aa, bb, X[ 7], 5); II(bb, cc, dd, ee, aa, X[15], 6); II(aa, bb, cc, dd, ee, X[14], 8); II(ee, aa, bb, cc, dd, X[ 5], 6); II(dd, ee, aa, bb, cc, X[ 6], 5); II(cc, dd, ee, aa, bb, X[ 2], 12); /* round 5 */ JJ(bb, cc, dd, ee, aa, X[ 4], 9); JJ(aa, bb, cc, dd, ee, X[ 0], 15); JJ(ee, aa, bb, cc, dd, X[ 5], 5); JJ(dd, ee, aa, bb, cc, X[ 9], 11); JJ(cc, dd, ee, aa, bb, X[ 7], 6); JJ(bb, cc, dd, ee, aa, X[12], 8); JJ(aa, bb, cc, dd, ee, X[ 2], 13); JJ(ee, aa, bb, cc, dd, X[10], 12); JJ(dd, ee, aa, bb, cc, X[14], 5); JJ(cc, dd, ee, aa, bb, X[ 1], 12); JJ(bb, cc, dd, ee, aa, X[ 3], 13); JJ(aa, bb, cc, dd, ee, X[ 8], 14); JJ(ee, aa, bb, cc, dd, X[11], 11); JJ(dd, ee, aa, bb, cc, X[ 6], 8); JJ(cc, dd, ee, aa, bb, X[15], 5); JJ(bb, cc, dd, ee, aa, X[13], 6); /* parallel round 1 */ JJJ(aaa, bbb, ccc, ddd, eee, X[ 5], 8); JJJ(eee, aaa, bbb, ccc, ddd, X[14], 9); JJJ(ddd, eee, aaa, bbb, ccc, X[ 7], 9); JJJ(ccc, ddd, eee, aaa, bbb, X[ 0], 11); JJJ(bbb, ccc, ddd, eee, aaa, X[ 9], 13); JJJ(aaa, bbb, ccc, ddd, eee, X[ 2], 15); JJJ(eee, aaa, bbb, ccc, ddd, X[11], 15); JJJ(ddd, eee, aaa, bbb, ccc, X[ 4], 5); JJJ(ccc, ddd, eee, aaa, bbb, X[13], 7); JJJ(bbb, ccc, ddd, eee, aaa, X[ 6], 7); JJJ(aaa, bbb, ccc, ddd, eee, X[15], 8); JJJ(eee, aaa, bbb, ccc, ddd, X[ 8], 11); JJJ(ddd, eee, aaa, bbb, ccc, X[ 1], 14); JJJ(ccc, ddd, eee, aaa, bbb, X[10], 14); JJJ(bbb, ccc, ddd, eee, aaa, X[ 3], 12); JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6); /* parallel round 2 */ III(eee, aaa, bbb, ccc, ddd, X[ 6], 9); III(ddd, eee, aaa, bbb, ccc, X[11], 13); III(ccc, ddd, eee, aaa, bbb, X[ 3], 15); III(bbb, ccc, ddd, eee, aaa, X[ 7], 7); III(aaa, bbb, ccc, ddd, eee, X[ 0], 12); III(eee, aaa, bbb, ccc, ddd, X[13], 8); III(ddd, eee, aaa, bbb, ccc, X[ 5], 9); III(ccc, ddd, eee, aaa, bbb, X[10], 11); III(bbb, ccc, ddd, eee, aaa, X[14], 7); III(aaa, bbb, ccc, ddd, eee, X[15], 7); III(eee, aaa, bbb, ccc, ddd, X[ 8], 12); III(ddd, eee, aaa, bbb, ccc, X[12], 7); III(ccc, ddd, eee, aaa, bbb, X[ 4], 6); III(bbb, ccc, ddd, eee, aaa, X[ 9], 15); III(aaa, bbb, ccc, ddd, eee, X[ 1], 13); III(eee, aaa, bbb, ccc, ddd, X[ 2], 11); /* parallel round 3 */ HHH(ddd, eee, aaa, bbb, ccc, X[15], 9); HHH(ccc, ddd, eee, aaa, bbb, X[ 5], 7); HHH(bbb, ccc, ddd, eee, aaa, X[ 1], 15); HHH(aaa, bbb, ccc, ddd, eee, X[ 3], 11); HHH(eee, aaa, bbb, ccc, ddd, X[ 7], 8); HHH(ddd, eee, aaa, bbb, ccc, X[14], 6); HHH(ccc, ddd, eee, aaa, bbb, X[ 6], 6); HHH(bbb, ccc, ddd, eee, aaa, X[ 9], 14); HHH(aaa, bbb, ccc, ddd, eee, X[11], 12); HHH(eee, aaa, bbb, ccc, ddd, X[ 8], 13); HHH(ddd, eee, aaa, bbb, ccc, X[12], 5); HHH(ccc, ddd, eee, aaa, bbb, X[ 2], 14); HHH(bbb, ccc, ddd, eee, aaa, X[10], 13); HHH(aaa, bbb, ccc, ddd, eee, X[ 0], 13); HHH(eee, aaa, bbb, ccc, ddd, X[ 4], 7); HHH(ddd, eee, aaa, bbb, ccc, X[13], 5); /* parallel round 4 */ GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15); GGG(bbb, ccc, ddd, eee, aaa, X[ 6], 5); GGG(aaa, bbb, ccc, ddd, eee, X[ 4], 8); GGG(eee, aaa, bbb, ccc, ddd, X[ 1], 11); GGG(ddd, eee, aaa, bbb, ccc, X[ 3], 14); GGG(ccc, ddd, eee, aaa, bbb, X[11], 14); GGG(bbb, ccc, ddd, eee, aaa, X[15], 6); GGG(aaa, bbb, ccc, ddd, eee, X[ 0], 14); GGG(eee, aaa, bbb, ccc, ddd, X[ 5], 6); GGG(ddd, eee, aaa, bbb, ccc, X[12], 9); GGG(ccc, ddd, eee, aaa, bbb, X[ 2], 12); GGG(bbb, ccc, ddd, eee, aaa, X[13], 9); GGG(aaa, bbb, ccc, ddd, eee, X[ 9], 12); GGG(eee, aaa, bbb, ccc, ddd, X[ 7], 5); GGG(ddd, eee, aaa, bbb, ccc, X[10], 15); GGG(ccc, ddd, eee, aaa, bbb, X[14], 8); /* parallel round 5 */ FFF(bbb, ccc, ddd, eee, aaa, X[12] , 8); FFF(aaa, bbb, ccc, ddd, eee, X[15] , 5); FFF(eee, aaa, bbb, ccc, ddd, X[10] , 12); FFF(ddd, eee, aaa, bbb, ccc, X[ 4] , 9); FFF(ccc, ddd, eee, aaa, bbb, X[ 1] , 12); FFF(bbb, ccc, ddd, eee, aaa, X[ 5] , 5); FFF(aaa, bbb, ccc, ddd, eee, X[ 8] , 14); FFF(eee, aaa, bbb, ccc, ddd, X[ 7] , 6); FFF(ddd, eee, aaa, bbb, ccc, X[ 6] , 8); FFF(ccc, ddd, eee, aaa, bbb, X[ 2] , 13); FFF(bbb, ccc, ddd, eee, aaa, X[13] , 6); FFF(aaa, bbb, ccc, ddd, eee, X[14] , 5); FFF(eee, aaa, bbb, ccc, ddd, X[ 0] , 15); FFF(ddd, eee, aaa, bbb, ccc, X[ 3] , 13); FFF(ccc, ddd, eee, aaa, bbb, X[ 9] , 11); FFF(bbb, ccc, ddd, eee, aaa, X[11] , 11); /* combine results */ ddd += cc + ctx->state[1]; /* final result for ctx->state[0] */ ctx->state[1] = ctx->state[2] + dd + eee; ctx->state[2] = ctx->state[3] + ee + aaa; ctx->state[3] = ctx->state[4] + aa + bbb; ctx->state[4] = ctx->state[0] + bb + ccc; ctx->state[0] = ddd; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int rmd160_compress(ltc_rmd160_ctx *ctx, const unsigned char *buf) { int err; err = _rmd160_compress(md, buf); ltc_burn_stack(sizeof(ulong32) * 26 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_rmd160_init(ltc_rmd160_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0xc3d2e1f0UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_rmd160_process, rmd160_compress, ltc_rmd160_ctx, rmd160, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (20 bytes) @return CRYPT_OK if successful */ int ltc_rmd160_done(ltc_rmd160_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } rmd160_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); rmd160_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 5; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(ltc_hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_rmd160_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char md[20]; } tests[] = { { "", { 0x9c, 0x11, 0x85, 0xa5, 0xc5, 0xe9, 0xfc, 0x54, 0x61, 0x28, 0x08, 0x97, 0x7e, 0xe8, 0xf5, 0x48, 0xb2, 0x25, 0x8d, 0x31 } }, { "a", { 0x0b, 0xdc, 0x9d, 0x2d, 0x25, 0x6b, 0x3e, 0xe9, 0xda, 0xae, 0x34, 0x7b, 0xe6, 0xf4, 0xdc, 0x83, 0x5a, 0x46, 0x7f, 0xfe } }, { "abc", { 0x8e, 0xb2, 0x08, 0xf7, 0xe0, 0x5d, 0x98, 0x7a, 0x9b, 0x04, 0x4a, 0x8e, 0x98, 0xc6, 0xb0, 0x87, 0xf1, 0x5a, 0x0b, 0xfc } }, { "message digest", { 0x5d, 0x06, 0x89, 0xef, 0x49, 0xd2, 0xfa, 0xe5, 0x72, 0xb8, 0x81, 0xb1, 0x23, 0xa8, 0x5f, 0xfa, 0x21, 0x59, 0x5f, 0x36 } }, { "abcdefghijklmnopqrstuvwxyz", { 0xf7, 0x1c, 0x27, 0x10, 0x9c, 0x69, 0x2c, 0x1b, 0x56, 0xbb, 0xdc, 0xeb, 0x5b, 0x9d, 0x28, 0x65, 0xb3, 0x70, 0x8d, 0xbc } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0x12, 0xa0, 0x53, 0x38, 0x4a, 0x9c, 0x0c, 0x88, 0xe4, 0x05, 0xa0, 0x6c, 0x27, 0xdc, 0xf4, 0x9a, 0xda, 0x62, 0xeb, 0x2b } } }; int x; unsigned char buf[20]; ltc_hash_state md; for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { ltc_rmd160_init(&md); ltc_rmd160_process(&md, (const unsigned char *)tests[x].msg, strlen(tests[x].msg)); ltc_rmd160_done(&md, buf); if (LTC_XMEMCMP(buf, tests[x].md, 20) != 0) { #if 0 printf("Failed test %d\n", x); #endif return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd160.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_rmd160.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_RMD160_H_ #define _LTC_RMD160_H_ #define LTC_RMD160_HASHSIZE 20 #define LTC_RMD160_BLOCKSIZE 64 typedef struct ltc_rmd160_state { uint64_t length; uint32_t state[5]; uint32_t curlen; unsigned char buf[LTC_RMD160_BLOCKSIZE]; } ltc_rmd160_ctx; int ltc_rmd160_init(ltc_rmd160_ctx *ctx); int ltc_rmd160_process(ltc_rmd160_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_rmd160_done(ltc_rmd160_ctx *ctx, unsigned char *hash); #endif /* _LTC_RMD160_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd256.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_rmd256.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" /** @param ltc_rmd256.c RLTC_MD256 Hash function */ const ccDescriptor ltc_rmd256_desc = { .implementation_info = &cc_rmd256_impinfo, .dtype.digest.hashsize = CC_RMD256_DIGEST_LENGTH, .dtype.digest.blocksize = CC_RMD256_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_rmd256_init, .dtype.digest.process = <c_rmd256_process, .dtype.digest.done = <c_rmd256_done, }; /* the four basic functions F(), G() and H() */ #define F(x, y, z) ((x) ^ (y) ^ (z)) #define G(x, y, z) (((x) & (y)) | (~(x) & (z))) #define H(x, y, z) (((x) | ~(y)) ^ (z)) #define I(x, y, z) (((x) & (z)) | ((y) & ~(z))) /* the eight basic operations FF() through III() */ #define FF(a, b, c, d, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)); #define GG(a, b, c, d, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\ (a) = LTC_ROLc((a), (s)); #define HH(a, b, c, d, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\ (a) = LTC_ROLc((a), (s)); #define II(a, b, c, d, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\ (a) = LTC_ROLc((a), (s)); #define FFF(a, b, c, d, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)); #define GGG(a, b, c, d, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x6d703ef3UL;\ (a) = LTC_ROLc((a), (s)); #define HHH(a, b, c, d, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x5c4dd124UL;\ (a) = LTC_ROLc((a), (s)); #define III(a, b, c, d, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x50a28be6UL;\ (a) = LTC_ROLc((a), (s)); #ifdef LTC_CLEAN_STACK static int _rmd256_compress(ltc_rmd256_ctx *ctx, const unsigned char *buf) #else static int rmd256_compress(ltc_rmd256_ctx *ctx, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,tmp,X[16]; int i; /* load words X */ for (i = 0; i < 16; i++){ LTC_LOAD32L(X[i], buf + (4 * i)); } /* load state */ aa = ctx->state[0]; bb = ctx->state[1]; cc = ctx->state[2]; dd = ctx->state[3]; aaa = ctx->state[4]; bbb = ctx->state[5]; ccc = ctx->state[6]; ddd = ctx->state[7]; /* round 1 */ FF(aa, bb, cc, dd, X[ 0], 11); FF(dd, aa, bb, cc, X[ 1], 14); FF(cc, dd, aa, bb, X[ 2], 15); FF(bb, cc, dd, aa, X[ 3], 12); FF(aa, bb, cc, dd, X[ 4], 5); FF(dd, aa, bb, cc, X[ 5], 8); FF(cc, dd, aa, bb, X[ 6], 7); FF(bb, cc, dd, aa, X[ 7], 9); FF(aa, bb, cc, dd, X[ 8], 11); FF(dd, aa, bb, cc, X[ 9], 13); FF(cc, dd, aa, bb, X[10], 14); FF(bb, cc, dd, aa, X[11], 15); FF(aa, bb, cc, dd, X[12], 6); FF(dd, aa, bb, cc, X[13], 7); FF(cc, dd, aa, bb, X[14], 9); FF(bb, cc, dd, aa, X[15], 8); /* parallel round 1 */ III(aaa, bbb, ccc, ddd, X[ 5], 8); III(ddd, aaa, bbb, ccc, X[14], 9); III(ccc, ddd, aaa, bbb, X[ 7], 9); III(bbb, ccc, ddd, aaa, X[ 0], 11); III(aaa, bbb, ccc, ddd, X[ 9], 13); III(ddd, aaa, bbb, ccc, X[ 2], 15); III(ccc, ddd, aaa, bbb, X[11], 15); III(bbb, ccc, ddd, aaa, X[ 4], 5); III(aaa, bbb, ccc, ddd, X[13], 7); III(ddd, aaa, bbb, ccc, X[ 6], 7); III(ccc, ddd, aaa, bbb, X[15], 8); III(bbb, ccc, ddd, aaa, X[ 8], 11); III(aaa, bbb, ccc, ddd, X[ 1], 14); III(ddd, aaa, bbb, ccc, X[10], 14); III(ccc, ddd, aaa, bbb, X[ 3], 12); III(bbb, ccc, ddd, aaa, X[12], 6); tmp = aa; aa = aaa; aaa = tmp; /* round 2 */ GG(aa, bb, cc, dd, X[ 7], 7); GG(dd, aa, bb, cc, X[ 4], 6); GG(cc, dd, aa, bb, X[13], 8); GG(bb, cc, dd, aa, X[ 1], 13); GG(aa, bb, cc, dd, X[10], 11); GG(dd, aa, bb, cc, X[ 6], 9); GG(cc, dd, aa, bb, X[15], 7); GG(bb, cc, dd, aa, X[ 3], 15); GG(aa, bb, cc, dd, X[12], 7); GG(dd, aa, bb, cc, X[ 0], 12); GG(cc, dd, aa, bb, X[ 9], 15); GG(bb, cc, dd, aa, X[ 5], 9); GG(aa, bb, cc, dd, X[ 2], 11); GG(dd, aa, bb, cc, X[14], 7); GG(cc, dd, aa, bb, X[11], 13); GG(bb, cc, dd, aa, X[ 8], 12); /* parallel round 2 */ HHH(aaa, bbb, ccc, ddd, X[ 6], 9); HHH(ddd, aaa, bbb, ccc, X[11], 13); HHH(ccc, ddd, aaa, bbb, X[ 3], 15); HHH(bbb, ccc, ddd, aaa, X[ 7], 7); HHH(aaa, bbb, ccc, ddd, X[ 0], 12); HHH(ddd, aaa, bbb, ccc, X[13], 8); HHH(ccc, ddd, aaa, bbb, X[ 5], 9); HHH(bbb, ccc, ddd, aaa, X[10], 11); HHH(aaa, bbb, ccc, ddd, X[14], 7); HHH(ddd, aaa, bbb, ccc, X[15], 7); HHH(ccc, ddd, aaa, bbb, X[ 8], 12); HHH(bbb, ccc, ddd, aaa, X[12], 7); HHH(aaa, bbb, ccc, ddd, X[ 4], 6); HHH(ddd, aaa, bbb, ccc, X[ 9], 15); HHH(ccc, ddd, aaa, bbb, X[ 1], 13); HHH(bbb, ccc, ddd, aaa, X[ 2], 11); tmp = bb; bb = bbb; bbb = tmp; /* round 3 */ HH(aa, bb, cc, dd, X[ 3], 11); HH(dd, aa, bb, cc, X[10], 13); HH(cc, dd, aa, bb, X[14], 6); HH(bb, cc, dd, aa, X[ 4], 7); HH(aa, bb, cc, dd, X[ 9], 14); HH(dd, aa, bb, cc, X[15], 9); HH(cc, dd, aa, bb, X[ 8], 13); HH(bb, cc, dd, aa, X[ 1], 15); HH(aa, bb, cc, dd, X[ 2], 14); HH(dd, aa, bb, cc, X[ 7], 8); HH(cc, dd, aa, bb, X[ 0], 13); HH(bb, cc, dd, aa, X[ 6], 6); HH(aa, bb, cc, dd, X[13], 5); HH(dd, aa, bb, cc, X[11], 12); HH(cc, dd, aa, bb, X[ 5], 7); HH(bb, cc, dd, aa, X[12], 5); /* parallel round 3 */ GGG(aaa, bbb, ccc, ddd, X[15], 9); GGG(ddd, aaa, bbb, ccc, X[ 5], 7); GGG(ccc, ddd, aaa, bbb, X[ 1], 15); GGG(bbb, ccc, ddd, aaa, X[ 3], 11); GGG(aaa, bbb, ccc, ddd, X[ 7], 8); GGG(ddd, aaa, bbb, ccc, X[14], 6); GGG(ccc, ddd, aaa, bbb, X[ 6], 6); GGG(bbb, ccc, ddd, aaa, X[ 9], 14); GGG(aaa, bbb, ccc, ddd, X[11], 12); GGG(ddd, aaa, bbb, ccc, X[ 8], 13); GGG(ccc, ddd, aaa, bbb, X[12], 5); GGG(bbb, ccc, ddd, aaa, X[ 2], 14); GGG(aaa, bbb, ccc, ddd, X[10], 13); GGG(ddd, aaa, bbb, ccc, X[ 0], 13); GGG(ccc, ddd, aaa, bbb, X[ 4], 7); GGG(bbb, ccc, ddd, aaa, X[13], 5); tmp = cc; cc = ccc; ccc = tmp; /* round 4 */ II(aa, bb, cc, dd, X[ 1], 11); II(dd, aa, bb, cc, X[ 9], 12); II(cc, dd, aa, bb, X[11], 14); II(bb, cc, dd, aa, X[10], 15); II(aa, bb, cc, dd, X[ 0], 14); II(dd, aa, bb, cc, X[ 8], 15); II(cc, dd, aa, bb, X[12], 9); II(bb, cc, dd, aa, X[ 4], 8); II(aa, bb, cc, dd, X[13], 9); II(dd, aa, bb, cc, X[ 3], 14); II(cc, dd, aa, bb, X[ 7], 5); II(bb, cc, dd, aa, X[15], 6); II(aa, bb, cc, dd, X[14], 8); II(dd, aa, bb, cc, X[ 5], 6); II(cc, dd, aa, bb, X[ 6], 5); II(bb, cc, dd, aa, X[ 2], 12); /* parallel round 4 */ FFF(aaa, bbb, ccc, ddd, X[ 8], 15); FFF(ddd, aaa, bbb, ccc, X[ 6], 5); FFF(ccc, ddd, aaa, bbb, X[ 4], 8); FFF(bbb, ccc, ddd, aaa, X[ 1], 11); FFF(aaa, bbb, ccc, ddd, X[ 3], 14); FFF(ddd, aaa, bbb, ccc, X[11], 14); FFF(ccc, ddd, aaa, bbb, X[15], 6); FFF(bbb, ccc, ddd, aaa, X[ 0], 14); FFF(aaa, bbb, ccc, ddd, X[ 5], 6); FFF(ddd, aaa, bbb, ccc, X[12], 9); FFF(ccc, ddd, aaa, bbb, X[ 2], 12); FFF(bbb, ccc, ddd, aaa, X[13], 9); FFF(aaa, bbb, ccc, ddd, X[ 9], 12); FFF(ddd, aaa, bbb, ccc, X[ 7], 5); FFF(ccc, ddd, aaa, bbb, X[10], 15); FFF(bbb, ccc, ddd, aaa, X[14], 8); tmp = dd; dd = ddd; ddd = tmp; /* combine results */ ctx->state[0] += aa; ctx->state[1] += bb; ctx->state[2] += cc; ctx->state[3] += dd; ctx->state[4] += aaa; ctx->state[5] += bbb; ctx->state[6] += ccc; ctx->state[7] += ddd; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int rmd256_compress(ltc_rmd256_ctx *ctx, const unsigned char *buf) { int err; err = _rmd256_compress(md, buf); ltc_burn_stack(sizeof(ulong32) * 25 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_rmd256_init(ltc_rmd256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0x76543210UL; ctx->state[5] = 0xfedcba98UL; ctx->state[6] = 0x89abcdefUL; ctx->state[7] = 0x01234567UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_rmd256_process, rmd256_compress, ltc_rmd256_ctx, rmd256, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (16 bytes) @return CRYPT_OK if successful */ int ltc_rmd256_done(ltc_rmd256_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } rmd256_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); rmd256_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 8; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_rmd256_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char md[32]; } tests[] = { { "", { 0x02, 0xba, 0x4c, 0x4e, 0x5f, 0x8e, 0xcd, 0x18, 0x77, 0xfc, 0x52, 0xd6, 0x4d, 0x30, 0xe3, 0x7a, 0x2d, 0x97, 0x74, 0xfb, 0x1e, 0x5d, 0x02, 0x63, 0x80, 0xae, 0x01, 0x68, 0xe3, 0xc5, 0x52, 0x2d } }, { "a", { 0xf9, 0x33, 0x3e, 0x45, 0xd8, 0x57, 0xf5, 0xd9, 0x0a, 0x91, 0xba, 0xb7, 0x0a, 0x1e, 0xba, 0x0c, 0xfb, 0x1b, 0xe4, 0xb0, 0x78, 0x3c, 0x9a, 0xcf, 0xcd, 0x88, 0x3a, 0x91, 0x34, 0x69, 0x29, 0x25 } }, { "abc", { 0xaf, 0xbd, 0x6e, 0x22, 0x8b, 0x9d, 0x8c, 0xbb, 0xce, 0xf5, 0xca, 0x2d, 0x03, 0xe6, 0xdb, 0xa1, 0x0a, 0xc0, 0xbc, 0x7d, 0xcb, 0xe4, 0x68, 0x0e, 0x1e, 0x42, 0xd2, 0xe9, 0x75, 0x45, 0x9b, 0x65 } }, { "message digest", { 0x87, 0xe9, 0x71, 0x75, 0x9a, 0x1c, 0xe4, 0x7a, 0x51, 0x4d, 0x5c, 0x91, 0x4c, 0x39, 0x2c, 0x90, 0x18, 0xc7, 0xc4, 0x6b, 0xc1, 0x44, 0x65, 0x55, 0x4a, 0xfc, 0xdf, 0x54, 0xa5, 0x07, 0x0c, 0x0e } }, { "abcdefghijklmnopqrstuvwxyz", { 0x64, 0x9d, 0x30, 0x34, 0x75, 0x1e, 0xa2, 0x16, 0x77, 0x6b, 0xf9, 0xa1, 0x8a, 0xcc, 0x81, 0xbc, 0x78, 0x96, 0x11, 0x8a, 0x51, 0x97, 0x96, 0x87, 0x82, 0xdd, 0x1f, 0xd9, 0x7d, 0x8d, 0x51, 0x33 } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", { 0x57, 0x40, 0xa4, 0x08, 0xac, 0x16, 0xb7, 0x20, 0xb8, 0x44, 0x24, 0xae, 0x93, 0x1c, 0xbb, 0x1f, 0xe3, 0x63, 0xd1, 0xd0, 0xbf, 0x40, 0x17, 0xf1, 0xa8, 0x9f, 0x7e, 0xa6, 0xde, 0x77, 0xa0, 0xb8 } } }; int x; unsigned char buf[32]; ltc_hash_state md; for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { ltc_rmd256_init(&md); ltc_rmd256_process(&md, (const unsigned char *)tests[x].msg, strlen(tests[x].msg)); ltc_rmd256_done(&md, buf); if (LTC_XMEMCMP(buf, tests[x].md, 32) != 0) { #if 0 printf("Failed test %d\n", x); #endif return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd256.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_rmd256.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_RMD256_H_ #define _LTC_RMD256_H_ #define LTC_RMD256_HASHSIZE 32 #define LTC_RMD256_BLOCKSIZE 64 typedef struct ltc_rmd256_state { uint64_t length; uint32_t state[8]; uint32_t curlen; unsigned char buf[LTC_RMD256_BLOCKSIZE]; } ltc_rmd256_ctx; int ltc_rmd256_init(ltc_rmd256_ctx *ctx); int ltc_rmd256_process(ltc_rmd256_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_rmd256_done(ltc_rmd256_ctx *ctx, unsigned char *hash); #endif /* _LTC_RMD256_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd320.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_rmd320.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" #include "CommonDigestSPI.h" /** @file ltc_rmd320.c RMD320 hash function */ const ccDescriptor ltc_rmd320_desc = { .implementation_info = &cc_rmd320_impinfo, .dtype.digest.hashsize = CC_RMD320_DIGEST_LENGTH, .dtype.digest.blocksize = CC_RMD320_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_rmd320_init, .dtype.digest.process = <c_rmd320_process, .dtype.digest.done = <c_rmd320_done, }; /* the five basic functions F(), G() and H() */ #define F(x, y, z) ((x) ^ (y) ^ (z)) #define G(x, y, z) (((x) & (y)) | (~(x) & (z))) #define H(x, y, z) (((x) | ~(y)) ^ (z)) #define I(x, y, z) (((x) & (z)) | ((y) & ~(z))) #define J(x, y, z) ((x) ^ ((y) | ~(z))) /* the ten basic operations FF() through III() */ #define FF(a, b, c, d, e, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define GG(a, b, c, d, e, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define HH(a, b, c, d, e, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define II(a, b, c, d, e, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define JJ(a, b, c, d, e, x, s) \ (a) += J((b), (c), (d)) + (x) + 0xa953fd4eUL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define FFF(a, b, c, d, e, x, s) \ (a) += F((b), (c), (d)) + (x);\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define GGG(a, b, c, d, e, x, s) \ (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define HHH(a, b, c, d, e, x, s) \ (a) += H((b), (c), (d)) + (x) + 0x6d703ef3UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define III(a, b, c, d, e, x, s) \ (a) += I((b), (c), (d)) + (x) + 0x5c4dd124UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #define JJJ(a, b, c, d, e, x, s) \ (a) += J((b), (c), (d)) + (x) + 0x50a28be6UL;\ (a) = LTC_ROLc((a), (s)) + (e);\ (c) = LTC_ROLc((c), 10); #ifdef LTC_CLEAN_STACK static int _rmd320_compress(ltc_rmd320_ctx *ctx, const unsigned char *buf) #else static int rmd320_compress(ltc_rmd320_ctx *ctx, const unsigned char *buf) #endif { ulong32 aa,bb,cc,dd,ee,aaa,bbb,ccc,ddd,eee,tmp,X[16]; int i; /* load words X */ for (i = 0; i < 16; i++){ LTC_LOAD32L(X[i], buf + (4 * i)); } /* load state */ aa = ctx->state[0]; bb = ctx->state[1]; cc = ctx->state[2]; dd = ctx->state[3]; ee = ctx->state[4]; aaa = ctx->state[5]; bbb = ctx->state[6]; ccc = ctx->state[7]; ddd = ctx->state[8]; eee = ctx->state[9]; /* round 1 */ FF(aa, bb, cc, dd, ee, X[ 0], 11); FF(ee, aa, bb, cc, dd, X[ 1], 14); FF(dd, ee, aa, bb, cc, X[ 2], 15); FF(cc, dd, ee, aa, bb, X[ 3], 12); FF(bb, cc, dd, ee, aa, X[ 4], 5); FF(aa, bb, cc, dd, ee, X[ 5], 8); FF(ee, aa, bb, cc, dd, X[ 6], 7); FF(dd, ee, aa, bb, cc, X[ 7], 9); FF(cc, dd, ee, aa, bb, X[ 8], 11); FF(bb, cc, dd, ee, aa, X[ 9], 13); FF(aa, bb, cc, dd, ee, X[10], 14); FF(ee, aa, bb, cc, dd, X[11], 15); FF(dd, ee, aa, bb, cc, X[12], 6); FF(cc, dd, ee, aa, bb, X[13], 7); FF(bb, cc, dd, ee, aa, X[14], 9); FF(aa, bb, cc, dd, ee, X[15], 8); /* parallel round 1 */ JJJ(aaa, bbb, ccc, ddd, eee, X[ 5], 8); JJJ(eee, aaa, bbb, ccc, ddd, X[14], 9); JJJ(ddd, eee, aaa, bbb, ccc, X[ 7], 9); JJJ(ccc, ddd, eee, aaa, bbb, X[ 0], 11); JJJ(bbb, ccc, ddd, eee, aaa, X[ 9], 13); JJJ(aaa, bbb, ccc, ddd, eee, X[ 2], 15); JJJ(eee, aaa, bbb, ccc, ddd, X[11], 15); JJJ(ddd, eee, aaa, bbb, ccc, X[ 4], 5); JJJ(ccc, ddd, eee, aaa, bbb, X[13], 7); JJJ(bbb, ccc, ddd, eee, aaa, X[ 6], 7); JJJ(aaa, bbb, ccc, ddd, eee, X[15], 8); JJJ(eee, aaa, bbb, ccc, ddd, X[ 8], 11); JJJ(ddd, eee, aaa, bbb, ccc, X[ 1], 14); JJJ(ccc, ddd, eee, aaa, bbb, X[10], 14); JJJ(bbb, ccc, ddd, eee, aaa, X[ 3], 12); JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6); tmp = aa; aa = aaa; aaa = tmp; /* round 2 */ GG(ee, aa, bb, cc, dd, X[ 7], 7); GG(dd, ee, aa, bb, cc, X[ 4], 6); GG(cc, dd, ee, aa, bb, X[13], 8); GG(bb, cc, dd, ee, aa, X[ 1], 13); GG(aa, bb, cc, dd, ee, X[10], 11); GG(ee, aa, bb, cc, dd, X[ 6], 9); GG(dd, ee, aa, bb, cc, X[15], 7); GG(cc, dd, ee, aa, bb, X[ 3], 15); GG(bb, cc, dd, ee, aa, X[12], 7); GG(aa, bb, cc, dd, ee, X[ 0], 12); GG(ee, aa, bb, cc, dd, X[ 9], 15); GG(dd, ee, aa, bb, cc, X[ 5], 9); GG(cc, dd, ee, aa, bb, X[ 2], 11); GG(bb, cc, dd, ee, aa, X[14], 7); GG(aa, bb, cc, dd, ee, X[11], 13); GG(ee, aa, bb, cc, dd, X[ 8], 12); /* parallel round 2 */ III(eee, aaa, bbb, ccc, ddd, X[ 6], 9); III(ddd, eee, aaa, bbb, ccc, X[11], 13); III(ccc, ddd, eee, aaa, bbb, X[ 3], 15); III(bbb, ccc, ddd, eee, aaa, X[ 7], 7); III(aaa, bbb, ccc, ddd, eee, X[ 0], 12); III(eee, aaa, bbb, ccc, ddd, X[13], 8); III(ddd, eee, aaa, bbb, ccc, X[ 5], 9); III(ccc, ddd, eee, aaa, bbb, X[10], 11); III(bbb, ccc, ddd, eee, aaa, X[14], 7); III(aaa, bbb, ccc, ddd, eee, X[15], 7); III(eee, aaa, bbb, ccc, ddd, X[ 8], 12); III(ddd, eee, aaa, bbb, ccc, X[12], 7); III(ccc, ddd, eee, aaa, bbb, X[ 4], 6); III(bbb, ccc, ddd, eee, aaa, X[ 9], 15); III(aaa, bbb, ccc, ddd, eee, X[ 1], 13); III(eee, aaa, bbb, ccc, ddd, X[ 2], 11); tmp = bb; bb = bbb; bbb = tmp; /* round 3 */ HH(dd, ee, aa, bb, cc, X[ 3], 11); HH(cc, dd, ee, aa, bb, X[10], 13); HH(bb, cc, dd, ee, aa, X[14], 6); HH(aa, bb, cc, dd, ee, X[ 4], 7); HH(ee, aa, bb, cc, dd, X[ 9], 14); HH(dd, ee, aa, bb, cc, X[15], 9); HH(cc, dd, ee, aa, bb, X[ 8], 13); HH(bb, cc, dd, ee, aa, X[ 1], 15); HH(aa, bb, cc, dd, ee, X[ 2], 14); HH(ee, aa, bb, cc, dd, X[ 7], 8); HH(dd, ee, aa, bb, cc, X[ 0], 13); HH(cc, dd, ee, aa, bb, X[ 6], 6); HH(bb, cc, dd, ee, aa, X[13], 5); HH(aa, bb, cc, dd, ee, X[11], 12); HH(ee, aa, bb, cc, dd, X[ 5], 7); HH(dd, ee, aa, bb, cc, X[12], 5); /* parallel round 3 */ HHH(ddd, eee, aaa, bbb, ccc, X[15], 9); HHH(ccc, ddd, eee, aaa, bbb, X[ 5], 7); HHH(bbb, ccc, ddd, eee, aaa, X[ 1], 15); HHH(aaa, bbb, ccc, ddd, eee, X[ 3], 11); HHH(eee, aaa, bbb, ccc, ddd, X[ 7], 8); HHH(ddd, eee, aaa, bbb, ccc, X[14], 6); HHH(ccc, ddd, eee, aaa, bbb, X[ 6], 6); HHH(bbb, ccc, ddd, eee, aaa, X[ 9], 14); HHH(aaa, bbb, ccc, ddd, eee, X[11], 12); HHH(eee, aaa, bbb, ccc, ddd, X[ 8], 13); HHH(ddd, eee, aaa, bbb, ccc, X[12], 5); HHH(ccc, ddd, eee, aaa, bbb, X[ 2], 14); HHH(bbb, ccc, ddd, eee, aaa, X[10], 13); HHH(aaa, bbb, ccc, ddd, eee, X[ 0], 13); HHH(eee, aaa, bbb, ccc, ddd, X[ 4], 7); HHH(ddd, eee, aaa, bbb, ccc, X[13], 5); tmp = cc; cc = ccc; ccc = tmp; /* round 4 */ II(cc, dd, ee, aa, bb, X[ 1], 11); II(bb, cc, dd, ee, aa, X[ 9], 12); II(aa, bb, cc, dd, ee, X[11], 14); II(ee, aa, bb, cc, dd, X[10], 15); II(dd, ee, aa, bb, cc, X[ 0], 14); II(cc, dd, ee, aa, bb, X[ 8], 15); II(bb, cc, dd, ee, aa, X[12], 9); II(aa, bb, cc, dd, ee, X[ 4], 8); II(ee, aa, bb, cc, dd, X[13], 9); II(dd, ee, aa, bb, cc, X[ 3], 14); II(cc, dd, ee, aa, bb, X[ 7], 5); II(bb, cc, dd, ee, aa, X[15], 6); II(aa, bb, cc, dd, ee, X[14], 8); II(ee, aa, bb, cc, dd, X[ 5], 6); II(dd, ee, aa, bb, cc, X[ 6], 5); II(cc, dd, ee, aa, bb, X[ 2], 12); /* parallel round 4 */ GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15); GGG(bbb, ccc, ddd, eee, aaa, X[ 6], 5); GGG(aaa, bbb, ccc, ddd, eee, X[ 4], 8); GGG(eee, aaa, bbb, ccc, ddd, X[ 1], 11); GGG(ddd, eee, aaa, bbb, ccc, X[ 3], 14); GGG(ccc, ddd, eee, aaa, bbb, X[11], 14); GGG(bbb, ccc, ddd, eee, aaa, X[15], 6); GGG(aaa, bbb, ccc, ddd, eee, X[ 0], 14); GGG(eee, aaa, bbb, ccc, ddd, X[ 5], 6); GGG(ddd, eee, aaa, bbb, ccc, X[12], 9); GGG(ccc, ddd, eee, aaa, bbb, X[ 2], 12); GGG(bbb, ccc, ddd, eee, aaa, X[13], 9); GGG(aaa, bbb, ccc, ddd, eee, X[ 9], 12); GGG(eee, aaa, bbb, ccc, ddd, X[ 7], 5); GGG(ddd, eee, aaa, bbb, ccc, X[10], 15); GGG(ccc, ddd, eee, aaa, bbb, X[14], 8); tmp = dd; dd = ddd; ddd = tmp; /* round 5 */ JJ(bb, cc, dd, ee, aa, X[ 4], 9); JJ(aa, bb, cc, dd, ee, X[ 0], 15); JJ(ee, aa, bb, cc, dd, X[ 5], 5); JJ(dd, ee, aa, bb, cc, X[ 9], 11); JJ(cc, dd, ee, aa, bb, X[ 7], 6); JJ(bb, cc, dd, ee, aa, X[12], 8); JJ(aa, bb, cc, dd, ee, X[ 2], 13); JJ(ee, aa, bb, cc, dd, X[10], 12); JJ(dd, ee, aa, bb, cc, X[14], 5); JJ(cc, dd, ee, aa, bb, X[ 1], 12); JJ(bb, cc, dd, ee, aa, X[ 3], 13); JJ(aa, bb, cc, dd, ee, X[ 8], 14); JJ(ee, aa, bb, cc, dd, X[11], 11); JJ(dd, ee, aa, bb, cc, X[ 6], 8); JJ(cc, dd, ee, aa, bb, X[15], 5); JJ(bb, cc, dd, ee, aa, X[13], 6); /* parallel round 5 */ FFF(bbb, ccc, ddd, eee, aaa, X[12] , 8); FFF(aaa, bbb, ccc, ddd, eee, X[15] , 5); FFF(eee, aaa, bbb, ccc, ddd, X[10] , 12); FFF(ddd, eee, aaa, bbb, ccc, X[ 4] , 9); FFF(ccc, ddd, eee, aaa, bbb, X[ 1] , 12); FFF(bbb, ccc, ddd, eee, aaa, X[ 5] , 5); FFF(aaa, bbb, ccc, ddd, eee, X[ 8] , 14); FFF(eee, aaa, bbb, ccc, ddd, X[ 7] , 6); FFF(ddd, eee, aaa, bbb, ccc, X[ 6] , 8); FFF(ccc, ddd, eee, aaa, bbb, X[ 2] , 13); FFF(bbb, ccc, ddd, eee, aaa, X[13] , 6); FFF(aaa, bbb, ccc, ddd, eee, X[14] , 5); FFF(eee, aaa, bbb, ccc, ddd, X[ 0] , 15); FFF(ddd, eee, aaa, bbb, ccc, X[ 3] , 13); FFF(ccc, ddd, eee, aaa, bbb, X[ 9] , 11); FFF(bbb, ccc, ddd, eee, aaa, X[11] , 11); tmp = ee; ee = eee; eee = tmp; /* combine results */ ctx->state[0] += aa; ctx->state[1] += bb; ctx->state[2] += cc; ctx->state[3] += dd; ctx->state[4] += ee; ctx->state[5] += aaa; ctx->state[6] += bbb; ctx->state[7] += ccc; ctx->state[8] += ddd; ctx->state[9] += eee; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int rmd320_compress(ltc_rmd320_ctx *ctx, const unsigned char *buf) { int err; err = _rmd320_compress(md, buf); ltc_burn_stack(sizeof(ulong32) * 27 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_rmd320_init(ltc_rmd320_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0xc3d2e1f0UL; ctx->state[5] = 0x76543210UL; ctx->state[6] = 0xfedcba98UL; ctx->state[7] = 0x89abcdefUL; ctx->state[8] = 0x01234567UL; ctx->state[9] = 0x3c2d1e0fUL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_rmd320_process, rmd320_compress, ltc_rmd320_ctx, rmd320, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (20 bytes) @return CRYPT_OK if successful */ int ltc_rmd320_done(ltc_rmd320_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } rmd320_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64L(ctx->length, ctx->buf+56); rmd320_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 10; i++) { LTC_STORE32L(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_rmd320_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char md[40]; } tests[] = { { "", { 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1, 0xfd, 0xf5, 0xc6, 0xde, 0x7b, 0x41, 0xb9, 0xf2, 0x73, 0x25, 0xeb, 0xc6, 0x1e, 0x85, 0x57, 0x17, 0x7d, 0x70, 0x5a, 0x0e, 0xc8, 0x80, 0x15, 0x1c, 0x3a, 0x32, 0xa0, 0x08, 0x99, 0xb8 } }, { "a", { 0xce, 0x78, 0x85, 0x06, 0x38, 0xf9, 0x26, 0x58, 0xa5, 0xa5, 0x85, 0x09, 0x75, 0x79, 0x92, 0x6d, 0xda, 0x66, 0x7a, 0x57, 0x16, 0x56, 0x2c, 0xfc, 0xf6, 0xfb, 0xe7, 0x7f, 0x63, 0x54, 0x2f, 0x99, 0xb0, 0x47, 0x05, 0xd6, 0x97, 0x0d, 0xff, 0x5d } }, { "abc", { 0xde, 0x4c, 0x01, 0xb3, 0x05, 0x4f, 0x89, 0x30, 0xa7, 0x9d, 0x09, 0xae, 0x73, 0x8e, 0x92, 0x30, 0x1e, 0x5a, 0x17, 0x08, 0x5b, 0xef, 0xfd, 0xc1, 0xb8, 0xd1, 0x16, 0x71, 0x3e, 0x74, 0xf8, 0x2f, 0xa9, 0x42, 0xd6, 0x4c, 0xdb, 0xc4, 0x68, 0x2d } }, { "message digest", { 0x3a, 0x8e, 0x28, 0x50, 0x2e, 0xd4, 0x5d, 0x42, 0x2f, 0x68, 0x84, 0x4f, 0x9d, 0xd3, 0x16, 0xe7, 0xb9, 0x85, 0x33, 0xfa, 0x3f, 0x2a, 0x91, 0xd2, 0x9f, 0x84, 0xd4, 0x25, 0xc8, 0x8d, 0x6b, 0x4e, 0xff, 0x72, 0x7d, 0xf6, 0x6a, 0x7c, 0x01, 0x97 } }, { "abcdefghijklmnopqrstuvwxyz", { 0xca, 0xbd, 0xb1, 0x81, 0x0b, 0x92, 0x47, 0x0a, 0x20, 0x93, 0xaa, 0x6b, 0xce, 0x05, 0x95, 0x2c, 0x28, 0x34, 0x8c, 0xf4, 0x3f, 0xf6, 0x08, 0x41, 0x97, 0x51, 0x66, 0xbb, 0x40, 0xed, 0x23, 0x40, 0x04, 0xb8, 0x82, 0x44, 0x63, 0xe6, 0xb0, 0x09 } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0xd0, 0x34, 0xa7, 0x95, 0x0c, 0xf7, 0x22, 0x02, 0x1b, 0xa4, 0xb8, 0x4d, 0xf7, 0x69, 0xa5, 0xde, 0x20, 0x60, 0xe2, 0x59, 0xdf, 0x4c, 0x9b, 0xb4, 0xa4, 0x26, 0x8c, 0x0e, 0x93, 0x5b, 0xbc, 0x74, 0x70, 0xa9, 0x69, 0xc9, 0xd0, 0x72, 0xa1, 0xac } } }; int x; unsigned char buf[40]; ltc_hash_state md; for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { ltc_rmd320_init(&md); ltc_rmd320_process(&md, (const unsigned char *)tests[x].msg, strlen(tests[x].msg)); ltc_rmd320_done(&md, buf); if (LTC_XMEMCMP(buf, tests[x].md, 40) != 0) { #if 0 printf("Failed test %d\n", x); #endif return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_rmd_descriptor/ltc_rmd320.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_rmd320.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_RMD320_H_ #define _LTC_RMD320_H_ #define LTC_RMD320_HASHSIZE 40 #define LTC_RMD320_BLOCKSIZE 64 typedef struct ltc_rmd320_state { uint64_t length; uint32_t state[10]; uint32_t curlen; unsigned char buf[LTC_RMD320_BLOCKSIZE]; } ltc_rmd320_ctx; int ltc_rmd320_init(ltc_rmd320_ctx *ctx); int ltc_rmd320_process(ltc_rmd320_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_rmd320_done(ltc_rmd320_ctx *ctx, unsigned char *hash); #endif /* _LTC_RMD320_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_sha1_descriptor/ltc_sha1.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_sha1.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file ltc_sha1.c LTC_SHA1 code by Tom St Denis */ const ccDescriptor ltc_sha1_desc = { .implementation_info = &cc_sha1_impinfo, .dtype.digest.hashsize = CC_SHA1_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA1_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_sha1_init, .dtype.digest.process = <c_sha1_process, .dtype.digest.done = <c_sha1_done, }; #define F0(x,y,z) (z ^ (x & (y ^ z))) #define F1(x,y,z) (x ^ y ^ z) #define F2(x,y,z) ((x & y) | (z & (x | y))) #define F3(x,y,z) (x ^ y ^ z) #ifdef LTC_CLEAN_STACK static int _sha1_compress(ltc_sha1_ctx *ctx, const unsigned char *buf) #else static int sha1_compress(ltc_sha1_ctx *ctx, const unsigned char *buf) #endif { ulong32 a,b,c,d,e,W[80],i; #ifdef LTC_SMALL_CODE ulong32 t; #endif /* copy the state into 512-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD32H(W[i], buf + (4*i)); } /* copy state */ a = ctx->state[0]; b = ctx->state[1]; c = ctx->state[2]; d = ctx->state[3]; e = ctx->state[4]; /* expand it */ for (i = 16; i < 80; i++) { W[i] = LTC_ROL(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1); } /* compress */ /* round one */ #define FF0(a,b,c,d,e,i) e = (LTC_ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = LTC_ROLc(b, 30); #define FF1(a,b,c,d,e,i) e = (LTC_ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = LTC_ROLc(b, 30); #define FF2(a,b,c,d,e,i) e = (LTC_ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = LTC_ROLc(b, 30); #define FF3(a,b,c,d,e,i) e = (LTC_ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = LTC_ROLc(b, 30); #ifdef LTC_SMALL_CODE for (i = 0; i < 20; ) { FF0(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; } for (; i < 40; ) { FF1(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; } for (; i < 60; ) { FF2(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; } for (; i < 80; ) { FF3(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; } #else for (i = 0; i < 20; ) { FF0(a,b,c,d,e,i++); FF0(e,a,b,c,d,i++); FF0(d,e,a,b,c,i++); FF0(c,d,e,a,b,i++); FF0(b,c,d,e,a,i++); } /* round two */ for (; i < 40; ) { FF1(a,b,c,d,e,i++); FF1(e,a,b,c,d,i++); FF1(d,e,a,b,c,i++); FF1(c,d,e,a,b,i++); FF1(b,c,d,e,a,i++); } /* round three */ for (; i < 60; ) { FF2(a,b,c,d,e,i++); FF2(e,a,b,c,d,i++); FF2(d,e,a,b,c,i++); FF2(c,d,e,a,b,i++); FF2(b,c,d,e,a,i++); } /* round four */ for (; i < 80; ) { FF3(a,b,c,d,e,i++); FF3(e,a,b,c,d,i++); FF3(d,e,a,b,c,i++); FF3(c,d,e,a,b,i++); FF3(b,c,d,e,a,i++); } #endif #undef FF0 #undef FF1 #undef FF2 #undef FF3 /* store */ ctx->state[0] = ctx->state[0] + a; ctx->state[1] = ctx->state[1] + b; ctx->state[2] = ctx->state[2] + c; ctx->state[3] = ctx->state[3] + d; ctx->state[4] = ctx->state[4] + e; return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int sha1_compress(ltc_sha1_ctx *ctx, const unsigned char *buf) { int err; err = _sha1_compress(ctx, buf); ltc_burn_stack(sizeof(ulong32) * 87); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_sha1_init(ltc_sha1_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0xc3d2e1f0UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_sha1_process, sha1_compress, ltc_sha1_ctx, sha1, 64) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (20 bytes) @return CRYPT_OK if successful */ int ltc_sha1_done(ltc_sha1_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } sha1_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+56); sha1_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 5; i++) { LTC_STORE32H(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(ltc_hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_sha1_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[20]; } tests[] = { { "abc", { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 } } }; int i; unsigned char tmp[20]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_sha1_init(&md); ltc_sha1_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_sha1_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 20) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_sha1_descriptor/ltc_sha1.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_sha1.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_SHA1_H_ #define _LTC_SHA1_H_ #define LTC_SHA1_HASHSIZE 20 #define LTC_SHA1_BLOCKSIZE 64 // Adjusted to take the same space as CC_SHA1_CTX // The order is important on a 64 bit system so that // the length variable is 64 bit aligned. typedef struct ltc_sha1_state { uint32_t state[5]; uint32_t curlen; uint64_t length; unsigned char buf[LTC_SHA1_BLOCKSIZE]; } ltc_sha1_ctx; int ltc_sha1_init(ltc_sha1_ctx *ctx); int ltc_sha1_process(ltc_sha1_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_sha1_done(ltc_sha1_ctx *ctx, unsigned char *hash); #endif /* _LTC_SHA1_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha224.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /** @param sha224.c LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis) */ const ccDescriptor ltc_sha224_desc = { .implementation_info = &cc_sha224_impinfo, .dtype.digest.hashsize = CC_SHA224_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA224_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_sha224_init, .dtype.digest.process = <c_sha256_process, .dtype.digest.done = <c_sha224_done, }; /* init the sha256 er... sha224 state ;-) */ /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_sha224_init(ltc_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->length = 0; ctx->state[0] = 0xc1059ed8UL; ctx->state[1] = 0x367cd507UL; ctx->state[2] = 0x3070dd17UL; ctx->state[3] = 0xf70e5939UL; ctx->state[4] = 0xffc00b31UL; ctx->state[5] = 0x68581511UL; ctx->state[6] = 0x64f98fa7UL; ctx->state[7] = 0xbefa4fa4UL; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (28 bytes) @return CRYPT_OK if successful */ int ltc_sha224_done(ltc_sha256_ctx *ctx, unsigned char *out) { unsigned char buf[32]; int err; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); err = ltc_sha256_done(ctx, buf); CC_XMEMCPY(out, buf, 28); #ifdef LTC_CLEAN_STACK ltc_zeromem(buf, sizeof(buf)); #endif return err; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_sha224_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[28]; } tests[] = { { "abc", { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22, 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3, 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7, 0xe3, 0x6c, 0x9d, 0xa7 } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc, 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50, 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19, 0x52, 0x52, 0x25, 0x25 } }, }; int i; unsigned char tmp[28]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_sha224_init(&md); ltc_sha224_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_sha224_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 28) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha224.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_sha224.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #ifndef _LTC_SHA224_H_ #define _LTC_SHA224_H_ /* * Note that ltc_sha256 is required for ltc_sha224. */ #define LTC_SHA224_HASHSIZE 28 #define LTC_SHA224_BLOCKSIZE 64 int ltc_sha224_init(ltc_sha256_ctx *ctx); #define ltc_sha224_process ltc_sha256_process int ltc_sha224_done(ltc_sha256_ctx *ctx, unsigned char *hash); int ltc_sha224_test(void); #endif /* _LTC_SHA224_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha256.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_sha256.h" #include "ltc_sha224.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file ltc_sha256.c LTC_SHA256 by Tom St Denis */ const ccDescriptor ltc_sha256_desc = { .implementation_info = &cc_sha256_impinfo, .dtype.digest.hashsize = CC_SHA256_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA256_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_sha256_init, .dtype.digest.process = <c_sha256_process, .dtype.digest.done = <c_sha256_done, }; #ifdef LTC_SMALL_CODE /* the K array */ static const ulong32 K[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; #endif /* Various logical functions */ #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) LTC_RORc((x),(n)) #define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) #define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) #define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) /* compress 512-bits */ #ifdef LTC_CLEAN_STACK static int _sha256_compress(ltc_sha256_ctx *ctx, const unsigned char *buf) #else static int sha256_compress(ltc_sha256_ctx *ctx, const unsigned char *buf) #endif { ulong32 S[8], W[64], t0, t1; #ifdef LTC_SMALL_CODE ulong32 t; #endif int i; /* copy state into S */ for (i = 0; i < 8; i++) { S[i] = ctx->state[i]; } /* copy the state into 512-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD32H(W[i], buf + (4*i)); } /* fill W[16..63] */ for (i = 16; i < 64; i++) { W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]; } /* Compress */ #ifdef LTC_SMALL_CODE #define RND(a,b,c,d,e,f,g,h,i) \ t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ t1 = Sigma0(a) + Maj(a, b, c); \ d += t0; \ h = t0 + t1; for (i = 0; i < 64; ++i) { RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i); t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4]; S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t; } #else #define RND(a,b,c,d,e,f,g,h,i,ki) \ t0 = h + Sigma1(e) + Ch(e, f, g) + ki + W[i]; \ t1 = Sigma0(a) + Maj(a, b, c); \ d += t0; \ h = t0 + t1; RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x71374491); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcf); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,0xe9b5dba5); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,0x3956c25b); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,0x59f111f1); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,0x923f82a4); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,0xab1c5ed5); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,0xd807aa98); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,0x12835b01); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,0x243185be); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,0x550c7dc3); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,0x72be5d74); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,0x80deb1fe); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,0x9bdc06a7); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,0xc19bf174); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,0xe49b69c1); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,0xefbe4786); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,0x0fc19dc6); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,0x240ca1cc); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,0x2de92c6f); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,0x4a7484aa); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,0x5cb0a9dc); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,0x76f988da); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,0x983e5152); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,0xa831c66d); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,0xb00327c8); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,0xbf597fc7); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,0xc6e00bf3); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,0xd5a79147); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,0x06ca6351); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,0x14292967); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,0x27b70a85); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,0x2e1b2138); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,0x4d2c6dfc); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,0x53380d13); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,0x650a7354); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,0x766a0abb); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,0x81c2c92e); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,0x92722c85); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,0xa2bfe8a1); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,0xa81a664b); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,0xc24b8b70); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,0xc76c51a3); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,0xd192e819); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,0xd6990624); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,0xf40e3585); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,0x106aa070); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,0x1e376c08); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,0x2748774c); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,0x34b0bcb5); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,0x391c0cb3); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,0x4ed8aa4a); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,0x5b9cca4f); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,0x682e6ff3); RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,0x748f82ee); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,0x78a5636f); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,0x84c87814); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,0x8cc70208); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,0x90befffa); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2); #undef RND #endif /* feedback */ for (i = 0; i < 8; i++) { ctx->state[i] = ctx->state[i] + S[i]; } return CRYPT_OK; } #ifdef LTC_CLEAN_STACK static int sha256_compress(ltc_sha256_ctx *ctx, const unsigned char *buf) { int err; err = _sha256_compress(ctx, buf); ltc_burn_stack(sizeof(ulong32) * 74); return err; } #endif #define FULLLENGTH_MASK 0xffffffffffffffc0 #define BUFFLENGTH_MASK 0x3f /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_sha256_init(ltc_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->length = 0; ctx->state[0] = 0x6A09E667UL; ctx->state[1] = 0xBB67AE85UL; ctx->state[2] = 0x3C6EF372UL; ctx->state[3] = 0xA54FF53AUL; ctx->state[4] = 0x510E527FUL; ctx->state[5] = 0x9B05688CUL; ctx->state[6] = 0x1F83D9ABUL; ctx->state[7] = 0x5BE0CD19UL; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ // LTC_HASH_PROCESS(ltc_sha256_process, sha256_compress, ltc_sha256_ctx, sha256, 64) int ltc_sha256_process(ltc_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed, i; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); curlen = ctx->length & BUFFLENGTH_MASK; if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (curlen == 0 && inlen >= LTC_SHA256_BLOCKSIZE) { fullblocks = inlen / LTC_SHA256_BLOCKSIZE; remainder = inlen % LTC_SHA256_BLOCKSIZE; processed = fullblocks * LTC_SHA256_BLOCKSIZE; for(i=0; i< fullblocks; i++) { sha256_compress (ctx, in); in += LTC_SHA256_BLOCKSIZE; } ctx->length += LTC_SHA256_BLOCKSIZE * 8 * fullblocks; inlen -= processed; } else { n = MIN(inlen, (LTC_SHA256_BLOCKSIZE - curlen)); memcpy(ctx->buf + curlen, in, (size_t)n); curlen += n; in += n; inlen -= n; if (curlen == LTC_SHA256_BLOCKSIZE) { sha256_compress (ctx, ctx->buf); ctx->length += 8*LTC_SHA256_BLOCKSIZE; curlen = 0; } } } ctx->length = (ctx->length & FULLLENGTH_MASK) + curlen; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (32 bytes) @return CRYPT_OK if successful */ int ltc_sha256_done(ltc_sha256_ctx *ctx, unsigned char *out) { int i; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); curlen = ctx->length & BUFFLENGTH_MASK; ctx->length &= FULLLENGTH_MASK; /* increase the length of the message */ ctx->length += curlen * 8; /* append the '1' bit */ ctx->buf[curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (curlen > 56) { while (curlen < 64) { ctx->buf[curlen++] = (unsigned char)0; } sha256_compress(ctx, ctx->buf); curlen = 0; } /* pad upto 56 bytes of zeroes */ while (curlen < 56) { ctx->buf[curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+56); sha256_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 8; i++) { LTC_STORE32H(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(ctx, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_sha256_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[32]; } tests[] = { { "abc", { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 } }, }; int i; unsigned char tmp[32]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_sha256_init(&md); ltc_sha256_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_sha256_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 32) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } #include "ltc_sha224.c" |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha256.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_sha256.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_SHA256_H_ #define _LTC_SHA256_H_ #define LTC_SHA256_HASHSIZE 32 #define LTC_SHA256_BLOCKSIZE 64 typedef struct ltc_sha256_state { uint64_t length; uint32_t state[8]; unsigned char buf[LTC_SHA256_BLOCKSIZE]; } ltc_sha256_ctx; int ltc_sha256_init(ltc_sha256_ctx *ctx); int ltc_sha256_process(ltc_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_sha256_done(ltc_sha256_ctx *ctx, unsigned char *hash); #endif /* _LTC_SHA256_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha384.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /** @param sha384.c LTC_SHA384 hash included in sha512.c, Tom St Denis */ const ccDescriptor ltc_sha384_desc = { .implementation_info = &cc_sha384_impinfo, .dtype.digest.hashsize = CC_SHA384_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA384_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_sha384_init, .dtype.digest.process = <c_sha512_process, .dtype.digest.done = <c_sha384_done, }; /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_sha384_init(ltc_sha512_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->curlen = 0; ctx->length = 0; ctx->state[0] = LTC_CONST64(0xcbbb9d5dc1059ed8); ctx->state[1] = LTC_CONST64(0x629a292a367cd507); ctx->state[2] = LTC_CONST64(0x9159015a3070dd17); ctx->state[3] = LTC_CONST64(0x152fecd8f70e5939); ctx->state[4] = LTC_CONST64(0x67332667ffc00b31); ctx->state[5] = LTC_CONST64(0x8eb44a8768581511); ctx->state[6] = LTC_CONST64(0xdb0c2e0d64f98fa7); ctx->state[7] = LTC_CONST64(0x47b5481dbefa4fa4); return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (48 bytes) @return CRYPT_OK if successful */ int ltc_sha384_done(ltc_sha512_ctx *ctx, unsigned char *out) { unsigned char buf[64]; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } ltc_sha512_done(ctx, buf); CC_XMEMCPY(out, buf, 48); #ifdef LTC_CLEAN_STACK ltc_zeromem(buf, sizeof(buf)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_sha384_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[48]; } tests[] = { { "abc", { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 } }, { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 } }, }; int i; unsigned char tmp[48]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_sha384_init(&md); ltc_sha384_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_sha384_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 48) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha384.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_sha384.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #ifndef _LTC_SHA384_H_ #define _LTC_SHA384_H_ /* * Note that ltc_sha512 is required for ltc_sha384. */ #define LTC_SHA384_HASHSIZE 48 #define LTC_SHA384_BLOCKSIZE 128 int ltc_sha384_init(ltc_sha512_ctx *ctx); #define ltc_sha384_process ltc_sha512_process int ltc_sha384_done(ltc_sha512_ctx *ctx, unsigned char *hash); #endif /* _LTC_SHA384_H_ */ |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha512.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <stdio.h> #include "ltc_sha512.h" #include "ltc_sha384.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @param ltc_sha512.c LTC_SHA512 by Tom St Denis */ const ccDescriptor ltc_sha512_desc = { .implementation_info = &cc_sha512_impinfo, .dtype.digest.hashsize = CC_SHA512_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA512_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = <c_sha512_init, .dtype.digest.process = <c_sha512_process, .dtype.digest.done = <c_sha512_done, }; /* the K array */ static const ulong64 K[80] = { LTC_CONST64(0x428a2f98d728ae22), LTC_CONST64(0x7137449123ef65cd), LTC_CONST64(0xb5c0fbcfec4d3b2f), LTC_CONST64(0xe9b5dba58189dbbc), LTC_CONST64(0x3956c25bf348b538), LTC_CONST64(0x59f111f1b605d019), LTC_CONST64(0x923f82a4af194f9b), LTC_CONST64(0xab1c5ed5da6d8118), LTC_CONST64(0xd807aa98a3030242), LTC_CONST64(0x12835b0145706fbe), LTC_CONST64(0x243185be4ee4b28c), LTC_CONST64(0x550c7dc3d5ffb4e2), LTC_CONST64(0x72be5d74f27b896f), LTC_CONST64(0x80deb1fe3b1696b1), LTC_CONST64(0x9bdc06a725c71235), LTC_CONST64(0xc19bf174cf692694), LTC_CONST64(0xe49b69c19ef14ad2), LTC_CONST64(0xefbe4786384f25e3), LTC_CONST64(0x0fc19dc68b8cd5b5), LTC_CONST64(0x240ca1cc77ac9c65), LTC_CONST64(0x2de92c6f592b0275), LTC_CONST64(0x4a7484aa6ea6e483), LTC_CONST64(0x5cb0a9dcbd41fbd4), LTC_CONST64(0x76f988da831153b5), LTC_CONST64(0x983e5152ee66dfab), LTC_CONST64(0xa831c66d2db43210), LTC_CONST64(0xb00327c898fb213f), LTC_CONST64(0xbf597fc7beef0ee4), LTC_CONST64(0xc6e00bf33da88fc2), LTC_CONST64(0xd5a79147930aa725), LTC_CONST64(0x06ca6351e003826f), LTC_CONST64(0x142929670a0e6e70), LTC_CONST64(0x27b70a8546d22ffc), LTC_CONST64(0x2e1b21385c26c926), LTC_CONST64(0x4d2c6dfc5ac42aed), LTC_CONST64(0x53380d139d95b3df), LTC_CONST64(0x650a73548baf63de), LTC_CONST64(0x766a0abb3c77b2a8), LTC_CONST64(0x81c2c92e47edaee6), LTC_CONST64(0x92722c851482353b), LTC_CONST64(0xa2bfe8a14cf10364), LTC_CONST64(0xa81a664bbc423001), LTC_CONST64(0xc24b8b70d0f89791), LTC_CONST64(0xc76c51a30654be30), LTC_CONST64(0xd192e819d6ef5218), LTC_CONST64(0xd69906245565a910), LTC_CONST64(0xf40e35855771202a), LTC_CONST64(0x106aa07032bbd1b8), LTC_CONST64(0x19a4c116b8d2d0c8), LTC_CONST64(0x1e376c085141ab53), LTC_CONST64(0x2748774cdf8eeb99), LTC_CONST64(0x34b0bcb5e19b48a8), LTC_CONST64(0x391c0cb3c5c95a63), LTC_CONST64(0x4ed8aa4ae3418acb), LTC_CONST64(0x5b9cca4f7763e373), LTC_CONST64(0x682e6ff3d6b2b8a3), LTC_CONST64(0x748f82ee5defb2fc), LTC_CONST64(0x78a5636f43172f60), LTC_CONST64(0x84c87814a1f0ab72), LTC_CONST64(0x8cc702081a6439ec), LTC_CONST64(0x90befffa23631e28), LTC_CONST64(0xa4506cebde82bde9), LTC_CONST64(0xbef9a3f7b2c67915), LTC_CONST64(0xc67178f2e372532b), LTC_CONST64(0xca273eceea26619c), LTC_CONST64(0xd186b8c721c0c207), LTC_CONST64(0xeada7dd6cde0eb1e), LTC_CONST64(0xf57d4f7fee6ed178), LTC_CONST64(0x06f067aa72176fba), LTC_CONST64(0x0a637dc5a2c898a6), LTC_CONST64(0x113f9804bef90dae), LTC_CONST64(0x1b710b35131c471b), LTC_CONST64(0x28db77f523047d84), LTC_CONST64(0x32caab7b40c72493), LTC_CONST64(0x3c9ebe0a15c9bebc), LTC_CONST64(0x431d67c49c100d4c), LTC_CONST64(0x4cc5d4becb3e42b6), LTC_CONST64(0x597f299cfc657e2a), LTC_CONST64(0x5fcb6fab3ad6faec), LTC_CONST64(0x6c44198c4a475817) }; /* Various logical functions */ #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) LTC_ROR64c(x, n) #define R(x, n) (((x) & LTC_CONST64(0xFFFFFFFFFFFFFFFF) )>>((ulong64)n)) #define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39)) #define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) #define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) #define Gamma1(x) (S(x, 19) ^ S(x, 61) ^ R(x, 6)) /* compress 1024-bits */ #ifdef LTC_CLEAN_STACK static int _sha512_compress(ltc_sha512_ctx *ctx, const unsigned char *buf) #else static int sha512_compress(ltc_sha512_ctx *ctx, const unsigned char *buf) #endif { ulong64 S[8], W[80], t0, t1; int i; /* copy state into S */ for (i = 0; i < 8; i++) { S[i] = ctx->state[i]; } /* copy the state into 1024-bits into W[0..15] */ for (i = 0; i < 16; i++) { LTC_LOAD64H(W[i], buf + (8*i)); } /* fill W[16..79] */ for (i = 16; i < 80; i++) { W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]; } /* Compress */ #ifdef LTC_SMALL_CODE for (i = 0; i < 80; i++) { t0 = S[7] + Sigma1(S[4]) + Ch(S[4], S[5], S[6]) + K[i] + W[i]; t1 = Sigma0(S[0]) + Maj(S[0], S[1], S[2]); S[7] = S[6]; S[6] = S[5]; S[5] = S[4]; S[4] = S[3] + t0; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t0 + t1; } #else #define RND(a,b,c,d,e,f,g,h,i) \ t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ t1 = Sigma0(a) + Maj(a, b, c); \ d += t0; \ h = t0 + t1; for (i = 0; i < 80; i += 8) { RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0); RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1); RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2); RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3); RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4); RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5); RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7); } #endif /* feedback */ for (i = 0; i < 8; i++) { ctx->state[i] = ctx->state[i] + S[i]; } return CRYPT_OK; } /* compress 1024-bits */ #ifdef LTC_CLEAN_STACK static int sha512_compress(ltc_sha512_ctx *ctx, const unsigned char *buf) { int err; err = _sha512_compress(md, buf); ltc_burn_stack(sizeof(ulong64) * 90 + sizeof(int)); return err; } #endif /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int ltc_sha512_init(ltc_sha512_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->curlen = 0; ctx->length = 0; ctx->state[0] = LTC_CONST64(0x6a09e667f3bcc908); ctx->state[1] = LTC_CONST64(0xbb67ae8584caa73b); ctx->state[2] = LTC_CONST64(0x3c6ef372fe94f82b); ctx->state[3] = LTC_CONST64(0xa54ff53a5f1d36f1); ctx->state[4] = LTC_CONST64(0x510e527fade682d1); ctx->state[5] = LTC_CONST64(0x9b05688c2b3e6c1f); ctx->state[6] = LTC_CONST64(0x1f83d9abfb41bd6b); ctx->state[7] = LTC_CONST64(0x5be0cd19137e2179); return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ LTC_HASH_PROCESS(ltc_sha512_process, sha512_compress, ltc_sha512_ctx, sha512, 128) /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (64 bytes) @return CRYPT_OK if successful */ int ltc_sha512_done(ltc_sha512_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * LTC_CONST64(8); /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 112 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 112) { while (ctx->curlen < 128) { ctx->buf[ctx->curlen++] = (unsigned char)0; } sha512_compress(ctx, ctx->buf); ctx->curlen = 0; } /* pad upto 120 bytes of zeroes * note: that from 112 to 120 is the 64 MSB of the length. We assume that * you won't hash > 2^64 bits of data... :-) */ while (ctx->curlen < 120) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+120); sha512_compress(ctx, ctx->buf); /* copy output */ for (i = 0; i < 8; i++) { LTC_STORE64H(ctx->state[i], out+(8*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int ltc_sha512_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[64]; } tests[] = { { "abc", { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a, 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f } }, { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 } }, }; int i; unsigned char tmp[64]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { ltc_sha512_init(&md); ltc_sha512_process(&md, (const unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); ltc_sha512_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 64) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } #include "ltc_sha384.c" |
Added Source/descriptors/digestDescriptors/ltc_sha2_descriptor/ltc_sha512.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * ltc_sha512.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #ifndef _LTC_SHA512_H_ #define _LTC_SHA512_H_ #define LTC_SHA512_HASHSIZE 64 #define LTC_SHA512_BLOCKSIZE 128 typedef struct ltc_sha512_state { uint64_t length, curlen; uint64_t state[8]; unsigned char buf[LTC_SHA512_BLOCKSIZE]; } ltc_sha512_ctx; int ltc_sha512_init(ltc_sha512_ctx *ctx); int ltc_sha512_process(ltc_sha512_ctx *ctx, const unsigned char *in, unsigned long inlen); int ltc_sha512_done(ltc_sha512_ctx *ctx, unsigned char *hash); int ltc_sha512_test(void); #endif /* _LTC_SHA512_H_ */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha1_descriptor/vng_neon_sha1.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) #include <stdio.h> #include "vng_neon_sha1.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file vng_neon_sha1.c original LTC_SHA1 code by Tom St Denis optimized compress function by the Vector and Numerics Group */ const ccDescriptor vng_neon_sha1_desc = { .implementation_info = &cc_sha1_impinfo, .dtype.digest.hashsize = CC_SHA1_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA1_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_neon_sha1_init, .dtype.digest.process = &vng_neon_sha1_process, .dtype.digest.done = &vng_neon_sha1_done, }; /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_neon_sha1_init(vng_neon_sha1_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0xc3d2e1f0UL; ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int vng_neon_sha1_process(vng_neon_sha1_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); if (ctx->curlen > sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (ctx->curlen == 0 && inlen >= VNG_NEON_SHA1_BLOCKSIZE && CC_XALIGNED(in, 4)) { fullblocks = inlen / VNG_NEON_SHA1_BLOCKSIZE; remainder = inlen % VNG_NEON_SHA1_BLOCKSIZE; processed = fullblocks * VNG_NEON_SHA1_BLOCKSIZE; sha1_vng_armv7neon_compress (ctx->state, fullblocks, in); ctx->length += VNG_NEON_SHA1_BLOCKSIZE * 8 * fullblocks; in += processed; inlen -= processed; } else { n = MIN(inlen, (VNG_NEON_SHA1_BLOCKSIZE - ctx->curlen)); memcpy(ctx->buf + ctx->curlen, in, (size_t)n); ctx->curlen += n; in += n; inlen -= n; if (ctx->curlen == VNG_NEON_SHA1_BLOCKSIZE) { sha1_vng_armv7neon_compress (ctx->state, 1, ctx->buf); ctx->length += 8*VNG_NEON_SHA1_BLOCKSIZE; ctx->curlen = 0; } } } return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (20 bytes) @return CRYPT_OK if successful */ int vng_neon_sha1_done(vng_neon_sha1_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } sha1_vng_armv7neon_compress(ctx->state, 1, ctx->buf); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+56); sha1_vng_armv7neon_compress(ctx->state, 1, ctx->buf); /* copy output */ for (i = 0; i < 5; i++) { LTC_STORE32H(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(md, sizeof(ltc_hash_state)); #endif return CRYPT_OK; } /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int vng_neon_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { const char *msg; unsigned char hash[20]; } tests[] = { { "abc", { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d } }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 } } }; int i; unsigned char tmp[20]; ltc_hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { vng_neon_sha1_init(&md); vng_neon_sha1_process(&md, (const unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); vng_neon_sha1_done(&md, tmp); if (LTC_XMEMCMP(tmp, tests[i].hash, 20) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha1_descriptor/vng_neon_sha1.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_neon_sha1.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <stdint.h> #include <arm/arch.h> #if defined(_ARM_ARCH_7) #ifndef _VNG_NEON_SHA1_H_ #define _VNG_NEON_SHA1_H_ #define VNG_NEON_SHA1_HASHSIZE 20 #define VNG_NEON_SHA1_BLOCKSIZE 64 typedef struct vng_neon_sha1_state { uint32_t state[5]; uint64_t length; unsigned char buf[VNG_NEON_SHA1_BLOCKSIZE]; int curlen; } vng_neon_sha1_ctx; int vng_neon_sha1_init(vng_neon_sha1_ctx *ctx); int vng_neon_sha1_process(vng_neon_sha1_ctx *ctx, const unsigned char *in, unsigned long inlen); int vng_neon_sha1_done(vng_neon_sha1_ctx *ctx, unsigned char *hash); void sha1_vng_armv7neon_compress(uint32_t state[], unsigned long nblocks, unsigned char *); #endif /* _ARM_ARCH_7 */ #endif /* _VNG_NEON_SHA1_H_ */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha1_descriptor/vng_neon_sha1Compress.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 | /* This file is copied from xnu-1776 (sha1armv7neon.s) and renamed to the current name to replace a buggy version (based on an earlier version I sent to murf (and eventually to Fabrice). It improves the sha1 performance slightly (8.3 to 7.5 cycles/byte), and also fixes a compiled-off vpop/vpush bug (compiled only for kernel code). The problem with the earlier code that murf/Fabrice was working on is that the order of the 2nd and 3rd calling arguments are switched. (r1/r2). While the internal code uses r1 as an temp register, simply changing the order will have the number of blocks corrupted with temp variable. This is fixed by staying with the original order (r0/r1/r2) = (out/in/blocks), and have r1/r2 switched the 1st thing the subroutine is called. I ran the test to verify this fixes the bug. cclee 1-13-11 sha1armv7neon.s : this file provides optimized armv7+neon implementation of the sha1 function CoreOS - vector & numerics group cclee 10-10-10 The implementation is based on the principle described in an Intel online article "Improving the Performance of the Secure Hash Algorithm (SHA-1)" http://software.intel.com/en-us/articles/improving-the-performance-of-the-secure-hash-algorithm-1/ Update HASH[] by processing a one 64-byte block in MESSAGE[] can be represented by the following C function void SHA1( int HASH[], int MESSAGE[] ) { int A[81], B[81], C[81], D[81], E[81]; int W[80]; int i, FN; A[0] = HASH[0]; B[0] = HASH[1]; C[0] = HASH[2]; D[0] = HASH[3]; E[0] = HASH[4]; for ( i=0; i<80; ++i ) { if ( i < 16 ) W[i] = BIG_ENDIAN_LOAD( MESSAGE[i] ); else W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); FN = F( i, B[i], C[i], D[i] ); A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + W[i] + K(i); B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; } HASH[0] += A[80]; HASH[1] += B[80]; HASH[2] += C[80]; HASH[3] += D[80]; HASH[4] += E[80]; } For i=0:15, W[i] is simply big-endian loading of MESSAGE[i]. For i=16:79, W[i] is updated according to W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); The approach (by Dean Gaudet) can be used to vectorize the computation of W[i] for i=16:79, 1. update 4 consequtive W[i] (stored in a single 16-byte register) W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 2. this additional calculation unfortunately requires many additional operations W[i+3] ^= W[i] rol 1 3. once we have 4 W[i] values in a Q register, we can also add four K values with one instruction W[i:i+3] += {K,K,K,K} Let W0 = {W[i] W[i+1] W[i+2] W[i+3]} be the current W-vector to be computed, W4 = {W[i-4] W[i-3] W[i-2] W[i-1]} be the previous vector, and so on The Dean Gaudet approach can be expressed as 1. W0 = rotate_left(left_shift(W4,32) ^ W8 ^ left_shift(concatenate(W16,W12),64) ^ W16,1); 2. W[i+3] ^= W[i] rol 1 3. W0 += {K,K,K,K} For i>=32, the Intel online article suggests that (using a basic identity (X rol 1) rol 1 = X rol 2) the update equation is equivalent to 1. W0 = rotate_left(left_shift(concatenate(W8,W4),64) ^ W16 ^ W28 ^ W32, 2); Note: 1. In total, we need 8 16-byte registers or memory for W0,W4,...,W28. W0 and W32 can be the same register or memory. 2. The registers are used in a circular buffering mode. For example, we start with W28,W24,...,W0 (with W0 indicating the most recent 16-byte) i=0, W28,W24,...,W0 i=4, W24,W20,...,W28 i=8, W20,W16,...,W24 . . and so forth. 3. once W-vector is computed, W+K is then computed and saved in the stack memory, this will be used later when updating the digests A/B/C/D/E the execution flow (for 1 single 64-byte block) looks like W_PRECALC_00_15 // big-endian loading of 64-bytes into 4 W-vectors, compute WK=W+K, save WK in the stack memory W_PRECALC_16_31 // for each vector, update digests, update W (Gaudet) and WK=W+K, save WK in the stack memory W_PRECALC_32_79 // for each vector, update digests, update W (Intel) and WK=W+K, save WK in the stack memory our implementation (allows multiple blocks per call) pipelines the loading of W/WK of a future block into the last 16 rounds of its previous block: ---------------------------------------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into 4 Q registers pre_calculate and store WK = W+K(0:15) in 16-byte aligned stack memory L_loop: load digests a-e from ctx->state; for (r=0;r<16;r+=4) { digests a-e update and permute round r:r+3 update W([r:r+3]%16) (Gaudet) and WK([r:r+3]%16) for the next 4th iteration } for (r=16;r<64;r+=4) { digests a-e update and permute round r:r+3 update W([r:r+3]%16) (Intel) and WK([r:r+3]%16) for the next 4th iteration } num_block--; if (num_block==0) jmp L_last_block; for (r=64;r<80;r+=4) { digests a-e update and permute round r:r+3 load W([r:r+3]%16) (big-endian per 4 bytes) into 4 Q registers pre_calculate and store W+K([r:r+3]%16) in stack } ctx->states += digests a-e; jmp L_loop; L_last_block: for (r=64;r<80;r+=4) { digests a-e update and permute round r:r+3 } ctx->states += digests a-e; ---------------------------------------------------------------------------------------------------------- */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) #define OPTIMIZED 1 // defined OPTIMIZED to use our final optimized assembly code #define Multiple_Blocks 1 // defined Multiple_Blocks to allow performing multiple blocks sha1 computation per call // i.e., change to prototype to void SHA1( int HASH[], int MESSAGE[], int num_blocks ); // symbolizing all used variables #define ctx r0 // SHA1_CTX *ctx; #define buf r1 // char *MESSAGE[]; #define num_blocks r2 // int num_blocks; this is used only if Multiple_Blocks is defined. #define K_BASE r3 // to point to the tables for K #define HASH_PTR r4 // copy of ctx, to release r0 for other usage #define BUFFER_PTR r5 // copy of buf, to release r1 for other usage // sha1 digests a-e #define A r6 #define B r8 #define C r9 #define D r10 #define E r11 // temp variables #define T1 r0 #define T2 r1 // used Q registers #define W_TMP q12 #define W_TMP2 q13 #define ZERO q14 #define K_VALUES q15 #define W0 q4 #define W4 q5 #define W8 q6 #define W12 q7 #define W16 q8 #define W20 q9 #define W24 q10 #define W28 q11 // for round t (0:79), W+K was previously saved in the stack space, and can be referenced by #define WK(t) [sp, #((t&15)*4)] // ----------- macros for initial rounds 0:15 big-endian loading of message[] and saving W+K into stack --------- .macro W_PRECALC_00_15_0 // default : BUFFER_PTR points to the current message block vld1.f32 {W_TMP},[BUFFER_PTR]! // loading 16-byte message[] (16-byte aligned) into W_TMP .endm .macro W_PRECALC_00_15_1 // input $0 : current 16-bytes in the circular buffer vrev32.8 $0, W_TMP // byte swap W_TMP and save to $0 .endm .macro W_PRECALC_00_15_2 // $0 = W, K_VALUES = (K,K,K,K) vadd.s32 W_TMP, $0, K_VALUES // W_TMP = W + K .endm .macro W_PRECALC_00_15_3 // default : lr points to the 16-byte aligned memory to store W+K vst1.s32 {W_TMP}, [lr,:128]! // save W[i]+K in 16-byte aligned stack memory .endm .macro INITIAL_W_PRECALC vld1.s32 {K_VALUES}, [K_BASE,:128]! // loading K values into a Q register // W28,W24,....,W4,W0 is used as memory in a circular buffer. They are listed in forward order from left to right. // The last one, e.g., W0=W[0], is the current 4 .long (4-bytes) register. W4 = W[-4]. W28 = W[-28]. // After a circular buffer rotation, W28 = W[0], W0 = W[-4], W4 = W[-8] and so forth. #if !OPTIMIZED // proliferate the code using the above 4 macros // at this point, lr = sp (16-bytes aligned), K_VALUES dupped with K, NUFFER_PTR points to the current message[] // i=0 // circular buffer : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 // W_TMP = (BUFFER_PTR) W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W[0] = W_TMP W_PRECALC_00_15_2 W0 // W_TMP = W[0] + K[0] W_PRECALC_00_15_3 // (sp) = W_TMP = W[0] + K[0] // i=4 // circular buffer : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 // W_TMP = 16(BUFFER_PTR) W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W[0] = W_TMP W_PRECALC_00_15_2 W28 // W_TMP = W[0] + K[0] W_PRECALC_00_15_3 // 16(sp) = W_TMP = W[0] + K[0] // i=8 // circular buffer : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 // W_TMP = 32(BUFFER_PTR) W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W[0] = W_TMP W_PRECALC_00_15_2 W24 // W_TMP = W[0] + K[0] W_PRECALC_00_15_3 // 32(sp) = W_TMP = W[0] + K[0] // i=12 // circular buffer : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 // W_TMP = 48(BUFFER_PTR) W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W[0] = W_TMP W_PRECALC_00_15_2 W20 // W_TMP = W[0] + K[0] W_PRECALC_00_15_3 // 48(sp) = W_TMP = W[0] + K[0] #else // the following performs the same task, using less instructions (and slightly fewer CPU cycles) //the code uses W4 W8 temporarily, with no harm vld1.f32 {W_TMP,W_TMP2},[BUFFER_PTR]! vld1.f32 {W4,W8},[BUFFER_PTR]! vrev32.8 W0, W_TMP vrev32.8 W28, W_TMP2 vrev32.8 W24, W4 vrev32.8 W20, W8 vadd.s32 W_TMP, W0, K_VALUES vadd.s32 W_TMP2, W28, K_VALUES vadd.s32 W4, W24, K_VALUES vadd.s32 W8, W20, K_VALUES vst1.s32 {W_TMP,W_TMP2}, [lr,:128]! // save W[i]+K(i) in stack memory vst1.s32 {W4,W8}, [lr,:128]! // save W[i]+K(i) in stack memory #endif .endm // INITIAL_W_PRECALC // ----------------- functions F1/F2/F3/F4 used in updating the sha1 digests ----------------------- // F1(b,c,d) = ((((c) ^ (d)) & (b)) ^ (d)) .macro F1 eor T1, $2, $1 and T1, $0 eor T1, $2 .endm // F2(b,c,d) = ((b) ^ (c) ^ (d)) .macro F2 eor T1, $1, $2 eor T1, $0 .endm // F3(b,c,d) = (((b) & (c)) | (((b) | (c)) & (d))) .macro F3 orr T1, $0, $1 and r12, $1, $0 and T1, $2 orr T1, r12 .endm #define F4 F2 // F4 = F2 // ------------------------------------------------------------------------------------------------- // ------ macros for performing sha1 digest update, rotating the roles of digest registers ------- /* FN = F( i, B[i], C[i], D[i] ); A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + WK[i]; B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; */ .macro RR0 $0 $2, $3, $4 // T1 = FN = F( i, B[i], C[i], D[i] ); ldr r12, WK($6) // r12 = WK[i] ror $2, #2 // C[i+1] = ROTATE_LEFT( B[i], 30 ); add $5, r12 // E[i] + WK[i] ldr r12, WK($6+1) // r12 = WK[i+1] add $4, r12 // D[i] + WK[i+1] add $5, T1 // E[i] + WK[i] + FN .endm .macro RR1 add $5, $5, $1, ror #27 // T2 = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + WK[i] add $4, $5, ror #27 // E[i+1] + WK[i+1] + ROTATE_LEFT( A[i+1], 5 ) $0 $1, $2, $3 // T1 = FN = F(i+1, B[i+1], C[i+1], D[i+1]) add $4, T1 // FN + FN + E[i+1] + ROTATE_LEFT( A[i+1], 5 ) + WK[i+1]; ror $1, #2 // C[i+1] = B[i] = ROTATE_LEFT( B[i], 30 ); .endm // ------------------------------------------------------------------------------------------------- // RR0/RR1 and F1/F2/F3 are combined (re-organize the instruction schedule to reduce stalls) // hence the following 6 combined macros .macro RR0_F1 ldr r12, WK($6) eor T1, $3, $4 ldr T2, WK($6+1) and T1, $2 add $5, r12 ror $2, #2 eor T1, $4 add $4, T2 add $5, T1 .endm .macro RR0_F2 ldrd T1,T2,WK($6) eor r12, $2, $4 ror $2, #2 eor r12, $3 add $5, T1 add $4, T2 add $5, r12 .endm .macro RR0_F3 ldr r12, WK($6) orr T1, $2, $3 and T2, $2, $3 ror $2, #2 add $5, r12 ldr r12, WK($6+1) and T1, $4 orr T1, T2 add $4, r12 add $5, T1 .endm .macro RR1_F1 add $5, $5, $1, ror #27 eor T1, $3, $2 and T1, $1 eor T1, $3 add $4, $5, ror #27 ror $1, #2 add $4, T1 .endm .macro RR1_F2 eor T1, $1, $2 add $5, $5, $1, ror #27 eor T1, $3 add $4, T1 add $4, $5, ror #27 ror $1, #2 .endm .macro RR1_F3 add $5, $5, $1, ror #27 orr T1, $1, $2 and T1, $3 and r12, $1, $2 orr T1, r12 add $4, $5, ror #27 ror $1, #2 add $4, T1 .endm // ------ rounds 16-31 compute W[0] using the vectorization approach by Dean Gaudet ------- /* W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 W[i+3] ^= W[i] rol 1 */ // -------------- macros for rounds 16-31 compute W (Gaudet's approach) and save W+K -------------- .macro W_PRECALC_16_31_0 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 veor $4, $2 // W_8 ^ W_14 vext.32 W_TMP,$3,ZERO,#1 .endm .macro W_PRECALC_16_31_1 // W_16,W veor W_TMP, $0 // W_3 ^ W_16 veor $1, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 vshl.i32 W_TMP, $1, #1 vext.32 W_TMP2,ZERO, $1, #1 vshr.u32 $1, #31 .endm .macro W_PRECALC_16_31_2 // W vorr W_TMP, $0 vshl.i32 $0, W_TMP2, #2 vshr.u32 W_TMP2, #30 .endm .macro W_PRECALC_16_31_3 // W, i, K_XMM veor W_TMP, W_TMP2 veor W_TMP, $0 vadd.s32 W_TMP2, W_TMP, K_VALUES vorr $0, W_TMP, W_TMP vst1.f32 {W_TMP2}, [lr,:128]! .endm // -------------- macros for rounds 32-79 compute W (Max's approach) and save W+K -------------- .macro W_PRECALC_32_79_0 // W_28,W_8,W_4,W veor $3, $0 vext.64 W_TMP, $1, $2, #1 .endm .macro W_PRECALC_32_79_1 // W_16,W veor W_TMP, $0 veor W_TMP, $1 vshr.u32 $1, W_TMP, #30 vshl.i32 W_TMP, #2 .endm .macro W_PRECALC_32_79_2 // W vorr W_TMP, $0 .endm .macro W_PRECALC_32_79_3 // W, i, K_XMM vadd.s32 W_TMP2, W_TMP, K_VALUES vorr $0, W_TMP, W_TMP vst1.f32 {W_TMP2}, [lr,:128]! .endm // the main code body in early revisions --- no so optimized #if !OPTIMIZED .macro INTERNAL // i=16 // circular buffer : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_16_31_0 W0,W28,W24,W20,W16 RR0_F1 F1,A,B,C,D,E,0 W_PRECALC_16_31_1 W0,W16 RR1_F1 F1,A,B,C,D,E,0 W_PRECALC_16_31_2 W16 RR0_F1 F1,D,E,A,B,C,2 W_PRECALC_16_31_3 W16, 2, 0 RR1_F1 F1,D,E,A,B,C,2 vld1.s32 {K_VALUES}, [K_BASE,:128]! // i=20, // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_16_31_0 W28,W24,W20,W16,W12 RR0_F1 F1,B,C,D,E,A,4 W_PRECALC_16_31_1 W28,W12 RR1_F1 F1,B,C,D,E,A,4 W_PRECALC_16_31_2 W12 RR0_F1 F1,E,A,B,C,D,6 W_PRECALC_16_31_3 W12, 6, 16 RR1_F1 F1,E,A,B,C,D,6 // i=24, // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_16_31_0 W24,W20,W16,W12,W8 RR0_F1 F1,C,D,E,A,B,8 W_PRECALC_16_31_1 W24,W8 RR1_F1 F1,C,D,E,A,B,8 W_PRECALC_16_31_2 W8 RR0_F1 F1,A,B,C,D,E,10 W_PRECALC_16_31_3 W8,10,16 RR1_F1 F1,A,B,C,D,E,10 // i=28 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_16_31_0 W20,W16,W12,W8,W4 RR0_F1 F1,D,E,A,B,C,12 W_PRECALC_16_31_1 W20,W4 RR1_F1 F1,D,E,A,B,C,12 W_PRECALC_16_31_2 W4 RR0_F1 F1,B,C,D,E,A,14 W_PRECALC_16_31_3 W4,14,16 RR1_F1 F1,B,C,D,E,A,14 sub lr, #0x40 //i=32 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0_F1 F1,E,A,B,C,D,16 W_PRECALC_32_79_1 W16,W0 RR1_F1 F1,E,A,B,C,D,16 W_PRECALC_32_79_2 W0 RR0_F1 F1,C,D,E,A,B,18 W_PRECALC_32_79_3 W0,18,16 RR1_F1 F1,C,D,E,A,B,18 //i=36 // W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_32_79_0 W24,W4,W0,W28 RR0_F2 F2,A,B,C,D,E,20 W_PRECALC_32_79_1 W12,W28 RR1_F2 F2,A,B,C,D,E,20 W_PRECALC_32_79_2 W28 RR0_F2 F2,D,E,A,B,C,22 W_PRECALC_32_79_3 W28,22,16 RR1_F2 F2,D,E,A,B,C,22 vld1.s32 {K_VALUES}, [K_BASE,:128]! //i=40 #undef K_XMM #define K_XMM 32 // W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_32_79_0 W20,W0,W28,W24 RR0_F2 F2,B,C,D,E,A,24 W_PRECALC_32_79_1 W8,W24 RR1_F2 F2,B,C,D,E,A,24 W_PRECALC_32_79_2 W24 RR0_F2 F2,E,A,B,C,D,26 W_PRECALC_32_79_3 W24,26,K_XMM RR1_F2 F2,E,A,B,C,D,26 //i=44 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0_F2 F2,C,D,E,A,B,28 W_PRECALC_32_79_1 W4,W20 RR1_F2 F2,C,D,E,A,B,28 W_PRECALC_32_79_2 W20 RR0_F2 F2,A,B,C,D,E,30 W_PRECALC_32_79_3 W20,30,K_XMM RR1_F2 F2,A,B,C,D,E,30 sub lr, #0x40 //i=48 // W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0 W12,W24,W20,W16 RR0_F2 F2,D,E,A,B,C,32 W_PRECALC_32_79_1 W0,W16 RR1_F2 F2,D,E,A,B,C,32 W_PRECALC_32_79_2 W16 RR0_F2 F2,B,C,D,E,A,34 W_PRECALC_32_79_3 W16,34,K_XMM RR1_F2 F2,B,C,D,E,A,34 //i=52 // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0 W8,W20,W16,W12 RR0_F2 F2,E,A,B,C,D,36 W_PRECALC_32_79_1 W28,W12 RR1_F2 F2,E,A,B,C,D,36 W_PRECALC_32_79_2 W12 RR0_F2 F2,C,D,E,A,B,38 W_PRECALC_32_79_3 W12,38,K_XMM RR1_F2 F2,C,D,E,A,B,38 //i=56 // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0 W4,W16,W12,W8 RR0_F3 F3,A,B,C,D,E,40 W_PRECALC_32_79_1 W24,W8 RR1 F3,A,B,C,D,E,40 W_PRECALC_32_79_2 W8 RR0_F3 F3,D,E,A,B,C,42 W_PRECALC_32_79_3 W8,42,K_XMM RR1_F3 F3,D,E,A,B,C,42 vld1.s32 {K_VALUES}, [K_BASE,:128]! //i=60 #undef K_XMM #define K_XMM 48 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_32_79_0 W0,W12,W8,W4 RR0_F3 F3,B,C,D,E,A,44 W_PRECALC_32_79_1 W20,W4 RR1_F3 F3,B,C,D,E,A,44 W_PRECALC_32_79_2 W4 RR0_F3 F3,E,A,B,C,D,46 W_PRECALC_32_79_3 W4,46,K_XMM RR1_F3 F3,E,A,B,C,D,46 sub lr, #0x40 //i=64 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0_F3 F3,C,D,E,A,B,48 W_PRECALC_32_79_1 W16,W0 RR1_F3 F3,C,D,E,A,B,48 W_PRECALC_32_79_2 W0 RR0_F3 F3,A,B,C,D,E,50 W_PRECALC_32_79_3 W0,50,K_XMM RR1_F3 F3,A,B,C,D,E,50 //i=68 // W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_32_79_0 W24,W4,W0,W28 RR0_F3 F3,D,E,A,B,C,52 W_PRECALC_32_79_1 W12,W28 RR1_F3 F3,D,E,A,B,C,52 W_PRECALC_32_79_2 W28 RR0_F3 F3,B,C,D,E,A,54 W_PRECALC_32_79_3 W28,54,K_XMM RR1_F3 F3,B,C,D,E,A,54 //i=72 // W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_32_79_0 W20,W0,W28,W24 RR0_F3 F3,E,A,B,C,D,56 W_PRECALC_32_79_1 W8,W24 RR1_F3 F3,E,A,B,C,D,56 W_PRECALC_32_79_2 W24 RR0_F3 F3,C,D,E,A,B,58 W_PRECALC_32_79_3 W24,58,K_XMM RR1_F3 F3,C,D,E,A,B,58 // starting using F4 //i=76 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0_F2 F4,A,B,C,D,E,60 W_PRECALC_32_79_1 W4,W20 RR1_F2 F4,A,B,C,D,E,60 W_PRECALC_32_79_2 W20 RR0_F2 F4,D,E,A,B,C,62 W_PRECALC_32_79_3 W20,62,K_XMM RR1_F2 F4,D,E,A,B,C,62 sub K_BASE, #64 sub lr, #0x40 .endm #endif // !OPTIMIZED // macros that further combined W_PRECALC_16_31_0 with RR0 to reduce pipeline stalls .macro W_PRECALC_16_31_0_RR0_0 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldr r12, WK(0) eor T1, $7, $8 ldr T2, WK(1) vext.32 W_TMP,$3,ZERO,#1 and T1, $6 add $9, r12 ror $6, #2 veor $4, $2 // W_8 ^ W_14 eor T1, $8 add $8, T2 add $9, T1 ror T2, $5, #27 .endm .macro W_PRECALC_16_31_0_RR0_4 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldr r12, WK(4) eor T1, $7, $8 ldr T2, WK(5) vext.32 W_TMP,$3,ZERO,#1 and T1, $6 add $9, r12 ror $6, #2 veor $4, $2 // W_8 ^ W_14 eor T1, $8 add $8, T2 add $9, T1 ror T2, $5, #27 .endm .macro W_PRECALC_16_31_0_RR0_8 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldr r12, WK(8) eor T1, $7, $8 ldr T2, WK(9) vext.32 W_TMP,$3,ZERO,#1 and T1, $6 add $9, r12 ror $6, #2 veor $4, $2 // W_8 ^ W_14 eor T1, $8 add $8, T2 add $9, T1 ror T2, $5, #27 .endm .macro W_PRECALC_16_31_0_RR0_12 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldr r12, WK(12) eor T1, $7, $8 ldr T2, WK(13) vext.32 W_TMP,$3,ZERO,#1 and T1, $6 add $9, r12 ror $6, #2 veor $4, $2 // W_8 ^ W_14 eor T1, $8 add $8, T2 add $9, T1 ror T2, $5, #27 .endm // macros that further combined W_PRECALC_16_31_1 with RR1 to reduce pipeline stalls .macro W_PRECALC_16_31_1_RR1 // W_16,W veor W_TMP, $0 // W_3 ^ W_16 eor T1, $4, $3 and T1, $2 add T2, $6 eor T1, $4 veor $1, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 orr $6, T2, T2 // ror T2, #27 vshl.i32 W_TMP, $1, #1 ror $2, #2 vext.32 W_TMP2,ZERO, $1, #1 add $5, T1 vshr.u32 $1, #31 add $5, T2, ror #27 .endm // macros that further combined W_PRECALC_16_31_2 with RR0 to reduce pipeline stalls .macro W_PRECALC_16_31_2_RR0 // W ldr r12, WK($6) vorr W_TMP, $0 eor T1, $3, $4 ldr T2, WK($6+1) and T1, $2 vshl.i32 $0, W_TMP2, #2 add $5, r12 ror $2, #2 eor T1, $4 add $4, T2 vshr.u32 W_TMP2, #30 ror T2, $1, #27 add $5, T1 .endm // macros that further combined W_PRECALC_16_31_3 with RR1 to reduce pipeline stalls .macro W_PRECALC_16_31_3_RR1 // W, i, K_XMM veor W_TMP, W_TMP2 eor T1, $3, $2 add T2, $5 and T1, $1 ror $1, #2 veor W_TMP, $0 orr $5, T2, T2 // ror T2, #27 vadd.s32 W_TMP2, W_TMP, K_VALUES eor T1, $3 vorr $0, W_TMP, W_TMP add $4, T2, ror #27 vst1.f32 {W_TMP2}, [lr,:128]! add $4, T1 .endm // a super macro that combines 4 macro proliferations to further reduce pipeline stalls // W_PRECALC_16_31_0_RR0_0 W0,W28,W24,W20,W16,A,B,C,D,E // W_PRECALC_16_31_1_RR1 W0,W16,A,B,C,D,E // W_PRECALC_16_31_2_RR0 W16,D,E,A,B,C,2 // W_PRECALC_16_31_3_RR1 W16,D,E,A,B,C .macro SUPER_W_PRECALC_16_31_0 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldrd T1, T2, WK(0) vext.32 W_TMP,$3,ZERO,#1 eor r12, $7, $8 veor $4, $2 // W_8 ^ W_14 and r12, $6 veor W_TMP, $0 // W_3 ^ W_16 add $9, T1 ror $6, #2 eor r12, $8 add $8, T2 veor $4, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 add $9, r12 eor r12, $7, $6 vext.32 W_TMP2,ZERO, $4, #1 add $9, $9, $5, ror #27 vshl.i32 W_TMP, $4, #1 and r12, $5 vshr.u32 $4, #31 eor r12, $7 vorr W_TMP, $4 ror $5, #2 vshl.i32 $4, W_TMP2, #2 add $8, r12 vshr.u32 W_TMP2, #30 add $8, $9, ror #27 ldrd T1, T2, WK(2) eor r12, $5, $6 veor W_TMP, W_TMP2 add $7, T1 and r12, $9 ror $9, #2 veor W_TMP, $4 eor r12, $6 add $6, T2 vadd.s32 W_TMP2, W_TMP, K_VALUES add $7, r12 vorr $4, W_TMP, W_TMP eor r12, $5, $9 add $7, $7, $8, ror #27 and r12, $8 ror $8, #2 eor r12, $5 add $6, $7, ror #27 vst1.f32 {W_TMP2}, [lr,:128]! add $6, r12 .endm // a super macro that combines 4 macro proliferations to further reduce pipeline stalls // W_PRECALC_16_31_0_RR0_4 W28,W24,W20,W16,W12,B,C,D,E,A // W_PRECALC_16_31_1_RR1 W28,W12,B,C,D,E,A // W_PRECALC_16_31_2_RR0 W12,E,A,B,C,D,6 // W_PRECALC_16_31_3_RR1 W12,E,A,B,C,D .macro SUPER_W_PRECALC_16_31_4 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldrd T1, T2, WK(4) vext.32 W_TMP,$3,ZERO,#1 eor r12, $7, $8 veor $4, $2 // W_8 ^ W_14 and r12, $6 veor W_TMP, $0 // W_3 ^ W_16 add $9, T1 ror $6, #2 eor r12, $8 add $8, T2 veor $4, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 add $9, r12 eor r12, $7, $6 vext.32 W_TMP2,ZERO, $4, #1 add $9, $9, $5, ror #27 vshl.i32 W_TMP, $4, #1 and r12, $5 vshr.u32 $4, #31 eor r12, $7 vorr W_TMP, $4 ror $5, #2 vshl.i32 $4, W_TMP2, #2 add $8, r12 vshr.u32 W_TMP2, #30 add $8, $9, ror #27 ldrd T1, T2, WK(6) eor r12, $5, $6 veor W_TMP, W_TMP2 add $7, T1 and r12, $9 ror $9, #2 veor W_TMP, $4 eor r12, $6 add $6, T2 vadd.s32 W_TMP2, W_TMP, K_VALUES add $7, r12 vorr $4, W_TMP, W_TMP eor r12, $5, $9 add $7, $7, $8, ror #27 and r12, $8 ror $8, #2 eor r12, $5 add $6, $7, ror #27 vst1.f32 {W_TMP2}, [lr,:128]! add $6, r12 .endm // a super macro that combines 4 macro proliferations to further reduce pipeline stalls // W_PRECALC_16_31_0_RR0_8 W24,W20,W16,W12,W8,C,D,E,A,B // W_PRECALC_16_31_1_RR1 W24,W8,C,D,E,A,B // W_PRECALC_16_31_2_RR0 W8,A,B,C,D,E,10 // W_PRECALC_16_31_3_RR1 W8,A,B,C,D,E .macro SUPER_W_PRECALC_16_31_8 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldrd T1, T2, WK(8) vext.32 W_TMP,$3,ZERO,#1 eor r12, $7, $8 veor $4, $2 // W_8 ^ W_14 and r12, $6 veor W_TMP, $0 // W_3 ^ W_16 add $9, T1 ror $6, #2 eor r12, $8 add $8, T2 veor $4, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 add $9, r12 //ror T2, $5, #27 eor r12, $7, $6 vext.32 W_TMP2,ZERO, $4, #1 add $9, $9, $5, ror #27 vshl.i32 W_TMP, $4, #1 and r12, $5 vshr.u32 $4, #31 eor r12, $7 vorr W_TMP, $4 ror $5, #2 vshl.i32 $4, W_TMP2, #2 add $8, r12 vshr.u32 W_TMP2, #30 add $8, $9, ror #27 ldrd T1, T2, WK(10) eor r12, $5, $6 veor W_TMP, W_TMP2 add $7, T1 and r12, $9 ror $9, #2 veor W_TMP, $4 eor r12, $6 add $6, T2 vadd.s32 W_TMP2, W_TMP, K_VALUES add $7, r12 vorr $4, W_TMP, W_TMP eor r12, $5, $9 add $7, $7, $8, ror #27 and r12, $8 ror $8, #2 eor r12, $5 add $6, $7, ror #27 vst1.f32 {W_TMP2}, [lr,:128]! add $6, r12 .endm // a super macro that combines 4 macro proliferations to further reduce pipeline stalls // W_PRECALC_16_31_0_RR0_12 W20,W16,W12,W8,W4,D,E,A,B,C // W_PRECALC_16_31_1_RR1 W20,W4,D,E,A,B,C // W_PRECALC_16_31_2_RR0 W4,B,C,D,E,A,14 // W_PRECALC_16_31_3_RR1 W4,B,C,D,E,A .macro SUPER_W_PRECALC_16_31_12 // W_16,W_12,W_8,W_4,W vext.64 $4, $0, $1, #1 ldrd T1, T2, WK(12) vext.32 W_TMP,$3,ZERO,#1 eor r12, $7, $8 veor $4, $2 // W_8 ^ W_14 and r12, $6 veor W_TMP, $0 // W_3 ^ W_16 add $9, T1 ror $6, #2 eor r12, $8 add $8, T2 veor $4, W_TMP // W_3 ^ W_16 ^ W_8 ^ W_14 add $9, r12 //ror T2, $5, #27 eor r12, $7, $6 vext.32 W_TMP2,ZERO, $4, #1 add $9, $9, $5, ror #27 vshl.i32 W_TMP, $4, #1 and r12, $5 vshr.u32 $4, #31 eor r12, $7 vorr W_TMP, $4 ror $5, #2 vshl.i32 $4, W_TMP2, #2 add $8, r12 vshr.u32 W_TMP2, #30 add $8, $9, ror #27 ldrd T1, T2, WK(14) eor r12, $5, $6 veor W_TMP, W_TMP2 add $7, T1 and r12, $9 ror $9, #2 veor W_TMP, $4 eor r12, $6 add $6, T2 vadd.s32 W_TMP2, W_TMP, K_VALUES add $7, r12 vorr $4, W_TMP, W_TMP eor r12, $5, $9 add $7, $7, $8, ror #27 and r12, $8 ror $8, #2 eor r12, $5 add $6, $7, ror #27 vst1.f32 {W_TMP2}, [lr,:128]! add $6, r12 .endm // macros that combine W_PRECALC_32_79 with RR0/RR1 and F1/F2/F3 macros .macro W_PRECALC_32_79_0_RR0_F1 // W_28,W_8,W_4,W ldr r12, WK($9) eor T1, $6, $7 ldr T2, WK($9+1) veor $3, $0 and T1, $5 add $8, r12 ror $5, #2 eor T1, $7 add $7, T2 vext.64 W_TMP, $1, $2, #1 add $8, T1 //ror T2, $4, #27 .endm .macro W_PRECALC_32_79_0_RR0_F2 // W_28,W_8,W_4,W ldr r12, WK($9) veor $3, $0 eor T1, $5, $7 ror $5, #2 add $8, r12 ldr r12, WK($9+1) eor T1, $6 vext.64 W_TMP, $1, $2, #1 add $8, T1 add $7, r12 .endm .macro W_PRECALC_32_79_0_RR0_F3 // W_28,W_8,W_4,W ldr r12, WK($9) veor $3, $0 orr T1, $5, $6 and T2, $5, $6 add $8, r12 ldr r12, WK($9+1) ror $5, #2 vext.64 W_TMP, $1, $2, #1 and T1, $7 add $7, r12 orr T1, T2 add $8, T1 .endm .macro W_PRECALC_32_79_1_RR1 // combined W_PRECALC_32_79_1 and RR1 to absorb some stalls veor W_TMP, $0 add $7, $7, $3, ror #27 veor W_TMP, $1 vshr.u32 $1, W_TMP, #30 add $6, $7, ror #27 vshl.i32 W_TMP, #2 $2 $3, $4, $5 add $6, T1 ror $3, #2 .endm .macro W_PRECALC_32_79_1_RR1_F1 // combined W_PRECALC_32_79_1 and RR1 to absorb some stalls veor W_TMP, $0 eor T1, $5, $4 add $7, $7, $3, ror #27 and T1, $3 veor W_TMP, $1 eor T1, $5 vshr.u32 $1, W_TMP, #30 add $6, T1 vshl.i32 W_TMP, #2 add $6, $7, ror #27 ror $3, #2 .endm .macro W_PRECALC_32_79_1_RR1_F2 // combined W_PRECALC_32_79_1 and RR1 to absorb some stalls veor W_TMP, $0 veor W_TMP, $1 eor T1, $3, $4 add $7, $7, $3, ror #27 eor T1, $5 ror $3, #2 add $6, T1 vshr.u32 $1, W_TMP, #30 vshl.i32 W_TMP, #2 add $6, $7, ror #27 .endm .macro W_PRECALC_32_79_1_RR1_F3 // combined W_PRECALC_32_79_1 and RR1 to absorb some stalls veor W_TMP, $0 veor W_TMP, $1 add $7, $7, $3, ror #27 orr T1, $3, $4 and r12, $4, $3 and T1, $5 add $6, $7, ror #27 orr T1, r12 vshr.u32 $1, W_TMP, #30 vshl.i32 W_TMP, #2 ror $3, #2 add $6, T1 .endm .macro W_PRECALC_32_79_2_RR0_F1 // W ldr r12, WK($6) eor T1, $3, $4 ldr T2, WK($6+1) and T1, $2 add $5, r12 ror $2, #2 eor T1, $4 add $4, T2 vorr W_TMP, $0 add $5, T1 .endm .macro W_PRECALC_32_79_2_RR0_F2 // W ldr r12, WK($6) eor T1, $2, $4 ror $2, #2 eor T1, $3 add $5, r12 ldr r12, WK($6+1) vorr W_TMP, $0 add $5, T1 add $4, r12 .endm .macro W_PRECALC_32_79_2_RR0_F3 // W ldr r12, WK($6) orr T1, $2, $3 and T2, $2, $3 ror $2, #2 add $5, r12 ldr r12, WK($6+1) and T1, $4 vorr W_TMP, $0 orr T1, T2 add $4, r12 add $5, T1 .endm .macro W_PRECALC_32_79_3_RR1_F1 // W, i, K_XMM vadd.s32 W_TMP2, W_TMP, K_VALUES add $5, $5, $1, ror #27 eor T1, $3, $2 vorr $0, W_TMP, W_TMP and T1, $1 ror $1, #2 vst1.f32 {W_TMP2}, [lr,:128]! add $4, $5, ror #27 eor T1, $3 add $4, T1 .endm .macro W_PRECALC_32_79_3_RR1_F2 // W, i, K_XMM vadd.s32 W_TMP2, W_TMP, K_VALUES vorr $0, W_TMP, W_TMP add $5, $5, $1, ror #27 eor T1, $1, $2 ror $1, #2 eor T1, $3 vst1.f32 {W_TMP2}, [lr,:128]! add $4, T1 add $4, $5, ror #27 .endm .macro W_PRECALC_32_79_3_RR1_F3 // W, i, K_XMM vadd.s32 W_TMP2, W_TMP, K_VALUES vorr $0, W_TMP, W_TMP orr T1, $1, $2 add $5, $5, $1, ror #27 and T1, $3 and r12, $1, $2 add $4, $5, ror #27 orr T1, r12 vst1.f32 {W_TMP2}, [lr,:128]! ror $1, #2 add $4, T1 .endm .macro LOAD_HASH ldr A, [HASH_PTR, #0] ldrd B,C, [HASH_PTR, #4] ldrd D,E, [HASH_PTR, #12] .endm // the main code body --- the final optimized version #if OPTIMIZED // rounds 16-31 use the approach by Dean Gaudet .macro INTERNAL // i=16 // circular buffer : W12,W8,W4,W0,W28,W24,W20,W16 #if 1 SUPER_W_PRECALC_16_31_0 W0,W28,W24,W20,W16,A,B,C,D,E #else W_PRECALC_16_31_0_RR0_0 W0,W28,W24,W20,W16,A,B,C,D,E W_PRECALC_16_31_1_RR1 W0,W16,A,B,C,D,E W_PRECALC_16_31_2_RR0 W16,D,E,A,B,C,2 W_PRECALC_16_31_3_RR1 W16,D,E,A,B,C #endif vld1.s32 {K_VALUES}, [K_BASE,:128]! // i=20, // W8,W4,W0,W28,W24,W20,W16,W12 #if 1 SUPER_W_PRECALC_16_31_4 W28,W24,W20,W16,W12,B,C,D,E,A #else W_PRECALC_16_31_0_RR0_4 W28,W24,W20,W16,W12,B,C,D,E,A W_PRECALC_16_31_1_RR1 W28,W12,B,C,D,E,A W_PRECALC_16_31_2_RR0 W12,E,A,B,C,D,6 W_PRECALC_16_31_3_RR1 W12,E,A,B,C,D #endif // i=24, // W4,W0,W28,W24,W20,W16,W12,W8 #if 1 SUPER_W_PRECALC_16_31_8 W24,W20,W16,W12,W8,C,D,E,A,B #else W_PRECALC_16_31_0_RR0_8 W24,W20,W16,W12,W8,C,D,E,A,B W_PRECALC_16_31_1_RR1 W24,W8,C,D,E,A,B W_PRECALC_16_31_2_RR0 W8,A,B,C,D,E,10 W_PRECALC_16_31_3_RR1 W8,A,B,C,D,E #endif // i=28 // W0,W28,W24,W20,W16,W12,W8,W4 #if 1 SUPER_W_PRECALC_16_31_12 W20,W16,W12,W8,W4,D,E,A,B,C #else W_PRECALC_16_31_0_RR0_12 W20,W16,W12,W8,W4,D,E,A,B,C W_PRECALC_16_31_1_RR1 W20,W4,D,E,A,B,C W_PRECALC_16_31_2_RR0 W4,B,C,D,E,A,14 W_PRECALC_16_31_3_RR1 W4,B,C,D,E,A #endif sub lr, #0x40 //i=32 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0_RR0_F1 W28,W8,W4,W0,E,A,B,C,D,16 W_PRECALC_32_79_1_RR1_F1 W16,W0,F1,E,A,B,C,D,16 W_PRECALC_32_79_2_RR0_F1 W0,C,D,E,A,B,18 W_PRECALC_32_79_3_RR1_F1 W0,C,D,E,A,B //i=36 // W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_32_79_0_RR0_F2 W24,W4,W0,W28,A,B,C,D,E,20 W_PRECALC_32_79_1_RR1_F2 W12,W28,F2,A,B,C,D,E,20 W_PRECALC_32_79_2_RR0_F2 W28,D,E,A,B,C,22 W_PRECALC_32_79_3_RR1_F2 W28,D,E,A,B,C vld1.s32 {K_VALUES}, [K_BASE,:128]! //i=40 // W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_32_79_0_RR0_F2 W20,W0,W28,W24,B,C,D,E,A,24 W_PRECALC_32_79_1_RR1_F2 W8,W24,F2,B,C,D,E,A,24 W_PRECALC_32_79_2_RR0_F2 W24,E,A,B,C,D,26 W_PRECALC_32_79_3_RR1_F2 W24,E,A,B,C,D //i=44 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0_RR0_F2 W16,W28,W24,W20,C,D,E,A,B,28 W_PRECALC_32_79_1_RR1_F2 W4,W20,F2,C,D,E,A,B,28 W_PRECALC_32_79_2_RR0_F2 W20,A,B,C,D,E,30 W_PRECALC_32_79_3_RR1_F2 W20,A,B,C,D,E sub lr, #0x40 //i=48 // W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0_RR0_F2 W12,W24,W20,W16,D,E,A,B,C,32 W_PRECALC_32_79_1_RR1_F2 W0,W16,F2,D,E,A,B,C,32 W_PRECALC_32_79_2_RR0_F2 W16,B,C,D,E,A,34 W_PRECALC_32_79_3_RR1_F2 W16,B,C,D,E,A //i=52 // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0_RR0_F2 W8,W20,W16,W12,E,A,B,C,D,36 W_PRECALC_32_79_1_RR1_F2 W28,W12,F2,E,A,B,C,D,36 W_PRECALC_32_79_2_RR0_F2 W12,C,D,E,A,B,38 W_PRECALC_32_79_3_RR1_F2 W12,C,D,E,A,B //i=56 // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0_RR0_F3 W4,W16,W12,W8,A,B,C,D,E,40 W_PRECALC_32_79_1_RR1_F3 W24,W8,F3,A,B,C,D,E,40 W_PRECALC_32_79_2_RR0_F3 W8,D,E,A,B,C,42 W_PRECALC_32_79_3_RR1_F3 W8,D,E,A,B,C vld1.s32 {K_VALUES}, [K_BASE,:128]! //i=60 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_32_79_0_RR0_F3 W0,W12,W8,W4,B,C,D,E,A,44 W_PRECALC_32_79_1_RR1_F3 W20,W4,F3,B,C,D,E,A,44 W_PRECALC_32_79_2_RR0_F3 W4,E,A,B,C,D,46 W_PRECALC_32_79_3_RR1_F3 W4,E,A,B,C,D sub lr, #0x40 //i=64 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0_RR0_F3 W28,W8,W4,W0,C,D,E,A,B,48 W_PRECALC_32_79_1_RR1_F3 W16,W0,F3,C,D,E,A,B,48 W_PRECALC_32_79_2_RR0_F3 W0,A,B,C,D,E,50 W_PRECALC_32_79_3_RR1_F3 W0,A,B,C,D,E //i=68 // W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_32_79_0_RR0_F3 W24,W4,W0,W28,D,E,A,B,C,52 W_PRECALC_32_79_1_RR1_F3 W12,W28,F3,D,E,A,B,C,52 W_PRECALC_32_79_2_RR0_F3 W28,B,C,D,E,A,54 W_PRECALC_32_79_3_RR1_F3 W28,B,C,D,E,A //i=72 // W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_32_79_0_RR0_F3 W20,W0,W28,W24,E,A,B,C,D,56 W_PRECALC_32_79_1_RR1_F3 W8,W24,F3,E,A,B,C,D,56 W_PRECALC_32_79_2_RR0_F3 W24,C,D,E,A,B,58 W_PRECALC_32_79_3_RR1_F3 W24,C,D,E,A,B // starting using F4 //i=76 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0_RR0_F2 W16,W28,W24,W20,A,B,C,D,E,60 W_PRECALC_32_79_1_RR1_F2 W4,W20,F4,A,B,C,D,E,60 W_PRECALC_32_79_2_RR0_F2 W20,D,E,A,B,C,62 W_PRECALC_32_79_3_RR1_F2 W20,D,E,A,B,C sub K_BASE, #64 sub lr, #0x40 .endm #endif // OPTIMIZED .macro SOFTWARE_PIPELINING vld1.s32 {K_VALUES}, [K_BASE,:128]! #if !OPTIMIZED // i=0 // circular buffer : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) RR0_F2 F4,B,C,D,E,A,64 W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W[0] = W_TMP RR1_F2 F4,B,C,D,E,A,64 W_PRECALC_00_15_2 W0 // W_TMP = W[0] + K[0] RR0_F2 F4,E,A,B,C,D,66 W_PRECALC_00_15_3 // (sp) = W_TMP = W[0] + K[0] RR1_F2 F4,E,A,B,C,D,66 // i=4 // circular buffer : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) RR0_F2 F4,C,D,E,A,B,68 W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W[0] = W_TMP RR1_F2 F4,C,D,E,A,B,68 W_PRECALC_00_15_2 W28 // W_TMP = W[0] + K[0] RR0_F2 F4,A,B,C,D,E,70 W_PRECALC_00_15_3 // 16(sp) = W_TMP = W[0] + K[0] RR1_F2 F4,A,B,C,D,E,70 // i=8 // circular buffer : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) RR0_F2 F4,D,E,A,B,C,72 W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W[0] = W_TMP RR1_F2 F4,D,E,A,B,C,72 W_PRECALC_00_15_2 W24 // W_TMP = W[0] + K[0] RR0_F2 F4,B,C,D,E,A,74 W_PRECALC_00_15_3 // 32(sp) = W_TMP = W[0] + K[0] RR1_F2 F4,B,C,D,E,A,74 // i=12 // circular buffer : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) RR0_F2 F4,E,A,B,C,D,76 W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W[0] = W_TMP RR1_F2 F4,E,A,B,C,D,76 W_PRECALC_00_15_2 W20 // W_TMP = W[0] + K[0] RR0_F2 F4,C,D,E,A,B,78 W_PRECALC_00_15_3 // 48(sp) = W_TMP = W[0] + K[0] RR1_F2 F4,C,D,E,A,B,78 #else // i=0 // circular buffer : W28,W24,W20,W16,W12,W8,W4,W0 RR0_F2 F4,B,C,D,E,A,64 vld1.f32 {W_TMP,W_TMP2},[BUFFER_PTR]! RR1_F2 F4,B,C,D,E,A,64 vld1.f32 {W4,W8},[BUFFER_PTR]! RR0_F2 F4,E,A,B,C,D,66 vrev32.8 W0, W_TMP RR1_F2 F4,E,A,B,C,D,66 // i=4 // circular buffer : W24,W20,W16,W12,W8,W4,W0,W28 RR0_F2 F4,C,D,E,A,B,68 vrev32.8 W28, W_TMP2 RR1_F2 F4,C,D,E,A,B,68 vrev32.8 W24, W4 RR0_F2 F4,A,B,C,D,E,70 vrev32.8 W20, W8 RR1_F2 F4,A,B,C,D,E,70 // i=8 // circular buffer : W20,W16,W12,W8,W4,W0,W28,W24 RR0_F2 F4,D,E,A,B,C,72 vadd.s32 W_TMP, W0, K_VALUES RR1_F2 F4,D,E,A,B,C,72 vadd.s32 W_TMP2, W28, K_VALUES RR0_F2 F4,B,C,D,E,A,74 vadd.s32 W4, W24, K_VALUES RR1_F2 F4,B,C,D,E,A,74 // i=12 // circular buffer : W16,W12,W8,W4,W0,W28,W24,W20 RR0_F2 F4,E,A,B,C,D,76 vadd.s32 W8, W20, K_VALUES RR1_F2 F4,E,A,B,C,D,76 vst1.s32 {W_TMP,W_TMP2}, [lr,:128]! // save W[i]+K(i) in stack memory RR0_F2 F4,C,D,E,A,B,78 vst1.s32 {W4,W8}, [lr,:128]! // save W[i]+K(i) in stack memory RR1_F2 F4,C,D,E,A,B,78 #endif sub lr, #0x40 .endm .macro ENDING //i=80 RR0_F2 F4,B,C,D,E,A,64 RR1_F2 F4,B,C,D,E,A,64 RR0_F2 F4,E,A,B,C,D,66 RR1_F2 F4,E,A,B,C,D,66 //i=84 RR0_F2 F4,C,D,E,A,B,68 RR1_F2 F4,C,D,E,A,B,68 RR0_F2 F4,A,B,C,D,E,70 RR1_F2 F4,A,B,C,D,E,70 //i=88 RR0_F2 F4,D,E,A,B,C,72 RR1_F2 F4,D,E,A,B,C,72 RR0_F2 F4,B,C,D,E,A,74 RR1_F2 F4,B,C,D,E,A,74 //i=92 RR0_F2 F4,E,A,B,C,D,76 RR1_F2 F4,E,A,B,C,D,76 RR0_F2 F4,C,D,E,A,B,78 RR1_F2 F4,C,D,E,A,B,78 .endm .macro UPDATE_ALL_HASH ldrd T1, T2, [HASH_PTR,#0] add A, T1 add B, T2 str A, [HASH_PTR,#0] ldrd T1, T2, [HASH_PTR,#8] add C, T1 add D, T2 strd B, C, [HASH_PTR,#4] ldr T1, [HASH_PTR,#16] add E, T1 strd D, E, [HASH_PTR,#12] .endm .macro SHA1_PIPELINED_MAIN_BODY LOAD_HASH // load initial hashes into A,B,C,D,E orr lr, sp, sp INITIAL_W_PRECALC sub lr, #0x40 0: INTERNAL #if Multiple_Blocks subs num_blocks, #1 // pre-decrement num_blocks by 1 ble 1f // if num_blocks <= 0, branch to finish off SOFTWARE_PIPELINING UPDATE_ALL_HASH b 0b 1: #endif ENDING UPDATE_ALL_HASH .endm .text .p2align 4 #define K1 0x5a827999 #define K2 0x6ed9eba1 #define K3 0x8f1bbcdc #define K4 0xca62c1d6 K_XMM_AR: .long K1 .long K1 .long K1 .long K1 .long K2 .long K2 .long K2 .long K2 .long K3 .long K3 .long K3 .long K3 .long K4 .long K4 .long K4 .long K4 .globl _sha1_vng_armv7neon_compress .private_extern _sha1_vng_armv7neon_compress _sha1_vng_armv7neon_compress: // due to the change of order in the 2nd and 3rd calling argument, // we need to switch r1/r2 to use the original code // cclee 1-13-11 mov r12, r1 mov r1, r2 mov r2, r12 push {r4-r7,lr} nop add r7, sp, #12 // set up base pointer for debug tracing push {r8-r11} // align sp to 16-byte boundary ands r12, sp, #15 // number of bytes to align to 16-byte boundary addeq r12, #16 // in case it's already 16-byte aligned and hence no where to store num_aligned_bytes sub sp, r12 str r12, [sp] #if KERNEL vpush {q8-q15} #endif vpush {q4-q7} #define stack_size (16*4) // circular buffer W0-W3 sub sp, #stack_size veor ZERO, ZERO orr HASH_PTR, ctx, ctx orr BUFFER_PTR, buf, buf adr K_BASE, K_XMM_AR SHA1_PIPELINED_MAIN_BODY add sp, #stack_size vpop {q4-q5} vpop {q6-q7} #if KERNEL vpop {q8-q9} vpop {q10-q11} vpop {q12-q13} vpop {q14-q15} #endif // restore sp to its original alignment ldr r12, [sp] add sp, r12 pop {r8-r11} pop {r4-r7,pc} #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha2_descriptor/vng_armv7neon_sha256_compress.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | /* This file provides armv7+neon hand implementation of the following function void SHA256_Transform(SHA256_ctx *ctx, char *data, unsigned int num_blocks); which is a C function in sha2.c (from xnu). sha256 algorithm per block description: 1. W(0:15) = big-endian (per 4 bytes) loading of input data (64 byte) 2. load 8 digests a-h from ctx->state 3. for r = 0:15 T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g 4. for r = 16:63 W[r] = W[r-16] + sigma1(W[r-2]) + W[r-7] + sigma0(W[r-15]); T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g In the assembly implementation: - a circular window of message schedule W(r:r+15) is updated and stored in q0-q3 - its corresponding W+K(r:r+15) is updated and stored in a stack space circular buffer - the 8 digests (a-h) will be stored in GPR or memory the implementation per block looks like ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into q0:q3 pre_calculate and store W+K(0:15) in stack load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ---------------------------------------------------------------------------- our implementation (allows multiple blocks per call) pipelines the loading of W/WK of a future block into the last 16 rounds of its previous block: ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into q0:q3 pre_calculate and store W+K(0:15) in stack L_loop: load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } num_block--; if (num_block==0) jmp L_last_block; for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 load W([r:r+3]%16) (big-endian per 4 bytes) into q0:q3 pre_calculate and store W+K([r:r+3]%16) in stack } ctx->states += digests a-h; jmp L_loop; L_last_block: for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ------------------------------------------------------------------------ Apple CoreOS vector & numerics cclee 10-12-10 */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) // associate variables with registers or memory #define ctx r0 #define data r1 #define num_blocks [sp, #64] #define a r2 #define b r3 #define c r4 #define d r5 #define e r8 #define f r9 #define g r10 #define h r11 #define K r6 // 2 local variables #define t r12 #define s lr // a window (16 words) of message scheule #define W0 q0 #define W1 q1 #define W2 q2 #define W3 q3 #define zero q8 // circular buffer for WK[(r:r+15)%16] #define WK(r) [sp,#(r&15)*4] // #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) .macro Ch mvn t, $0 // ~x and s, $0, $1 // (x) & (y) and t, t, $2 // (~(x)) & (z) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) .endm // #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .macro Maj eor t, $1, $2 // y^z and s, $1, $2 // y&z and t, t, $0 // x&(y^z) eor t, t, s // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .endm // #define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) // performs sigma0_256 on 4 words on a Q register // use q6/q7 as intermediate registers .macro sigma0 vshr.u32 q6, $0, #7 vshl.i32 q7, $0, #14 vshr.u32 $0, $0, #3 veor $0, q6 veor $0, q7 vshr.u32 q6, #11 vshl.i32 q7, #11 veor $0, q6 veor $0, q7 .endm // #define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) // performs sigma1_256 on 4 words on a Q register // use q6/q7 as intermediate registers .macro sigma1 vshr.u32 q6, $0, #17 vshl.i32 q7, $0, #13 vshr.u32 $0, $0, #10 veor $0, q6 veor $0, q7 vshr.u32 q6, #2 vshl.i32 q7, #2 veor $0, q6 veor $0, q7 .endm // #define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .macro Sigma0 ror t, $0, #2 // S32(2, (x)) ror s, $0, #13 // S32(13, (x)) eor t, t, s // S32(2, (x)) ^ S32(13, (x)) ror s, s, #9 // S32(22, (x)) eor t, t, s // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .endm // #define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .macro Sigma1 ror t, $0, #6 // S32(6, (x)) ror s, $0, #11 // S32(11, (x)) eor t, t, s // S32(6, (x)) ^ S32(11, (x)) ror s, s, #14 // S32(25, (x)) eor t, t, s // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .endm // per round digests update .macro round // ror t, $4, #6 // S32(6, (x)) eor t, t, $4, ror #11 // S32(6, (x)) ^ S32(11, (x)) eor t, t, $4, ror #25 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) and s, $4, $5 // (x) & (y) add $7, t // use h to store h+Sigma1(e) bic t, $6, $4 // (~(x)) & (z) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK($8) // add $7, t // t = h+Sigma1(e)+Ch(e,f,g); ror t, $0, #2 // S32(2, (x)) add $7, s // h = T1 eor t, t, $0, ror #13 // S32(2, (x)) ^ S32(13, (x)) add $3, $7 // d += T1; eor t, t, $0, ror #22 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add $7, t // h = T1 + Sigma0(a); eor t, $1, $2 // y^z and s, $1, $2 // y&z and t, t, $0 // x&(y^z) eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) // add $7, s // h = T1 + Sigma0(a) + Maj(a,b,c); .endm // per 4 rounds digests update and permutation // permutation is absorbed by rotating the roles of digests a-h .macro rounds ror t, $4, #6 round $0, $1, $2, $3, $4, $5, $6, $7, 0+$8 ror t, $3, #6 add $7, s round $7, $0, $1, $2, $3, $4, $5, $6, 1+$8 ror t, $2, #6 add $6, s round $6, $7, $0, $1, $2, $3, $4, $5, 2+$8 ror t, $1, #6 add $5, s round $5, $6, $7, $0, $1, $2, $3, $4, 3+$8 add $4, s .endm .macro rounds_a ror t, e, #6 round a, b, c, d, e, f, g, h, 0+$0 ror t, d, #6 add h, s round h, a, b, c, d, e, f, g, 1+$0 ror t, c, #6 add g, s round g, h, a, b, c, d, e, f, 2+$0 ror t, b, #6 add f, s round f, g, h, a, b, c, d, e, 3+$0 add e, s .endm .macro rounds_e ror t, a, #6 round e, f, g, h, a, b, c, d, 0+$0 ror t, h, #6 add d, s round d, e, f, g, h, a, b, c, 1+$0 ror t, g, #6 add c, s round c, d, e, f, g, h, a, b, 2+$0 ror t, f, #6 add b, s round b, c, d, e, f, g, h, a, 3+$0 add a, s .endm // update the message schedule W and W+K (4 rounds) 16 rounds ahead in the future .macro message_schedule vld1.32 {q5},[K,:128]! vext.32 q4, $0, $1, #1 // Q4 = w4:w1 sigma0 q4 // sigma0(w4:w1) vadd.s32 $0, q4 // w3:w0 + sigma0(w4:w1) vext.32 q6, $2, $3, #1 // Q6 = w12:w9 vadd.s32 $0, q6 // w3:w0 + sigma0(w4:w1) + w12:w9 vext.64 q4, $3, zero, #1 // 0 0 w15:w14 sigma1 q4 // Q4 = sigma1(0 0 w15:w14) vadd.s32 $0, q4 // w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(0 0 w15:w14) vext.64 q4, zero, $0, #1 // Q4 = (w17:w16 0 0) sigma1 q4 // sigma1(w17:w16 0 0) vadd.s32 $0, q4 // w19:w16 = w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(w17:w14) add t, sp, #(($4&15)*4) vadd.s32 q5, $0 // W+K vst1.32 {q5},[t,:128] .endm // this macro is used in the last 16 rounds of a current block // it reads the next message (16 4-byte words), load it into 4 words W[r:r+3], computes WK[r:r+3] // and save into stack to prepare for next block .macro update_W_WK vld1.s32 {$1},[data]! vrev32.8 $1, $1 add t, sp, #($0*16) vld1.s32 {q4},[K,:128]! vadd.s32 q4, $1 vst1.32 {q4},[t] .endm .macro Update_Digits ldr t, [ctx] ldr s, [ctx,#4] add a, t add b, s strd a, b, [ctx] ldr t, [ctx,#8] ldr s, [ctx,#12] add c, t add d, s strd c, d, [ctx, #8] ldr t, [ctx,#16] ldr s, [ctx,#20] add e, t add f, s strd e, f, [ctx, #16] ldr t, [ctx,#24] ldr s, [ctx,#28] add g, t add h, s strd g, h, [ctx, #24] .endm .macro rounds_a_schedule_update eor t, e, e, ror #5 // S32(6, (x)) ^ S32(11, (x)) vld1.32 {q5},[K,:128]! eor t, t, e, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) vext.32 q4, $1, $2, #1 // Q4 = w4:w1 and s, e, f // (x) & (y) add h, t, ror #6 // use h to store h+Sigma1(e) bic t, g, e // (~(x)) & (z) vshr.u32 q6, q4, #7 eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) vshl.i32 q7, q4, #14 ldr s, WK($0) // add h, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, a, a, ror #11 // S32(2, (x)) ^ S32(13, (x)) add h, s // h = T1 eor t, t, a, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add d, h // d += T1; vshr.u32 q4, q4, #3 add h, t, ror #2 // h = T1 + Sigma0(a); eor t, b, c // y^z and s, b, c // y&z veor q4, q6 vshr.u32 q6, #11 and t, t, a // x&(y^z) eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) eor t, d, d, ror #5 // S32(6, (x)) ^ S32(11, (x)) veor q4, q7 vshl.i32 q7, #11 add h, s eor t, t, d, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) and s, d, e // (x) & (y) add g, t, ror #6 // use h to store h+Sigma1(e) bic t, f, d // (~(x)) & (z) veor q4, q6 veor q4, q7 vext.32 q6, $3, $4, #1 // Q6 = w12:w9 vadd.s32 $1, q4 // w3:w0 + sigma0(w4:w1) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(1+$0) // add g, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, h, h, ror #11 // S32(2, (x)) ^ S32(13, (x)) add g, s // h = T1 eor t, t, h, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); vadd.s32 $1, q6 // w3:w0 + sigma0(w4:w1) + w12:w9 vext.64 q4, $4, zero, #1 // 0 0 w15:w14 add c, g // d += T1; add g, t, ror #2 // h = T1 + Sigma0(a); eor t, a, b // y^z and s, a, b // y&z and t, t, h // x&(y^z) vshr.u32 q6, q4, #17 vshl.i32 q7, q4, #13 vshr.u32 q4, q4, #10 eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) veor q4, q6 veor q4, q7 vshr.u32 q6, #2 vshl.i32 q7, #2 veor q4, q6 veor q4, q7 eor t, c, c, ror #5 // S32(6, (x)) ^ S32(11, (x)) add g, s eor t, t, c, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) vadd.s32 $1, q4 // w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(0 0 w15:w14) and s, c, d // (x) & (y) add f, t, ror #6 // use h to store h+Sigma1(e) bic t, e, c // (~(x)) & (z) vext.64 q4, zero, $1, #1 // Q4 = (w17:w16 0 0) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(2+$0) // add f, t // t = h+Sigma1(e)+Ch(e,f,g); vshr.u32 q6, q4, #17 vshl.i32 q7, q4, #13 vshr.u32 q4, q4, #10 eor t, g, g, ror #11 // S32(2, (x)) ^ S32(13, (x)) add f, s // h = T1 eor t, t, g, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add b, f // d += T1; veor q4, q6 veor q4, q7 add f, t, ror #2 // h = T1 + Sigma0(a); eor t, h, a // y^z and s, h, a // y&z and t, t, g // x&(y^z) vshr.u32 q6, #2 vshl.i32 q7, #2 eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) eor t, b, b, ror #5 // S32(6, (x)) ^ S32(11, (x)) add f, s eor t, t, b, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) veor q4, q6 veor q4, q7 vadd.s32 $1, q4 // w19:w16 = w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(w17:w14) and s, b, c // (x) & (y) add e, t, ror #6 // use h to store h+Sigma1(e) bic t, d, b // (~(x)) & (z) vadd.s32 q5, $1 // W+K eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(3+$0) // add e, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, f, f, ror #11 // S32(2, (x)) ^ S32(13, (x)) add e, s // h = T1 eor t, t, f, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add a, e // d += T1; add e, t, ror #2 // h = T1 + Sigma0(a); eor t, g, h // y^z and s, g, h // y&z and t, t, f // x&(y^z) eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) add t, sp, #(($0&15)*4) add e, s vst1.32 {q5},[t,:128] .endm .macro rounds_e_schedule_update eor t, a, a, ror #5 // S32(6, (x)) ^ S32(11, (x)) vld1.32 {q5},[K,:128]! eor t, t, a, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) vext.32 q4, $1, $2, #1 // Q4 = w4:w1 and s, a, b // (x) & (y) add d, t, ror #6 // use h to store h+Sigma1(e) bic t, c, a // (~(x)) & (z) vshr.u32 q6, q4, #7 eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) vshl.i32 q7, q4, #14 ldr s, WK($0) // add d, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, e, e, ror #11 // S32(2, (x)) ^ S32(13, (x)) add d, s // h = T1 eor t, t, e, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add h, d // d += T1; vshr.u32 q4, q4, #3 add d, t, ror #2 // h = T1 + Sigma0(a); eor t, f, g // y^z and s, f, g // y&z veor q4, q6 vshr.u32 q6, #11 and t, t, e // x&(y^z) eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) eor t, h, h, ror #5 // S32(6, (x)) ^ S32(11, (x)) veor q4, q7 vshl.i32 q7, #11 add d, s eor t, t, h, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) and s, h, a // (x) & (y) add c, t, ror #6 // use h to store h+Sigma1(e) bic t, b, h // (~(x)) & (z) veor q4, q6 veor q4, q7 vext.32 q6, $3, $4, #1 // Q6 = w12:w9 vadd.s32 $1, q4 // w3:w0 + sigma0(w4:w1) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(1+$0) // add c, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, d, d, ror #11 // S32(2, (x)) ^ S32(13, (x)) add c, s // h = T1 eor t, t, d, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); vadd.s32 $1, q6 // w3:w0 + sigma0(w4:w1) + w12:w9 vext.64 q4, $4, zero, #1 // 0 0 w15:w14 add g, c // d += T1; add c, t, ror #2 // h = T1 + Sigma0(a); eor t, e, f // y^z and s, e, f // y&z and t, t, d // x&(y^z) vshr.u32 q6, q4, #17 vshl.i32 q7, q4, #13 vshr.u32 q4, q4, #10 eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) veor q4, q6 veor q4, q7 vshr.u32 q6, #2 vshl.i32 q7, #2 veor q4, q6 veor q4, q7 eor t, g, g, ror #5 // S32(6, (x)) ^ S32(11, (x)) add c, s eor t, t, g, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) vadd.s32 $1, q4 // w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(0 0 w15:w14) and s, g, h // (x) & (y) add b, t, ror #6 // use h to store h+Sigma1(e) bic t, a, g // (~(x)) & (z) vext.64 q4, zero, $1, #1 // Q4 = (w17:w16 0 0) eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(2+$0) // add b, t // t = h+Sigma1(e)+Ch(e,f,g); vshr.u32 q6, q4, #17 vshl.i32 q7, q4, #13 vshr.u32 q4, q4, #10 eor t, c, c, ror #11 // S32(2, (x)) ^ S32(13, (x)) add b, s // h = T1 eor t, t, c, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add f, b // d += T1; veor q4, q6 veor q4, q7 add b, t, ror #2 // h = T1 + Sigma0(a); eor t, d, e // y^z and s, d, e // y&z and t, t, c // x&(y^z) vshr.u32 q6, #2 vshl.i32 q7, #2 eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) eor t, f, f, ror #5 // S32(6, (x)) ^ S32(11, (x)) add b, s eor t, t, f, ror #19 // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) veor q4, q6 veor q4, q7 vadd.s32 $1, q4 // w19:w16 = w3:w0 + sigma0(w4:w1) + w12:w9 + sigma1(w17:w14) and s, f, g // (x) & (y) add a, t, ror #6 // use h to store h+Sigma1(e) bic t, h, f // (~(x)) & (z) vadd.s32 q5, $1 // W+K eor t, t, s // t = Ch(x,y,z) = (((x) & (y)) ^ ((~(x)) & (z))) ldr s, WK(3+$0) // add a, t // t = h+Sigma1(e)+Ch(e,f,g); eor t, b, b, ror #11 // S32(2, (x)) ^ S32(13, (x)) add a, s // h = T1 eor t, t, b, ror #20 // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) // t = Sigma0(a); add e, a // d += T1; add a, t, ror #2 // h = T1 + Sigma0(a); eor t, c, d // y^z and s, c, d // y&z and t, t, b // x&(y^z) eor s, s, t // t = Maj(x,y,z) = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) add t, sp, #(($0&15)*4) add a, s vst1.32 {q5},[t,:128] .endm .text .align 4 K256: .long 0x428a2f98 .long 0x71374491 .long 0xb5c0fbcf .long 0xe9b5dba5 .long 0x3956c25b .long 0x59f111f1 .long 0x923f82a4 .long 0xab1c5ed5 .long 0xd807aa98 .long 0x12835b01 .long 0x243185be .long 0x550c7dc3 .long 0x72be5d74 .long 0x80deb1fe .long 0x9bdc06a7 .long 0xc19bf174 .long 0xe49b69c1 .long 0xefbe4786 .long 0x0fc19dc6 .long 0x240ca1cc .long 0x2de92c6f .long 0x4a7484aa .long 0x5cb0a9dc .long 0x76f988da .long 0x983e5152 .long 0xa831c66d .long 0xb00327c8 .long 0xbf597fc7 .long 0xc6e00bf3 .long 0xd5a79147 .long 0x06ca6351 .long 0x14292967 .long 0x27b70a85 .long 0x2e1b2138 .long 0x4d2c6dfc .long 0x53380d13 .long 0x650a7354 .long 0x766a0abb .long 0x81c2c92e .long 0x92722c85 .long 0xa2bfe8a1 .long 0xa81a664b .long 0xc24b8b70 .long 0xc76c51a3 .long 0xd192e819 .long 0xd6990624 .long 0xf40e3585 .long 0x106aa070 .long 0x19a4c116 .long 0x1e376c08 .long 0x2748774c .long 0x34b0bcb5 .long 0x391c0cb3 .long 0x4ed8aa4a .long 0x5b9cca4f .long 0x682e6ff3 .long 0x748f82ee .long 0x78a5636f .long 0x84c87814 .long 0x8cc70208 .long 0x90befffa .long 0xa4506ceb .long 0xbef9a3f7 .long 0xc67178f2 .globl _vng_armv7neon_sha256_compress .private_extern _vng_armv7neon_sha256_compress _vng_armv7neon_sha256_compress: // due to the change of order in the 2nd and 3rd calling argument, // we need to switch r1/r2 to use the original code // cclee 1-13-11 mov r12, r1 mov r1, r2 mov r2, r12 // push callee-saved registers push {r4-r7,lr} add r7, sp, #12 // set up dtrace frame pointer push {r8-r11} // align sp to 16-byte boundary ands r12, sp, #15 // bytes to align to 16-byte boundary addeq r12, #16 // if nothing, enforce to insert 16 bytes sub sp, r12 str r12, [sp] #if KERNEL vpush {q8} #endif vpush {q0-q7} #define stack_size (16*5) // circular buffer W0-W3, extra 16 to save num_blocks sub sp, #stack_size str r2, num_blocks veor zero, zero // set up pointer to table K256[] adr K, K256 // load W[0:15] vld1.s32 {W0-W1},[data]! vld1.s32 {W2-W3},[data]! // load K[0:15] & per word byte swap vrev32.8 W0, W0 vrev32.8 W1, W1 vld1.s32 {q4-q5}, [K,:128]! vrev32.8 W2, W2 vrev32.8 W3, W3 vld1.s32 {q6-q7}, [K,:128]! // compute WK[0:15] and save in stack vadd.s32 q4, q0 vadd.s32 q5, q1 vadd.s32 q6, q2 vadd.s32 q7, q3 vstmia sp,{q4-q7} // digests a-h = ctx->states; ldmia ctx,{a-d,e-h} L_loop: // rounds 0:47 interleaved with W/WK update for rounds 16:63 #if 1 rounds_a_schedule_update 0,W0,W1,W2,W3 rounds_e_schedule_update 4,W1,W2,W3,W0 rounds_a_schedule_update 8,W2,W3,W0,W1 rounds_e_schedule_update 12,W3,W0,W1,W2 rounds_a_schedule_update 16,W0,W1,W2,W3 rounds_e_schedule_update 20,W1,W2,W3,W0 rounds_a_schedule_update 24,W2,W3,W0,W1 rounds_e_schedule_update 28,W3,W0,W1,W2 rounds_a_schedule_update 32,W0,W1,W2,W3 rounds_e_schedule_update 36,W1,W2,W3,W0 rounds_a_schedule_update 40,W2,W3,W0,W1 rounds_e_schedule_update 44,W3,W0,W1,W2 #else rounds_a 0 message_schedule W0,W1,W2,W3,16 rounds_e 4 message_schedule W1,W2,W3,W0,20 rounds_a 8 message_schedule W2,W3,W0,W1,24 rounds_e 12 message_schedule W3,W0,W1,W2,28 rounds_a 16 message_schedule W0,W1,W2,W3,32 rounds_e 20 message_schedule W1,W2,W3,W0,36 rounds_a 24 message_schedule W2,W3,W0,W1,40 rounds_e 28 message_schedule W3,W0,W1,W2,44 rounds_a 32 message_schedule W0,W1,W2,W3,48 rounds_e 36 message_schedule W1,W2,W3,W0,52 rounds_a 40 message_schedule W2,W3,W0,W1,56 rounds_e 44 message_schedule W3,W0,W1,W2,60 #endif // revert K to the beginning of K256[] ldr t, num_blocks sub K, #256 subs t, #1 // num_blocks-- beq L_final_block // if final block, wrap up final rounds str t, num_blocks // rounds 48:63 interleaved with W/WK initialization for next block rounds 0:15 rounds_a 48 update_W_WK 0, W0 rounds_e 52 update_W_WK 1, W1 rounds_a 56 update_W_WK 2, W2 rounds_e 60 update_W_WK 3, W3 // ctx->states += digests a-h Update_Digits // digests a-h = ctx->states; ldmia ctx,{a-d,e-h} bal L_loop // branch for next block // wrap up digest update round 48:63 for final block L_final_block: rounds_a 48 rounds_e 52 rounds_a 56 rounds_e 60 // ctx->states += digests a-h Update_Digits // free allocated stack memory add sp, #stack_size // if kernel, restore q0-q8 vpop {q0-q1} vpop {q2-q3} vpop {q4-q5} vpop {q6-q7} #if KERNEL vpop {q8} #endif // dealign sp from the 16-byte boundary ldr r12, [sp] add sp, r12 // restore callee-save registers and return pop {r8-r11} pop {r4-r7,pc} #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha2_descriptor/vng_neon_sha224.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* Adapted from LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /** @param sha224.c vng_neon_SHA-224 new NIST standard based off of vng_neon_SHA-256 truncated to 224 bits (Tom St Denis) */ const ccDescriptor vng_neon_sha224_desc = { .implementation_info = &cc_sha224_impinfo, .dtype.digest.hashsize = CC_SHA224_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA224_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_neon_sha224_init, .dtype.digest.process = &vng_neon_sha256_process, .dtype.digest.done = &vng_neon_sha224_done, }; /* init the sha256 er... sha224 state ;-) */ /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_neon_sha224_init(vng_neon_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); // ctx->curlen = 0; ctx->length = 0; ctx->state[0] = 0xc1059ed8UL; ctx->state[1] = 0x367cd507UL; ctx->state[2] = 0x3070dd17UL; ctx->state[3] = 0xf70e5939UL; ctx->state[4] = 0xffc00b31UL; ctx->state[5] = 0x68581511UL; ctx->state[6] = 0x64f98fa7UL; ctx->state[7] = 0xbefa4fa4UL; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (28 bytes) @return CRYPT_OK if successful */ int vng_neon_sha224_done(vng_neon_sha256_ctx *ctx, unsigned char *out) { unsigned char buf[32]; int err; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); err = vng_neon_sha256_done(ctx, buf); CC_XMEMCPY(out, buf, 28); return err; } |
Added Source/descriptors/digestDescriptors/vng_neon_sha2_descriptor/vng_neon_sha224.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_neon_sha224.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) #ifndef _VNG_NEON_SHA224_H_ #define _VNG_NEON_SHA224_H_ /* * Note that vng_neon_sha256 is required for vng_neon_sha224. */ #define VNG_NEON_SHA224_HASHSIZE 28 #define VNG_NEON_SHA224_BLOCKSIZE 64 int vng_neon_sha224_init(vng_neon_sha256_ctx *ctx); #define vng_neon_sha224_process vng_neon_sha256_process int vng_neon_sha224_done(vng_neon_sha256_ctx *ctx, unsigned char *hash); #endif /* _VNG_NEON_SHA224_H_ */ #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha2_descriptor/vng_neon_sha256.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) #include <stdio.h> #include "vng_neon_sha256.h" #include "vng_neon_sha224.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file vng_neon_sha256.c vng_neon_SHA256 by Tom St Denis */ const ccDescriptor vng_neon_sha256_desc = { .implementation_info = &cc_sha256_impinfo, .dtype.digest.hashsize = CC_SHA256_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA256_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_neon_sha256_init, .dtype.digest.process = &vng_neon_sha256_process, .dtype.digest.done = &vng_neon_sha256_done, }; #ifdef LTC_SMALL_CODE /* the K array */ static const ulong32 K[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; #endif /* Various logical functions */ #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) LTC_RORc((x),(n)) #define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) #define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) #define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) #define FULLLENGTH_MASK 0xffffffffffffffc0 #define BUFFLENGTH_MASK 0x3f /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_neon_sha256_init(vng_neon_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->length = 0; ctx->state[0] = 0x6A09E667UL; ctx->state[1] = 0xBB67AE85UL; ctx->state[2] = 0x3C6EF372UL; ctx->state[3] = 0xA54FF53AUL; ctx->state[4] = 0x510E527FUL; ctx->state[5] = 0x9B05688CUL; ctx->state[6] = 0x1F83D9ABUL; ctx->state[7] = 0x5BE0CD19UL; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int vng_neon_sha256_process(vng_neon_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); curlen = ctx->length & BUFFLENGTH_MASK; if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (curlen == 0 && inlen >= VNG_NEON_SHA256_BLOCKSIZE && CC_XALIGNED(in, 4)) { fullblocks = inlen / VNG_NEON_SHA256_BLOCKSIZE; remainder = inlen % VNG_NEON_SHA256_BLOCKSIZE; processed = fullblocks * VNG_NEON_SHA256_BLOCKSIZE; vng_armv7neon_sha256_compress (ctx->state, fullblocks, in); ctx->length += VNG_NEON_SHA256_BLOCKSIZE * 8 * fullblocks; in += processed; inlen -= processed; } else { n = MIN(inlen, (VNG_NEON_SHA256_BLOCKSIZE - curlen)); memcpy(ctx->buf + curlen, in, (size_t)n); curlen += n; in += n; inlen -= n; if (curlen == VNG_NEON_SHA256_BLOCKSIZE) { vng_armv7neon_sha256_compress (ctx->state, 1, ctx->buf); ctx->length += 8*VNG_NEON_SHA256_BLOCKSIZE; curlen = 0; } } } ctx->length = (ctx->length & FULLLENGTH_MASK) + curlen; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (32 bytes) @return CRYPT_OK if successful */ int vng_neon_sha256_done(vng_neon_sha256_ctx *ctx, unsigned char *out) { int i; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); curlen = ctx->length & BUFFLENGTH_MASK; ctx->length &= FULLLENGTH_MASK; /* increase the length of the message */ ctx->length += curlen * 8; /* append the '1' bit */ ctx->buf[curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (curlen > 56) { while (curlen < 64) { ctx->buf[curlen++] = (unsigned char)0; } vng_armv7neon_sha256_compress (ctx->state, 1, ctx->buf); curlen = 0; } /* pad upto 56 bytes of zeroes */ while (curlen < 56) { ctx->buf[curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+56); vng_armv7neon_sha256_compress (ctx->state, 1, ctx->buf); /* copy output */ for (i = 0; i < 8; i++) { LTC_STORE32H(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(ctx, sizeof(hash_state)); #endif return CRYPT_OK; } #include "vng_neon_sha224.c" #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_neon_sha2_descriptor/vng_neon_sha256.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_neon_sha256.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #include <arm/arch.h> #if defined(_ARM_ARCH_7) #include <stdint.h> #ifndef _VNG_NEON_SHA256_H_ #define _VNG_NEON_SHA256_H_ #define VNG_NEON_SHA256_HASHSIZE 32 #define VNG_NEON_SHA256_BLOCKSIZE 64 typedef struct vng_neon_sha256_state { uint64_t length; uint32_t state[8]; unsigned char buf[VNG_NEON_SHA256_BLOCKSIZE]; } vng_neon_sha256_ctx; int vng_neon_sha256_init(vng_neon_sha256_ctx *ctx); int vng_neon_sha256_process(vng_neon_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen); int vng_neon_sha256_done(vng_neon_sha256_ctx *ctx, unsigned char *hash); void vng_armv7neon_sha256_compress(void *c, unsigned long num, const void *p); #endif /* _VNG_NEON_SHA256_H_ */ #endif /* _ARM_ARCH_7 */ |
Added Source/descriptors/digestDescriptors/vng_x86_sha1_descriptor/vng_x86_sha1.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #include <stdio.h> #include "vng_x86_sha1.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file vng_x86_sha1.c original LTC_SHA1 code by Tom St Denis optimized compress function by the Vector and Numerics Group */ const ccDescriptor vng_x86_sha1_desc = { .implementation_info = &cc_sha1_impinfo, .dtype.digest.hashsize = CC_SHA1_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA1_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_x86_sha1_init, .dtype.digest.process = &vng_x86_sha1_process, .dtype.digest.done = &vng_x86_sha1_done, }; /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_x86_sha1_init(vng_x86_sha1_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->state[0] = 0x67452301UL; ctx->state[1] = 0xefcdab89UL; ctx->state[2] = 0x98badcfeUL; ctx->state[3] = 0x10325476UL; ctx->state[4] = 0xc3d2e1f0UL; CC_XZEROMEM(ctx->buf, CC_SHA1_BLOCK_BYTES); ctx->curlen = 0; ctx->length = 0; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int vng_x86_sha1_process(vng_x86_sha1_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); if (ctx->curlen > sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (ctx->curlen == 0 && inlen >= VNG_X86_SHA1_BLOCKSIZE && CC_XALIGNED(in, 4)) { fullblocks = inlen / VNG_X86_SHA1_BLOCKSIZE; // remainder = inlen % VNG_X86_SHA1_BLOCKSIZE; processed = fullblocks * VNG_X86_SHA1_BLOCKSIZE; sha1_x86_compress_data_order (ctx->state, in, fullblocks); ctx->length += processed * 8; in += processed; inlen -= processed; } else { n = MIN(inlen, (VNG_X86_SHA1_BLOCKSIZE - ctx->curlen)); CC_XMEMCPY(ctx->buf + ctx->curlen, in, n); ctx->curlen += n; in += n; inlen -= n; if (ctx->curlen == VNG_X86_SHA1_BLOCKSIZE) { sha1_x86_compress_data_order (ctx->state, ctx->buf, 1); ctx->length += 8*VNG_X86_SHA1_BLOCKSIZE; ctx->curlen = 0; } } } return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (20 bytes) @return CRYPT_OK if successful */ int vng_x86_sha1_done(vng_x86_sha1_ctx *ctx, unsigned char *out) { int i; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); if (ctx->curlen >= sizeof(ctx->buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ ctx->length += ctx->curlen * 8; /* append the '1' bit */ ctx->buf[ctx->curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (ctx->curlen > 56) { while (ctx->curlen < 64) { ctx->buf[ctx->curlen++] = (unsigned char)0; } sha1_x86_compress_data_order(ctx->state, ctx->buf, 1); ctx->curlen = 0; } /* pad upto 56 bytes of zeroes */ while (ctx->curlen < 56) { ctx->buf[ctx->curlen++] = (unsigned char)0; } /* store length */ CC_XSTORE64H(ctx->length, ctx->buf+56); sha1_x86_compress_data_order(ctx->state, ctx->buf, 1); /* copy output */ for(i=0; i<5; i++, out+=4) CC_XSTORE32H(ctx->state[i], out); return CRYPT_OK; } #endif /* x86 */ |
Added Source/descriptors/digestDescriptors/vng_x86_sha1_descriptor/vng_x86_sha1.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_x86_sha1.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2011 Apple Inc. All rights reserved. * */ #include <stdint.h> #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #ifndef _VNG_X86_SHA1_H_ #define _VNG_X86_SHA1_H_ #define VNG_X86_SHA1_HASHSIZE 20 #define VNG_X86_SHA1_BLOCKSIZE 64 // Adjusted to take the same space as CC_SHA1_CTX // The order is important on a 64 bit system so that // the length variable is 64 bit aligned. typedef struct vng_x86_sha1_state { uint32_t state[5]; // 20 uint32_t curlen; // 4 uint64_t length; // 8 unsigned char buf[VNG_X86_SHA1_BLOCKSIZE]; // 64 } vng_x86_sha1_ctx; int vng_x86_sha1_init(vng_x86_sha1_ctx *ctx); int vng_x86_sha1_process(vng_x86_sha1_ctx *ctx, const unsigned char *in, unsigned long inlen); int vng_x86_sha1_done(vng_x86_sha1_ctx *ctx, unsigned char *hash); // I think the x86 version takes the blocks as the third argument. void sha1_x86_compress_data_order(uint32_t state[], unsigned char *, unsigned long nblocks); #endif /* x86 */ #endif /* _VNG_X86_SHA1_H_ */ |
Added Source/descriptors/digestDescriptors/vng_x86_sha1_descriptor/vng_x86_sha1BE.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 | /* * Copyright (c) 2011 Apple Computer, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* sha1edp.s : this file provides optimized x86_64 and i386 implementation of the sha1 function CoreOS - vector and numerics group cclee 6-21-10 The implementation is based on the principle described in an Intel online article "Improving the Performance of the Secure Hash Algorithm (SHA-1)" http://software.intel.com/en-us/articles/improving-the-performance-of-the-secure-hash-algorithm-1/ Update HASH[] by processing a one 64-byte block in MESSAGE[] can be represented by the following C function void SHA1( int HASH[], int MESSAGE[] ) { int A[81], B[81], C[81], D[81], E[81]; int W[80]; int i, FN; A[0] = HASH[0]; B[0] = HASH[1]; C[0] = HASH[2]; D[0] = HASH[3]; E[0] = HASH[4]; for ( i=0; i<80; ++i ) { if ( i < 16 ) W[i] = BIG_ENDIAN_LOAD( MESSAGE[i] ); else W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); FN = F( i, B[i], C[i], D[i] ); A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + W[i] + K(i); B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; } HASH[0] += A[80]; HASH[1] += B[80]; HASH[2] += C[80]; HASH[3] += D[80]; HASH[4] += E[80]; } For i=0:15, W[i] is simply big-endian loading of MESSAGE[i]. For i=16:79, W[i] is updated according to W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); The approach (by Dean Gaudet) can be used to vectorize the computation of W[i] for i=16:79, 1. done on 4 consequtive W[i] values in a single XMM register W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 2. this additional calculation unfortunately requires many additional operations W[i+3] ^= W[i] rol 1 3. once we have 4 W[i] values in XMM we can also add four K values with one instruction W[i:i+3] += {K,K,K,K} Let W0 = {W[i] W[i+1] W[i+2] W[i+3]} be the current W-vector to be computed, W4 = {W[i-4] W[i-3] W[i-2] W[i-1]} be the previous vector, and so on The Dean Gaudet approach can be expressed as 1. W0 = rotate_left(left_shift(W4,32) ^ W8 ^ left_shift(concatenate(W16,W12),64) ^ W16,1); 2. W[i+3] ^= W[i] rol 1 3. W0 += {K,K,K,K} For i>=32, the Intel online article suggests that (using a basic identity (X rol 1) rol 1 = X rol 2) the update equation is equivalent to 1. W0 = rotate_left(left_shift(concatenate(W8,W4),64) ^ W16 ^ W28 ^ W32, 2); Note: 1. In total, we need 8 16-byte registers or memory for W0,W4,...,W28. W0 and W32 can be the same register or memory. 2. The registers are used in a circular buffering mode. For example, we start with W28,W24,...,W0 (with W0 indicating the most recent 16-byte) i=0, W28,W24,...,W0 i=4, W24,W20,...,W28 i=8, W20,W16,...,W24 . . and so forth. 3. 2 ssse3 instructions are used in the Intel article, pshufb and palignr. a. pshufb is used to simplify the BIG_ENDIAN_LOAD operation b. palignr is used to simplify the computation of left_shift(concatenate(W12,W8),64) 4. we probe __cpu_capabilities to detect ssse3 support and dispatch code with ssse3 support when available. If ssse3 is not supported, a suboptimal code (pshufb and palignr workaround) is dispatched. */ /* the code can be compiled into single block (64 bytes) per call mode by setting Multiple_blocks to 0 */ #define Multiple_Blocks 1 #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #if defined(__x86_64__) // set up for x86_64 #define stack_size (8+16*11+16*4) // 8 (alignedment) + x0-x10 + 4 128-bits for intermediate WK(t) storage #define sp %rsp // unifying architectural stack pointer representation #define ctx %rdi // 1st input argument, will move to HASH_PTR (%r9) #define buf %rsi // 2nd input argument, will move to BUFFER_PTR (%r10) #define cnt %r11 // will copy from the 3rd input argument (%rdx) #define K_BASE %r8 // an aligned pointer to point to shufb reference numbers of table of K values #define HASH_PTR %r9 // pointer to Hash values (A,B,C,D,E) #define BUFFER_PTR %r10 // pointer to input blocks #else // !__x86_64__ // set up for i386 #define stack_size (12+16*2+16*11+16*4) // 12-bytes (alignment) + extra 2 + 3 (W24/W28/XMM_SHUFB_BSWAP) + 8 (xmm0-xmm7) + 4 (WK(t)) #define sp %esp // unifying architectural stack pointer representation #define HASH_PTR stack_size+16+4(sp) // use 1st input argument from caller function, 16 for (esi/edi/ebx/ebp) #define BUFFER_PTR stack_size+16+8(sp) // use 2nd input argument from caller function #define cnt stack_size+16+12(sp) // use 3rd input argument from caller function #define K_BASE stack_size-4(sp) // use for K_BASE #endif // __x86_64__ // symbolizing registers or stack memory with algorithmic variables W0,W4,...,W28 + W_TMP, W_TMP2, and XMM_SHUFB_BSWAP for code with ssse3 support #define W_TMP %xmm0 #define W_TMP2 %xmm1 #define W0 %xmm2 #define W4 %xmm3 #define W8 %xmm4 #define W12 %xmm5 #define W16 %xmm6 #define W20 %xmm7 #if defined(__x86_64__) #define W24 %xmm8 #define W28 %xmm9 #define XMM_SHUFB_BSWAP %xmm10 // used only when ssse3 is supported #else // defined (__i386__) #define W24 12*16(sp) #define W28 13*16(sp) #define XMM_SHUFB_BSWAP 14*16(sp) // used only when ssse3 is supported #endif #define xmov movaps // aligned 16-byte move #define xmovu movups // unaligned 16-byte move // intermediate hash variables #define A %ecx #define B %esi #define C %edi #define D %ebp #define E %edx // temp variables #define T1 %eax #define T2 %ebx #define WK(t) (t&15)*4(sp) // int F1(int B, int C, int D) { return (D ^ ( B & (C ^ D)); } // result in T1 .macro F1 mov $1, T1 xor $2, T1 and $0, T1 xor $2, T1 .endm // int F2(int B, int C, int D) { return (D ^ B ^ C); } // result in T1 .macro F2 mov $2, T1 xor $1, T1 xor $0, T1 .endm // int F3(int B, int C, int D) { return (B & C) | (D & (B ^ C)); } // result in T1 .macro F3 mov $1, T1 mov $0, T2 or $0, T1 and $1, T2 and $2, T1 or T2, T1 .endm // for i=60:79, F4 is identical to F2 #define F4 F2 /* i=0:15, W[i] = BIG_ENDIAN_LOAD(MESSAGE[i]); with ssse3 support, this is achived via for (i=0;i<16;i+=4) { 1. W_TMP = new 16 bytes from MESSAGE[] 2. W_TMP = pshufb(W_TMP, XMM_SHUFB_BSWAP); save to W circular buffer for updating W 3. WTMP += {K,K,K,K}; 4. save quadruple W[i]+K[i] = W_TMP in the stack memory; } each step is represented in one of the following 4 macro definitions */ .macro W_PRECALC_00_15_0 // input argument $0 : 0/4/8/12 #if defined (__x86_64__) // BUFFER_PTR is already an address register in x86_64 xmovu $0*4(BUFFER_PTR), W_TMP // read 16-bytes into W_TMP, BUFFER_PTR possibly not 16-byte aligned #else // BUFFER_PTR is from the argument set up in the caller mov BUFFER_PTR, T1 // T1 = BUFFER_PTR xmovu $0*4(T1), W_TMP // read 16-bytes into W_TMP, BUFFER_PTR possibly not 16-byte aligned #endif .endm .macro W_PRECALC_00_15_1 // input argument $0 : current 16-bytes in the circular buffer, one of W0,W4,W8,...,W28 xmov W_TMP, $0 // save W_TMP in the circular buffer .endm .macro W_PRECALC_00_15_2 // K_BASE points to the current K quadruple. #if defined (__x86_64__) // K_BASE is already an address register in x86_64 paddd (K_BASE), W_TMP // W_TMP += {K,K,K,K}; #else // K_BASE is previously set up in the stack memory mov K_BASE, T1 // T1 = K_BASE paddd (T1), W_TMP // W_TMP += {K,K,K,K}; #endif .endm .macro W_PRECALC_00_15_3 xmov W_TMP, WK($0&~3) // save quadruple W[i]+K in the stack memory, which would be used later for updating the hashes A/B/C/D/E .endm // rounds 16-31 compute W[0] using the vectorization approach by Dean Gaudet /* W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 W[i+3] ^= W[i] rol 1; // this W[i] is already rol by 1, if we are taking from the intial W before rol 1, we should rol this by 2 The operation (updating W and W+K) is scheduled as and divided into 4 steps 0. W_tmp = W3; W = W14 ^ W8 1. W = W3 ^ W8 ^ W14 ^ W16; W_TMP = W; W_TMP2 = (W[i] 0 0 0); 2. W_TMP = (W3 ^ W8 ^ W14 ^ W16) rol 1; split (W[i] 0 0 0) rol 2 in W_TMP2 and W 3. W = W_TMP = W_TMP ^ W_TMP2 ^ W = (W3 ^ W8 ^ W14 ^ W16) rol 1 ^ (W[i] 0 0 0) rol 2; WK = W _TMP+K; */ .macro W_PRECALC_16_31_0_ssse3 // input arguments : W16,W12,W8,W4,W xmov $1, $4 // W = W12 palignr $$8, $0, $4 // W = W14 xmov $3, W_TMP // W_TMP = W4 psrldq $$4, W_TMP // W_TMP = W3 pxor $2, $4 // W = W8 ^ W14 .endm .macro W_PRECALC_16_31_1 // input arguments : W16,W pxor $0, W_TMP // W_TMP = W3 ^ W16 pxor W_TMP, $1 // W = W3 ^ W16 ^ W8 ^ W14 xmov $1, W_TMP2 // W_TMP2 = W3 ^ W16 ^ W8 ^ W14 xmov $1, W_TMP // W_TMP = W3 ^ W16 ^ W8 ^ W14 pslldq $$12, W_TMP2 // W_TMP2 = (W[i] 0 0 0) .endm .macro W_PRECALC_16_31_2 // input argument : W psrld $$31, $0 // (W3 ^ W16 ^ W8 ^ W14)>>31 pslld $$1, W_TMP // (W3 ^ W16 ^ W8 ^ W14)<<1 por $0, W_TMP // W_TMP = (W3 ^ W16 ^ W8 ^ W14) rol 1 xmov W_TMP2, $0 // copy W[i] at location of W[i+3] psrld $$30, W_TMP2 // W_TMP2 = W[i] lower 2 bits after rol 2 pslld $$2, $0 // W = W[i] higher 30 bits after rol 2 .endm .macro W_PRECALC_16_31_3 // input arguments: W, i, K_XMM #if defined (__i386__) mov K_BASE, T1 // K_BASE is store in the stack memory for i386 #endif pxor $0, W_TMP pxor W_TMP2, W_TMP // W_TMP = (W3 ^ W16 ^ W8 ^ W14) rol 1 ^ (W[i] 0 0 0) rol 2 xmov W_TMP, $0 // save W = W_TMP in the W circular buffer #if defined (__x86_64__) paddd $2(K_BASE), W_TMP // W+K #else paddd $2(T1), W_TMP // W+K #endif xmov W_TMP, WK($1&~3) // save WK = W+K for later update of the hashes A/B/C/D/E .endm // the following is a variant of W_PRECALC_16_31_0_ssse3 to be used for system without ssse3, palignr is replaced with 4 instructions .macro W_PRECALC_16_31_0_nossse3 // input arguments : W16,W12,W8,W4,W xmov $1, $4 // W = W12 = (w9 w10 w11 w12) // the following is a wrokaround for palignr xmov $0, W_TMP // W16 = (w13 w14 w15 w16) pslldq $$8, $4 // shift left to make (w11 w12 0 0) psrldq $$8, W_TMP // shift right to make (0 0 w13 w14) por W_TMP, $4 // W = W14 = (w11 w12 w13 w14) xmov $3, W_TMP // W_TMP = W4 = (w1 w2 w3 w4) psrldq $$4, W_TMP // W_TMP = W3 = (0 w1 w2 w3) pxor $2, $4 // W = W8 ^ W14 .endm /* rounds 32-79 compute W und W+K iusing the vectorization approach from the Intel article W = rotate_left(left_shift(concatenate(W8,W4),64) ^ W16 ^ W28 ^ W32, 2); where left_shift(concatenate(W8,W4),64) is equivalent to W6. Note also that W32 and W use the same register. 0. W_tmp = W6; W = W28 ^ W32; 1. W = W_tmp = W6 ^ W16 ^ W28 ^ W32; 2. W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2; 3. W = W_Tmp; WK = W_tmp + K; */ .macro W_PRECALC_32_79_0_ssse3 // inputr arguments : W28,W8,W4,W xmov $2, W_TMP // (w1 w2 w3 w4) pxor $0, $3 // W = W28 ^ W32; palignr $$8, $1, W_TMP // W_tmp = (w3 w4 w5 w6) = W6; .endm // the following is a variant and will be used for system without ssse3 support .macro W_PRECALC_32_79_0_nossse3 // input arguments : W28,W8,W4,W xmov $2, W_TMP // (w1 w2 w3 w4) xmov $1, W_TMP2 // (w5 w6 w7 w8) pxor $0, $3 // W = W28 ^ W32 pslldq $$8, W_TMP // (w3 w4 0 0) psrldq $$8, W_TMP2 // (0 0 w5 w6) por W_TMP2, W_TMP // W_tmp = (w3 w4 w5 w6) = W6 .endm // this is a variant of W_PRECALC_32_79_0_ssse3 for i386 (as W24/W28 are stored in memory, not in registers) .macro W_PRECALC_32_79_0_i386_ssse3 // input arguments : W28,W8,W4,W xmov $3, W_TMP // W32 pxor $0, W_TMP // W28 ^ W32 xmov W_TMP, $3 // W = W28 ^ W32; xmov $2, W_TMP // W4 palignr $$8, $1, W_TMP // W_tmp = (w3 w4 w5 w6) = W6; .endm // this is a variant of W_PRECALC_32_79_0_nossse3 for i386 (as W24/W28 are stored in memory, not in registers) .macro W_PRECALC_32_79_0_i386_nossse3 // input arguments : W28,W8,W4,W xmov $3, W_TMP // W32 pxor $0, W_TMP // W28 ^ W32 xmov W_TMP, $3 // W = W28 ^ W32 xmov $2, W_TMP // W4 = (w1 w2 w3 w4) xmov $1, W_TMP2 // W8 = (w5 w6 w7 w8) pslldq $$8, W_TMP // (w3 w4 0 0) psrldq $$8, W_TMP2 // (0 0 w5 w6) por W_TMP2, W_TMP // W_tmp = (w3 w4 w5 w6) = W6 .endm .macro W_PRECALC_32_79_1 // input arguments : W16,W pxor $0, W_TMP // W_tmp = W6 ^ W16 pxor $1, W_TMP // W_tmp = W6 ^ W16 ^ W28 ^ W32 xmov W_TMP, $1 // W = W_tmp = W6 ^ W16 ^ W28 ^ W32 .endm .macro W_PRECALC_32_79_2 // input argument : W psrld $$30, $0 // W >> 30 pslld $$2, W_TMP // W << 2 por $0, W_TMP // W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2 .endm // this is a variant of W_PRECALC_32_79_2 for i386 (as W24/W28 are stored in memory, not in registers) // this should be used when the input is either W24 or W28 on i386 architecture .macro W_PRECALC_32_79_2_i386 // input argument : W xmov $0, W_TMP2 // W psrld $$30, W_TMP2 // W >> 30 xmov W_TMP2, $0 // save (W >> 30) at W pslld $$2, W_TMP // W_tmp << 2 por $0, W_TMP // W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2 .endm .macro W_PRECALC_32_79_3 // input argument W, i, K_XMM #if defined (__x86_64__) xmov W_TMP, $0 // W = (W6 ^ W16 ^ W28 ^ W32) rol 2 paddd $2(K_BASE), W_TMP // W + K xmov W_TMP, WK($1&~3) // write W+K #else mov K_BASE, T1 // T1 = K_BASE (which is in the caller argument) xmov W_TMP, $0 // W = (W6 ^ W16 ^ W28 ^ W32) rol 2 paddd $2(T1), W_TMP // W_tmp = W + K xmov W_TMP, WK($1&~3) // write WK #endif .endm /* The hash update operation is completed by the following statements. A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + WK(i); B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; Suppose we start with A0,B0,C0,D0,E0. The 1st iteration can be expressed as follows: A1 = FN + E0 + rol(A0,5) + WK; B1 = A0; C1 = rol(B0, 30); D1 = C0; E1 = D0; to avoid excessive memory movement between registers, 1. A1 = FN + E0 + rol(A0,5) + WK; can be temporarily saved in E0, 2. C1 = rol(B0,30) can be temporarily saved in B0. Therefore, ignoring the time index, the update operation is equivalent to 1. E = FN(B,C,D) + E + rol(A,5) + WK(i) 2. B = rol(B,30) 3. the hashes are now stored in the order of E,A,B,C,D To pack 2 hash update operations in 1 iteration, starting with A,B,C,D,E 1. E = FN(B,C,D) + E + rol(A,5) + WK(i) 2. B = rol(B,30) // now the hashes are in the order of E,A,B,C,D 3. D = FN(A,B,C) + D + rol(E,5) + WK(i+1) 4. A = rol(A,30) // now the hashes are in the order of D,E,A,B,C These operations are distributed into the following 2 macro definitions RR0 and RR1. */ .macro RR0 // input arguments : FN, A, B, C, D, E, i $0 $2, $3, $4 // T1 = FN(B,C,D) add WK($6), $5 // E + WK(i) rol $$30, $2 // B = rol(B,30) mov $1, T2 // T2 = A add WK($6+1), $4 // D + WK(i+1) rol $$5, T2 // rol(A,5) add T1, $5 // E = FN(B,C,D) + E + WK(i) .endm .macro RR1 add $5, T2 // T2 = FN(B,C,D) + E + rol(A,5) + WK(i) mov T2, $5 // E = FN(B,C,D) + E + rol(A,5) + WK(i) rol $$5, T2 // rol(E,5) add T2, $4 // D + WK(i+1) + rol(E,5) $0 $1, $2, $3 // FN(A,B,C) add T1, $4 // D = FN(A,B,C) + D + rol(E,5) + WK(i+1) rol $$30, $1 // A = rol(A,30) .endm /* The following macro definitions are used to expand code for the per-block sha1 operation. INITIAL_W_PRECALC_ssse3 : BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack memory INTERNAL_ssse3 : updating W (16:79) and update the digests A/B/C/D/E (i=0:63, based on W+K stored in the stack memory) ENDING : finishing up update the digests A/B/C/D/E (i=64:79) For multiple-block sha1 operation (Multiple_Blocks = 1), INITIAL_W_PRECALC_ssse3 and ENDING are combined into 1 macro definition for software pipeling. SOFTWARE_PIPELINING_ssse3 : BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack, and finishing up update the digests A/B/C/D/E (i=64:79) assume cnt (the number of blocks) >= 1, the main code body should look like INITIAL_W_PRECALC_ssse3 // W = big_endian_load and pre-compute W+K (i=0:15) do { INTERNAL_ssse3 // update W(i=16:79), and update hash digests A/B/C/D/E (i=0:63) cnt--; if (cnt==0) break; BUFFER_PTR += 64; SOFTWARE_PIPELINING_ssse3; // update hash digests A/B/C/D/E (i=64:79) + W = big_endian_load and pre-compute W+K (i=0:15) } ENDING // update hash digests A/B/C/D/E (i=64:79) */ #define W_PRECALC_16_31_0 W_PRECALC_16_31_0_ssse3 #define W_PRECALC_32_79_0 W_PRECALC_32_79_0_ssse3 #define W_PRECALC_32_79_0_i386 W_PRECALC_32_79_0_i386_ssse3 .macro INITIAL_W_PRECALC_ssse3 // BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack memory // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP W_PRECALC_00_15_2 // W_TMP = W0 + K W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP W_PRECALC_00_15_2 // W_TMP = W28 + K W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP W_PRECALC_00_15_2 // W_TMP = W24 + K W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP W_PRECALC_00_15_2 // W_TMP = W20 + K W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K .endm .macro INTERNAL_ssse3 // updating W (16:79) and update the digests A/B/C/D/E (i=0:63, based on W+K stored in the stack memory) // i=16 : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_16_31_0 W0,W28,W24,W20,W16 RR0 F1,A,B,C,D,E,0 W_PRECALC_16_31_1 W0,W16 RR1 F1,A,B,C,D,E,0 W_PRECALC_16_31_2 W16 RR0 F1,D,E,A,B,C,2 W_PRECALC_16_31_3 W16, 2, 0 RR1 F1,D,E,A,B,C,2 // i=20 : W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_16_31_0 W28,W24,W20,W16,W12 RR0 F1,B,C,D,E,A,4 W_PRECALC_16_31_1 W28,W12 RR1 F1,B,C,D,E,A,4 W_PRECALC_16_31_2 W12 RR0 F1,E,A,B,C,D,6 W_PRECALC_16_31_3 W12, 6, 16 RR1 F1,E,A,B,C,D,6 // i=24 : W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_16_31_0 W24,W20,W16,W12,W8 RR0 F1,C,D,E,A,B,8 W_PRECALC_16_31_1 W24,W8 RR1 F1,C,D,E,A,B,8 W_PRECALC_16_31_2 W8 RR0 F1,A,B,C,D,E,10 W_PRECALC_16_31_3 W8,10,16 RR1 F1,A,B,C,D,E,10 // i=28 : W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_16_31_0 W20,W16,W12,W8,W4 RR0 F1,D,E,A,B,C,12 W_PRECALC_16_31_1 W20,W4 RR1 F1,D,E,A,B,C,12 W_PRECALC_16_31_2 W4 RR0 F1,B,C,D,E,A,14 W_PRECALC_16_31_3 W4,14,16 RR1 F1,B,C,D,E,A,14 // i=32 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F1,E,A,B,C,D,16 W_PRECALC_32_79_1 W16,W0 RR1 F1,E,A,B,C,D,16 W_PRECALC_32_79_2 W0 RR0 F1,C,D,E,A,B,18 W_PRECALC_32_79_3 W0,18,16 RR1 F1,C,D,E,A,B,18 // starting using F2 // i=36 : W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F2,A,B,C,D,E,20 W_PRECALC_32_79_1 W12,W28 RR1 F2,A,B,C,D,E,20 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F2,D,E,A,B,C,22 W_PRECALC_32_79_3 W28,22,16 RR1 F2,D,E,A,B,C,22 // i=40 : W20,W16,W12,W8,W4,W0,W28,W24 #undef K_XMM #define K_XMM 32 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F2,B,C,D,E,A,24 W_PRECALC_32_79_1 W8,W24 RR1 F2,B,C,D,E,A,24 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F2,E,A,B,C,D,26 W_PRECALC_32_79_3 W24,26,K_XMM RR1 F2,E,A,B,C,D,26 // i=44 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F2,C,D,E,A,B,28 W_PRECALC_32_79_1 W4,W20 RR1 F2,C,D,E,A,B,28 W_PRECALC_32_79_2 W20 RR0 F2,A,B,C,D,E,30 W_PRECALC_32_79_3 W20,30,K_XMM RR1 F2,A,B,C,D,E,30 // i=48 : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0 W12,W24,W20,W16 RR0 F2,D,E,A,B,C,32 W_PRECALC_32_79_1 W0,W16 RR1 F2,D,E,A,B,C,32 W_PRECALC_32_79_2 W16 RR0 F2,B,C,D,E,A,34 W_PRECALC_32_79_3 W16,34,K_XMM RR1 F2,B,C,D,E,A,34 // i=52 : W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0 W8,W20,W16,W12 RR0 F2,E,A,B,C,D,36 W_PRECALC_32_79_1 W28,W12 RR1 F2,E,A,B,C,D,36 W_PRECALC_32_79_2 W12 RR0 F2,C,D,E,A,B,38 W_PRECALC_32_79_3 W12,38,K_XMM RR1 F2,C,D,E,A,B,38 // starting using F3 // i=56 : W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0 W4,W16,W12,W8 RR0 F3,A,B,C,D,E,40 W_PRECALC_32_79_1 W24,W8 RR1 F3,A,B,C,D,E,40 W_PRECALC_32_79_2 W8 RR0 F3,D,E,A,B,C,42 W_PRECALC_32_79_3 W8,42,K_XMM RR1 F3,D,E,A,B,C,42 // i=60 : W0,W28,W24,W20,W16,W12,W8,W4 #undef K_XMM #define K_XMM 48 W_PRECALC_32_79_0 W0,W12,W8,W4 RR0 F3,B,C,D,E,A,44 W_PRECALC_32_79_1 W20,W4 RR1 F3,B,C,D,E,A,44 W_PRECALC_32_79_2 W4 RR0 F3,E,A,B,C,D,46 W_PRECALC_32_79_3 W4,46,K_XMM RR1 F3,E,A,B,C,D,46 // i=64 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F3,C,D,E,A,B,48 W_PRECALC_32_79_1 W16,W0 RR1 F3,C,D,E,A,B,48 W_PRECALC_32_79_2 W0 RR0 F3,A,B,C,D,E,50 W_PRECALC_32_79_3 W0,50,K_XMM RR1 F3,A,B,C,D,E,50 // i=68 : W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F3,D,E,A,B,C,52 W_PRECALC_32_79_1 W12,W28 RR1 F3,D,E,A,B,C,52 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F3,B,C,D,E,A,54 W_PRECALC_32_79_3 W28,54,K_XMM RR1 F3,B,C,D,E,A,54 // i=72 : W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F3,E,A,B,C,D,56 W_PRECALC_32_79_1 W8,W24 RR1 F3,E,A,B,C,D,56 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F3,C,D,E,A,B,58 W_PRECALC_32_79_3 W24,58,K_XMM RR1 F3,C,D,E,A,B,58 // starting using F4 // i=76 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F4,A,B,C,D,E,60 W_PRECALC_32_79_1 W4,W20 RR1 F4,A,B,C,D,E,60 W_PRECALC_32_79_2 W20 RR0 F4,D,E,A,B,C,62 W_PRECALC_32_79_3 W20,62,K_XMM RR1 F4,D,E,A,B,C,62 .endm .macro SOFTWARE_PIPELINING_ssse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) RR0 F4,B,C,D,E,A,64 W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP RR1 F4,B,C,D,E,A,64 W_PRECALC_00_15_2 // W_TMP = W0 + K RR0 F4,E,A,B,C,D,66 W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K RR1 F4,E,A,B,C,D,66 // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) RR0 F4,C,D,E,A,B,68 W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP RR1 F4,C,D,E,A,B,68 W_PRECALC_00_15_2 // W_TMP = W28 + K RR0 F4,A,B,C,D,E,70 W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K[0] RR1 F4,A,B,C,D,E,70 // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) RR0 F4,D,E,A,B,C,72 W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP RR1 F4,D,E,A,B,C,72 W_PRECALC_00_15_2 // W_TMP = W24 + K RR0 F4,B,C,D,E,A,74 W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K RR1 F4,B,C,D,E,A,74 // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) RR0 F4,E,A,B,C,D,76 W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP RR1 F4,E,A,B,C,D,76 W_PRECALC_00_15_2 // W_TMP = W20 + K RR0 F4,C,D,E,A,B,78 W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K RR1 F4,C,D,E,A,B,78 .endm #undef W_PRECALC_16_31_0 #undef W_PRECALC_32_79_0 #undef W_PRECALC_32_79_0_i386 /* The following are 3 macro definitions that are no-ssse3 variants of the previous 3 macro definitions. INITIAL_W_PRECALC_nossse3 INTERNAL_nossse3 SOFTWARE_PIPELINING_nossse3 They will be used in a sha1 code main body definition that will be used for system without ssse3 support. */ #define W_PRECALC_16_31_0 W_PRECALC_16_31_0_nossse3 #define W_PRECALC_32_79_0 W_PRECALC_32_79_0_nossse3 #define W_PRECALC_32_79_0_i386 W_PRECALC_32_79_0_i386_nossse3 .macro INITIAL_W_PRECALC_nossse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP W_PRECALC_00_15_2 // W_TMP = W0 + K W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP W_PRECALC_00_15_2 // W_TMP = W28 + K W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP W_PRECALC_00_15_2 // W_TMP = W24 + K W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP W_PRECALC_00_15_2 // W_TMP = W20 + K W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K .endm .macro INTERNAL_nossse3 // i=16 // circular buffer : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_16_31_0 W0,W28,W24,W20,W16 RR0 F1,A,B,C,D,E,0 W_PRECALC_16_31_1 W0,W16 RR1 F1,A,B,C,D,E,0 W_PRECALC_16_31_2 W16 RR0 F1,D,E,A,B,C,2 W_PRECALC_16_31_3 W16, 2, 0 RR1 F1,D,E,A,B,C,2 // i=20, // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_16_31_0 W28,W24,W20,W16,W12 RR0 F1,B,C,D,E,A,4 W_PRECALC_16_31_1 W28,W12 RR1 F1,B,C,D,E,A,4 W_PRECALC_16_31_2 W12 RR0 F1,E,A,B,C,D,6 W_PRECALC_16_31_3 W12, 6, 16 RR1 F1,E,A,B,C,D,6 // i=24, // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_16_31_0 W24,W20,W16,W12,W8 RR0 F1,C,D,E,A,B,8 W_PRECALC_16_31_1 W24,W8 RR1 F1,C,D,E,A,B,8 W_PRECALC_16_31_2 W8 RR0 F1,A,B,C,D,E,10 W_PRECALC_16_31_3 W8,10,16 RR1 F1,A,B,C,D,E,10 // i=28 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_16_31_0 W20,W16,W12,W8,W4 RR0 F1,D,E,A,B,C,12 W_PRECALC_16_31_1 W20,W4 RR1 F1,D,E,A,B,C,12 W_PRECALC_16_31_2 W4 RR0 F1,B,C,D,E,A,14 W_PRECALC_16_31_3 W4,14,16 RR1 F1,B,C,D,E,A,14 //i=32 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F1,E,A,B,C,D,16 W_PRECALC_32_79_1 W16,W0 RR1 F1,E,A,B,C,D,16 W_PRECALC_32_79_2 W0 RR0 F1,C,D,E,A,B,18 W_PRECALC_32_79_3 W0,18,16 RR1 F1,C,D,E,A,B,18 //i=36 // W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F2,A,B,C,D,E,20 W_PRECALC_32_79_1 W12,W28 RR1 F2,A,B,C,D,E,20 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F2,D,E,A,B,C,22 W_PRECALC_32_79_3 W28,22,16 RR1 F2,D,E,A,B,C,22 //i=40 #undef K_XMM #define K_XMM 32 // W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F2,B,C,D,E,A,24 W_PRECALC_32_79_1 W8,W24 RR1 F2,B,C,D,E,A,24 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F2,E,A,B,C,D,26 W_PRECALC_32_79_3 W24,26,K_XMM RR1 F2,E,A,B,C,D,26 //i=44 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F2,C,D,E,A,B,28 W_PRECALC_32_79_1 W4,W20 RR1 F2,C,D,E,A,B,28 W_PRECALC_32_79_2 W20 RR0 F2,A,B,C,D,E,30 W_PRECALC_32_79_3 W20,30,K_XMM RR1 F2,A,B,C,D,E,30 //i=48 // W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0 W12,W24,W20,W16 RR0 F2,D,E,A,B,C,32 W_PRECALC_32_79_1 W0,W16 RR1 F2,D,E,A,B,C,32 W_PRECALC_32_79_2 W16 RR0 F2,B,C,D,E,A,34 W_PRECALC_32_79_3 W16,34,K_XMM RR1 F2,B,C,D,E,A,34 //i=52 // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0 W8,W20,W16,W12 RR0 F2,E,A,B,C,D,36 W_PRECALC_32_79_1 W28,W12 RR1 F2,E,A,B,C,D,36 W_PRECALC_32_79_2 W12 RR0 F2,C,D,E,A,B,38 W_PRECALC_32_79_3 W12,38,K_XMM RR1 F2,C,D,E,A,B,38 //i=56 // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0 W4,W16,W12,W8 RR0 F3,A,B,C,D,E,40 W_PRECALC_32_79_1 W24,W8 RR1 F3,A,B,C,D,E,40 W_PRECALC_32_79_2 W8 RR0 F3,D,E,A,B,C,42 W_PRECALC_32_79_3 W8,42,K_XMM RR1 F3,D,E,A,B,C,42 //i=60 #undef K_XMM #define K_XMM 48 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_32_79_0 W0,W12,W8,W4 RR0 F3,B,C,D,E,A,44 W_PRECALC_32_79_1 W20,W4 RR1 F3,B,C,D,E,A,44 W_PRECALC_32_79_2 W4 RR0 F3,E,A,B,C,D,46 W_PRECALC_32_79_3 W4,46,K_XMM RR1 F3,E,A,B,C,D,46 //i=64 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F3,C,D,E,A,B,48 W_PRECALC_32_79_1 W16,W0 RR1 F3,C,D,E,A,B,48 W_PRECALC_32_79_2 W0 RR0 F3,A,B,C,D,E,50 W_PRECALC_32_79_3 W0,50,K_XMM RR1 F3,A,B,C,D,E,50 //i=68 // W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F3,D,E,A,B,C,52 W_PRECALC_32_79_1 W12,W28 RR1 F3,D,E,A,B,C,52 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F3,B,C,D,E,A,54 W_PRECALC_32_79_3 W28,54,K_XMM RR1 F3,B,C,D,E,A,54 //i=72 // W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F3,E,A,B,C,D,56 W_PRECALC_32_79_1 W8,W24 RR1 F3,E,A,B,C,D,56 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F3,C,D,E,A,B,58 W_PRECALC_32_79_3 W24,58,K_XMM RR1 F3,C,D,E,A,B,58 // starting using F4 //i=76 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F4,A,B,C,D,E,60 W_PRECALC_32_79_1 W4,W20 RR1 F4,A,B,C,D,E,60 W_PRECALC_32_79_2 W20 RR0 F4,D,E,A,B,C,62 W_PRECALC_32_79_3 W20,62,K_XMM RR1 F4,D,E,A,B,C,62 .endm .macro SOFTWARE_PIPELINING_nossse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) RR0 F4,B,C,D,E,A,64 W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP RR1 F4,B,C,D,E,A,64 W_PRECALC_00_15_2 // W_TMP = W0 + K RR0 F4,E,A,B,C,D,66 W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K RR1 F4,E,A,B,C,D,66 // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) RR0 F4,C,D,E,A,B,68 W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP RR1 F4,C,D,E,A,B,68 W_PRECALC_00_15_2 // W_TMP = W28 + K RR0 F4,A,B,C,D,E,70 W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K[0] RR1 F4,A,B,C,D,E,70 // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) RR0 F4,D,E,A,B,C,72 W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP RR1 F4,D,E,A,B,C,72 W_PRECALC_00_15_2 // W_TMP = W24 + K RR0 F4,B,C,D,E,A,74 W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K RR1 F4,B,C,D,E,A,74 // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) RR0 F4,E,A,B,C,D,76 W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP RR1 F4,E,A,B,C,D,76 W_PRECALC_00_15_2 // W_TMP = W20 + K RR0 F4,C,D,E,A,B,78 W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K RR1 F4,C,D,E,A,B,78 .endm .macro ENDING // finish up updating hash digests (i=64:79) //i=80 RR0 F4,B,C,D,E,A,64 RR1 F4,B,C,D,E,A,64 RR0 F4,E,A,B,C,D,66 RR1 F4,E,A,B,C,D,66 //i=84 RR0 F4,C,D,E,A,B,68 RR1 F4,C,D,E,A,B,68 RR0 F4,A,B,C,D,E,70 RR1 F4,A,B,C,D,E,70 //i=88 RR0 F4,D,E,A,B,C,72 RR1 F4,D,E,A,B,C,72 RR0 F4,B,C,D,E,A,74 RR1 F4,B,C,D,E,A,74 //i=92 RR0 F4,E,A,B,C,D,76 RR1 F4,E,A,B,C,D,76 RR0 F4,C,D,E,A,B,78 RR1 F4,C,D,E,A,B,78 .endm // load hash digests A,B,C,D,E from memory into registers .macro LOAD_HASH #if defined (__x86_64__) mov (HASH_PTR), A mov 4(HASH_PTR), B mov 8(HASH_PTR), C mov 12(HASH_PTR), D mov 16(HASH_PTR), E #else mov HASH_PTR, T1 mov (T1), A mov 4(T1), B mov 8(T1), C mov 12(T1), D mov 16(T1), E #endif .endm .macro UPDATE_HASH add $0, $1 mov $1, $0 .endm .macro UPDATE_ALL_HASH #if defined (__x86_64__) UPDATE_HASH (HASH_PTR), A UPDATE_HASH 4(HASH_PTR), B UPDATE_HASH 8(HASH_PTR), C UPDATE_HASH 12(HASH_PTR), D UPDATE_HASH 16(HASH_PTR), E #else mov HASH_PTR, T1 UPDATE_HASH (T1), A UPDATE_HASH 4(T1), B UPDATE_HASH 8(T1), C UPDATE_HASH 12(T1), D UPDATE_HASH 16(T1), E #endif .endm /* main sha1 code for system without ssse3 support */ .macro SHA1_PIPELINED_MAIN_BODY_nossse3 LOAD_HASH // load initial hashes into A,B,C,D,E (registers) INITIAL_W_PRECALC_nossse3 // big_endian_load(W) and W+K (i=0:15) .align 4,0x90 0: INTERNAL_nossse3 // update W (i=16:79) and update ABCDE (i=0:63) #if Multiple_Blocks #if defined(__x86_64__) add $$64, BUFFER_PTR // BUFFER_PTR+=64; sub $$1, cnt // pre-decrement cnt by 1 #else addl $$64, BUFFER_PTR // BUFFER_PTR+=64; subl $$1, cnt // pre-decrement cnt by 1 #endif jbe 1f // if cnt <= 0, branch to finish off SOFTWARE_PIPELINING_nossse3 // update ABCDE (i=64:79) || big_endian_load(W) and W+K (i=0:15) UPDATE_ALL_HASH // update output hashes jmp 0b // repeat for next block .align 4,0x90 1: #endif ENDING // update ABCDE (i=64:79) UPDATE_ALL_HASH // update output hashes .endm /* main sha1 code for system with ssse3 support */ .macro SHA1_PIPELINED_MAIN_BODY_ssse3 LOAD_HASH // load initial hashes into A,B,C,D,E INITIAL_W_PRECALC_ssse3 // big_endian_load(W) and W+K (i=0:15) .align 4,0x90 0: INTERNAL_ssse3 // update W (i=16:79) and update ABCDE (i=0:63) #if Multiple_Blocks #if defined(__x86_64__) add $$64, BUFFER_PTR // BUFFER_PTR+=64; sub $$1, cnt // pre-decrement cnt by 1 #else addl $$64, BUFFER_PTR // BUFFER_PTR+=64; subl $$1, cnt // pre-decrement cnt by 1 #endif jbe 1f // if cnt <= 0, branch to finish off SOFTWARE_PIPELINING_ssse3 // update ABCDE (i=64:79) || big_endian_load(W) and W+K (i=0:15) UPDATE_ALL_HASH // update output hashes jmp 0b // repeat for next block .align 4,0x90 1: #endif ENDING // update ABCDE (i=64:79) UPDATE_ALL_HASH // update output hashes .endm #if KERNEL #include <i386/cpu_capabilities.h> #else #include <System/i386/cpu_capabilities.h> #endif .text .globl _sha1_x86_compress_host_order .private_extern _sha1_x86_compress_host_order _sha1_x86_compress_host_order: // detect SSSE3 and dispatch appropriate code branch #if defined __x86_64__ movq __cpu_capabilities@GOTPCREL(%rip), %rax // %rax -> __cpu_capabilities mov (%rax), %eax // %eax = __cpu_capabilities #else // i386 #if defined KERNEL leal __cpu_capabilities, %eax // %eax -> __cpu_capabilities mov (%eax), %eax // %eax = __cpu_capabilities #else mov _COMM_PAGE_CPU_CAPABILITIES, %eax #endif #endif test $(kHasSupplementalSSE3), %eax je _SHA1Compress_x86nossse3_host_order // branch to no-ssse3 code // start the sha1 code with ssse3 support // save callee-save registers #if defined (__x86_64__) push %rbx push %rbp #else push %ebx push %ebp push %esi push %edi #endif sub $stack_size, sp // allocate stack memory for use // save used xmm register if this is for kernel #if KERNEL xmov %xmm0, 4*16(sp) xmov %xmm1, 5*16(sp) xmov %xmm2, 6*16(sp) xmov %xmm3, 7*16(sp) xmov %xmm4, 8*16(sp) xmov %xmm5, 9*16(sp) xmov %xmm6, 10*16(sp) xmov %xmm7, 11*16(sp) #if defined (__x86_64__) xmov %xmm8, 12*16(sp) xmov %xmm9, 13*16(sp) xmov %xmm10, 14*16(sp) #endif #endif #if defined (__x86_64__) // set up registers to free %edx/%edi/%esi for other use (ABCDE) mov ctx, HASH_PTR mov buf, BUFFER_PTR #if Multiple_Blocks mov %rdx, cnt #endif lea K_XMM_AR(%rip), K_BASE xmov -16(K_BASE), XMM_SHUFB_BSWAP #else // __i386__ #if KERNEL lea K_XMM_AR, %eax #else // Get address of 0 in R. call 0f // Push program counter onto stack. 0: pop %eax // Get program counter. lea K_XMM_AR-0b(%eax), %eax #endif mov %eax, K_BASE xmov -16(%eax), %xmm0 xmov %xmm0, XMM_SHUFB_BSWAP #endif SHA1_PIPELINED_MAIN_BODY_ssse3 // restore used xmm registers if this is for kernel #if KERNEL xmov 4*16(sp), %xmm0 xmov 5*16(sp), %xmm1 xmov 6*16(sp), %xmm2 xmov 7*16(sp), %xmm3 xmov 8*16(sp), %xmm4 xmov 9*16(sp), %xmm5 xmov 10*16(sp), %xmm6 xmov 11*16(sp), %xmm7 #if defined (__x86_64__) xmov 12*16(sp), %xmm8 xmov 13*16(sp), %xmm9 xmov 14*16(sp), %xmm10 #endif #endif add $stack_size, sp // deallocate stack memory // restore callee-save registers #if defined (__x86_64__) pop %rbp pop %rbx #else pop %edi pop %esi pop %ebp pop %ebx #endif ret // return // this is equivalent to the above function _SHA1Transform, but it does not use ssse3 instructions .globl _SHA1Compress_x86nossse3_host_order .private_extern _SHA1Compress_x86nossse3_host_order _SHA1Compress_x86nossse3_host_order: // push callee-save registers #if defined (__x86_64__) push %rbx push %rbp #else push %ebx push %ebp push %esi push %edi #endif sub $stack_size, sp // allocate stack memory for local use // save used xmm registers if this is for kernel #if KERNEL xmov %xmm0, 4*16(sp) xmov %xmm1, 5*16(sp) xmov %xmm2, 6*16(sp) xmov %xmm3, 7*16(sp) xmov %xmm4, 8*16(sp) xmov %xmm5, 9*16(sp) xmov %xmm6, 10*16(sp) xmov %xmm7, 11*16(sp) #if defined (__x86_64__) xmov %xmm8, 12*16(sp) xmov %xmm9, 13*16(sp) #endif #endif #if defined (__x86_64__) // set up registers to free %edx/%edi/%esi for other use (ABCDE) mov ctx, HASH_PTR mov buf, BUFFER_PTR #if Multiple_Blocks mov %rdx, cnt #endif lea K_XMM_AR(%rip), K_BASE #else // __i386__ #if KERNEL lea K_XMM_AR, %eax #else // Get address of 0 in R. call 0f // Push program counter onto stack. 0: pop %eax // Get program counter. lea K_XMM_AR-0b(%eax), %eax #endif mov %eax, K_BASE #endif SHA1_PIPELINED_MAIN_BODY_nossse3 // restore used xmm registers if this is for kernel #if KERNEL xmov 4*16(sp), %xmm0 xmov 5*16(sp), %xmm1 xmov 6*16(sp), %xmm2 xmov 7*16(sp), %xmm3 xmov 8*16(sp), %xmm4 xmov 9*16(sp), %xmm5 xmov 10*16(sp), %xmm6 xmov 11*16(sp), %xmm7 #if defined (__x86_64__) xmov 12*16(sp), %xmm8 xmov 13*16(sp), %xmm9 #endif #endif add $stack_size, sp // deallocate stack memory // restore callee-save registers #if defined (__x86_64__) pop %rbp pop %rbx #else pop %edi pop %esi pop %ebp pop %ebx #endif ret // return .const .align 4, 0x90 #define K1 0x5a827999 #define K2 0x6ed9eba1 #define K3 0x8f1bbcdc #define K4 0xca62c1d6 bswap_shufb_ctl: .long 0x00010203 .long 0x04050607 .long 0x08090a0b .long 0x0c0d0e0f K_XMM_AR: .long K1 .long K1 .long K1 .long K1 .long K2 .long K2 .long K2 .long K2 .long K3 .long K3 .long K3 .long K3 .long K4 .long K4 .long K4 .long K4 #endif // architecture x86_64 or i386 |
Added Source/descriptors/digestDescriptors/vng_x86_sha1_descriptor/vng_x86_sha1LE.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | /* * Copyright (c) 2011 Apple Computer, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* sha1edp.s : this file provides optimized x86_64 and i386 implementation of the sha1 function CoreOS - vector and numerics group cclee 6-21-10 The implementation is based on the principle described in an Intel online article "Improving the Performance of the Secure Hash Algorithm (SHA-1)" http://software.intel.com/en-us/articles/improving-the-performance-of-the-secure-hash-algorithm-1/ Update HASH[] by processing a one 64-byte block in MESSAGE[] can be represented by the following C function void SHA1( int HASH[], int MESSAGE[] ) { int A[81], B[81], C[81], D[81], E[81]; int W[80]; int i, FN; A[0] = HASH[0]; B[0] = HASH[1]; C[0] = HASH[2]; D[0] = HASH[3]; E[0] = HASH[4]; for ( i=0; i<80; ++i ) { if ( i < 16 ) W[i] = BIG_ENDIAN_LOAD( MESSAGE[i] ); else W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); FN = F( i, B[i], C[i], D[i] ); A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + W[i] + K(i); B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; } HASH[0] += A[80]; HASH[1] += B[80]; HASH[2] += C[80]; HASH[3] += D[80]; HASH[4] += E[80]; } For i=0:15, W[i] is simply big-endian loading of MESSAGE[i]. For i=16:79, W[i] is updated according to W[i] = ROTATE_LEFT( W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1 ); The approach (by Dean Gaudet) can be used to vectorize the computation of W[i] for i=16:79, 1. done on 4 consequtive W[i] values in a single XMM register W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 2. this additional calculation unfortunately requires many additional operations W[i+3] ^= W[i] rol 1 3. once we have 4 W[i] values in XMM we can also add four K values with one instruction W[i:i+3] += {K,K,K,K} Let W0 = {W[i] W[i+1] W[i+2] W[i+3]} be the current W-vector to be computed, W4 = {W[i-4] W[i-3] W[i-2] W[i-1]} be the previous vector, and so on The Dean Gaudet approach can be expressed as 1. W0 = rotate_left(left_shift(W4,32) ^ W8 ^ left_shift(concatenate(W16,W12),64) ^ W16,1); 2. W[i+3] ^= W[i] rol 1 3. W0 += {K,K,K,K} For i>=32, the Intel online article suggests that (using a basic identity (X rol 1) rol 1 = X rol 2) the update equation is equivalent to 1. W0 = rotate_left(left_shift(concatenate(W8,W4),64) ^ W16 ^ W28 ^ W32, 2); Note: 1. In total, we need 8 16-byte registers or memory for W0,W4,...,W28. W0 and W32 can be the same register or memory. 2. The registers are used in a circular buffering mode. For example, we start with W28,W24,...,W0 (with W0 indicating the most recent 16-byte) i=0, W28,W24,...,W0 i=4, W24,W20,...,W28 i=8, W20,W16,...,W24 . . and so forth. 3. 2 ssse3 instructions are used in the Intel article, pshufb and palignr. a. pshufb is used to simplify the BIG_ENDIAN_LOAD operation b. palignr is used to simplify the computation of left_shift(concatenate(W12,W8),64) 4. we probe __cpu_capabilities to detect ssse3 support and dispatch code with ssse3 support when available. If ssse3 is not supported, a suboptimal code (pshufb and palignr workaround) is dispatched. */ /* the code can be compiled into single block (64 bytes) per call mode by setting Multiple_blocks to 0 */ #define Multiple_Blocks 1 #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #if defined(__x86_64__) // set up for x86_64 #define stack_size (8+16*11+16*4) // 8 (alignedment) + x0-x10 + 4 128-bits for intermediate WK(t) storage #define sp %rsp // unifying architectural stack pointer representation #define ctx %rdi // 1st input argument, will move to HASH_PTR (%r9) #define buf %rsi // 2nd input argument, will move to BUFFER_PTR (%r10) #define cnt %r11 // will copy from the 3rd input argument (%rdx) #define K_BASE %r8 // an aligned pointer to point to shufb reference numbers of table of K values #define HASH_PTR %r9 // pointer to Hash values (A,B,C,D,E) #define BUFFER_PTR %r10 // pointer to input blocks #else // !__x86_64__ // set up for i386 #define stack_size (12+16*2+16*11+16*4) // 12-bytes (alignment) + extra 2 + 3 (W24/W28/XMM_SHUFB_BSWAP) + 8 (xmm0-xmm7) + 4 (WK(t)) #define sp %esp // unifying architectural stack pointer representation #define HASH_PTR stack_size+16+4(sp) // use 1st input argument from caller function, 16 for (esi/edi/ebx/ebp) #define BUFFER_PTR stack_size+16+8(sp) // use 2nd input argument from caller function #define cnt stack_size+16+12(sp) // use 3rd input argument from caller function #define K_BASE stack_size-4(sp) // use for K_BASE #endif // __x86_64__ // symbolizing registers or stack memory with algorithmic variables W0,W4,...,W28 + W_TMP, W_TMP2, and XMM_SHUFB_BSWAP for code with ssse3 support #define W_TMP %xmm0 #define W_TMP2 %xmm1 #define W0 %xmm2 #define W4 %xmm3 #define W8 %xmm4 #define W12 %xmm5 #define W16 %xmm6 #define W20 %xmm7 #if defined(__x86_64__) #define W24 %xmm8 #define W28 %xmm9 #define XMM_SHUFB_BSWAP %xmm10 // used only when ssse3 is supported #else // defined (__i386__) #define W24 12*16(sp) #define W28 13*16(sp) #define XMM_SHUFB_BSWAP 14*16(sp) // used only when ssse3 is supported #endif #define xmov movaps // aligned 16-byte move #define xmovu movups // unaligned 16-byte move // intermediate hash variables #define A %ecx #define B %esi #define C %edi #define D %ebp #define E %edx // temp variables #define T1 %eax #define T2 %ebx #define WK(t) (t&15)*4(sp) // int F1(int B, int C, int D) { return (D ^ ( B & (C ^ D)); } // result in T1 .macro F1 mov $1, T1 xor $2, T1 and $0, T1 xor $2, T1 .endm // int F2(int B, int C, int D) { return (D ^ B ^ C); } // result in T1 .macro F2 mov $2, T1 xor $1, T1 xor $0, T1 .endm // int F3(int B, int C, int D) { return (B & C) | (D & (B ^ C)); } // result in T1 .macro F3 mov $1, T1 mov $0, T2 or $0, T1 and $1, T2 and $2, T1 or T2, T1 .endm // for i=60:79, F4 is identical to F2 #define F4 F2 /* i=0:15, W[i] = BIG_ENDIAN_LOAD(MESSAGE[i]); with ssse3 support, this is achived via for (i=0;i<16;i+=4) { 1. W_TMP = new 16 bytes from MESSAGE[] 2. W_TMP = pshufb(W_TMP, XMM_SHUFB_BSWAP); save to W circular buffer for updating W 3. WTMP += {K,K,K,K}; 4. save quadruple W[i]+K[i] = W_TMP in the stack memory; } each step is represented in one of the following 4 macro definitions */ .macro W_PRECALC_00_15_0_ssse3 // input argument $0 : 0/4/8/12 #if defined (__x86_64__) // BUFFER_PTR is already an address register in x86_64 xmovu $0*4(BUFFER_PTR), W_TMP // read 16-bytes into W_TMP, BUFFER_PTR possibly not 16-byte aligned #else // BUFFER_PTR is from the argument set up in the caller mov BUFFER_PTR, T1 // T1 = BUFFER_PTR xmovu $0*4(T1), W_TMP // read 16-bytes into W_TMP, BUFFER_PTR possibly not 16-byte aligned #endif .endm .macro W_PRECALC_00_15_1_ssse3 // input argument $0 : current 16-bytes in the circular buffer, one of W0,W4,W8,...,W28 pshufb XMM_SHUFB_BSWAP, W_TMP // convert W_TMP from little-endian into big-endian xmov W_TMP, $0 // save W_TMP in the circular buffer .endm .macro W_PRECALC_00_15_2 // K_BASE points to the current K quadruple. #if defined (__x86_64__) // K_BASE is already an address register in x86_64 paddd (K_BASE), W_TMP // W_TMP += {K,K,K,K}; #else // K_BASE is previously set up in the stack memory mov K_BASE, T1 // T1 = K_BASE paddd (T1), W_TMP // W_TMP += {K,K,K,K}; #endif .endm .macro W_PRECALC_00_15_3 xmov W_TMP, WK($0&~3) // save quadruple W[i]+K in the stack memory, which would be used later for updating the hashes A/B/C/D/E .endm /* without ssse3 support, steps 1 and 2 need to be modified 1. sequentially load 4 words into T1, bswap T1, and save it to 4-bytes in the stack space 2. load the 16-bytes from the aligned stack memory into W_TMP */ .macro W_PRECALC_00_15_0_nossse3 // input argument $0 : 0/4/8/12 #if defined (__x86_64__) #define BUFFERP BUFFER_PTR #else mov BUFFER_PTR, T2 // copy BUFFER_PTR (from caller 2nd argument) to T2 #define BUFFERP T2 #endif // load 1st word, bswap it, save it to stack mov $0*4(BUFFERP), T1 bswap T1 mov T1, 14*16(sp) // load 2nd word, bswap it, save it to stack mov 4+$0*4(BUFFERP), T1 bswap T1 mov T1, 4+14*16(sp) // load 3rd word, bswap it, save it to stack mov 8+$0*4(BUFFERP), T1 bswap T1 mov T1, 8+14*16(sp) // load 4th word, bswap it, save it to stack mov 12+$0*4(BUFFERP), T1 bswap T1 mov T1, 12+14*16(sp) .endm .macro W_PRECALC_00_15_1_nossse3 // input argument $0 : current 16-bytes in the circular buffer, one of W0,W4,W8,...,W28 xmov 14*16(sp), W_TMP // load the bswapped 16-bytes from the aligned stack memory xmov W_TMP, $0 // save W = W_TMP in the circular buffer .endm // rounds 16-31 compute W[0] using the vectorization approach by Dean Gaudet /* W[i ] = (W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) rol 1 W[i+1] = (W[i-2] ^ W[i-7] ^ W[i-13] ^ W[i-15]) rol 1 W[i+2] = (W[i-1] ^ W[i-6] ^ W[i-12] ^ W[i-14]) rol 1 W[i+3] = ( 0 ^ W[i-5] ^ W[i-11] ^ W[i-13]) rol 1 W[i+3] ^= W[i] rol 1; // this W[i] is already rol by 1, if we are taking from the intial W before rol 1, we should rol this by 2 The operation (updating W and W+K) is scheduled as and divided into 4 steps 0. W_tmp = W3; W = W14 ^ W8 1. W = W3 ^ W8 ^ W14 ^ W16; W_TMP = W; W_TMP2 = (W[i] 0 0 0); 2. W_TMP = (W3 ^ W8 ^ W14 ^ W16) rol 1; split (W[i] 0 0 0) rol 2 in W_TMP2 and W 3. W = W_TMP = W_TMP ^ W_TMP2 ^ W = (W3 ^ W8 ^ W14 ^ W16) rol 1 ^ (W[i] 0 0 0) rol 2; WK = W _TMP+K; */ .macro W_PRECALC_16_31_0_ssse3 // input arguments : W16,W12,W8,W4,W xmov $1, $4 // W = W12 palignr $$8, $0, $4 // W = W14 xmov $3, W_TMP // W_TMP = W4 psrldq $$4, W_TMP // W_TMP = W3 pxor $2, $4 // W = W8 ^ W14 .endm .macro W_PRECALC_16_31_1 // input arguments : W16,W pxor $0, W_TMP // W_TMP = W3 ^ W16 pxor W_TMP, $1 // W = W3 ^ W16 ^ W8 ^ W14 xmov $1, W_TMP2 // W_TMP2 = W3 ^ W16 ^ W8 ^ W14 xmov $1, W_TMP // W_TMP = W3 ^ W16 ^ W8 ^ W14 pslldq $$12, W_TMP2 // W_TMP2 = (W[i] 0 0 0) .endm .macro W_PRECALC_16_31_2 // input argument : W psrld $$31, $0 // (W3 ^ W16 ^ W8 ^ W14)>>31 pslld $$1, W_TMP // (W3 ^ W16 ^ W8 ^ W14)<<1 por $0, W_TMP // W_TMP = (W3 ^ W16 ^ W8 ^ W14) rol 1 xmov W_TMP2, $0 // copy W[i] at location of W[i+3] psrld $$30, W_TMP2 // W_TMP2 = W[i] lower 2 bits after rol 2 pslld $$2, $0 // W = W[i] higher 30 bits after rol 2 .endm .macro W_PRECALC_16_31_3 // input arguments: W, i, K_XMM #if defined (__i386__) mov K_BASE, T1 // K_BASE is store in the stack memory for i386 #endif pxor $0, W_TMP pxor W_TMP2, W_TMP // W_TMP = (W3 ^ W16 ^ W8 ^ W14) rol 1 ^ (W[i] 0 0 0) rol 2 xmov W_TMP, $0 // save W = W_TMP in the W circular buffer #if defined (__x86_64__) paddd $2(K_BASE), W_TMP // W+K #else paddd $2(T1), W_TMP // W+K #endif xmov W_TMP, WK($1&~3) // save WK = W+K for later update of the hashes A/B/C/D/E .endm // the following is a variant of W_PRECALC_16_31_0_ssse3 to be used for system without ssse3, palignr is replaced with 4 instructions .macro W_PRECALC_16_31_0_nossse3 // input arguments : W16,W12,W8,W4,W xmov $1, $4 // W = W12 = (w9 w10 w11 w12) // the following is a wrokaround for palignr xmov $0, W_TMP // W16 = (w13 w14 w15 w16) pslldq $$8, $4 // shift left to make (w11 w12 0 0) psrldq $$8, W_TMP // shift right to make (0 0 w13 w14) por W_TMP, $4 // W = W14 = (w11 w12 w13 w14) xmov $3, W_TMP // W_TMP = W4 = (w1 w2 w3 w4) psrldq $$4, W_TMP // W_TMP = W3 = (0 w1 w2 w3) pxor $2, $4 // W = W8 ^ W14 .endm /* rounds 32-79 compute W und W+K iusing the vectorization approach from the Intel article W = rotate_left(left_shift(concatenate(W8,W4),64) ^ W16 ^ W28 ^ W32, 2); where left_shift(concatenate(W8,W4),64) is equivalent to W6. Note also that W32 and W use the same register. 0. W_tmp = W6; W = W28 ^ W32; 1. W = W_tmp = W6 ^ W16 ^ W28 ^ W32; 2. W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2; 3. W = W_Tmp; WK = W_tmp + K; */ .macro W_PRECALC_32_79_0_ssse3 // inputr arguments : W28,W8,W4,W xmov $2, W_TMP // (w1 w2 w3 w4) pxor $0, $3 // W = W28 ^ W32; palignr $$8, $1, W_TMP // W_tmp = (w3 w4 w5 w6) = W6; .endm // the following is a variant and will be used for system without ssse3 support .macro W_PRECALC_32_79_0_nossse3 // input arguments : W28,W8,W4,W xmov $2, W_TMP // (w1 w2 w3 w4) xmov $1, W_TMP2 // (w5 w6 w7 w8) pxor $0, $3 // W = W28 ^ W32 pslldq $$8, W_TMP // (w3 w4 0 0) psrldq $$8, W_TMP2 // (0 0 w5 w6) por W_TMP2, W_TMP // W_tmp = (w3 w4 w5 w6) = W6 .endm // this is a variant of W_PRECALC_32_79_0_ssse3 for i386 (as W24/W28 are stored in memory, not in registers) .macro W_PRECALC_32_79_0_i386_ssse3 // input arguments : W28,W8,W4,W xmov $3, W_TMP // W32 pxor $0, W_TMP // W28 ^ W32 xmov W_TMP, $3 // W = W28 ^ W32; xmov $2, W_TMP // W4 palignr $$8, $1, W_TMP // W_tmp = (w3 w4 w5 w6) = W6; .endm // this is a variant of W_PRECALC_32_79_0_nossse3 for i386 (as W24/W28 are stored in memory, not in registers) .macro W_PRECALC_32_79_0_i386_nossse3 // input arguments : W28,W8,W4,W xmov $3, W_TMP // W32 pxor $0, W_TMP // W28 ^ W32 xmov W_TMP, $3 // W = W28 ^ W32 xmov $2, W_TMP // W4 = (w1 w2 w3 w4) xmov $1, W_TMP2 // W8 = (w5 w6 w7 w8) pslldq $$8, W_TMP // (w3 w4 0 0) psrldq $$8, W_TMP2 // (0 0 w5 w6) por W_TMP2, W_TMP // W_tmp = (w3 w4 w5 w6) = W6 .endm .macro W_PRECALC_32_79_1 // input arguments : W16,W pxor $0, W_TMP // W_tmp = W6 ^ W16 pxor $1, W_TMP // W_tmp = W6 ^ W16 ^ W28 ^ W32 xmov W_TMP, $1 // W = W_tmp = W6 ^ W16 ^ W28 ^ W32 .endm .macro W_PRECALC_32_79_2 // input argument : W psrld $$30, $0 // W >> 30 pslld $$2, W_TMP // W << 2 por $0, W_TMP // W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2 .endm // this is a variant of W_PRECALC_32_79_2 for i386 (as W24/W28 are stored in memory, not in registers) // this should be used when the input is either W24 or W28 on i386 architecture .macro W_PRECALC_32_79_2_i386 // input argument : W xmov $0, W_TMP2 // W psrld $$30, W_TMP2 // W >> 30 xmov W_TMP2, $0 // save (W >> 30) at W pslld $$2, W_TMP // W_tmp << 2 por $0, W_TMP // W_tmp = (W6 ^ W16 ^ W28 ^ W32) rol 2 .endm .macro W_PRECALC_32_79_3 // input argument W, i, K_XMM #if defined (__x86_64__) xmov W_TMP, $0 // W = (W6 ^ W16 ^ W28 ^ W32) rol 2 paddd $2(K_BASE), W_TMP // W + K xmov W_TMP, WK($1&~3) // write W+K #else mov K_BASE, T1 // T1 = K_BASE (which is in the caller argument) xmov W_TMP, $0 // W = (W6 ^ W16 ^ W28 ^ W32) rol 2 paddd $2(T1), W_TMP // W_tmp = W + K xmov W_TMP, WK($1&~3) // write WK #endif .endm /* The hash update operation is completed by the following statements. A[i+1] = FN + E[i] + ROTATE_LEFT( A[i], 5 ) + WK(i); B[i+1] = A[i]; C[i+1] = ROTATE_LEFT( B[i], 30 ); D[i+1] = C[i]; E[i+1] = D[i]; Suppose we start with A0,B0,C0,D0,E0. The 1st iteration can be expressed as follows: A1 = FN + E0 + rol(A0,5) + WK; B1 = A0; C1 = rol(B0, 30); D1 = C0; E1 = D0; to avoid excessive memory movement between registers, 1. A1 = FN + E0 + rol(A0,5) + WK; can be temporarily saved in E0, 2. C1 = rol(B0,30) can be temporarily saved in B0. Therefore, ignoring the time index, the update operation is equivalent to 1. E = FN(B,C,D) + E + rol(A,5) + WK(i) 2. B = rol(B,30) 3. the hashes are now stored in the order of E,A,B,C,D To pack 2 hash update operations in 1 iteration, starting with A,B,C,D,E 1. E = FN(B,C,D) + E + rol(A,5) + WK(i) 2. B = rol(B,30) // now the hashes are in the order of E,A,B,C,D 3. D = FN(A,B,C) + D + rol(E,5) + WK(i+1) 4. A = rol(A,30) // now the hashes are in the order of D,E,A,B,C These operations are distributed into the following 2 macro definitions RR0 and RR1. */ .macro RR0 // input arguments : FN, A, B, C, D, E, i $0 $2, $3, $4 // T1 = FN(B,C,D) add WK($6), $5 // E + WK(i) rol $$30, $2 // B = rol(B,30) mov $1, T2 // T2 = A add WK($6+1), $4 // D + WK(i+1) rol $$5, T2 // rol(A,5) add T1, $5 // E = FN(B,C,D) + E + WK(i) .endm .macro RR1 add $5, T2 // T2 = FN(B,C,D) + E + rol(A,5) + WK(i) mov T2, $5 // E = FN(B,C,D) + E + rol(A,5) + WK(i) rol $$5, T2 // rol(E,5) add T2, $4 // D + WK(i+1) + rol(E,5) $0 $1, $2, $3 // FN(A,B,C) add T1, $4 // D = FN(A,B,C) + D + rol(E,5) + WK(i+1) rol $$30, $1 // A = rol(A,30) .endm /* The following macro definitions are used to expand code for the per-block sha1 operation. INITIAL_W_PRECALC_ssse3 : BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack memory INTERNAL_ssse3 : updating W (16:79) and update the digests A/B/C/D/E (i=0:63, based on W+K stored in the stack memory) ENDING : finishing up update the digests A/B/C/D/E (i=64:79) For multiple-block sha1 operation (Multiple_Blocks = 1), INITIAL_W_PRECALC_ssse3 and ENDING are combined into 1 macro definition for software pipeling. SOFTWARE_PIPELINING_ssse3 : BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack, and finishing up update the digests A/B/C/D/E (i=64:79) assume cnt (the number of blocks) >= 1, the main code body should look like INITIAL_W_PRECALC_ssse3 // W = big_endian_load and pre-compute W+K (i=0:15) do { INTERNAL_ssse3 // update W(i=16:79), and update hash digests A/B/C/D/E (i=0:63) cnt--; if (cnt==0) break; BUFFER_PTR += 64; SOFTWARE_PIPELINING_ssse3; // update hash digests A/B/C/D/E (i=64:79) + W = big_endian_load and pre-compute W+K (i=0:15) } ENDING // update hash digests A/B/C/D/E (i=64:79) */ #define W_PRECALC_00_15_0 W_PRECALC_00_15_0_ssse3 #define W_PRECALC_00_15_1 W_PRECALC_00_15_1_ssse3 #define W_PRECALC_16_31_0 W_PRECALC_16_31_0_ssse3 #define W_PRECALC_32_79_0 W_PRECALC_32_79_0_ssse3 #define W_PRECALC_32_79_0_i386 W_PRECALC_32_79_0_i386_ssse3 .macro INITIAL_W_PRECALC_ssse3 // BIG_ENDIAN_LOAD(64 bytes block) into W (i=0:15) and store W+K into the stack memory // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP W_PRECALC_00_15_2 // W_TMP = W0 + K W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP W_PRECALC_00_15_2 // W_TMP = W28 + K W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP W_PRECALC_00_15_2 // W_TMP = W24 + K W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP W_PRECALC_00_15_2 // W_TMP = W20 + K W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K .endm .macro INTERNAL_ssse3 // updating W (16:79) and update the digests A/B/C/D/E (i=0:63, based on W+K stored in the stack memory) // i=16 : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_16_31_0 W0,W28,W24,W20,W16 RR0 F1,A,B,C,D,E,0 W_PRECALC_16_31_1 W0,W16 RR1 F1,A,B,C,D,E,0 W_PRECALC_16_31_2 W16 RR0 F1,D,E,A,B,C,2 W_PRECALC_16_31_3 W16, 2, 0 RR1 F1,D,E,A,B,C,2 // i=20 : W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_16_31_0 W28,W24,W20,W16,W12 RR0 F1,B,C,D,E,A,4 W_PRECALC_16_31_1 W28,W12 RR1 F1,B,C,D,E,A,4 W_PRECALC_16_31_2 W12 RR0 F1,E,A,B,C,D,6 W_PRECALC_16_31_3 W12, 6, 16 RR1 F1,E,A,B,C,D,6 // i=24 : W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_16_31_0 W24,W20,W16,W12,W8 RR0 F1,C,D,E,A,B,8 W_PRECALC_16_31_1 W24,W8 RR1 F1,C,D,E,A,B,8 W_PRECALC_16_31_2 W8 RR0 F1,A,B,C,D,E,10 W_PRECALC_16_31_3 W8,10,16 RR1 F1,A,B,C,D,E,10 // i=28 : W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_16_31_0 W20,W16,W12,W8,W4 RR0 F1,D,E,A,B,C,12 W_PRECALC_16_31_1 W20,W4 RR1 F1,D,E,A,B,C,12 W_PRECALC_16_31_2 W4 RR0 F1,B,C,D,E,A,14 W_PRECALC_16_31_3 W4,14,16 RR1 F1,B,C,D,E,A,14 // i=32 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F1,E,A,B,C,D,16 W_PRECALC_32_79_1 W16,W0 RR1 F1,E,A,B,C,D,16 W_PRECALC_32_79_2 W0 RR0 F1,C,D,E,A,B,18 W_PRECALC_32_79_3 W0,18,16 RR1 F1,C,D,E,A,B,18 // starting using F2 // i=36 : W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F2,A,B,C,D,E,20 W_PRECALC_32_79_1 W12,W28 RR1 F2,A,B,C,D,E,20 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F2,D,E,A,B,C,22 W_PRECALC_32_79_3 W28,22,16 RR1 F2,D,E,A,B,C,22 // i=40 : W20,W16,W12,W8,W4,W0,W28,W24 #undef K_XMM #define K_XMM 32 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F2,B,C,D,E,A,24 W_PRECALC_32_79_1 W8,W24 RR1 F2,B,C,D,E,A,24 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F2,E,A,B,C,D,26 W_PRECALC_32_79_3 W24,26,K_XMM RR1 F2,E,A,B,C,D,26 // i=44 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F2,C,D,E,A,B,28 W_PRECALC_32_79_1 W4,W20 RR1 F2,C,D,E,A,B,28 W_PRECALC_32_79_2 W20 RR0 F2,A,B,C,D,E,30 W_PRECALC_32_79_3 W20,30,K_XMM RR1 F2,A,B,C,D,E,30 // i=48 : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0 W12,W24,W20,W16 RR0 F2,D,E,A,B,C,32 W_PRECALC_32_79_1 W0,W16 RR1 F2,D,E,A,B,C,32 W_PRECALC_32_79_2 W16 RR0 F2,B,C,D,E,A,34 W_PRECALC_32_79_3 W16,34,K_XMM RR1 F2,B,C,D,E,A,34 // i=52 : W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0 W8,W20,W16,W12 RR0 F2,E,A,B,C,D,36 W_PRECALC_32_79_1 W28,W12 RR1 F2,E,A,B,C,D,36 W_PRECALC_32_79_2 W12 RR0 F2,C,D,E,A,B,38 W_PRECALC_32_79_3 W12,38,K_XMM RR1 F2,C,D,E,A,B,38 // starting using F3 // i=56 : W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0 W4,W16,W12,W8 RR0 F3,A,B,C,D,E,40 W_PRECALC_32_79_1 W24,W8 RR1 F3,A,B,C,D,E,40 W_PRECALC_32_79_2 W8 RR0 F3,D,E,A,B,C,42 W_PRECALC_32_79_3 W8,42,K_XMM RR1 F3,D,E,A,B,C,42 // i=60 : W0,W28,W24,W20,W16,W12,W8,W4 #undef K_XMM #define K_XMM 48 W_PRECALC_32_79_0 W0,W12,W8,W4 RR0 F3,B,C,D,E,A,44 W_PRECALC_32_79_1 W20,W4 RR1 F3,B,C,D,E,A,44 W_PRECALC_32_79_2 W4 RR0 F3,E,A,B,C,D,46 W_PRECALC_32_79_3 W4,46,K_XMM RR1 F3,E,A,B,C,D,46 // i=64 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F3,C,D,E,A,B,48 W_PRECALC_32_79_1 W16,W0 RR1 F3,C,D,E,A,B,48 W_PRECALC_32_79_2 W0 RR0 F3,A,B,C,D,E,50 W_PRECALC_32_79_3 W0,50,K_XMM RR1 F3,A,B,C,D,E,50 // i=68 : W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F3,D,E,A,B,C,52 W_PRECALC_32_79_1 W12,W28 RR1 F3,D,E,A,B,C,52 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F3,B,C,D,E,A,54 W_PRECALC_32_79_3 W28,54,K_XMM RR1 F3,B,C,D,E,A,54 // i=72 : W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F3,E,A,B,C,D,56 W_PRECALC_32_79_1 W8,W24 RR1 F3,E,A,B,C,D,56 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F3,C,D,E,A,B,58 W_PRECALC_32_79_3 W24,58,K_XMM RR1 F3,C,D,E,A,B,58 // starting using F4 // i=76 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F4,A,B,C,D,E,60 W_PRECALC_32_79_1 W4,W20 RR1 F4,A,B,C,D,E,60 W_PRECALC_32_79_2 W20 RR0 F4,D,E,A,B,C,62 W_PRECALC_32_79_3 W20,62,K_XMM RR1 F4,D,E,A,B,C,62 .endm .macro SOFTWARE_PIPELINING_ssse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) RR0 F4,B,C,D,E,A,64 W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP RR1 F4,B,C,D,E,A,64 W_PRECALC_00_15_2 // W_TMP = W0 + K RR0 F4,E,A,B,C,D,66 W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K RR1 F4,E,A,B,C,D,66 // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) RR0 F4,C,D,E,A,B,68 W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP RR1 F4,C,D,E,A,B,68 W_PRECALC_00_15_2 // W_TMP = W28 + K RR0 F4,A,B,C,D,E,70 W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K[0] RR1 F4,A,B,C,D,E,70 // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) RR0 F4,D,E,A,B,C,72 W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP RR1 F4,D,E,A,B,C,72 W_PRECALC_00_15_2 // W_TMP = W24 + K RR0 F4,B,C,D,E,A,74 W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K RR1 F4,B,C,D,E,A,74 // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) RR0 F4,E,A,B,C,D,76 W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP RR1 F4,E,A,B,C,D,76 W_PRECALC_00_15_2 // W_TMP = W20 + K RR0 F4,C,D,E,A,B,78 W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K RR1 F4,C,D,E,A,B,78 .endm #undef W_PRECALC_00_15_0 #undef W_PRECALC_00_15_1 #undef W_PRECALC_16_31_0 #undef W_PRECALC_32_79_0 #undef W_PRECALC_32_79_0_i386 /* The following are 3 macro definitions that are no-ssse3 variants of the previous 3 macro definitions. INITIAL_W_PRECALC_nossse3 INTERNAL_nossse3 SOFTWARE_PIPELINING_nossse3 They will be used in a sha1 code main body definition that will be used for system without ssse3 support. */ #define W_PRECALC_00_15_0 W_PRECALC_00_15_0_nossse3 #define W_PRECALC_00_15_1 W_PRECALC_00_15_1_nossse3 #define W_PRECALC_16_31_0 W_PRECALC_16_31_0_nossse3 #define W_PRECALC_32_79_0 W_PRECALC_32_79_0_nossse3 #define W_PRECALC_32_79_0_i386 W_PRECALC_32_79_0_i386_nossse3 .macro INITIAL_W_PRECALC_nossse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP W_PRECALC_00_15_2 // W_TMP = W0 + K W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP W_PRECALC_00_15_2 // W_TMP = W28 + K W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP W_PRECALC_00_15_2 // W_TMP = W24 + K W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP W_PRECALC_00_15_2 // W_TMP = W20 + K W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K .endm .macro INTERNAL_nossse3 // i=16 // circular buffer : W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_16_31_0 W0,W28,W24,W20,W16 RR0 F1,A,B,C,D,E,0 W_PRECALC_16_31_1 W0,W16 RR1 F1,A,B,C,D,E,0 W_PRECALC_16_31_2 W16 RR0 F1,D,E,A,B,C,2 W_PRECALC_16_31_3 W16, 2, 0 RR1 F1,D,E,A,B,C,2 // i=20, // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_16_31_0 W28,W24,W20,W16,W12 RR0 F1,B,C,D,E,A,4 W_PRECALC_16_31_1 W28,W12 RR1 F1,B,C,D,E,A,4 W_PRECALC_16_31_2 W12 RR0 F1,E,A,B,C,D,6 W_PRECALC_16_31_3 W12, 6, 16 RR1 F1,E,A,B,C,D,6 // i=24, // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_16_31_0 W24,W20,W16,W12,W8 RR0 F1,C,D,E,A,B,8 W_PRECALC_16_31_1 W24,W8 RR1 F1,C,D,E,A,B,8 W_PRECALC_16_31_2 W8 RR0 F1,A,B,C,D,E,10 W_PRECALC_16_31_3 W8,10,16 RR1 F1,A,B,C,D,E,10 // i=28 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_16_31_0 W20,W16,W12,W8,W4 RR0 F1,D,E,A,B,C,12 W_PRECALC_16_31_1 W20,W4 RR1 F1,D,E,A,B,C,12 W_PRECALC_16_31_2 W4 RR0 F1,B,C,D,E,A,14 W_PRECALC_16_31_3 W4,14,16 RR1 F1,B,C,D,E,A,14 //i=32 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F1,E,A,B,C,D,16 W_PRECALC_32_79_1 W16,W0 RR1 F1,E,A,B,C,D,16 W_PRECALC_32_79_2 W0 RR0 F1,C,D,E,A,B,18 W_PRECALC_32_79_3 W0,18,16 RR1 F1,C,D,E,A,B,18 //i=36 // W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F2,A,B,C,D,E,20 W_PRECALC_32_79_1 W12,W28 RR1 F2,A,B,C,D,E,20 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F2,D,E,A,B,C,22 W_PRECALC_32_79_3 W28,22,16 RR1 F2,D,E,A,B,C,22 //i=40 #undef K_XMM #define K_XMM 32 // W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F2,B,C,D,E,A,24 W_PRECALC_32_79_1 W8,W24 RR1 F2,B,C,D,E,A,24 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F2,E,A,B,C,D,26 W_PRECALC_32_79_3 W24,26,K_XMM RR1 F2,E,A,B,C,D,26 //i=44 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F2,C,D,E,A,B,28 W_PRECALC_32_79_1 W4,W20 RR1 F2,C,D,E,A,B,28 W_PRECALC_32_79_2 W20 RR0 F2,A,B,C,D,E,30 W_PRECALC_32_79_3 W20,30,K_XMM RR1 F2,A,B,C,D,E,30 //i=48 // W12,W8,W4,W0,W28,W24,W20,W16 W_PRECALC_32_79_0 W12,W24,W20,W16 RR0 F2,D,E,A,B,C,32 W_PRECALC_32_79_1 W0,W16 RR1 F2,D,E,A,B,C,32 W_PRECALC_32_79_2 W16 RR0 F2,B,C,D,E,A,34 W_PRECALC_32_79_3 W16,34,K_XMM RR1 F2,B,C,D,E,A,34 //i=52 // W8,W4,W0,W28,W24,W20,W16,W12 W_PRECALC_32_79_0 W8,W20,W16,W12 RR0 F2,E,A,B,C,D,36 W_PRECALC_32_79_1 W28,W12 RR1 F2,E,A,B,C,D,36 W_PRECALC_32_79_2 W12 RR0 F2,C,D,E,A,B,38 W_PRECALC_32_79_3 W12,38,K_XMM RR1 F2,C,D,E,A,B,38 //i=56 // W4,W0,W28,W24,W20,W16,W12,W8 W_PRECALC_32_79_0 W4,W16,W12,W8 RR0 F3,A,B,C,D,E,40 W_PRECALC_32_79_1 W24,W8 RR1 F3,A,B,C,D,E,40 W_PRECALC_32_79_2 W8 RR0 F3,D,E,A,B,C,42 W_PRECALC_32_79_3 W8,42,K_XMM RR1 F3,D,E,A,B,C,42 //i=60 #undef K_XMM #define K_XMM 48 // W0,W28,W24,W20,W16,W12,W8,W4 W_PRECALC_32_79_0 W0,W12,W8,W4 RR0 F3,B,C,D,E,A,44 W_PRECALC_32_79_1 W20,W4 RR1 F3,B,C,D,E,A,44 W_PRECALC_32_79_2 W4 RR0 F3,E,A,B,C,D,46 W_PRECALC_32_79_3 W4,46,K_XMM RR1 F3,E,A,B,C,D,46 //i=64 // W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_32_79_0 W28,W8,W4,W0 RR0 F3,C,D,E,A,B,48 W_PRECALC_32_79_1 W16,W0 RR1 F3,C,D,E,A,B,48 W_PRECALC_32_79_2 W0 RR0 F3,A,B,C,D,E,50 W_PRECALC_32_79_3 W0,50,K_XMM RR1 F3,A,B,C,D,E,50 //i=68 // W24,W20,W16,W12,W8,W4,W0,W28 #if defined (__x86_64__) W_PRECALC_32_79_0 W24,W4,W0,W28 #else W_PRECALC_32_79_0_i386 W24,W4,W0,W28 #endif RR0 F3,D,E,A,B,C,52 W_PRECALC_32_79_1 W12,W28 RR1 F3,D,E,A,B,C,52 #if defined (__x86_64__) W_PRECALC_32_79_2 W28 #else W_PRECALC_32_79_2_i386 W28 #endif RR0 F3,B,C,D,E,A,54 W_PRECALC_32_79_3 W28,54,K_XMM RR1 F3,B,C,D,E,A,54 //i=72 // W20,W16,W12,W8,W4,W0,W28,W24 #if defined (__x86_64__) W_PRECALC_32_79_0 W20,W0,W28,W24 #else W_PRECALC_32_79_0_i386 W20,W0,W28,W24 #endif RR0 F3,E,A,B,C,D,56 W_PRECALC_32_79_1 W8,W24 RR1 F3,E,A,B,C,D,56 #if defined (__x86_64__) W_PRECALC_32_79_2 W24 #else W_PRECALC_32_79_2_i386 W24 #endif RR0 F3,C,D,E,A,B,58 W_PRECALC_32_79_3 W24,58,K_XMM RR1 F3,C,D,E,A,B,58 // starting using F4 //i=76 // W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_32_79_0 W16,W28,W24,W20 RR0 F4,A,B,C,D,E,60 W_PRECALC_32_79_1 W4,W20 RR1 F4,A,B,C,D,E,60 W_PRECALC_32_79_2 W20 RR0 F4,D,E,A,B,C,62 W_PRECALC_32_79_3 W20,62,K_XMM RR1 F4,D,E,A,B,C,62 .endm .macro SOFTWARE_PIPELINING_nossse3 // i=0 : W28,W24,W20,W16,W12,W8,W4,W0 W_PRECALC_00_15_0 0 // W_TMP = (BUFFER_PTR) RR0 F4,B,C,D,E,A,64 W_PRECALC_00_15_1 W0 // convert W_TMP to big-endian, and save W0 = W_TMP RR1 F4,B,C,D,E,A,64 W_PRECALC_00_15_2 // W_TMP = W0 + K RR0 F4,E,A,B,C,D,66 W_PRECALC_00_15_3 3 // (sp) = W_TMP = W0 + K RR1 F4,E,A,B,C,D,66 // i=4 : W24,W20,W16,W12,W8,W4,W0,W28 W_PRECALC_00_15_0 4 // W_TMP = 16(BUFFER_PTR) RR0 F4,C,D,E,A,B,68 W_PRECALC_00_15_1 W28 // convert W_TMP to big-endian, and save W28 = W_TMP RR1 F4,C,D,E,A,B,68 W_PRECALC_00_15_2 // W_TMP = W28 + K RR0 F4,A,B,C,D,E,70 W_PRECALC_00_15_3 7 // 16(sp) = W_TMP = W28 + K[0] RR1 F4,A,B,C,D,E,70 // i=8 : W20,W16,W12,W8,W4,W0,W28,W24 W_PRECALC_00_15_0 8 // W_TMP = 32(BUFFER_PTR) RR0 F4,D,E,A,B,C,72 W_PRECALC_00_15_1 W24 // convert W_TMP to big-endian, and save W24 = W_TMP RR1 F4,D,E,A,B,C,72 W_PRECALC_00_15_2 // W_TMP = W24 + K RR0 F4,B,C,D,E,A,74 W_PRECALC_00_15_3 11 // 32(sp) = W_TMP = W24 + K RR1 F4,B,C,D,E,A,74 // i=12 : W16,W12,W8,W4,W0,W28,W24,W20 W_PRECALC_00_15_0 12 // W_TMP = 48(BUFFER_PTR) RR0 F4,E,A,B,C,D,76 W_PRECALC_00_15_1 W20 // convert W_TMP to big-endian, and save W20 = W_TMP RR1 F4,E,A,B,C,D,76 W_PRECALC_00_15_2 // W_TMP = W20 + K RR0 F4,C,D,E,A,B,78 W_PRECALC_00_15_3 15 // 48(sp) = W_TMP = W20 + K RR1 F4,C,D,E,A,B,78 .endm .macro ENDING // finish up updating hash digests (i=64:79) //i=80 RR0 F4,B,C,D,E,A,64 RR1 F4,B,C,D,E,A,64 RR0 F4,E,A,B,C,D,66 RR1 F4,E,A,B,C,D,66 //i=84 RR0 F4,C,D,E,A,B,68 RR1 F4,C,D,E,A,B,68 RR0 F4,A,B,C,D,E,70 RR1 F4,A,B,C,D,E,70 //i=88 RR0 F4,D,E,A,B,C,72 RR1 F4,D,E,A,B,C,72 RR0 F4,B,C,D,E,A,74 RR1 F4,B,C,D,E,A,74 //i=92 RR0 F4,E,A,B,C,D,76 RR1 F4,E,A,B,C,D,76 RR0 F4,C,D,E,A,B,78 RR1 F4,C,D,E,A,B,78 .endm // load hash digests A,B,C,D,E from memory into registers .macro LOAD_HASH #if defined (__x86_64__) mov (HASH_PTR), A mov 4(HASH_PTR), B mov 8(HASH_PTR), C mov 12(HASH_PTR), D mov 16(HASH_PTR), E #else mov HASH_PTR, T1 mov (T1), A mov 4(T1), B mov 8(T1), C mov 12(T1), D mov 16(T1), E #endif .endm .macro UPDATE_HASH add $0, $1 mov $1, $0 .endm .macro UPDATE_ALL_HASH #if defined (__x86_64__) UPDATE_HASH (HASH_PTR), A UPDATE_HASH 4(HASH_PTR), B UPDATE_HASH 8(HASH_PTR), C UPDATE_HASH 12(HASH_PTR), D UPDATE_HASH 16(HASH_PTR), E #else mov HASH_PTR, T1 UPDATE_HASH (T1), A UPDATE_HASH 4(T1), B UPDATE_HASH 8(T1), C UPDATE_HASH 12(T1), D UPDATE_HASH 16(T1), E #endif .endm /* main sha1 code for system without ssse3 support */ .macro SHA1_PIPELINED_MAIN_BODY_nossse3 LOAD_HASH // load initial hashes into A,B,C,D,E (registers) INITIAL_W_PRECALC_nossse3 // big_endian_load(W) and W+K (i=0:15) .align 4,0x90 0: INTERNAL_nossse3 // update W (i=16:79) and update ABCDE (i=0:63) #if Multiple_Blocks #if defined(__x86_64__) add $$64, BUFFER_PTR // BUFFER_PTR+=64; sub $$1, cnt // pre-decrement cnt by 1 #else addl $$64, BUFFER_PTR // BUFFER_PTR+=64; subl $$1, cnt // pre-decrement cnt by 1 #endif jbe 1f // if cnt <= 0, branch to finish off SOFTWARE_PIPELINING_nossse3 // update ABCDE (i=64:79) || big_endian_load(W) and W+K (i=0:15) UPDATE_ALL_HASH // update output hashes jmp 0b // repeat for next block .align 4,0x90 1: #endif ENDING // update ABCDE (i=64:79) UPDATE_ALL_HASH // update output hashes .endm /* main sha1 code for system with ssse3 support */ .macro SHA1_PIPELINED_MAIN_BODY_ssse3 LOAD_HASH // load initial hashes into A,B,C,D,E INITIAL_W_PRECALC_ssse3 // big_endian_load(W) and W+K (i=0:15) .align 4,0x90 0: INTERNAL_ssse3 // update W (i=16:79) and update ABCDE (i=0:63) #if Multiple_Blocks #if defined(__x86_64__) add $$64, BUFFER_PTR // BUFFER_PTR+=64; sub $$1, cnt // pre-decrement cnt by 1 #else addl $$64, BUFFER_PTR // BUFFER_PTR+=64; subl $$1, cnt // pre-decrement cnt by 1 #endif jbe 1f // if cnt <= 0, branch to finish off SOFTWARE_PIPELINING_ssse3 // update ABCDE (i=64:79) || big_endian_load(W) and W+K (i=0:15) UPDATE_ALL_HASH // update output hashes jmp 0b // repeat for next block .align 4,0x90 1: #endif ENDING // update ABCDE (i=64:79) UPDATE_ALL_HASH // update output hashes .endm #if KERNEL #include <i386/cpu_capabilities.h> #else #include <System/i386/cpu_capabilities.h> #endif .text .globl _sha1_x86_compress_data_order .private_extern _sha1_x86_compress_data_order _sha1_x86_compress_data_order: // detect SSSE3 and dispatch appropriate code branch #if defined __x86_64__ movq __cpu_capabilities@GOTPCREL(%rip), %rax // %rax -> __cpu_capabilities mov (%rax), %eax // %eax = __cpu_capabilities #else // i386 #if KERNEL leal __cpu_capabilities, %eax // %eax -> __cpu_capabilities mov (%eax), %eax // %eax = __cpu_capabilities #else mov _COMM_PAGE_CPU_CAPABILITIES, %eax #endif #endif test $(kHasSupplementalSSE3), %eax je _SHA1Compress_x86nossse3 // branch to no-ssse3 code // start the sha1 code with ssse3 support // save callee-save registers #if defined (__x86_64__) push %rbx push %rbp #else push %ebx push %ebp push %esi push %edi #endif sub $stack_size, sp // allocate stack memory for use // save used xmm register if this is for kernel #if KERNEL xmov %xmm0, 4*16(sp) xmov %xmm1, 5*16(sp) xmov %xmm2, 6*16(sp) xmov %xmm3, 7*16(sp) xmov %xmm4, 8*16(sp) xmov %xmm5, 9*16(sp) xmov %xmm6, 10*16(sp) xmov %xmm7, 11*16(sp) #if defined (__x86_64__) xmov %xmm8, 12*16(sp) xmov %xmm9, 13*16(sp) xmov %xmm10, 14*16(sp) #endif #endif #if defined (__x86_64__) // set up registers to free %edx/%edi/%esi for other use (ABCDE) mov ctx, HASH_PTR mov buf, BUFFER_PTR #if Multiple_Blocks mov %rdx, cnt #endif lea K_XMM_AR(%rip), K_BASE xmov 0x40(K_BASE), XMM_SHUFB_BSWAP #else // __i386__ #if KERNEL lea K_XMM_AR, %eax #else // Get address of 0 in R. call 0f // Push program counter onto stack. 0: pop %eax // Get program counter. lea K_XMM_AR-0b(%eax), %eax #endif mov %eax, K_BASE xmov 0x40(%eax), %xmm0 xmov %xmm0, XMM_SHUFB_BSWAP #endif SHA1_PIPELINED_MAIN_BODY_ssse3 // restore used xmm registers if this is for kernel #if KERNEL xmov 4*16(sp), %xmm0 xmov 5*16(sp), %xmm1 xmov 6*16(sp), %xmm2 xmov 7*16(sp), %xmm3 xmov 8*16(sp), %xmm4 xmov 9*16(sp), %xmm5 xmov 10*16(sp), %xmm6 xmov 11*16(sp), %xmm7 #if defined (__x86_64__) xmov 12*16(sp), %xmm8 xmov 13*16(sp), %xmm9 xmov 14*16(sp), %xmm10 #endif #endif add $stack_size, sp // deallocate stack memory // restore callee-save registers #if defined (__x86_64__) pop %rbp pop %rbx #else pop %edi pop %esi pop %ebp pop %ebx #endif ret // return // this is equivalent to the above function _SHA1Transform, but it does not use ssse3 instructions .globl _SHA1Compress_x86nossse3 .private_extern _SHA1Compress_x86nossse3 _SHA1Compress_x86nossse3: // push callee-save registers #if defined (__x86_64__) push %rbx push %rbp #else push %ebx push %ebp push %esi push %edi #endif sub $stack_size, sp // allocate stack memory for local use // save used xmm registers if this is for kernel #if KERNEL xmov %xmm0, 4*16(sp) xmov %xmm1, 5*16(sp) xmov %xmm2, 6*16(sp) xmov %xmm3, 7*16(sp) xmov %xmm4, 8*16(sp) xmov %xmm5, 9*16(sp) xmov %xmm6, 10*16(sp) xmov %xmm7, 11*16(sp) #if defined (__x86_64__) xmov %xmm8, 12*16(sp) xmov %xmm9, 13*16(sp) #endif #endif #if defined (__x86_64__) // set up registers to free %edx/%edi/%esi for other use (ABCDE) mov ctx, HASH_PTR mov buf, BUFFER_PTR #if Multiple_Blocks mov %rdx, cnt #endif lea K_XMM_AR(%rip), K_BASE #else // __i386__ #if KERNEL lea K_XMM_AR, %eax #else // Get address of 0 in R. call 0f // Push program counter onto stack. 0: pop %eax // Get program counter. lea K_XMM_AR-0b(%eax), %eax #endif mov %eax, K_BASE #endif SHA1_PIPELINED_MAIN_BODY_nossse3 // restore used xmm registers if this is for kernel #if KERNEL xmov 4*16(sp), %xmm0 xmov 5*16(sp), %xmm1 xmov 6*16(sp), %xmm2 xmov 7*16(sp), %xmm3 xmov 8*16(sp), %xmm4 xmov 9*16(sp), %xmm5 xmov 10*16(sp), %xmm6 xmov 11*16(sp), %xmm7 #if defined (__x86_64__) xmov 12*16(sp), %xmm8 xmov 13*16(sp), %xmm9 #endif #endif add $stack_size, sp // deallocate stack memory // restore callee-save registers #if defined (__x86_64__) pop %rbp pop %rbx #else pop %edi pop %esi pop %ebp pop %ebx #endif ret // return .const .align 4, 0x90 #define K1 0x5a827999 #define K2 0x6ed9eba1 #define K3 0x8f1bbcdc #define K4 0xca62c1d6 K_XMM_AR: .long K1 .long K1 .long K1 .long K1 .long K2 .long K2 .long K2 .long K2 .long K3 .long K3 .long K3 .long K3 .long K4 .long K4 .long K4 .long K4 // bswap_shufb_ctl: accessed thru 0x40(K_XMM_AR) .long 0x00010203 .long 0x04050607 .long 0x08090a0b .long 0x0c0d0e0f #endif // architecture x86_64 or i386 |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/sha256.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | /* * Copyright (c) 2011 Apple Computer, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* This file provides x86_64/i386 hand implementation of the following function void SHA256_Transform(SHA256_ctx *ctx, char *data, unsigned int num_blocks); which is a C function in sha2.c (from xnu). The code 1st probes cpu_capabilities to detect whether ssse3 is supported. If not, it branches to SHA256_Transform_nossse3 (in a separate source file sha256nossse3.s) that was cloned from this file with all ssse3 instructions replaced with sse3 or below instructions. sha256 algorithm per block description: 1. W(0:15) = big-endian (per 4 bytes) loading of input data (64 byte) 2. load 8 digests a-h from ctx->state 3. for r = 0:15 T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g 4. for r = 16:63 W[r] = W[r-16] + sigma1(W[r-2]) + W[r-7] + sigma0(W[r-15]); T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g In the assembly implementation: - a circular window of message schedule W(r:r+15) is updated and stored in xmm0-xmm3 - its corresponding W+K(r:r+15) is updated and stored in a stack space circular buffer - the 8 digests (a-h) will be stored in GPR or m32 (all in GPR for x86_64, and some in m32 for i386) the implementation per block looks like ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K(0:15) in stack load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ---------------------------------------------------------------------------- our implementation (allows multiple blocks per call) pipelines the loading of W/WK of a future block into the last 16 rounds of its previous block: ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K(0:15) in stack L_loop: load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } num_block--; if (num_block==0) jmp L_last_block; for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 load W([r:r+3]%16) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K([r:r+3]%16) in stack } ctx->states += digests a-h; jmp L_loop; L_last_block: for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ------------------------------------------------------------------------ Apple CoreOS vector & numerics cclee 8-3-10 */ #if defined __i386__ || defined __x86_64__ #if defined KERNEL #include <i386/cpu_capabilities.h> #else #include <System/i386/cpu_capabilities.h> #endif #if defined (__i386__) .section __IMPORT,__pointers,non_lazy_symbol_pointers L_K256$non_lazy_ptr: .indirect_symbol _K256 .long 0 #endif // associate variables with registers or memory #if defined (__x86_64__) #define sp %rsp #define ctx %rdi #define data %rsi #define num_blocks %rdx #define a %r8d #define b %r9d #define c %r10d #define d %r11d #define e %r12d #define f %r13d #define g %r14d #define h %r15d #define K %rbx #define stack_size (8+16*8+16+64) // 8 (align) + xmm0:xmm7 + L_aligned_bswap + WK(0:15) #define L_aligned_bswap 64(sp) // bswap : big-endian loading of 4-byte words #define xmm_save 80(sp) // starting address for xmm save/restore #else #define sp %esp #define stack_size (12+16*8+16+16+64) // 12 (align) + xmm0:xmm7 + 16 (c,f,h,K) + L_aligned_bswap + WK(0:15) #define ctx_addr 20+stack_size(sp) // ret_addr + 4 registers = 20, 1st caller argument #define data_addr 24+stack_size(sp) // 2nd caller argument #define num_blocks 28+stack_size(sp) // 3rd caller argument #define a %ebx #define b %edx #define c 64(sp) #define d %ebp #define e %esi #define f 68(sp) #define g %edi #define h 72(sp) #define K 76(sp) // pointer to K256[] table #define L_aligned_bswap 80(sp) // bswap : big-endian loading of 4-byte words #define xmm_save 96(sp) // starting address for xmm save/restore #endif // 2 local variables #define t %eax #define s %ecx // a window (16 words) of message scheule #define W0 %xmm0 #define W1 %xmm1 #define W2 %xmm2 #define W3 %xmm3 // circular buffer for WK[(r:r+15)%16] #define WK(x) (x&15)*4(sp) // #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) .macro Ch mov $0, t // x mov $0, s // x not t // ~x and $1, s // x & y and $2, t // ~x & z xor s, t // t = ((x) & (y)) ^ ((~(x)) & (z)); .endm // #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .macro Maj mov $0, t // x mov $1, s // y and s, t // x&y and $2, s // y&z xor s, t // (x&y) ^ (y&z) mov $2, s // z and $0, s // (x&z) xor s, t // t = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .endm /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ // #define R(b,x) ((x) >> (b)) /* 32-bit Rotate-right (used in SHA-256): */ // #define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) // #define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) // performs sigma0_256 on 4 words on an xmm registers // use xmm6/xmm7 as intermediate registers .macro sigma0 movdqa $0, %xmm6 movdqa $0, %xmm7 psrld $$3, $0 // SHR3(x) psrld $$7, %xmm6 // part of ROTR7 pslld $$14, %xmm7 // part of ROTR18 pxor %xmm6, $0 pxor %xmm7, $0 psrld $$11, %xmm6 // part of ROTR18 pslld $$11, %xmm7 // part of ROTR7 pxor %xmm6, $0 pxor %xmm7, $0 .endm // #define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) // performs sigma1_256 on 4 words on an xmm registers // use xmm6/xmm7 as intermediate registers .macro sigma1 movdqa $0, %xmm6 movdqa $0, %xmm7 psrld $$10, $0 // SHR10(x) psrld $$17, %xmm6 // part of ROTR17 pxor %xmm6, $0 pslld $$13, %xmm7 // part of ROTR19 pxor %xmm7, $0 psrld $$2, %xmm6 // part of ROTR19 pxor %xmm6, $0 pslld $$2, %xmm7 // part of ROTR17 pxor %xmm7, $0 .endm // #define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .macro Sigma0 mov $0, t // x mov $0, s // x ror $$2, t // S32(2, (x)) ror $$13, s // S32(13, (x)) xor s, t // S32(2, (x)) ^ S32(13, (x)) ror $$9, s // S32(22, (x)) xor s, t // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .endm // #define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .macro Sigma1 mov $0, s // x ror $$6, s // S32(6, (x)) mov s, t // S32(6, (x)) ror $$5, s // S32(11, (x)) xor s, t // S32(6, (x)) ^ S32(11, (x)) ror $$14, s // S32(25, (x)) xor s, t // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .endm // per round digests update .macro round Sigma1 $4 // t = T1 add t, $7 // use h to store h+Sigma1(e) Ch $4, $5, $6 // t = Ch (e, f, g); add $7, t // t = h+Sigma1(e)+Ch(e,f,g); add WK($8), t // h = T1 add t, $3 // d += T1; mov t, $7 // h = T1 Sigma0 $0 // t = Sigma0(a); add t, $7 // h = T1 + Sigma0(a); Maj $0, $1, $2 // t = Maj(a,b,c) add t, $7 // h = T1 + Sigma0(a) + Maj(a,b,c); .endm // per 4 rounds digests update and permutation // permutation is absorbed by rotating the roles of digests a-h .macro rounds round $0, $1, $2, $3, $4, $5, $6, $7, 0+$8 round $7, $0, $1, $2, $3, $4, $5, $6, 1+$8 round $6, $7, $0, $1, $2, $3, $4, $5, 2+$8 round $5, $6, $7, $0, $1, $2, $3, $4, 3+$8 .endm // update the message schedule W and W+K (4 rounds) 16 rounds ahead in the future .macro message_schedule // 4 32-bit K256 words in xmm5 #if defined (__x86_64__) movdqu (K), %xmm5 add $$16, K // K points to next K256 word for next iteration #else mov K, t movdqu (t), %xmm5 addl $$16, K // K points to next K256 word for next iteration #endif movdqa $1, %xmm4 // W7:W4 palignr $$4, $0, %xmm4 // W4:W1 sigma0 %xmm4 // sigma0(W4:W1) movdqa $3, %xmm6 // W15:W12 paddd %xmm4, $0 // $0 = W3:W0 + sigma0(W4:W1) palignr $$4, $2, %xmm6 // W12:W9 paddd %xmm6, $0 // $0 = W12:W9 + sigma0(W4:W1) + W3:W0 movdqa $3, %xmm4 // W15:W12 psrldq $$8, %xmm4 // 0,0,W15,W14 sigma1 %xmm4 // sigma1(0,0,W15,W14) paddd %xmm4, $0 // sigma1(0,0,W15,W14) + W12:W9 + sigma0(W4:W1) + W3:W0 movdqa $0, %xmm4 // W19-sigma1(W17), W18-sigma1(W16), W17, W16 pslldq $$8, %xmm4 // W17, W16, 0, 0 sigma1 %xmm4 // sigma1(W17,W16,0,0) paddd %xmm4, $0 // W19:W16 paddd $0, %xmm5 // WK movdqa %xmm5, WK($4) .endm // this macro is used in the last 16 rounds of a current block // it reads the next message (16 4-byte words), load it into 4 words W[r:r+3], computes WK[r:r+3] // and save into stack to prepare for next block .macro update_W_WK #if defined (__x86_64__) movdqu $0*16(data), $1 // read 4 4-byte words pshufb L_aligned_bswap, $1 // big-endian of each 4-byte word, W[r:r+3] movdqu $0*16(K), %xmm4 // K[r:r+3] #else mov data_addr, t movdqu $0*16(t), $1 // read 4 4-byte words pshufb L_aligned_bswap, $1 // big-endian of each 4-byte word, W[r:r+3] mov K, t movdqu $0*16(t), %xmm4 // K[r:r+3] #endif paddd $1, %xmm4 // WK[r:r+3] movdqa %xmm4, WK($0*4) // save WK[r:r+3] into stack circular buffer .endm .text #if defined (__x86_64__) || defined (__i386__) .globl _vng_x86_sha256_compress _vng_x86_sha256_compress: // detect SSSE3 and dispatch appropriate code branch #if defined __x86_64__ movq __cpu_capabilities@GOTPCREL(%rip), %rax // %rax -> __cpu_capabilities mov (%rax), %eax // %eax = __cpu_capabilities #else // i386 #if defined KERNEL leal __cpu_capabilities, %eax // %eax -> __cpu_capabilities mov (%eax), %eax // %eax = __cpu_capabilities #else mov _COMM_PAGE_CPU_CAPABILITIES, %eax #endif #endif test $(kHasSupplementalSSE3), %eax je _SHA256_Transform_nossse3 // branch to no-ssse3 code // push callee-saved registers #if defined (__x86_64__) push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 #else push %ebp push %ebx push %esi push %edi #endif // allocate stack space sub $stack_size, sp // if kernel code, save used xmm registers #if KERNEL movdqa %xmm0, 0*16+xmm_save movdqa %xmm1, 1*16+xmm_save movdqa %xmm2, 2*16+xmm_save movdqa %xmm3, 3*16+xmm_save movdqa %xmm4, 4*16+xmm_save movdqa %xmm5, 5*16+xmm_save movdqa %xmm6, 6*16+xmm_save movdqa %xmm7, 7*16+xmm_save #endif // set up bswap parameters in the aligned stack space and pointer to table K256[] #if defined (__x86_64__) lea _K256(%rip), K lea L_bswap(%rip), %rax movdqa (%rax), %xmm0 #else #if defined (KERNEL) lea _K256, t #else call 0f // Push program counter onto stack. 0: pop t // Get program counter. movl L_K256$non_lazy_ptr-0b(t), t #endif mov t, K call 0f // Push program counter onto stack. 0: pop t // Get program counter. lea L_bswap-0b(t), t movdqa (%eax), %xmm0 #endif movdqa %xmm0, L_aligned_bswap // load W[0:15] into xmm0-xmm3 #if defined (__x86_64__) movdqu 0*16(data), W0 movdqu 1*16(data), W1 movdqu 2*16(data), W2 movdqu 3*16(data), W3 add $64, data #else mov data_addr, t movdqu 0*16(t), W0 movdqu 1*16(t), W1 movdqu 2*16(t), W2 movdqu 3*16(t), W3 addl $64, data_addr #endif pshufb L_aligned_bswap, W0 pshufb L_aligned_bswap, W1 pshufb L_aligned_bswap, W2 pshufb L_aligned_bswap, W3 // compute WK[0:15] and save in stack #if defined (__x86_64__) movdqu 0*16(K), %xmm4 movdqu 1*16(K), %xmm5 movdqu 2*16(K), %xmm6 movdqu 3*16(K), %xmm7 add $64, K #else mov K, t movdqu 0*16(t), %xmm4 movdqu 1*16(t), %xmm5 movdqu 2*16(t), %xmm6 movdqu 3*16(t), %xmm7 addl $64, K #endif paddd %xmm0, %xmm4 paddd %xmm1, %xmm5 paddd %xmm2, %xmm6 paddd %xmm3, %xmm7 movdqa %xmm4, WK(0) movdqa %xmm5, WK(4) movdqa %xmm6, WK(8) movdqa %xmm7, WK(12) L_loop: // digests a-h = ctx->states; #if defined (__x86_64__) mov 0*4(ctx), a mov 1*4(ctx), b mov 2*4(ctx), c mov 3*4(ctx), d mov 4*4(ctx), e mov 5*4(ctx), f mov 6*4(ctx), g mov 7*4(ctx), h #else mov ctx_addr, t mov 0*4(t), a mov 1*4(t), b mov 2*4(t), s mov s, c mov 3*4(t), d mov 4*4(t), e mov 5*4(t), s mov s, f mov 6*4(t), g mov 7*4(t), s mov s, h #endif // rounds 0:47 interleaved with W/WK update for rounds 16:63 rounds a, b, c, d, e, f, g, h, 0 message_schedule W0,W1,W2,W3,16 rounds e, f, g, h, a, b, c, d, 4 message_schedule W1,W2,W3,W0,20 rounds a, b, c, d, e, f, g, h, 8 message_schedule W2,W3,W0,W1,24 rounds e, f, g, h, a, b, c, d, 12 message_schedule W3,W0,W1,W2,28 rounds a, b, c, d, e, f, g, h, 16 message_schedule W0,W1,W2,W3,32 rounds e, f, g, h, a, b, c, d, 20 message_schedule W1,W2,W3,W0,36 rounds a, b, c, d, e, f, g, h, 24 message_schedule W2,W3,W0,W1,40 rounds e, f, g, h, a, b, c, d, 28 message_schedule W3,W0,W1,W2,44 rounds a, b, c, d, e, f, g, h, 32 message_schedule W0,W1,W2,W3,48 rounds e, f, g, h, a, b, c, d, 36 message_schedule W1,W2,W3,W0,52 rounds a, b, c, d, e, f, g, h, 40 message_schedule W2,W3,W0,W1,56 rounds e, f, g, h, a, b, c, d, 44 message_schedule W3,W0,W1,W2,60 // revert K to the beginning of K256[] #if defined __x86_64__ sub $256, K sub $1, num_blocks // num_blocks-- #else subl $256, K subl $1, num_blocks // num_blocks-- #endif je L_final_block // if final block, wrap up final rounds // rounds 48:63 interleaved with W/WK initialization for next block rounds 0:15 rounds a, b, c, d, e, f, g, h, 48 update_W_WK 0, W0 rounds e, f, g, h, a, b, c, d, 52 update_W_WK 1, W1 rounds a, b, c, d, e, f, g, h, 56 update_W_WK 2, W2 rounds e, f, g, h, a, b, c, d, 60 update_W_WK 3, W3 #if defined (__x86_64__) add $64, K add $64, data #else addl $64, K addl $64, data_addr #endif // ctx->states += digests a-h #if defined (__x86_64__) add a, 0*4(ctx) add b, 1*4(ctx) add c, 2*4(ctx) add d, 3*4(ctx) add e, 4*4(ctx) add f, 5*4(ctx) add g, 6*4(ctx) add h, 7*4(ctx) #else mov ctx_addr, t add a, 0*4(t) add b, 1*4(t) mov c, s add s, 2*4(t) add d, 3*4(t) add e, 4*4(t) mov f, s add s, 5*4(t) add g, 6*4(t) mov h, s add s, 7*4(t) #endif jmp L_loop // branch for next block // wrap up digest update round 48:63 for final block L_final_block: rounds a, b, c, d, e, f, g, h, 48 rounds e, f, g, h, a, b, c, d, 52 rounds a, b, c, d, e, f, g, h, 56 rounds e, f, g, h, a, b, c, d, 60 // ctx->states += digests a-h #if defined (__x86_64__) add a, 0*4(ctx) add b, 1*4(ctx) add c, 2*4(ctx) add d, 3*4(ctx) add e, 4*4(ctx) add f, 5*4(ctx) add g, 6*4(ctx) add h, 7*4(ctx) #else mov ctx_addr, t add a, 0*4(t) add b, 1*4(t) mov c, s add s, 2*4(t) add d, 3*4(t) add e, 4*4(t) mov f, s add s, 5*4(t) add g, 6*4(t) mov h, s add s, 7*4(t) #endif // if kernel, restore xmm0-xmm7 #if KERNEL movdqa 0*16+xmm_save, %xmm0 movdqa 1*16+xmm_save, %xmm1 movdqa 2*16+xmm_save, %xmm2 movdqa 3*16+xmm_save, %xmm3 movdqa 4*16+xmm_save, %xmm4 movdqa 5*16+xmm_save, %xmm5 movdqa 6*16+xmm_save, %xmm6 movdqa 7*16+xmm_save, %xmm7 #endif // free allocated stack memory add $stack_size, sp // restore callee-saved registers #if defined (__x86_64__) pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp #else pop %edi pop %esi pop %ebx pop %ebp #endif // return ret .const .align 4, 0x90 L_bswap: .long 0x00010203 .long 0x04050607 .long 0x08090a0b .long 0x0c0d0e0f #endif // x86_64/i386 #endif // x86_64/i386 |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/sha256_nossse3.s.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | /* * Copyright (c) 2011 Apple Computer, Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* This file provides x86_64/i386 hand implementation of the following function void SHA256_Transform(SHA256_ctx *ctx, char *data, unsigned int num_blocks); which is a C function in sha2.c (from xnu). The code SHA256_Transform_nossse3 is a clone of SHA256_Transform with all ssse3 instructions replaced with sse3 or below instructions. For performance reason, this function should not be called directly. This file should be working together with the one that implements SHA256_Transform. There, cpu_capabilities is probed to detect ssse3. If ssse3 is not supported, the execution will be branched to this no-ssse3-specific function. sha256 algorithm per block description: 1. W(0:15) = big-endian (per 4 bytes) loading of input data (64 byte) 2. load 8 digests a-h from ctx->state 3. for r = 0:15 T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g 4. for r = 16:63 W[r] = W[r-16] + sigma1(W[r-2]) + W[r-7] + sigma0(W[r-15]); T1 = h + Sigma1(e) + Ch(e,f,g) + K[r] + W[r]; d += T1; h = T1 + Sigma0(a) + Maj(a,b,c) permute a,b,c,d,e,f,g,h into h,a,b,c,d,e,f,g In the assembly implementation: - a circular window of message schedule W(r:r+15) is updated and stored in xmm0-xmm3 - its corresponding W+K(r:r+15) is updated and stored in a stack space circular buffer - the 8 digests (a-h) will be stored in GPR or m32 (all in GPR for x86_64, and some in m32 for i386) the implementation per block looks like ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K(0:15) in stack load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ---------------------------------------------------------------------------- our implementation (allows multiple blocks per call) pipelines the loading of W/WK of a future block into the last 16 rounds of its previous block: ---------------------------------------------------------------------------- load W(0:15) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K(0:15) in stack L_loop: load digests a-h from ctx->state; for (r=0;r<48;r+=4) { digests a-h update and permute round r:r+3 update W([r:r+3]%16) and WK([r:r+3]%16) for the next 4th iteration } num_block--; if (num_block==0) jmp L_last_block; for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 load W([r:r+3]%16) (big-endian per 4 bytes) into xmm0:xmm3 pre_calculate and store W+K([r:r+3]%16) in stack } ctx->states += digests a-h; jmp L_loop; L_last_block: for (r=48;r<64;r+=4) { digests a-h update and permute round r:r+3 } ctx->states += digests a-h; ------------------------------------------------------------------------ Apple CoreOS vector & numerics cclee 8-3-10 */ #if defined (__x86_64__) || defined (__i386__) #if defined KERNEL #include <i386/cpu_capabilities.h> #else #include <System/i386/cpu_capabilities.h> #endif #if defined (__i386__) .section __IMPORT,__pointers,non_lazy_symbol_pointers L_K256$non_lazy_ptr: .indirect_symbol _K256 .long 0 #endif // associate variables with registers or memory #if defined (__x86_64__) #define sp %rsp #define ctx %rdi #define data %rsi #define num_blocks %rdx #define a %r8d #define b %r9d #define c %r10d #define d %r11d #define e %r12d #define f %r13d #define g %r14d #define h %r15d #define K %rbx #define stack_size (8+16*8+16+64) // 8 (align) + xmm0:xmm7 + L_aligned_bswap + WK(0:15) #define xmm_save 80(sp) // starting address for xmm save/restore #else #define sp %esp #define stack_size (12+16*8+16+16+64) // 12 (align) + xmm0:xmm7 + 16 (c,f,h,K) + L_aligned_bswap + WK(0:15) #define ctx_addr 20+stack_size(sp) // ret_addr + 4 registers = 20, 1st caller argument #define data_addr 24+stack_size(sp) // 2nd caller argument #define num_blocks 28+stack_size(sp) // 3rd caller argument #define a %ebx #define b %edx #define c 64(sp) #define d %ebp #define e %esi #define f 68(sp) #define g %edi #define h 72(sp) #define K 76(sp) // pointer to K256[] table #define xmm_save 96(sp) // starting address for xmm save/restore #endif // 2 local variables #define t %eax #define s %ecx // a window (16 words) of message scheule #define W0 %xmm0 #define W1 %xmm1 #define W2 %xmm2 #define W3 %xmm3 // circular buffer for WK[(r:r+15)%16] #define WK(x) (x&15)*4(sp) // #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) .macro Ch mov $0, t // x mov $0, s // x not t // ~x and $1, s // x & y and $2, t // ~x & z xor s, t // t = ((x) & (y)) ^ ((~(x)) & (z)); .endm // #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .macro Maj mov $0, t // x mov $1, s // y and s, t // x&y and $2, s // y&z xor s, t // (x&y) ^ (y&z) mov $2, s // z and $0, s // (x&z) xor s, t // t = (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) .endm /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ // #define R(b,x) ((x) >> (b)) /* 32-bit Rotate-right (used in SHA-256): */ // #define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) // #define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) // performs sigma0_256 on 4 words on an xmm registers // use xmm6/xmm7 as intermediate registers .macro sigma0 movdqa $0, %xmm6 movdqa $0, %xmm7 psrld $$3, $0 // SHR3(x) psrld $$7, %xmm6 // part of ROTR7 pslld $$14, %xmm7 // part of ROTR18 pxor %xmm6, $0 pxor %xmm7, $0 psrld $$11, %xmm6 // part of ROTR18 pslld $$11, %xmm7 // part of ROTR7 pxor %xmm6, $0 pxor %xmm7, $0 .endm // #define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) // performs sigma1_256 on 4 words on an xmm registers // use xmm6/xmm7 as intermediate registers .macro sigma1 movdqa $0, %xmm6 movdqa $0, %xmm7 psrld $$10, $0 // SHR10(x) psrld $$17, %xmm6 // part of ROTR17 pxor %xmm6, $0 pslld $$13, %xmm7 // part of ROTR19 pxor %xmm7, $0 psrld $$2, %xmm6 // part of ROTR19 pxor %xmm6, $0 pslld $$2, %xmm7 // part of ROTR17 pxor %xmm7, $0 .endm // #define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .macro Sigma0 mov $0, t // x mov $0, s // x ror $$2, t // S32(2, (x)) ror $$13, s // S32(13, (x)) xor s, t // S32(2, (x)) ^ S32(13, (x)) ror $$9, s // S32(22, (x)) xor s, t // t = (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) .endm // #define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .macro Sigma1 mov $0, s // x ror $$6, s // S32(6, (x)) mov s, t // S32(6, (x)) ror $$5, s // S32(11, (x)) xor s, t // S32(6, (x)) ^ S32(11, (x)) ror $$14, s // S32(25, (x)) xor s, t // t = (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) .endm // per round digests update .macro round Sigma1 $4 // t = T1 add t, $7 // use h to store h+Sigma1(e) Ch $4, $5, $6 // t = Ch (e, f, g); add $7, t // t = h+Sigma1(e)+Ch(e,f,g); add WK($8), t // h = T1 add t, $3 // d += T1; mov t, $7 // h = T1 Sigma0 $0 // t = Sigma0(a); add t, $7 // h = T1 + Sigma0(a); Maj $0, $1, $2 // t = Maj(a,b,c) add t, $7 // h = T1 + Sigma0(a) + Maj(a,b,c); .endm // per 4 rounds digests update and permutation // permutation is absorbed by rotating the roles of digests a-h .macro rounds round $0, $1, $2, $3, $4, $5, $6, $7, 0+$8 round $7, $0, $1, $2, $3, $4, $5, $6, 1+$8 round $6, $7, $0, $1, $2, $3, $4, $5, 2+$8 round $5, $6, $7, $0, $1, $2, $3, $4, 3+$8 .endm // update the message schedule W and W+K (4 rounds) 16 rounds ahead in the future .macro message_schedule // 4 32-bit K256 words in xmm5 #if defined (__x86_64__) movdqu (K), %xmm5 add $$16, K // K points to next K256 word for next iteration #else mov K, t movdqu (t), %xmm5 addl $$16, K // K points to next K256 word for next iteration #endif movdqa $1, %xmm4 // W7:W4 #if 0 palignr $$4, $0, %xmm4 // W4:W1 #else // no-ssse3 implementation of palignr movdqa $0, %xmm7 pslldq $$12, %xmm4 psrldq $$4, %xmm7 por %xmm7, %xmm4 #endif sigma0 %xmm4 // sigma0(W4:W1) movdqa $3, %xmm6 // W15:W12 paddd %xmm4, $0 // $0 = W3:W0 + sigma0(W4:W1) #if 0 palignr $$4, $2, %xmm6 // W12:W9 #else // no-ssse3 implementation of palignr movdqa $2, %xmm7 pslldq $$12, %xmm6 psrldq $$4, %xmm7 por %xmm7, %xmm6 #endif paddd %xmm6, $0 // $0 = W12:W9 + sigma0(W4:W1) + W3:W0 movdqa $3, %xmm4 // W15:W12 psrldq $$8, %xmm4 // 0,0,W15,W14 sigma1 %xmm4 // sigma1(0,0,W15,W14) paddd %xmm4, $0 // sigma1(0,0,W15,W14) + W12:W9 + sigma0(W4:W1) + W3:W0 movdqa $0, %xmm4 // W19-sigma1(W17), W18-sigma1(W16), W17, W16 pslldq $$8, %xmm4 // W17, W16, 0, 0 sigma1 %xmm4 // sigma1(W17,W16,0,0) paddd %xmm4, $0 // W19:W16 paddd $0, %xmm5 // WK movdqa %xmm5, WK($4) .endm // this macro is used in the last 16 rounds of a current block // it reads the next message (16 4-byte words), load it into 4 words W[r:r+3], computes WK[r:r+3] // and save into stack to prepare for next block .macro update_W_WK #if defined (__x86_64__) #if 0 movdqu $0*16(data), $1 // read 4 4-byte words pshufb L_aligned_bswap, $1 // big-endian of each 4-byte word, W[r:r+3] #else // no-ssse3 implementation mov 0+$0*16(data), s bswap s mov s, 0+WK($0*4) mov 4+$0*16(data), s bswap s mov s, 4+WK($0*4) mov 8+$0*16(data), s bswap s mov s, 8+WK($0*4) mov 12+$0*16(data), s bswap s mov s, 12+WK($0*4) movdqa WK($0*4), $1 #endif movdqu $0*16(K), %xmm4 // K[r:r+3] #else mov data_addr, t #if 0 movdqu $0*16(t), $1 // read 4 4-byte words pshufb L_aligned_bswap, $1 // big-endian of each 4-byte word, W[r:r+3] #else // no-ssse3 implementation mov 0+$0*16(t), s bswap s mov s, 0+WK($0*4) mov 4+$0*16(t), s bswap s mov s, 4+WK($0*4) mov 8+$0*16(t), s bswap s mov s, 8+WK($0*4) mov 12+$0*16(t), s bswap s mov s, 12+WK($0*4) movdqa WK($0*4), $1 #endif mov K, t movdqu $0*16(t), %xmm4 // K[r:r+3] #endif paddd $1, %xmm4 // WK[r:r+3] movdqa %xmm4, WK($0*4) // save WK[r:r+3] into stack circular buffer .endm .text #if defined (__x86_64__) || defined (__i386__) .globl _SHA256_Transform_nossse3 _SHA256_Transform_nossse3: // push callee-saved registers #if defined (__x86_64__) push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 #else push %ebp push %ebx push %esi push %edi #endif // allocate stack space sub $stack_size, sp // if kernel code, save used xmm registers #if KERNEL movdqa %xmm0, 0*16+xmm_save movdqa %xmm1, 1*16+xmm_save movdqa %xmm2, 2*16+xmm_save movdqa %xmm3, 3*16+xmm_save movdqa %xmm4, 4*16+xmm_save movdqa %xmm5, 5*16+xmm_save movdqa %xmm6, 6*16+xmm_save movdqa %xmm7, 7*16+xmm_save #endif // set up pointer to table K256[] #if defined (__x86_64__) lea _K256(%rip), K #else #if defined (KERNEL) lea _K256, t #else call 0f // Push program counter onto stack. 0: pop t // Get program counter. movl L_K256$non_lazy_ptr-0b(t), t #endif mov t, K #endif // load W[0:15] into xmm0-xmm3 .macro mybswap movl 0+$0*16($1), a movl 4+$0*16($1), b movl 8+$0*16($1), e movl 12+$0*16($1), d bswap a bswap b bswap e bswap d movl a, $0*16(sp) movl b, 4+$0*16(sp) movl e, 8+$0*16(sp) movl d, 12+$0*16(sp) .endm #if defined (__x86_64__) mybswap 0, data mybswap 1, data mybswap 2, data mybswap 3, data add $64, data #else mov data_addr, t mybswap 0, t mybswap 1, t mybswap 2, t mybswap 3, t addl $64, data_addr #endif movdqa 0*16(sp), W0 movdqa 1*16(sp), W1 movdqa 2*16(sp), W2 movdqa 3*16(sp), W3 // compute WK[0:15] and save in stack #if defined (__x86_64__) movdqu 0*16(K), %xmm4 movdqu 1*16(K), %xmm5 movdqu 2*16(K), %xmm6 movdqu 3*16(K), %xmm7 add $64, K #else mov K, t movdqu 0*16(t), %xmm4 movdqu 1*16(t), %xmm5 movdqu 2*16(t), %xmm6 movdqu 3*16(t), %xmm7 addl $64, K #endif paddd %xmm0, %xmm4 paddd %xmm1, %xmm5 paddd %xmm2, %xmm6 paddd %xmm3, %xmm7 movdqa %xmm4, WK(0) movdqa %xmm5, WK(4) movdqa %xmm6, WK(8) movdqa %xmm7, WK(12) L_loop: // digests a-h = ctx->states; #if defined (__x86_64__) mov 0*4(ctx), a mov 1*4(ctx), b mov 2*4(ctx), c mov 3*4(ctx), d mov 4*4(ctx), e mov 5*4(ctx), f mov 6*4(ctx), g mov 7*4(ctx), h #else mov ctx_addr, t mov 0*4(t), a mov 1*4(t), b mov 2*4(t), s mov s, c mov 3*4(t), d mov 4*4(t), e mov 5*4(t), s mov s, f mov 6*4(t), g mov 7*4(t), s mov s, h #endif // rounds 0:47 interleaved with W/WK update for rounds 16:63 rounds a, b, c, d, e, f, g, h, 0 message_schedule W0,W1,W2,W3,16 rounds e, f, g, h, a, b, c, d, 4 message_schedule W1,W2,W3,W0,20 rounds a, b, c, d, e, f, g, h, 8 message_schedule W2,W3,W0,W1,24 rounds e, f, g, h, a, b, c, d, 12 message_schedule W3,W0,W1,W2,28 rounds a, b, c, d, e, f, g, h, 16 message_schedule W0,W1,W2,W3,32 rounds e, f, g, h, a, b, c, d, 20 message_schedule W1,W2,W3,W0,36 rounds a, b, c, d, e, f, g, h, 24 message_schedule W2,W3,W0,W1,40 rounds e, f, g, h, a, b, c, d, 28 message_schedule W3,W0,W1,W2,44 rounds a, b, c, d, e, f, g, h, 32 message_schedule W0,W1,W2,W3,48 rounds e, f, g, h, a, b, c, d, 36 message_schedule W1,W2,W3,W0,52 rounds a, b, c, d, e, f, g, h, 40 message_schedule W2,W3,W0,W1,56 rounds e, f, g, h, a, b, c, d, 44 message_schedule W3,W0,W1,W2,60 // revert K to the beginning of K256[] #if defined __x86_64__ sub $256, K sub $1, num_blocks // num_blocks-- #else subl $256, K subl $1, num_blocks // num_blocks-- #endif je L_final_block // if final block, wrap up final rounds // rounds 48:63 interleaved with W/WK initialization for next block rounds 0:15 rounds a, b, c, d, e, f, g, h, 48 update_W_WK 0, W0 rounds e, f, g, h, a, b, c, d, 52 update_W_WK 1, W1 rounds a, b, c, d, e, f, g, h, 56 update_W_WK 2, W2 rounds e, f, g, h, a, b, c, d, 60 update_W_WK 3, W3 #if defined (__x86_64__) add $64, K add $64, data #else addl $64, K addl $64, data_addr #endif // ctx->states += digests a-h #if defined (__x86_64__) add a, 0*4(ctx) add b, 1*4(ctx) add c, 2*4(ctx) add d, 3*4(ctx) add e, 4*4(ctx) add f, 5*4(ctx) add g, 6*4(ctx) add h, 7*4(ctx) #else mov ctx_addr, t add a, 0*4(t) add b, 1*4(t) mov c, s add s, 2*4(t) add d, 3*4(t) add e, 4*4(t) mov f, s add s, 5*4(t) add g, 6*4(t) mov h, s add s, 7*4(t) #endif jmp L_loop // branch for next block // wrap up digest update round 48:63 for final block L_final_block: rounds a, b, c, d, e, f, g, h, 48 rounds e, f, g, h, a, b, c, d, 52 rounds a, b, c, d, e, f, g, h, 56 rounds e, f, g, h, a, b, c, d, 60 // ctx->states += digests a-h #if defined (__x86_64__) add a, 0*4(ctx) add b, 1*4(ctx) add c, 2*4(ctx) add d, 3*4(ctx) add e, 4*4(ctx) add f, 5*4(ctx) add g, 6*4(ctx) add h, 7*4(ctx) #else mov ctx_addr, t add a, 0*4(t) add b, 1*4(t) mov c, s add s, 2*4(t) add d, 3*4(t) add e, 4*4(t) mov f, s add s, 5*4(t) add g, 6*4(t) mov h, s add s, 7*4(t) #endif // if kernel, restore xmm0-xmm7 #if KERNEL movdqa 0*16+xmm_save, %xmm0 movdqa 1*16+xmm_save, %xmm1 movdqa 2*16+xmm_save, %xmm2 movdqa 3*16+xmm_save, %xmm3 movdqa 4*16+xmm_save, %xmm4 movdqa 5*16+xmm_save, %xmm5 movdqa 6*16+xmm_save, %xmm6 movdqa 7*16+xmm_save, %xmm7 #endif // free allocated stack memory add $stack_size, sp // restore callee-saved registers #if defined (__x86_64__) pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp #else pop %edi pop %esi pop %ebx pop %ebp #endif // return ret #endif // x86_64/i386 #endif // x86_64/i386 |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/vng_x86_sha224.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* Adapted from LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /** @param sha224.c vng_x86_SHA-224 new NIST standard based off of vng_x86_SHA-256 truncated to 224 bits (Tom St Denis) */ #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures const ccDescriptor vng_x86_sha224_desc = { .implementation_info = &cc_sha224_impinfo, .dtype.digest.hashsize = CC_SHA224_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA224_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_x86_sha224_init, .dtype.digest.process = &vng_x86_sha256_process, .dtype.digest.done = &vng_x86_sha224_done, }; /* init the sha256 er... sha224 state ;-) */ /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_x86_sha224_init(vng_x86_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); // ctx->curlen = 0; ctx->length = 0; ctx->state[0] = 0xc1059ed8UL; ctx->state[1] = 0x367cd507UL; ctx->state[2] = 0x3070dd17UL; ctx->state[3] = 0xf70e5939UL; ctx->state[4] = 0xffc00b31UL; ctx->state[5] = 0x68581511UL; ctx->state[6] = 0x64f98fa7UL; ctx->state[7] = 0xbefa4fa4UL; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (28 bytes) @return CRYPT_OK if successful */ int vng_x86_sha224_done(vng_x86_sha256_ctx *ctx, unsigned char *out) { unsigned char buf[32]; int err; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); err = vng_x86_sha256_done(ctx, buf); CC_XMEMCPY(out, buf, 28); return err; } #endif |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/vng_x86_sha224.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_x86_sha224.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #ifndef _VNG_X86_SHA224_H_ #define _VNG_X86_SHA224_H_ /* * Note that vng_x86_sha256 is required for vng_x86_sha224. */ #define VNG_X86_SHA224_HASHSIZE 28 #define VNG_X86_SHA224_BLOCKSIZE 64 int vng_x86_sha224_init(vng_x86_sha256_ctx *ctx); #define vng_x86_sha224_process vng_x86_sha256_process int vng_x86_sha224_done(vng_x86_sha256_ctx *ctx, unsigned char *hash); #endif /* _VNG_X86_SHA224_H_ */ #endif /* x86 */ |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/vng_x86_sha256.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #include <stdio.h> #include "vng_x86_sha256.h" #include "vng_x86_sha224.h" #include "ltc_hashcommon.h" #include "tomcrypt_cfg.h" #include "tomcrypt_macros.h" #include "tomcrypt_argchk.h" #include "ccDescriptors.h" #include "ccErrors.h" #include "ccMemory.h" #include "CommonDigest.h" /** @file vng_x86_sha256.c vng_x86_SHA256 by Tom St Denis */ const ccDescriptor vng_x86_sha256_desc = { .implementation_info = &cc_sha256_impinfo, .dtype.digest.hashsize = CC_SHA256_DIGEST_LENGTH, .dtype.digest.blocksize = CC_SHA256_BLOCK_BYTES, .dtype.digest.digest_info = NULL, .dtype.digest.init = &vng_x86_sha256_init, .dtype.digest.process = &vng_x86_sha256_process, .dtype.digest.done = &vng_x86_sha256_done, }; extern const uint32_t K256[64] = { 0x428a2f98ul, 0x71374491ul, 0xb5c0fbcful, 0xe9b5dba5ul, 0x3956c25bul, 0x59f111f1ul, 0x923f82a4ul, 0xab1c5ed5ul, 0xd807aa98ul, 0x12835b01ul, 0x243185beul, 0x550c7dc3ul, 0x72be5d74ul, 0x80deb1feul, 0x9bdc06a7ul, 0xc19bf174ul, 0xe49b69c1ul, 0xefbe4786ul, 0x0fc19dc6ul, 0x240ca1ccul, 0x2de92c6ful, 0x4a7484aaul, 0x5cb0a9dcul, 0x76f988daul, 0x983e5152ul, 0xa831c66dul, 0xb00327c8ul, 0xbf597fc7ul, 0xc6e00bf3ul, 0xd5a79147ul, 0x06ca6351ul, 0x14292967ul, 0x27b70a85ul, 0x2e1b2138ul, 0x4d2c6dfcul, 0x53380d13ul, 0x650a7354ul, 0x766a0abbul, 0x81c2c92eul, 0x92722c85ul, 0xa2bfe8a1ul, 0xa81a664bul, 0xc24b8b70ul, 0xc76c51a3ul, 0xd192e819ul, 0xd6990624ul, 0xf40e3585ul, 0x106aa070ul, 0x19a4c116ul, 0x1e376c08ul, 0x2748774cul, 0x34b0bcb5ul, 0x391c0cb3ul, 0x4ed8aa4aul, 0x5b9cca4ful, 0x682e6ff3ul, 0x748f82eeul, 0x78a5636ful, 0x84c87814ul, 0x8cc70208ul, 0x90befffaul, 0xa4506cebul, 0xbef9a3f7ul, 0xc67178f2ul, }; /* Various logical functions */ #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) LTC_RORc((x),(n)) #define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) #define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) #define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) #define FULLLENGTH_MASK 0xffffffffffffffc0 #define BUFFLENGTH_MASK 0x3f /** Initialize the hash state @param md The hash state you wish to initialize @return CRYPT_OK if successful */ int vng_x86_sha256_init(vng_x86_sha256_ctx *ctx) { LTC_ARGCHK(ctx != NULL); ctx->length = 0; ctx->state[0] = 0x6A09E667UL; ctx->state[1] = 0xBB67AE85UL; ctx->state[2] = 0x3C6EF372UL; ctx->state[3] = 0xA54FF53AUL; ctx->state[4] = 0x510E527FUL; ctx->state[5] = 0x9B05688CUL; ctx->state[6] = 0x1F83D9ABUL; ctx->state[7] = 0x5BE0CD19UL; return CRYPT_OK; } /** Process a block of memory though the hash @param md The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int vng_x86_sha256_process(vng_x86_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen) { unsigned long n; int err; int fullblocks, remainder, processed; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(in != NULL); curlen = ctx->length & BUFFLENGTH_MASK; if ((ctx->length + inlen) < ctx->length) { return CRYPT_HASH_OVERFLOW; } while (inlen > 0) { if (curlen == 0 && inlen >= VNG_X86_SHA256_BLOCKSIZE && CC_XALIGNED(in, 4)) { fullblocks = inlen / VNG_X86_SHA256_BLOCKSIZE; remainder = inlen % VNG_X86_SHA256_BLOCKSIZE; processed = fullblocks * VNG_X86_SHA256_BLOCKSIZE; vng_x86_sha256_compress (ctx->state, in, fullblocks); ctx->length += VNG_X86_SHA256_BLOCKSIZE * 8 * fullblocks; in += processed; inlen -= processed; } else { n = MIN(inlen, (VNG_X86_SHA256_BLOCKSIZE - curlen)); memcpy(ctx->buf + curlen, in, (size_t)n); curlen += n; in += n; inlen -= n; if (curlen == VNG_X86_SHA256_BLOCKSIZE) { vng_x86_sha256_compress (ctx->state, ctx->buf, 1); ctx->length += 8*VNG_X86_SHA256_BLOCKSIZE; curlen = 0; } } } ctx->length = (ctx->length & FULLLENGTH_MASK) + curlen; return CRYPT_OK; } /** Terminate the hash to get the digest @param md The hash state @param out [out] The destination of the hash (32 bytes) @return CRYPT_OK if successful */ int vng_x86_sha256_done(vng_x86_sha256_ctx *ctx, unsigned char *out) { int i; uint64_t curlen; LTC_ARGCHK(ctx != NULL); LTC_ARGCHK(out != NULL); curlen = ctx->length & BUFFLENGTH_MASK; ctx->length &= FULLLENGTH_MASK; /* increase the length of the message */ ctx->length += curlen * 8; /* append the '1' bit */ ctx->buf[curlen++] = (unsigned char)0x80; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (curlen > 56) { while (curlen < 64) { ctx->buf[curlen++] = (unsigned char)0; } vng_x86_sha256_compress (ctx->state, ctx->buf, 1); curlen = 0; } /* pad upto 56 bytes of zeroes */ while (curlen < 56) { ctx->buf[curlen++] = (unsigned char)0; } /* store length */ LTC_STORE64H(ctx->length, ctx->buf+56); vng_x86_sha256_compress (ctx->state, ctx->buf, 1); /* copy output */ for (i = 0; i < 8; i++) { LTC_STORE32H(ctx->state[i], out+(4*i)); } #ifdef LTC_CLEAN_STACK ltc_zeromem(ctx, sizeof(hash_state)); #endif return CRYPT_OK; } #include "vng_x86_sha224.c" #endif /* x86 */ |
Added Source/descriptors/digestDescriptors/vng_x86_sha2_descriptor/vng_x86_sha256.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * Copyright (c) 2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * vng_x86_sha256.h * MacTomCrypt * * InfoSec Standard Configuration * Copyright 2010 Apple Inc. All rights reserved. * */ #if defined (__x86_64__) || defined(__i386__) // x86_64 or i386 architectures #include <stdint.h> #ifndef _VNG_X86_SHA256_H_ #define _VNG_X86_SHA256_H_ #define VNG_X86_SHA256_HASHSIZE 32 #define VNG_X86_SHA256_BLOCKSIZE 64 typedef struct vng_x86_sha256_state { uint64_t length; uint32_t state[8]; unsigned char buf[VNG_X86_SHA256_BLOCKSIZE]; } vng_x86_sha256_ctx; int vng_x86_sha256_init(vng_x86_sha256_ctx *ctx); int vng_x86_sha256_process(vng_x86_sha256_ctx *ctx, const unsigned char *in, unsigned long inlen); int vng_x86_sha256_done(vng_x86_sha256_ctx *ctx, unsigned char *hash); void vng_x86_sha256_compress(void *c, const void *p, unsigned long num); #endif /* _VNG_X86_SHA256_H_ */ #endif /* x86 */ |
Added Source/libDER/README.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | libDER Library Notes Last update to this file Jan. 26 2006 by dmitch This module is a very lightweight implementation of a DER encoder and decoder. Unlike most other DER packages, this one does no malloc or copies when it encodes or decodes; decoding an item yields a pointer and a byte count which refer to memory inside of the "thing" being decoded. Likewise, when encoding, the caller mustsupply a target buffer to which the encoded item is written. Support for encoding sequences and for decoding sequences and sets of known items is also included; when you decode a sequence, you get a sequence of pointers and byte counts - again, no mallocs or copies occur. The directory libDER contains the DER decoding library proper. The main API is in DER_Decode.h. Support for RSA keys, X509 certs, X509 CRLs, and miscellaneous OIDs can also be found in libDER. Command line programs to parse and display the contents of X509 certificates and CRLs, using libDER, can be found in the Tests directory. Revision History ---------------- Date svk tag Changes -------- ----------- ---------------------------------------- 01/26/06 libDER-5 Avoid varargs macros for portability. 01/03/06 libDER-4 Initial distribution in RSACertLib. 12/23/05 libDER-3 Fix DER_DECODE_ENABLE ifdef for DER_Decode.c. Add MD2, MD5 OID and DigestInfo capabilities. 12/13/05 libDER-2 Added Apple Custom RSA public key formats. Added PKCS1 RSA private keys. 11/28/05 libDER-1 Initial tag. |
Added Source/libDER/Tests/AppleMobilePersonalizedTicket.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* * AppleMobilePersonalizedTicket.h * ticketlib * * Created by Jason Gosnell on 9/24/09. * Copyright 2009 Apple, Inc. All rights reserved. * */ #ifndef APPLEMOBILEPERSONALIZEDTICKET_H #define APPLEMOBILEPERSONALIZEDTICKET_H const unsigned kApECIDTag = 1; const unsigned kApChipIDTag = 2; const unsigned kApBoardIDTag = 3; const unsigned kApProductionModeTag = 4; const unsigned kApSecurityDomainTag = 5; const unsigned kLLBBuildStringTag = 6; const unsigned kiBootDigestTag = 7; const unsigned kAppleLogoDigestTag = 8; const unsigned kDeviceTreeDigestTag = 9; const unsigned kKernelCacheDigestTag = 10; const unsigned kDiagsDigestTag = 11; const unsigned kBatteryChargingDigestTag = 12; const unsigned kBatteryPluginDigestTag = 13; const unsigned kBatteryLow0DigestTag = 14; const unsigned kBatteryLow1DigestTag = 15; const unsigned kRecoveryModeDigestTag = 16; const unsigned kNeedServiceDigestTag = 17; const unsigned kApNonceTag = 18; const unsigned kApPriorTicketIDTag = 19; const unsigned kiBSSBuildStringTag = 20; const unsigned kHostiBootTag = 21; const unsigned kiBECBuildStringTag = 22; const unsigned kRestoreLogoDigestTag = 23; const unsigned kRestoreDeviceTreeDigestTag = 24; const unsigned kRestoreKernelCacheDigestTag = 25; const unsigned kRestoreRamDiskDigestTag = 26; const unsigned kOSDigestTag = 27; const unsigned kApBindingDigestTag = 28; const unsigned kApServerNonceTag = 29; const unsigned kLLBPartialDigestTag = 30; const unsigned kiBootPartialDigestTag = 31; const unsigned kAppleLogoPartialDigestTag = 32; const unsigned kDeviceTreePartialDigestTag = 33; const unsigned kKernelCachePartialDigestTag = 34; const unsigned kDiagsPartialDigestTag = 35; const unsigned kBatteryChargingPartialDigestTag = 36; const unsigned kBatteryPluginPartialDigestTag = 37; const unsigned kBatteryLow0PartialDigestTag = 38; const unsigned kBatteryLow1PartialDigestTag = 39; const unsigned kRecoveryModePartialDigestTag = 40; const unsigned kNeedServicePartialDigestTag = 41; const unsigned kiBSSPartialDigestTag = 42; const unsigned kiBECPartialDigestTag = 43; const unsigned kRestoreLogoPartialDigestTag = 44; const unsigned kRestoreDeviceTreePartialDigestTag = 45; const unsigned kRestoreKernelCachePartialDigestTag = 46; const unsigned kRestoreRamDiskPartialDigestTag = 47; const unsigned kiBootTrustedTag = 48; const unsigned kAppleLogoTrustedTag = 49; const unsigned kDeviceTreeTrustedTag = 50; const unsigned kKernelCacheTrustedTag = 51; const unsigned kDiagsTrustedTag = 52; const unsigned kBatteryChargingTrustedTag = 53; const unsigned kBatteryPluginTrustedTag = 54; const unsigned kBatteryLow0TrustedTag = 55; const unsigned kBatteryLow1TrustedTag = 56; const unsigned kRecoveryModeTrustedTag = 57; const unsigned kNeedServiceTrustedTag = 58; const unsigned kRestoreLogoTrustedTag = 59; const unsigned kRestoreDeviceTreeTrustedTag = 60; const unsigned kRestoreKernelCacheTrustedTag = 61; const unsigned kRestoreRamDiskTrustedTag = 62; const unsigned kBbSNUMTag = 63; const unsigned kBbChipIDTag = 64; const unsigned kBbProductionModeTag = 65; const unsigned kFlashPSIBuildStringTag = 66; const unsigned kModemStackDigestTag = 67; const unsigned kBbNonceTag = 68; const unsigned kBbPriorTicketIdTag = 69; const unsigned kRamPSIBuildStringTag = 70; const unsigned kHostFlashPSITag = 71; const unsigned kEBLDigestTag = 72; const unsigned kStaticEEPDigestTag = 73; const unsigned kBbApBindingDigestTag = 74; const unsigned kBbServerNonceTag = 75; const unsigned kRamPSIPartialDigestTag = 76; const unsigned kFlashPSIPartialDigestTag = 77; const unsigned kBatteryCharging0DigestTag = 78; const unsigned kBatteryCharging1DigestTag = 79; const unsigned kBatteryFullDigestTag = 80; const unsigned kBatteryCharging0PartialDigestTag = 81; const unsigned kBatteryCharging1PartialDigestTag = 82; const unsigned kBatteryFullPartialDigestTag = 83; const unsigned kBatteryCharging0TrustedTag = 84; const unsigned kBatteryCharging1TrustedTag = 85; const unsigned kBatteryFullTrustedTag = 86; const unsigned kUniqueBuildIDTag = 87; const unsigned kBbGoldCertIdTag = 88; const unsigned kBbSkeyIdTag = 89; const unsigned kBasebandFirmwareFlashPSIVersionTag = 90; const unsigned kBasebandFirmwareModemStackDigestTag = 91; const unsigned kBasebandFirmwareRamPSIVersionTag = 92; const unsigned kBasebandFirmwareEBLDigestTag = 93; const unsigned kBasebandFirmwareFlashPSISecPackDigestTag = 94; const unsigned kBasebandFirmwareModemStackSecPackDigestTag= 95; const unsigned kBasebandFirmwareFlashPSIDigestTag = 96; const unsigned kBasebandFirmwareRamPSIPartialDigestTag = 97; const unsigned kBasebandFirmwareFlashPSIPartialDigestTag = 98; const unsigned kBbJtagEnableTag = 99; #endif /* APPLEMOBILEPERSONALIZEDTICKET_H */ |
Added Source/libDER/Tests/DER_Ticket.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /* * DER_Ticket.c * libDER * * Created by Michael Brouwer on 10/13/09. * Copyright 2009 Apple Inc. All rights reserved. * */ #include "DER_Ticket.h" #include <libDER/asn1Types.h> #include <libDER/DER_Decode.h> #include <libDER/DER_Encode.h> #include <libDER/DER_Keys.h> /* Application Processor Ticket */ const DERItemSpec DERApTicketItemSpecs[] = { { DER_OFFSET(DERApTicket, signatureAlgorithm), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS | DER_ENC_WRITE_DER }, { DER_OFFSET(DERApTicket, body), ASN1_CONSTR_SET, DER_DEC_NO_OPTS | DER_DEC_SAVE_DER | DER_ENC_WRITE_DER }, { DER_OFFSET(DERApTicket, signature), ASN1_OCTET_STRING, DER_DEC_NO_OPTS }, { DER_OFFSET(DERApTicket, certificates), ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 1, DER_DEC_NO_OPTS | DER_ENC_WRITE_DER } }; const DERSize DERNumApTicketItemSpecs = sizeof(DERApTicketItemSpecs) / sizeof(DERItemSpec); /* Baseband Ticket */ const DERItemSpec DERBbTicketItemSpecs[] = { { DER_OFFSET(DERBbTicket, signatureAlgorithm), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS | DER_ENC_WRITE_DER }, { DER_OFFSET(DERBbTicket, body), ASN1_CONSTR_SET, DER_DEC_NO_OPTS | DER_DEC_SAVE_DER | DER_ENC_WRITE_DER }, { DER_OFFSET(DERBbTicket, signature), ASN1_OCTET_STRING, DER_DEC_NO_OPTS }, { DER_OFFSET(DERBbTicket, gpuk), ASN1_CONTEXT_SPECIFIC | 2, DER_DEC_NO_OPTS } }; const DERSize DERNumBbTicketItemSpecs = sizeof(DERBbTicketItemSpecs) / sizeof(DERItemSpec); #if 0 /* We need to verify this value and use it here. */ const DERByte rsaWithSha1Algorithm[] = { 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05 }; #endif #ifdef FAST_SET_LOOKUP /* Iterates over all the tags in the set to build an index returned in derSet. */ DERReturn DERDecodeSetContentInit( const DERItem *content, /* data to decode */ DERSet *derSet) /* IN/OUT, to use in DERDecodeSetTag */ { DERReturn drtn; DERSequence derSeq; memset(derSet->byTag, 0, derSet->capacity); drtn = DERDecodeSeqContentInit(content, &derSeq); if (drtn == DR_Success) { DERDecodedInfo element; while ((drtn = DERDecodeSeqNext(&derSeq, &element)) == DR_Success) { if (element.tag >= derSet->capacity) return DR_UnexpectedTag; derSet->byTag[element.tag] = element.content.data; } if (drtn == DR_EndOfSequence) drtn = DR_Success; } derSet->end = content->data + content->length; return drtn; } DERReturn DERDecodeSetTag( DERSet *derSet, /* data to decode */ DERTag tag, /* tag in sequence/set we are looking for. */ DERItem *content) /* RETURNED */ { DERReturn drtn; DERTag tagNumber = tag & ASN1_TAGNUM_MASK; if (tagNumber > derSet->capacity) return DR_UnexpectedTag; DERByte *start = derSet->byTag[tagNumber]; if (!start) return DR_UnexpectedTag; DERItem derItem = { .data = start, .length = derSet->end - start }; DERDecodedInfo element; drtn = DERDecodeItem(&derItem, &element); if (drtn) return drtn; if (tag != element.tag) return DR_UnexpectedTag; *content = element.content; return drtn; } #endif /* FAST_SET_LOOKUP */ /* Returns the item with tag from the sequence or set pointed to by der. result DR_EndOfSequence if the tag was not found. */ DERReturn DERSetDecodeItemWithTag( const DERItem *der, /* data to decode */ DERTag tag, /* tag in sequence/set we are looking for. */ DERItem *content) /* RETURNED */ { DERReturn drtn; DERSequence derSeq; DERTag topTag; drtn = DERDecodeSeqInit(der, &topTag, &derSeq); if (drtn == DR_Success) { DERDecodedInfo info; while ((drtn = DERDecodeSeqNext(&derSeq, &info)) == DR_Success) { if (info.tag == tag) { *content = info.content; return DR_Success; } } } return drtn; } DERReturn DERDecodeApTicket( const DERItem *contents, DERApTicket *ticket, /* RETURNED */ DERSize *numUsedBytes) /* RETURNED */ { DERReturn drtn; DERDecodedInfo decodedTicket; drtn = DERDecodeItem(contents, &decodedTicket); if (drtn != DR_Success) goto badTicket; drtn = DERParseSequenceContent(&decodedTicket.content, DERNumApTicketItemSpecs, DERApTicketItemSpecs, ticket, 0); if (drtn != DR_Success) goto badTicket; /* Decode the algorithm sequence. */ DERAlgorithmId algorithm = {}; drtn = DERParseSequenceContent(&ticket->signatureAlgorithm, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs, &algorithm, 0); if (drtn != DR_Success) goto badTicket; /* TODO Check algorithm oid and ensure there are no params. Alternatively replace the code above with a simple memcmp with an already ASN.1 encoded algorithm parms block. */ badTicket: *numUsedBytes = decodedTicket.content.length + decodedTicket.content.data - contents->data; return drtn; } DERReturn DERDecodeBbTicket( const DERItem *contents, DERBbTicket *ticket, /* RETURNED */ DERSize *numUsedBytes) /* RETURNED */ { DERReturn drtn; DERDecodedInfo decodedTicket; drtn = DERDecodeItem(contents, &decodedTicket); if (drtn != DR_Success) goto badTicket; drtn = DERParseSequenceContent(&decodedTicket.content, DERNumBbTicketItemSpecs, DERBbTicketItemSpecs, ticket, 0); if (drtn != DR_Success) goto badTicket; /* Decode the algorithm sequence. */ DERAlgorithmId algorithm = {}; drtn = DERParseSequenceContent(&ticket->signatureAlgorithm, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs, &algorithm, 0); if (drtn != DR_Success) goto badTicket; /* TODO Check algorithm oid and ensure there are no params. Alternatively replace the code above with a simple memcmp with an already ASN.1 encoded algorithm parms block. */ badTicket: *numUsedBytes = decodedTicket.content.length + decodedTicket.content.data - contents->data; return drtn; } |
Added Source/libDER/Tests/DER_Ticket.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* * DER_Ticket.h * libDER * * Created by Michael Brouwer on 10/13/09. * Copyright 2009 Apple Inc. All rights reserved. * */ #include <libDER/libDER.h> #define FAST_SET_LOOKUP 1 #ifdef FAST_SET_LOOKUP /* state representing a fast by tag set accessor, the caller needs to provide a set large enough to hold all */ typedef struct { DERTag capacity; /* should be large enough to hold all encountered tags. otherwise DR_UnexpectedTag will be returned, note that only one tag per tag number can exist. */ DERByte *end; DERByte *byTag[]; /* maxTag element array of pointers to tag + length of items in set indexed by tagNumber. */ } DERSet; /* Iterates over all the tags in the set to build an index returned in derSet. */ DERReturn DERDecodeSetContentInit( const DERItem *der, /* data to decode */ DERSet *derSet); /* IN/OUT, to use in DERDecodeSetTag */ /* Returns DR_UnexpectedTag if the requested tag is not in derSet, returns the content of the decoded item in content otherwise. */ DERReturn DERDecodeSetTag( DERSet *derSeq, /* data to decode */ DERTag tag, /* tag in sequence/set we are looking for. */ DERItem *content); /* RETURNED */ #endif /* FAST_SET_LOOKUP */ DERReturn DERSetDecodeItemWithTag( const DERItem *der, /* data to decode */ DERTag tag, /* tag in sequence/set we are looking for. */ DERItem *content); /* RETURNED */ /* Application Processor Ticket */ typedef struct { DERItem signatureAlgorithm; /* AlgorithmId */ DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */ DERItem signature; /* OCTET STRING */ DERItem certificates; /* SEQUENCE of CERTIFICATE */ } DERApTicket; /* DERItemSpecs to decode into a DERApTicket */ extern const DERItemSpec DERApTicketItemSpecs[]; extern const DERSize DERNumApTicketItemSpecs; DERReturn DERDecodeApTicket( const DERItem *contents, DERApTicket *ticket, /* RETURNED */ DERSize *numUsedBytes); /* RETURNED */ /* Baseband Ticket */ typedef struct { DERItem signatureAlgorithm; /* AlgorithmId */ DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */ DERItem signature; /* OCTET STRING */ DERItem gpuk; /* OCTET STRING */ } DERBbTicket; /* DERItemSpecs to decode into a DERBbTicket */ extern const DERItemSpec DERBbTicketItemSpecs[]; extern const DERSize DERNumBbTicketItemSpecs; DERReturn DERDecodeBbTicket( const DERItem *contents, DERBbTicket *ticket, /* RETURNED */ DERSize *numUsedBytes); /* RETURNED */ |
Added Source/libDER/Tests/G1_GPrK.pem.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | -----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQCv34jZMZdANoIYptLYgU121ucX5UAKaKQUlihPwS6W2R5phNog w5PH0cBv+znVYhqmZLW8ctV0nQqk8Zo33I0qeJeBE2zptK6Yv79mhmbY14VhKeMc Smjb2+o3kVYlLMKoB3Xl76yjB0InYOnddK8JoLXkK7PYbTiBfejxT8ZuMQIBAwKB gHU/sJDLuirPAWXEjJBWM6SPRLqY1VxFwrhkGt/WHw87aZut5sCCYoU2gEqne+OW vG7tzn2h46MTXG32Zs/oXhs1dKaKdHJyKZcrC+SMKjpL+tSVflujUDkF3qFnCneX x1n16nWMOuwAoVlrXuqG3TLUiYBBbJAZy2rJuDYid/WjAkEA1tzwbnj4coGtW++2 ExAbIt6szd96y2MOGWbm3a+rm0D2FHrUfq8yamGsrRRtF9HM+kbTgSM3ulGExA6w 0L0p4wJBANGLltVFRZbuiKM92aEXZkKudXvGGAoNeDm1XpkWxi3WqwIbYR6lDpvu dJLHEJKRcGeg0EhtyIw13ItF70tVU9sCQQCPPfWe+1BMVnOSn863YBIXPx3elPyH l167me8+dR0SK064UeL/H3bxlnMeDZ4P4TNRhI0AwiUm4QMtXyCLKMaXAkEAi7Jk ji4uZJ8Fwik7wLpELHROUoQQBrOle84/ELnZc+RyAWeWFG4JvUmjDIS1twugRRXg MEkwXXk9si6fh4435wJAOYJia32scDKS4C20zVc12mQutnaK6g9Bdt2vzH3u82Ef nchdtuR4ipWl3v8xX6jX3XdD31xa2Dh840iP1wjPrg== -----END RSA PRIVATE KEY----- |
Added Source/libDER/Tests/S5L8920_TATSU_FAC_DARWIN_DEV_CHAIN.der.
cannot compute difference between binary files
Added Source/libDER/Tests/bb_ticket.bin.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/EndCertificateCP.01.01.crt.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/Test_CRL_CA1.crl.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/Test_CRL_CA1.crl.pem.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | -----BEGIN X509 CRL----- MIIB3zCByDANBgkqhkiG9w0BAQQFADBvMQswCQYDVQQGEwJkZTEgMB4GA1UEChMX SW5zZWN1cmVUZXN0Q2VydGlmaWNhdGUxFzAVBgNVBAMTDkZvciBUZXN0cyBPbmx5 MSUwIwYJKoZIhvcNAQkBFhZpbnNlY3VyZUB0ZXN0Lmluc2VjdXJlFw0wMTA4MTcx MTEyMDNaFw0wNjA4MTYxMTEyMDNaMCgwEgIBAxcNMDEwODE3MTExMDM5WjASAgEF Fw0wMTA4MTcxMTExNTlaMA0GCSqGSIb3DQEBBAUAA4IBAQB47lMVCKlPoBAgLway 76eNRq1749jt/7g/Ouh06isNM66/CgzVL2xKSC3s2FX4xKg320niWI6Dvm4H3M6I 7RvuoCvZBVpu1MA8z2No89g2UPWlSxUAvuvo2GOGRgo+8nc/84g8biLUxTSF8Vs4 T1Hngo1qrfePM4ou1uu7LhRnR8tuIVoQT6W3RSlEsQRBRM3y+VkOPAf0GBGyl6WG WiymXHqsqis80WbX50tr859Cltqbu2yaFAX++IEBBDB7JoVi1blumgarqfXYkoUW n9d3F8qySNjsfhOV613fXpmfXFZ33uTFsLSoihP8f6+Cusx2rfuGap7jOPv7j7sj l2Y1 -----END X509 CRL----- |
Added Source/libDER/Tests/certsCrls/TrustAnchorCP.01.01.crt.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/TrustAnchorCRLCP.01.01.crl.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/apple_v3.000.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/apple_v3.001.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/entrust_v3.100.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/entrust_v3.101.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/keybank_v3.100.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/keybank_v3.101.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/certsCrls/keybank_v3.102.cer.
cannot compute difference between binary files
Added Source/libDER/Tests/parseCert.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* * Copyright (c) 2005-2007,2010 Apple Inc. All Rights Reserved. * * parseCert.c - parse a DER-encoded X509 certificate using libDER. */ #include <stdlib.h> #include <strings.h> #include <stdio.h> #include <unistd.h> #include <libDER/libDER.h> #include <libDER/asn1Types.h> #include <libDER/DER_CertCrl.h> #include <libDER/DER_Keys.h> #include <libDERUtils/fileIo.h> #include <libDERUtils/libDERUtils.h> #include <libDERUtils/printFields.h> static void usage(char **argv) { printf("usage: %s certFile [options]\n", argv[0]); printf("Options:\n"); printf(" -v -- verbose \n"); /* etc. */ exit(1); } static void printValidity( DERItem *validity, int verbose) { DERReturn drtn; DERValidity derv; drtn = DERParseSequenceContent(validity, DERNumValidityItemSpecs, DERValidityItemSpecs, &derv, sizeof(derv)); if(drtn) { DERPerror("DERParseSequenceContent(validity)", drtn); return; } decodePrintItem("notBefore", IT_Leaf, verbose, &derv.notBefore); decodePrintItem("notAfter", IT_Leaf, verbose, &derv.notAfter); } int main(int argc, char **argv) { unsigned char *certData = NULL; unsigned certDataLen = 0; DERSignedCertCrl signedCert; DERTBSCert tbs; DERReturn drtn; DERItem item; int verbose = 0; extern char *optarg; int arg; extern int optind; if(argc < 2) { usage(argv); } if(readFile(argv[1], &certData, &certDataLen)) { printf("***Error reading cert from %s. Aborting.\n", argv[1]); exit(1); } optind = 2; while ((arg = getopt(argc, argv, "vh")) != -1) { switch (arg) { case 'v': verbose = 1; break; case 'h': usage(argv); } } if(optind != argc) { usage(argv); } /* Top level decode of signed cert into 3 components */ item.data = certData; item.length = certDataLen; drtn = DERParseSequence(&item, DERNumSignedCertCrlItemSpecs, DERSignedCertCrlItemSpecs, &signedCert, sizeof(signedCert)); if(drtn) { DERPerror("DERParseSequence(SignedCert)", drtn); exit(1); } printItem("TBSCert", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCert.tbs); incrIndent(); /* decode the TBSCert - it was saved in full DER form */ drtn = DERParseSequence(&signedCert.tbs, DERNumTBSCertItemSpecs, DERTBSCertItemSpecs, &tbs, sizeof(tbs)); if(drtn) { DERPerror("DERParseSequenceContent(TBSCert)", drtn); exit(1); } if(tbs.version.data) { /* unwrap the explicitly tagged integer.... */ decodePrintItem("version", IT_Leaf, verbose, &tbs.version); } printItem("serialNum", IT_Leaf, verbose, ASN1_INTEGER, &tbs.serialNum); printItem("tbsSigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.tbsSigAlg); incrIndent(); printAlgId(&tbs.tbsSigAlg, verbose); decrIndent(); printItem("issuer", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.issuer); printItem("subject", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.subject); printItem("validity", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.validity); incrIndent(); printValidity(&tbs.validity, verbose); decrIndent(); printItem("subjectPubKey", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.subjectPubKey); incrIndent(); printSubjPubKeyInfo(&tbs.subjectPubKey, verbose); decrIndent(); if(tbs.issuerID.data) { /* found tag is implicit context specific: tell printItem what it really is */ printItem("issuerID", IT_Leaf, verbose, ASN1_BIT_STRING, &tbs.issuerID); } if(tbs.subjectID.data) { printItem("subjectID", IT_Leaf, verbose, ASN1_BIT_STRING, &tbs.subjectID); } if(tbs.extensions.data) { printItem("extensions", IT_Leaf, verbose, ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 3, &tbs.extensions); } decrIndent(); printItem("sigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCert.sigAlg); incrIndent(); printAlgId(&signedCert.sigAlg, verbose); decrIndent(); printItem("sig", IT_Leaf, verbose, ASN1_BIT_STRING, &signedCert.sig); return 0; } |
Added Source/libDER/Tests/parseCrl.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /* * Copyright (c) 2005-2007,2010 Apple Inc. All Rights Reserved. * * parseCrl.c - parse a DER-encoded X509 CRL using libDER. */ #include <stdlib.h> #include <strings.h> #include <stdio.h> #include <unistd.h> #include <libDER/libDER.h> #include <libDER/asn1Types.h> #include <libDER/DER_CertCrl.h> #include <libDER/DER_Keys.h> #include <libDERUtils/fileIo.h> #include <libDERUtils/libDERUtils.h> #include <libDERUtils/printFields.h> static void usage(char **argv) { printf("usage: %s crlFile [options]\n", argv[0]); printf("Options:\n"); printf(" -v -- verbose \n"); /* etc. */ exit(1); } /* * This is a SEQUENCE OF so we use the low-level DERDecodeSeq* routines to snag one entry * at a time. */ static void printRevokedCerts( DERItem *revokedCerts, int verbose) { DERReturn drtn; DERDecodedInfo currItem; DERSequence seq; unsigned certNum; DERRevokedCert revoked; drtn = DERDecodeSeqContentInit(revokedCerts, &seq); if(drtn) { DERPerror("DERDecodeSeqContentInit(revokedCerts)", drtn); return; } for(certNum=0; ; certNum++) { drtn = DERDecodeSeqNext(&seq, &currItem); switch(drtn) { case DR_EndOfSequence: /* normal termination */ return; default: DERPerror("DERDecodeSeqNext", drtn); return; case DR_Success: doIndent(); printf("revoked cert %u\n", certNum); incrIndent(); drtn = DERParseSequenceContent(&currItem.content, DERNumRevokedCertItemSpecs, DERRevokedCertItemSpecs, &revoked, sizeof(revoked)); if(drtn) { DERPerror("DERParseSequenceContent(RevokedCert)", drtn); decrIndent(); return; } printItem("serialNum", IT_Leaf, verbose, ASN1_INTEGER, &revoked.serialNum); decodePrintItem("revocationDate", IT_Leaf, verbose, &revoked.revocationDate); printItem("extensions", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &revoked.extensions); decrIndent(); } } } int main(int argc, char **argv) { unsigned char *crlData = NULL; unsigned crlDataLen = 0; DERSignedCertCrl signedCrl; DERTBSCrl tbs; DERReturn drtn; DERItem item; int verbose = 0; extern char *optarg; int arg; extern int optind; if(argc < 2) { usage(argv); } if(readFile(argv[1], &crlData, &crlDataLen)) { printf("***Error reading CRL from %s. Aborting.\n", argv[1]); exit(1); } optind = 2; while ((arg = getopt(argc, argv, "vh")) != -1) { switch (arg) { case 'v': verbose = 1; break; case 'h': usage(argv); } } if(optind != argc) { usage(argv); } /* Top level decode of signed CRL into 3 components */ item.data = crlData; item.length = crlDataLen; drtn = DERParseSequence(&item, DERNumSignedCertCrlItemSpecs, DERSignedCertCrlItemSpecs, &signedCrl, sizeof(signedCrl)); if(drtn) { DERPerror("DERParseSequence(SignedCrl)", drtn); exit(1); } printItem("TBSCrl", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCrl.tbs); incrIndent(); /* decode the TBSCrl - it was saved in full DER form */ drtn = DERParseSequence(&signedCrl.tbs, DERNumTBSCrlItemSpecs, DERTBSCrlItemSpecs, &tbs, sizeof(tbs)); if(drtn) { DERPerror("DERParseSequenceContent(TBSCrl)", drtn); exit(1); } if(tbs.version.data) { printItem("version", IT_Leaf, verbose, ASN1_INTEGER, &tbs.version); } printItem("tbsSigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.tbsSigAlg); incrIndent(); printAlgId(&tbs.tbsSigAlg, verbose); decrIndent(); printItem("issuer", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.issuer); decodePrintItem("thisUpdate", IT_Leaf, verbose, &tbs.thisUpdate); decodePrintItem("nextUpdate", IT_Leaf, verbose, &tbs.nextUpdate); if(tbs.revokedCerts.data) { printItem("version", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.revokedCerts); incrIndent(); printRevokedCerts(&tbs.revokedCerts, verbose); decrIndent(); } if(tbs.extensions.data) { printItem("extensions", IT_Leaf, verbose, ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 3, &tbs.extensions); } printItem("sigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCrl.sigAlg); incrIndent(); printAlgId(&signedCrl.sigAlg, verbose); decrIndent(); printItem("sig", IT_Leaf, verbose, ASN1_BIT_STRING, &signedCrl.sig); return 0; } |
Added Source/libDER/Tests/parseTicket.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <openssl/pem.h> #include <openssl/rsa.h> #include <openssl/engine.h> #include <openssl/bio.h> #include <openssl/x509.h> #include <openssl/sha.h> #include "AppleMobilePersonalizedTicket.h" #include <libDER/libDER.h> #include <libDER/asn1Types.h> #include <libDER/DER_Decode.h> #include <libDER/DER_Encode.h> #include <libDER/DER_Keys.h> #include <libDER/oids.h> #include "DER_Ticket.h" const unsigned char GoldKeyCert[] = { 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x31, 0x6e, 0xc6, 0x4f, 0xf1, 0xe8, 0x7d, 0x81, 0x38, 0x6d, 0xd8, 0xb3, 0x2b, 0xe4, 0xb5, 0xa0, 0x09, 0xaf, 0x74, 0xdd, 0xe9, 0x60, 0x27, 0x42, 0x07, 0xa3, 0xac, 0xef, 0xe5, 0x75, 0x07, 0xa8, 0xc2, 0x2c, 0x25, 0x56, 0x91, 0x37, 0xea, 0xdb, 0xdb, 0x68, 0x4a, 0x1c, 0xe3, 0x29, 0x61, 0x85, 0xd7, 0xd8, 0x66, 0x86, 0x66, 0xbf, 0xbf, 0x98, 0xae, 0xb4, 0xe9, 0x6c, 0x13, 0x81, 0x97, 0x78, 0x2a, 0x8d, 0xdc, 0x37, 0x9a, 0xf1, 0xa4, 0x0a, 0x9d, 0x74, 0xd5, 0x72, 0xbc, 0xb5, 0x64, 0xa6, 0x1a, 0x62, 0xd5, 0x39, 0xfb, 0x6f, 0xc0, 0xd1, 0xc7, 0x93, 0xc3, 0x20, 0xda, 0x84, 0x69, 0x1e, 0xd9, 0x96, 0x2e, 0xc1, 0x4f, 0x28, 0x96, 0x14, 0xa4, 0x68, 0x0a, 0x40, 0xe5, 0x17, 0xe7, 0xd6, 0x76, 0x4d, 0x81, 0xd8, 0xd2, 0xa6, 0x18, 0x82, 0x36, 0x40, 0x97, 0x31, 0xd9, 0x88, 0xdf, 0xaf, 0x05, 0x3a, 0x4b, 0x4e, 0x1b, 0x4a, 0x76, 0x6f, 0xb9, 0x6c, 0x18, 0x5d, 0xd5, 0x98, 0xf0, 0xf1, 0xbe, 0x0a, 0xd9, 0x57, 0x85, 0xc6, 0xc9, 0x63, 0xb3, 0xf5, 0x21, 0x26, 0x07, 0xba, 0x6a, 0x05, 0xfb, 0x5a, 0x06, 0x87, 0x2a, 0x30, 0x3f, 0xa9, 0xea, 0xab, 0x0e, 0x50, 0x70, 0x3b, 0x7e, 0xd4, 0xd2, 0x8c, 0xf3, 0xa1, 0xcf, 0x9a, 0x6c, 0x6b, 0xcf, 0x9b, 0x1b, 0x2a, 0x97, 0x6a, 0x3c, 0x38, 0x40, 0x43, 0xb1, 0x97, 0x19, 0x07, 0x64, 0x11, 0x94, 0x73, 0x14, 0xc9, 0xa3, 0xfe, 0x7f, 0xf6, 0x64, 0x23, 0x73, 0xe3, 0x76, 0xce, 0xf7, 0xf4, 0x2f, 0x6c, 0x9d, 0x0a, 0xf6, 0x39, 0xe6, 0x1d, 0xb2, 0x17, 0x29, 0x39, 0x98, 0x52, 0xda, 0xe0, 0x31, 0xa1, 0xfa, 0x85, 0x52, 0xc2, 0x60, 0xb5, 0x11, 0x42, 0xc6, 0x9b, 0x55, 0xd8, 0x40, 0x37, 0xf7, 0xdb, 0x01, 0x6a, 0xd5, 0x26, 0x3b, 0x27, 0x07, 0x20, 0xf7, 0x58, 0xd5, 0xa4, 0x1c, 0xe6, 0x2f, 0x74, 0x14, 0x6e, 0xa4, 0xe8, 0xc8, 0xe8, 0x9a, 0x39, 0x6d, 0xde, 0x7f, 0x67, 0x65, 0x40, 0x68, 0x26, 0x65, 0x62, 0x95, 0x87, 0x45, 0x62, 0x0d, 0x8d, 0x42, 0xad, 0x3b, 0x4f, 0xd3, 0x8f, 0x58, 0xcb, 0x61, 0x46, 0xc9, 0x3d, 0x7d, 0x75, 0x3c, 0x6d, 0xac, 0xdf, 0x53, 0xf4, 0x66, 0x9e, 0x14, 0x82, 0xc7, 0xd1, 0xd0, 0xec, 0x92, 0x24, 0x97, 0x1e, 0xc9, 0x7a, 0xfd, 0x8f, 0x75, 0xe2, 0xfd, 0x7e, 0x07, 0x44, 0x46, 0x56, 0x64, 0x9b, 0x1b, 0x17, 0xfa, 0xd6, 0xf5, 0xdb, 0xc9, 0x27, 0x3b, 0x60, 0x27, 0x2f, 0x84, 0xd7, 0xac, 0x7f, 0xf3, 0xa7, 0x16, 0x31, 0xfa, 0x19, 0x54, 0x57, 0x98, 0xb5, 0xdb, 0x9c, 0xc3, 0xb5, 0x55, 0x72, 0x98, 0x2f, 0x56, 0x33, 0x7c, 0x38, 0x1f, 0xb4, 0x8c, 0x94, 0x1a, 0x6a, 0x26, 0x8a, 0x84, 0xfc, 0x8d, 0xb1, 0x49, 0xbb, 0x6d, 0x11, 0x36, 0xc9, 0x05, 0x57, 0x87, 0xd2, 0xdb, 0xd3, 0xe3, 0xea, 0x08, 0xb2, 0x9f, 0x44, 0x85, 0xd7, 0xd4, 0x96, 0x25, 0xeb, 0x2b, 0xca, 0x86, 0x0f, 0x33, 0x69, 0xc4, 0xda, 0x98, 0x68, 0x21, 0xad, 0xd8, 0xc4, 0x4e, 0x46, 0x33, 0x43, 0xad, 0xe7, 0xfe, 0x58, 0x10, 0x00, 0x76, 0x3c, 0xd4, 0x14, 0x5a, 0x74, 0x43, 0x04, 0xc3, 0xdd, 0x46, 0xc3, 0xe0, 0x4b, 0x46, 0xb5, 0x84, 0xcb, 0xe6, 0x40, 0x71, 0xdf, 0x50, 0x16, 0x5f, 0xf0, 0x0f, 0xc5, 0x9c, 0x50, 0x64, 0xe0, 0x64, 0x1c, 0x58, 0x87, 0xae, 0x91, 0x9c, 0xb6, 0x57, 0x77, 0xf0, 0xc4, 0x3e, 0xcf, 0xb6, 0xc5, 0x10, 0x0c, 0xea, 0x5b, 0xcc, 0xaf, 0xee, 0x7b, 0x15, 0x4e, 0x4e, 0x3c, 0x29, 0x9c, 0xf8, 0xe6, 0x59, 0xca, 0xaf, 0x48, 0x12, 0x99, 0x76, 0xde, 0x54, 0xe2, 0x75, 0x62, 0x31, 0x17, }; #define SIG_LEN 128 #define HASH_LEN 20 const unsigned char fakeAlgOID[] = { 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05 }; const unsigned char fakeG3Cert[] = { 0x01,0x00,0x00,0x00, 0x1c,0x00,0x00,0x00, 0x01,0x08,0x00,0x00, 0x10,0x0a,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x04,0x00,0x00, 0x01,0x00,0x01,0x00, 0x19,0xfc,0xb6,0x7b,0x4e,0xa8,0xd7,0xb1,0xeb,0xf9,0x19,0x28,0x07,0x7f,0x47,0x4c, 0xe1,0x9f,0xbe,0x01,0x15,0x5c,0xea,0xda,0xc3,0xd1,0x59,0x3c,0x75,0xed,0x00,0x7b, 0x22,0x67,0x22,0xd6,0xd3,0xee,0xc2,0x04,0xdf,0x47,0xc4,0x85,0xc0,0x56,0xa4,0x8d, 0xf3,0xf0,0xcf,0x00,0x9d,0xd2,0x03,0xc1,0x23,0x3f,0xc8,0x9f,0xef,0xfe,0xea,0x50, 0x33,0x6b,0xbe,0x74,0x1a,0xa3,0x3c,0x13,0xa2,0xc5,0xf6,0x75,0x88,0x1d,0x3f,0xba, 0xff,0x0d,0x47,0xab,0xbe,0xfe,0x42,0xd3,0xea,0xe2,0xe2,0xb0,0x06,0xd7,0x88,0xf8, 0x1d,0x93,0xdf,0x86,0xbd,0xd8,0xa8,0x5f,0x2b,0xe3,0x97,0x41,0xa1,0xc6,0x1d,0x69, 0xe9,0x88,0xdf,0x87,0xbb,0x1b,0xff,0x31,0x82,0xae,0x8a,0x69,0x31,0xca,0xc3,0x90, 0x0f,0x0d,0x22,0xa3,0xcf,0x8d,0xcc,0x23,0x03,0x10,0xed,0x74,0x8e,0x13,0x74,0x49, 0x9d,0x9a,0x1c,0xf2,0x57,0x2d,0x18,0x89,0x6d,0xb8,0xcc,0xab,0xcf,0xd9,0xd8,0x0e, 0x46,0x68,0x98,0xa3,0x81,0x5d,0x18,0xe8,0x4d,0x03,0x96,0x14,0xc5,0xaf,0x21,0x91, 0xb7,0x8c,0x97,0xa1,0x85,0xde,0x85,0x78,0xa8,0xd7,0x25,0x20,0x9b,0x2b,0x98,0x36, 0xd5,0xfe,0x14,0x9b,0x5d,0xe3,0x78,0xf4,0xd6,0xb2,0x15,0xc9,0xfd,0x13,0x77,0x7b, 0x8a,0x5e,0x9e,0x85,0xff,0x53,0x6d,0x24,0x5d,0xc9,0x52,0x16,0x98,0x18,0xb1,0xaf, 0xe1,0x6a,0xd6,0xe8,0xa9,0x7c,0x78,0x8e,0x9f,0x79,0x21,0xa1,0xde,0xf4,0xaf,0x9c, 0xd4,0x61,0x52,0xf9,0xe7,0xfc,0xd7,0x10,0x1b,0x91,0x66,0x14,0x26,0xfd,0xda,0xee, 0xe5,0xd9,0x4c,0xb7,0x9d,0x6d,0x17,0xf8,0xc2,0x21,0xb4,0x34,0x08,0x0c,0x44,0x79, 0x53,0x9c,0x81,0xbf,0x1f,0x22,0x0a,0xa6,0xe7,0x22,0x5f,0x5c,0xcb,0x31,0x2e,0xf5, 0x0c,0x1a,0xf1,0x67,0x13,0x7f,0xe6,0xb3,0xb2,0xfe,0x6b,0x09,0xac,0xa6,0xd4,0x14, 0xe7,0xe9,0x11,0x0e,0x49,0x99,0x06,0x04,0xa4,0x43,0x22,0xec,0x9f,0x59,0x83,0xfb, 0xef,0xa3,0x8f,0x6b,0xde,0x70,0x0c,0xbb,0x89,0xe9,0x88,0xbc,0xeb,0x36,0x42,0x42, 0x50,0x84,0xf5,0x93,0x98,0x93,0xed,0xa2,0x1f,0x13,0x60,0x36,0xc8,0x2f,0x9f,0xd1, 0xc4,0x23,0xf6,0xd0,0x49,0x40,0xab,0xbe,0xf7,0x43,0x02,0x96,0xf0,0x74,0xa5,0x7d, 0x68,0x89,0xfa,0x58, 0xad, 0x7b, 0x2f, 0x7d, 0xe8, 0x21, 0x34, 0x5e, 0x6c, 0x20, 0x97, 0x9e }; const unsigned char fakeSig[] = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10, 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10 }; static void dumpBytes( const char *title, const unsigned char *data, int len, int nonewline ); static int rsa_sign( const char *keyFile, unsigned char *plain, unsigned plainLength, unsigned char signature[SIG_LEN] ) { int rc = -1; FILE *fp = NULL; RSA *rsa = NULL; unsigned signatureLength = 0; fp = fopen ( (char*) keyFile, "r" ); if ( !fp ) { fprintf( stderr, "failed to open file=%s\n", keyFile ); goto cleanup; } rsa = RSA_new(); if ( !rsa ) { fprintf( stderr, "RSA_new() failed\n" ); goto cleanup; } rsa = (RSA*)PEM_read_RSAPrivateKey( fp, &rsa, NULL, NULL ); if ( !rsa ) { fprintf( stderr, "PEM_read_RSAPrivateKey() failed\n" ); goto cleanup; } signatureLength = SIG_LEN; char sha1[20] = {}; (void) SHA1( plain, plainLength, (unsigned char*)sha1 ); rc = RSA_sign( NID_sha1, (unsigned char*)sha1, sizeof( sha1), signature, &signatureLength, rsa ); if ( rc != 1 ) { fprintf(stderr, "RSA_sign failed=%d\n", rc ); rc = -1; goto cleanup; } else { rc = 0; } cleanup: if ( fp ) fclose( fp ); RSA_free( rsa ); return rc; } static int rsa_verify( const char *keyFile, unsigned char *plain, unsigned plainLength, unsigned char signature[SIG_LEN] ) { int rc = -1; FILE *fp = NULL; RSA *rsa = NULL; unsigned signatureLength = 0; fp = fopen ( (char*) keyFile, "r" ); if ( !fp ) { fprintf( stderr, "failed to open file=%s\n", keyFile ); goto cleanup; } rsa = RSA_new(); if ( !rsa ) { fprintf( stderr, "RSA_new() failed\n" ); goto cleanup; } rsa = (RSA*)PEM_read_RSAPrivateKey( fp, &rsa, NULL, NULL ); if ( !rsa ) { fprintf( stderr, "PEM_read_RSAPrivateKey() failed\n" ); goto cleanup; } signatureLength = SIG_LEN; char sha1[20] = {}; (void) SHA1( plain, plainLength, (unsigned char*)sha1 ); rc = RSA_verify( NID_sha1, (unsigned char*)sha1, sizeof( sha1 ), signature, signatureLength, rsa ); if ( rc != 1 ) { fprintf(stderr, "RSA_verify failed=%d\n", rc ); rc = -1; goto cleanup; } else { rc = 0; } cleanup: if ( fp ) fclose( fp ); RSA_free( rsa ); return rc; return rc; } static void dumpBytes( const char *title, const unsigned char *data, int len, int nonewline ) { int width = 16; int line = 0; int multiple = 0; multiple = ( len % width == 0 ); printf( "[%s: %d bytes]\n", title, len ); while ( len-- > 0 ) { line++; printf( "%02X ", *data++ ); if ( line % width == 0 && len > 0 && !nonewline ) { printf( "\n" ); } } printf("\n"); } static void readFile(char *filename, unsigned char **data, unsigned *len) { int size = 0; FILE *file = NULL; if ((file = fopen(filename, "r")) == NULL) { fprintf(stderr, "could not open file=%s", filename); return; } fseek(file, 0, SEEK_END); size = ftell(file); *len = size; *data = (unsigned char*)malloc(*len); if (!*data) { fprintf(stderr, "Out of memory"); fclose(file); return; } rewind(file); (void)fread(*data, size, 1, file); fclose(file); } static void writeFile( char* filename, unsigned char* buf, int len ) { FILE *file = NULL; file = fopen( filename, "w" ); if ( file ) { fwrite( buf, len, 1, file ); fclose( file ); } } static void verify_bb_ticket( unsigned char *ticketData, unsigned ticketLength, const char *keyFile, bool doPrint ) { if ( doPrint ) { dumpBytes( "Ticket (whole)", ticketData, ticketLength, 0 ); printf( "\nBreakdown:\n" ); } DERItem derTicket = { .data = ticketData, .length = ticketLength }; DERReturn drtn; DERBbTicket ticket = {}; DERSize ticketSize; drtn = DERDecodeBbTicket(&derTicket, &ticket, &ticketSize); if (drtn != DR_Success) goto badTicket; fprintf( stderr, "ticketSize=%u\n", ticketSize ); // Verify signature if key file exists (we should really use the certificate or GPUK in the ticket here. */ if ( keyFile ) { int status = rsa_verify( keyFile, (unsigned char *)ticket.body.data, ticket.body.length, (unsigned char *)ticket.signature.data ); if ( status ) { fprintf( stderr, "rsa_verify failed=%d\n", status ); } else { fprintf( stdout, "Signature verified successfully\n"); } } /* Example of how to retrive fields from ticket. */ DERItem snum; drtn = DERSetDecodeItemWithTag(&ticket.body, ASN1_CONTEXT_SPECIFIC | kBbSNUMTag, &snum); if (drtn != DR_Success) goto badTicket; DERItem chipId; drtn = DERSetDecodeItemWithTag(&ticket.body, ASN1_CONTEXT_SPECIFIC | kBbChipIDTag, &chipId); if (drtn != DR_Success) goto badTicket; return; badTicket: fprintf( stdout, "Bad ticket\n"); return; } static void verify_ticket_file( const char *ticketFile, const char *keyFile ) { unsigned char *ticket = NULL; unsigned ticketLength = 0; readFile( (char*)ticketFile, &ticket, &ticketLength ); verify_bb_ticket( ticket, ticketLength, keyFile, false ); } static void make_sample_ap_ticket( void ) { unsigned char chipId[] = { 0x01, 0x02, 0x03, 0x04 }; unsigned char ecid[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; DERApTicket ticket = { }; /* Encode the signatureAlgorithm field of the ticket. */ DERAlgorithmId algorithmId = { .oid = oidSha1Rsa, .params = {} }; ticket.signatureAlgorithm.length = DERLengthOfEncodedSequence( ASN1_CONSTR_SEQUENCE, &algorithmId, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs); ticket.signatureAlgorithm.data = malloc(ticket.signatureAlgorithm.length); DEREncodeSequence(ASN1_CONSTR_SEQUENCE, &algorithmId, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs, ticket.signatureAlgorithm.data, &ticket.signatureAlgorithm.length); /* Construct ticket body. */ DERSize numBodyItemSpecs = 0; DERItemSpec bodyItemSpecs[50] = {}; DERItem bodyItems[50] = {}; /* Add tags in sorted order. */ bodyItemSpecs[numBodyItemSpecs].offset = numBodyItemSpecs * sizeof(DERItem); bodyItemSpecs[numBodyItemSpecs].tag = ASN1_CONTEXT_SPECIFIC | kApECIDTag; bodyItemSpecs[numBodyItemSpecs].options = DER_ENC_NO_OPTS; bodyItems[numBodyItemSpecs].data = ecid; bodyItems[numBodyItemSpecs].length = sizeof(ecid); numBodyItemSpecs++; bodyItemSpecs[numBodyItemSpecs].offset = numBodyItemSpecs * sizeof(DERItem); bodyItemSpecs[numBodyItemSpecs].tag = ASN1_CONTEXT_SPECIFIC | kApChipIDTag; bodyItemSpecs[numBodyItemSpecs].options = DER_ENC_NO_OPTS; bodyItems[numBodyItemSpecs].data = chipId; bodyItems[numBodyItemSpecs].length = sizeof(chipId); numBodyItemSpecs++; /* Encode ticket body. */ ticket.body.length = DERLengthOfEncodedSequence(ASN1_CONSTR_SET, &bodyItems, numBodyItemSpecs, bodyItemSpecs); ticket.body.data = malloc(ticket.body.length); DEREncodeSequence(ASN1_CONSTR_SET, &bodyItems, numBodyItemSpecs, bodyItemSpecs, ticket.body.data, &ticket.body.length); // Signature ticket.signature.data = (DERByte *)fakeSig; ticket.signature.length = sizeof(fakeSig); // Certificates DERItemSpec certItemSpecs[1]; DERItem certItems[1]; certItemSpecs[0].offset = 0; certItemSpecs[0].tag = ASN1_CONSTR_SEQUENCE; certItemSpecs[0].options = DER_ENC_WRITE_DER; // NOTE: The Certificate should be added to the ticket by the host. I'm just simulating that here // to generate the final ticket blob. readFile("S5L8920_TATSU_FAC_DARWIN_DEV_CHAIN.der", &certItems[0].data, &certItems[0].length); ticket.certificates.length = DERLengthOfEncodedSequence( ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 1, &certItems, 1, certItemSpecs); ticket.certificates.data = malloc(ticket.certificates.length); DEREncodeSequence(ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 1, &certItems, 1, certItemSpecs, ticket.certificates.data, &ticket.certificates.length); /* Encode the entire ticket. */ DERSize ticketLength = DERLengthOfEncodedSequence(ASN1_CONSTR_SEQUENCE, &ticket, DERNumApTicketItemSpecs, DERApTicketItemSpecs); DERByte *ticketBytes = malloc(ticketLength); DEREncodeSequence(ASN1_CONSTR_SEQUENCE, &ticket, DERNumApTicketItemSpecs, DERApTicketItemSpecs, ticketBytes, &ticketLength); // save ticket to file writeFile("ApTicket.bin", ticketBytes, ticketLength); //cleanup: free(ticket.body.data); free(ticket.signatureAlgorithm.data); free(ticket.certificates.data); free(ticketBytes); } static void make_sample_bb_ticket( void ) { int status = 0; unsigned char chipId[] = { 0x01, 0x02, 0x03, 0x04 }; unsigned char snum[] = { 0x01, 0x02, 0x03, 0x04 }; unsigned char signature[SIG_LEN] = {}; DERByte *ticketBytes = NULL; DERBbTicket ticket = {}; /* Encode the signatureAlgorithm field of the ticket. */ DERAlgorithmId algorithmId = { .oid = oidSha1Rsa }; ticket.signatureAlgorithm.length = DERLengthOfEncodedSequence( ASN1_CONSTR_SEQUENCE, &algorithmId, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs); ticket.signatureAlgorithm.data = malloc(ticket.signatureAlgorithm.length); DEREncodeSequence(ASN1_CONSTR_SEQUENCE, &algorithmId, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs, ticket.signatureAlgorithm.data, &ticket.signatureAlgorithm.length); /* Construct ticket body. */ DERSize numBodyItemSpecs = 0; DERItemSpec bodyItemSpecs[50] = {}; DERItem bodyItems[50] = {}; /* Add tags in sorted order. */ bodyItemSpecs[numBodyItemSpecs].offset = numBodyItemSpecs * sizeof(DERItem); bodyItemSpecs[numBodyItemSpecs].tag = ASN1_CONTEXT_SPECIFIC | kBbSNUMTag; bodyItemSpecs[numBodyItemSpecs].options = DER_ENC_NO_OPTS; bodyItems[numBodyItemSpecs].data = snum; bodyItems[numBodyItemSpecs].length = sizeof(snum); numBodyItemSpecs++; bodyItemSpecs[numBodyItemSpecs].offset = numBodyItemSpecs * sizeof(DERItem); bodyItemSpecs[numBodyItemSpecs].tag = ASN1_CONTEXT_SPECIFIC | kBbChipIDTag; bodyItemSpecs[numBodyItemSpecs].options = DER_ENC_NO_OPTS; bodyItems[numBodyItemSpecs].data = chipId; bodyItems[numBodyItemSpecs].length = sizeof(chipId); numBodyItemSpecs++; /* Encode ticket body. */ ticket.body.length = DERLengthOfEncodedSequence(ASN1_CONSTR_SET, &bodyItems, numBodyItemSpecs, bodyItemSpecs); ticket.body.data = malloc(ticket.body.length); DEREncodeSequence(ASN1_CONSTR_SET, &bodyItems, numBodyItemSpecs, bodyItemSpecs, ticket.body.data, &ticket.body.length); // NOTE: In the SEE machine, the Body above will then be hashed/signed to generate signature status = rsa_sign( "G1_GPrK.pem", ticket.body.data, ticket.body.length, (unsigned char *)signature ); if ( status ) { fprintf( stderr, "rsa_sign failed=%d\n", status ); goto cleanup; } else { fprintf( stdout, "Signed successfully\n"); } status = rsa_verify( "G1_GPrK.pem", ticket.body.data, ticket.body.length, (unsigned char *)signature ); if ( status ) { fprintf( stderr, "rsa_verify failed=%d\n", status ); goto cleanup; } else { fprintf( stdout, "Signature verified successfully\n"); } // Signature ticket.signature.data = signature; ticket.signature.length = SIG_LEN; // Certificates ticket.gpuk.length = sizeof(GoldKeyCert); ticket.gpuk.data = (DERByte *)GoldKeyCert; /* Encode the entire ticket. */ DERSize ticketLength = DERLengthOfEncodedSequence(ASN1_CONSTR_SEQUENCE, &ticket, DERNumBbTicketItemSpecs, DERBbTicketItemSpecs); ticketBytes = malloc(ticketLength); DEREncodeSequence(ASN1_CONSTR_SEQUENCE, &ticket, DERNumBbTicketItemSpecs, DERBbTicketItemSpecs, ticketBytes, &ticketLength); // save ticket to file writeFile("BbTicket.bin", ticketBytes, ticketLength); cleanup: free(ticket.body.data); free(ticket.signatureAlgorithm.data); free(ticketBytes); } static void long_tag_test(void) { printf("ASN1_TAG_MASK 0x%.016qx\n", (uint64_t)ASN1_TAG_MASK); printf("ASN1_TAGNUM_MASK 0x%.016qx\n", (uint64_t)ASN1_TAGNUM_MASK); printf("ASN1_METHOD_MASK 0x%.016qx\n", (uint64_t)ASN1_METHOD_MASK); printf("ASN1_PRIMITIVE 0x%.016qx\n", (uint64_t)ASN1_PRIMITIVE); printf("ASN1_CONSTRUCTED 0x%.016qx\n", (uint64_t)ASN1_CONSTRUCTED); printf("ASN1_CLASS_MASK 0x%.016qx\n", (uint64_t)ASN1_CLASS_MASK); printf("ASN1_UNIVERSAL 0x%.016qx\n", (uint64_t)ASN1_UNIVERSAL); printf("ASN1_APPLICATION 0x%.016qx\n", (uint64_t)ASN1_APPLICATION); printf("ASN1_CONTEXT_SPECIFIC 0x%.016qx\n", (uint64_t)ASN1_CONTEXT_SPECIFIC); printf("ASN1_PRIVATE 0x%.016qx\n", (uint64_t)ASN1_PRIVATE); DERByte buf[10]; DERSize len = sizeof(buf); DERReturn drtn; DERTag tag = ASN1_CONTEXT_SPECIFIC | ASN1_TAGNUM_MASK; drtn = DEREncodeItem(tag, 0, 0, buf, &len); if (drtn) { printf("DEREncodeItem: %u\n", drtn); } DERItem der = { .data = buf, .length = len }; dumpBytes("tlv", buf, len, 0); DERDecodedInfo decoded; drtn = DERDecodeItem(&der, &decoded); if (drtn) { printf("DERDecodeItem: %u\n", drtn); } if (decoded.tag != tag) { printf("DERDecodeItem tag: 0x%qx != 0x%qx\n", (uint64_t)decoded.tag, (uint64_t)tag); } printf("DERDecodeItem tag: 0x%qx encoded in %u bytes, decoded length: %u\n", (uint64_t)tag, len, decoded.content.length); } int main(int argc, char **argv) { long_tag_test(); printf( "=> Making sample BB ticket...\n"); make_sample_bb_ticket(); printf( "=> Making sample AP ticket...\n"); make_sample_ap_ticket(); printf( "=> Verifying signature in bb_ticket.bin ...\n"); verify_ticket_file( "bb_ticket.bin", "G1_GPrK.pem" ); return 0; } |
Added Source/libDER/libDER.xcodeproj/project.pbxproj.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ 053BA30F091C00B100A7007A /* World */ = { isa = PBXAggregateTarget; buildConfigurationList = 4CD81A6D09BE1FD2000A9641 /* Build configuration list for PBXAggregateTarget "World" */; buildPhases = ( ); dependencies = ( 053BA317091C017E00A7007A /* PBXTargetDependency */, 053BA463091FE60E00A7007A /* PBXTargetDependency */, 058ECC54091FF0000050AA30 /* PBXTargetDependency */, 058F16680925224F009FA1C5 /* PBXTargetDependency */, 4C96C8DC113F4174005483E8 /* PBXTargetDependency */, ); name = World; productName = World; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 053BA324091C02B700A7007A /* DER_Decode.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA321091C02B700A7007A /* DER_Decode.h */; }; 053BA325091C02B700A7007A /* libDER_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA322091C02B700A7007A /* libDER_config.h */; }; 053BA326091C02B700A7007A /* libDER.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA323091C02B700A7007A /* libDER.h */; }; 053BA344091C089B00A7007A /* asn1Types.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA342091C089B00A7007A /* asn1Types.h */; }; 053BA345091C089B00A7007A /* DER_Decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 053BA343091C089B00A7007A /* DER_Decode.c */; }; 053BA399091C258100A7007A /* DER_CertCrl.c in Sources */ = {isa = PBXBuildFile; fileRef = 053BA397091C258100A7007A /* DER_CertCrl.c */; }; 053BA39A091C258100A7007A /* DER_CertCrl.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA398091C258100A7007A /* DER_CertCrl.h */; }; 053BA45D091FE5E700A7007A /* libDER.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 053BA314091C00BF00A7007A /* libDER.a */; }; 053BA461091FE60700A7007A /* parseCert.c in Sources */ = {isa = PBXBuildFile; fileRef = 053BA460091FE60700A7007A /* parseCert.c */; }; 053BA470091FE6C100A7007A /* fileIo.c in Sources */ = {isa = PBXBuildFile; fileRef = 053BA46E091FE6C100A7007A /* fileIo.c */; }; 053BA471091FE6C100A7007A /* fileIo.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA46F091FE6C100A7007A /* fileIo.h */; }; 053BA47D091FE7CC00A7007A /* libDERUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 053BA47B091FE7CC00A7007A /* libDERUtils.h */; }; 053BA47E091FE7CC00A7007A /* libDERUtils.c in Sources */ = {isa = PBXBuildFile; fileRef = 053BA47C091FE7CC00A7007A /* libDERUtils.c */; }; 0544AEA10940939C00DD6C0B /* DER_Encode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0544AE9F0940939C00DD6C0B /* DER_Encode.h */; }; 0544AEA20940939C00DD6C0B /* DER_Encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 0544AEA00940939C00DD6C0B /* DER_Encode.c */; }; 058ECC52091FEFF70050AA30 /* libDERUtils.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 053BA46B091FE63E00A7007A /* libDERUtils.a */; }; 058ECD350920F5E30050AA30 /* DER_Keys.c in Sources */ = {isa = PBXBuildFile; fileRef = 058ECD330920F5E30050AA30 /* DER_Keys.c */; }; 058ECD360920F5E30050AA30 /* DER_Keys.h in Headers */ = {isa = PBXBuildFile; fileRef = 058ECD340920F5E30050AA30 /* DER_Keys.h */; }; 058F15C20922B73F009FA1C5 /* printFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 058F15C00922B73F009FA1C5 /* printFields.h */; }; 058F15C30922B73F009FA1C5 /* printFields.c in Sources */ = {isa = PBXBuildFile; fileRef = 058F15C10922B73F009FA1C5 /* printFields.c */; }; 058F163109250D16009FA1C5 /* oids.c in Sources */ = {isa = PBXBuildFile; fileRef = 058F162D09250D0D009FA1C5 /* oids.c */; }; 058F163209250D17009FA1C5 /* oids.h in Headers */ = {isa = PBXBuildFile; fileRef = 058F162E09250D0D009FA1C5 /* oids.h */; }; 058F1659092513A7009FA1C5 /* parseCrl.c in Sources */ = {isa = PBXBuildFile; fileRef = 058F1658092513A7009FA1C5 /* parseCrl.c */; }; 058F16710925230E009FA1C5 /* libDER.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 053BA314091C00BF00A7007A /* libDER.a */; }; 058F16720925230F009FA1C5 /* libDERUtils.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 053BA46B091FE63E00A7007A /* libDERUtils.a */; }; 05E0E40709228A5E005F4693 /* DER_Digest.h in Headers */ = {isa = PBXBuildFile; fileRef = 05E0E40509228A5E005F4693 /* DER_Digest.h */; }; 05E0E40809228A5E005F4693 /* DER_Digest.c in Sources */ = {isa = PBXBuildFile; fileRef = 05E0E40609228A5E005F4693 /* DER_Digest.c */; }; 4C96C8D6113F4165005483E8 /* DER_Ticket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C96C8D3113F4165005483E8 /* DER_Ticket.c */; }; 4C96C8D7113F4165005483E8 /* parseTicket.c in Sources */ = {isa = PBXBuildFile; fileRef = 4C96C8D5113F4165005483E8 /* parseTicket.c */; }; 4C96C8E2113F4232005483E8 /* libDER.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 053BA314091C00BF00A7007A /* libDER.a */; }; 4C96C8ED113F42D1005483E8 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C96C8EC113F42C4005483E8 /* libcrypto.dylib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 053BA316091C017E00A7007A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA313091C00BF00A7007A; remoteInfo = libDER; }; 053BA458091FE59900A7007A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA313091C00BF00A7007A; remoteInfo = libDER; }; 053BA462091FE60E00A7007A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA444091FE58C00A7007A; remoteInfo = parseCert; }; 058ECC53091FF0000050AA30 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA46A091FE63E00A7007A; remoteInfo = libDERUtils; }; 058ECC55091FF0090050AA30 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA46A091FE63E00A7007A; remoteInfo = libDERUtils; }; 058F16670925224F009FA1C5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 058F16530925135E009FA1C5; remoteInfo = parseCrl; }; 058F1675092523D8009FA1C5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA313091C00BF00A7007A; remoteInfo = libDER; }; 058F1677092523DD009FA1C5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA46A091FE63E00A7007A; remoteInfo = libDERUtils; }; 4C96C8DB113F4174005483E8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 4C96C8CD113F4132005483E8; remoteInfo = parseTicket; }; 4C96C8E0113F4223005483E8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 053BA30A091C00A400A7007A /* Project object */; proxyType = 1; remoteGlobalIDString = 053BA313091C00BF00A7007A; remoteInfo = libDER; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 053BA314091C00BF00A7007A /* libDER.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDER.a; sourceTree = BUILT_PRODUCTS_DIR; }; 053BA321091C02B700A7007A /* DER_Decode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DER_Decode.h; sourceTree = "<group>"; }; 053BA322091C02B700A7007A /* libDER_config.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = libDER_config.h; sourceTree = "<group>"; }; 053BA323091C02B700A7007A /* libDER.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = libDER.h; sourceTree = "<group>"; }; 053BA342091C089B00A7007A /* asn1Types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = asn1Types.h; sourceTree = "<group>"; }; 053BA343091C089B00A7007A /* DER_Decode.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = DER_Decode.c; sourceTree = "<group>"; }; 053BA397091C258100A7007A /* DER_CertCrl.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = DER_CertCrl.c; sourceTree = "<group>"; }; 053BA398091C258100A7007A /* DER_CertCrl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DER_CertCrl.h; sourceTree = "<group>"; }; 053BA445091FE58C00A7007A /* parseCert */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = parseCert; sourceTree = BUILT_PRODUCTS_DIR; }; 053BA460091FE60700A7007A /* parseCert.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = parseCert.c; sourceTree = "<group>"; }; 053BA46B091FE63E00A7007A /* libDERUtils.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDERUtils.a; sourceTree = BUILT_PRODUCTS_DIR; }; 053BA46E091FE6C100A7007A /* fileIo.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = fileIo.c; sourceTree = "<group>"; }; 053BA46F091FE6C100A7007A /* fileIo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = fileIo.h; sourceTree = "<group>"; }; 053BA47B091FE7CC00A7007A /* libDERUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libDERUtils.h; sourceTree = "<group>"; }; 053BA47C091FE7CC00A7007A /* libDERUtils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = libDERUtils.c; sourceTree = "<group>"; }; 0544AE9F0940939C00DD6C0B /* DER_Encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Encode.h; sourceTree = "<group>"; }; 0544AEA00940939C00DD6C0B /* DER_Encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Encode.c; sourceTree = "<group>"; }; 058ECD330920F5E30050AA30 /* DER_Keys.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = DER_Keys.c; sourceTree = "<group>"; }; 058ECD340920F5E30050AA30 /* DER_Keys.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DER_Keys.h; sourceTree = "<group>"; }; 058ECE5C09211AE40050AA30 /* libGiants.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGiants.a; sourceTree = BUILT_PRODUCTS_DIR; }; 058ECE5E09211AFB0050AA30 /* libgRSA.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgRSA.a; sourceTree = BUILT_PRODUCTS_DIR; }; 058F15C00922B73F009FA1C5 /* printFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = printFields.h; sourceTree = "<group>"; }; 058F15C10922B73F009FA1C5 /* printFields.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = printFields.c; sourceTree = "<group>"; }; 058F162D09250D0D009FA1C5 /* oids.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = oids.c; sourceTree = "<group>"; }; 058F162E09250D0D009FA1C5 /* oids.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = oids.h; sourceTree = "<group>"; }; 058F16540925135E009FA1C5 /* parseCrl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = parseCrl; sourceTree = BUILT_PRODUCTS_DIR; }; 058F1658092513A7009FA1C5 /* parseCrl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = parseCrl.c; sourceTree = "<group>"; }; 05E0E40509228A5E005F4693 /* DER_Digest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Digest.h; sourceTree = "<group>"; }; 05E0E40609228A5E005F4693 /* DER_Digest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Digest.c; sourceTree = "<group>"; }; 4C86289E1137D5BE009EAB5A /* iPhoneFamily.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = iPhoneFamily.xcconfig; path = AppleInternal/XcodeConfig/iPhoneFamily.xcconfig; sourceTree = DEVELOPER_DIR; }; 4C96C8CE113F4132005483E8 /* parseTicket */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = parseTicket; sourceTree = BUILT_PRODUCTS_DIR; }; 4C96C8D2113F4165005483E8 /* AppleMobilePersonalizedTicket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleMobilePersonalizedTicket.h; sourceTree = "<group>"; }; 4C96C8D3113F4165005483E8 /* DER_Ticket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DER_Ticket.c; sourceTree = "<group>"; }; 4C96C8D4113F4165005483E8 /* DER_Ticket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DER_Ticket.h; sourceTree = "<group>"; }; 4C96C8D5113F4165005483E8 /* parseTicket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = parseTicket.c; sourceTree = "<group>"; }; 4C96C8EC113F42C4005483E8 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = /usr/lib/libcrypto.dylib; sourceTree = "<absolute>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 053BA312091C00BF00A7007A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 053BA443091FE58C00A7007A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 058ECC52091FEFF70050AA30 /* libDERUtils.a in Frameworks */, 053BA45D091FE5E700A7007A /* libDER.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 053BA469091FE63E00A7007A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 058F16520925135E009FA1C5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 058F16720925230F009FA1C5 /* libDERUtils.a in Frameworks */, 058F16710925230E009FA1C5 /* libDER.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 4C96C8CC113F4132005483E8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4C96C8E2113F4232005483E8 /* libDER.a in Frameworks */, 4C96C8ED113F42D1005483E8 /* libcrypto.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 053BA306091C00A400A7007A = { isa = PBXGroup; children = ( 053BA31E091C029900A7007A /* libDER */, 053BA466091FE62100A7007A /* libDERUtils */, 053BA45C091FE5CE00A7007A /* Tests */, 4C86289E1137D5BE009EAB5A /* iPhoneFamily.xcconfig */, 058ECE5B09211AB20050AA30 /* External Libs */, 053BA315091C00BF00A7007A /* Products */, ); sourceTree = "<group>"; }; 053BA315091C00BF00A7007A /* Products */ = { isa = PBXGroup; children = ( 053BA314091C00BF00A7007A /* libDER.a */, 053BA445091FE58C00A7007A /* parseCert */, 053BA46B091FE63E00A7007A /* libDERUtils.a */, 058F16540925135E009FA1C5 /* parseCrl */, 4C96C8CE113F4132005483E8 /* parseTicket */, ); name = Products; sourceTree = "<group>"; }; 053BA31E091C029900A7007A /* libDER */ = { isa = PBXGroup; children = ( 058ECD330920F5E30050AA30 /* DER_Keys.c */, 058ECD340920F5E30050AA30 /* DER_Keys.h */, 053BA342091C089B00A7007A /* asn1Types.h */, 053BA397091C258100A7007A /* DER_CertCrl.c */, 053BA398091C258100A7007A /* DER_CertCrl.h */, 053BA343091C089B00A7007A /* DER_Decode.c */, 053BA321091C02B700A7007A /* DER_Decode.h */, 0544AEA00940939C00DD6C0B /* DER_Encode.c */, 0544AE9F0940939C00DD6C0B /* DER_Encode.h */, 053BA322091C02B700A7007A /* libDER_config.h */, 053BA323091C02B700A7007A /* libDER.h */, 05E0E40509228A5E005F4693 /* DER_Digest.h */, 05E0E40609228A5E005F4693 /* DER_Digest.c */, 058F162D09250D0D009FA1C5 /* oids.c */, 058F162E09250D0D009FA1C5 /* oids.h */, ); path = libDER; sourceTree = "<group>"; }; 053BA45C091FE5CE00A7007A /* Tests */ = { isa = PBXGroup; children = ( 4C96C8D2113F4165005483E8 /* AppleMobilePersonalizedTicket.h */, 4C96C8D3113F4165005483E8 /* DER_Ticket.c */, 4C96C8D4113F4165005483E8 /* DER_Ticket.h */, 4C96C8D5113F4165005483E8 /* parseTicket.c */, 053BA460091FE60700A7007A /* parseCert.c */, 058F1658092513A7009FA1C5 /* parseCrl.c */, ); path = Tests; sourceTree = "<group>"; }; 053BA466091FE62100A7007A /* libDERUtils */ = { isa = PBXGroup; children = ( 053BA47B091FE7CC00A7007A /* libDERUtils.h */, 053BA47C091FE7CC00A7007A /* libDERUtils.c */, 053BA46E091FE6C100A7007A /* fileIo.c */, 053BA46F091FE6C100A7007A /* fileIo.h */, 058F15C00922B73F009FA1C5 /* printFields.h */, 058F15C10922B73F009FA1C5 /* printFields.c */, ); path = libDERUtils; sourceTree = "<group>"; }; 058ECE5B09211AB20050AA30 /* External Libs */ = { isa = PBXGroup; children = ( 058ECE5E09211AFB0050AA30 /* libgRSA.a */, 058ECE5C09211AE40050AA30 /* libGiants.a */, 4C96C8EC113F42C4005483E8 /* libcrypto.dylib */, ); name = "External Libs"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 053BA310091C00BF00A7007A /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 053BA324091C02B700A7007A /* DER_Decode.h in Headers */, 053BA325091C02B700A7007A /* libDER_config.h in Headers */, 053BA326091C02B700A7007A /* libDER.h in Headers */, 053BA344091C089B00A7007A /* asn1Types.h in Headers */, 053BA39A091C258100A7007A /* DER_CertCrl.h in Headers */, 058ECD360920F5E30050AA30 /* DER_Keys.h in Headers */, 05E0E40709228A5E005F4693 /* DER_Digest.h in Headers */, 058F163209250D17009FA1C5 /* oids.h in Headers */, 0544AEA10940939C00DD6C0B /* DER_Encode.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; 053BA467091FE63E00A7007A /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 053BA471091FE6C100A7007A /* fileIo.h in Headers */, 053BA47D091FE7CC00A7007A /* libDERUtils.h in Headers */, 058F15C20922B73F009FA1C5 /* printFields.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 053BA313091C00BF00A7007A /* libDER */ = { isa = PBXNativeTarget; buildConfigurationList = 4CD81A5D09BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "libDER" */; buildPhases = ( 053BA310091C00BF00A7007A /* Headers */, 053BA311091C00BF00A7007A /* Sources */, 053BA312091C00BF00A7007A /* Frameworks */, ); buildRules = ( ); dependencies = ( ); name = libDER; productName = libDER; productReference = 053BA314091C00BF00A7007A /* libDER.a */; productType = "com.apple.product-type.library.static"; }; 053BA444091FE58C00A7007A /* parseCert */ = { isa = PBXNativeTarget; buildConfigurationList = 4CD81A6509BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "parseCert" */; buildPhases = ( 053BA442091FE58C00A7007A /* Sources */, 053BA443091FE58C00A7007A /* Frameworks */, ); buildRules = ( ); dependencies = ( 053BA459091FE59900A7007A /* PBXTargetDependency */, 058ECC56091FF0090050AA30 /* PBXTargetDependency */, ); name = parseCert; productName = parseCert; productReference = 053BA445091FE58C00A7007A /* parseCert */; productType = "com.apple.product-type.tool"; }; 053BA46A091FE63E00A7007A /* libDERUtils */ = { isa = PBXNativeTarget; buildConfigurationList = 4CD81A6109BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "libDERUtils" */; buildPhases = ( 053BA467091FE63E00A7007A /* Headers */, 053BA468091FE63E00A7007A /* Sources */, 053BA469091FE63E00A7007A /* Frameworks */, ); buildRules = ( ); dependencies = ( ); name = libDERUtils; productName = libDERUtils; productReference = 053BA46B091FE63E00A7007A /* libDERUtils.a */; productType = "com.apple.product-type.library.static"; }; 058F16530925135E009FA1C5 /* parseCrl */ = { isa = PBXNativeTarget; buildConfigurationList = 4CD81A6909BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "parseCrl" */; buildPhases = ( 058F16510925135E009FA1C5 /* Sources */, 058F16520925135E009FA1C5 /* Frameworks */, ); buildRules = ( ); dependencies = ( 058F1676092523D8009FA1C5 /* PBXTargetDependency */, 058F1678092523DD009FA1C5 /* PBXTargetDependency */, ); name = parseCrl; productName = parseCrl; productReference = 058F16540925135E009FA1C5 /* parseCrl */; productType = "com.apple.product-type.tool"; }; 4C96C8CD113F4132005483E8 /* parseTicket */ = { isa = PBXNativeTarget; buildConfigurationList = 4C96C8D8113F4165005483E8 /* Build configuration list for PBXNativeTarget "parseTicket" */; buildPhases = ( 4C96C8CB113F4132005483E8 /* Sources */, 4C96C8CC113F4132005483E8 /* Frameworks */, ); buildRules = ( ); dependencies = ( 4C96C8E1113F4223005483E8 /* PBXTargetDependency */, ); name = parseTicket; productName = parseTicket; productReference = 4C96C8CE113F4132005483E8 /* parseTicket */; productType = "com.apple.product-type.tool"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 053BA30A091C00A400A7007A /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0420; }; buildConfigurationList = 4CD81A7109BE1FD2000A9641 /* Build configuration list for PBXProject "libDER" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( English, Japanese, French, German, ); mainGroup = 053BA306091C00A400A7007A; productRefGroup = 053BA315091C00BF00A7007A /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 053BA30F091C00B100A7007A /* World */, 053BA313091C00BF00A7007A /* libDER */, 053BA444091FE58C00A7007A /* parseCert */, 053BA46A091FE63E00A7007A /* libDERUtils */, 058F16530925135E009FA1C5 /* parseCrl */, 4C96C8CD113F4132005483E8 /* parseTicket */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ 053BA311091C00BF00A7007A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 053BA345091C089B00A7007A /* DER_Decode.c in Sources */, 053BA399091C258100A7007A /* DER_CertCrl.c in Sources */, 058ECD350920F5E30050AA30 /* DER_Keys.c in Sources */, 05E0E40809228A5E005F4693 /* DER_Digest.c in Sources */, 058F163109250D16009FA1C5 /* oids.c in Sources */, 0544AEA20940939C00DD6C0B /* DER_Encode.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 053BA442091FE58C00A7007A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 053BA461091FE60700A7007A /* parseCert.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 053BA468091FE63E00A7007A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 053BA470091FE6C100A7007A /* fileIo.c in Sources */, 053BA47E091FE7CC00A7007A /* libDERUtils.c in Sources */, 058F15C30922B73F009FA1C5 /* printFields.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 058F16510925135E009FA1C5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 058F1659092513A7009FA1C5 /* parseCrl.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4C96C8CB113F4132005483E8 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 4C96C8D6113F4165005483E8 /* DER_Ticket.c in Sources */, 4C96C8D7113F4165005483E8 /* parseTicket.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 053BA317091C017E00A7007A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA313091C00BF00A7007A /* libDER */; targetProxy = 053BA316091C017E00A7007A /* PBXContainerItemProxy */; }; 053BA459091FE59900A7007A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA313091C00BF00A7007A /* libDER */; targetProxy = 053BA458091FE59900A7007A /* PBXContainerItemProxy */; }; 053BA463091FE60E00A7007A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA444091FE58C00A7007A /* parseCert */; targetProxy = 053BA462091FE60E00A7007A /* PBXContainerItemProxy */; }; 058ECC54091FF0000050AA30 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA46A091FE63E00A7007A /* libDERUtils */; targetProxy = 058ECC53091FF0000050AA30 /* PBXContainerItemProxy */; }; 058ECC56091FF0090050AA30 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA46A091FE63E00A7007A /* libDERUtils */; targetProxy = 058ECC55091FF0090050AA30 /* PBXContainerItemProxy */; }; 058F16680925224F009FA1C5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 058F16530925135E009FA1C5 /* parseCrl */; targetProxy = 058F16670925224F009FA1C5 /* PBXContainerItemProxy */; }; 058F1676092523D8009FA1C5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA313091C00BF00A7007A /* libDER */; targetProxy = 058F1675092523D8009FA1C5 /* PBXContainerItemProxy */; }; 058F1678092523DD009FA1C5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA46A091FE63E00A7007A /* libDERUtils */; targetProxy = 058F1677092523DD009FA1C5 /* PBXContainerItemProxy */; }; 4C96C8DC113F4174005483E8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4C96C8CD113F4132005483E8 /* parseTicket */; targetProxy = 4C96C8DB113F4174005483E8 /* PBXContainerItemProxy */; }; 4C96C8E1113F4223005483E8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 053BA313091C00BF00A7007A /* libDER */; targetProxy = 4C96C8E0113F4223005483E8 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ 4C96C8D0113F4132005483E8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseTicket; }; name = Debug; }; 4C96C8D1113F4132005483E8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseTicket; }; name = Release; }; 792E01120CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { INSTALL_PATH = "$(INDIGO_INSTALL_PATH_PREFIX)/usr/local/lib"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = DER; SKIP_INSTALL = YES; }; name = Debug; }; 792E01130CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { INSTALL_PATH = "$(INDIGO_INSTALL_PATH_PREFIX)/usr/local/lib"; LIBRARY_STYLE = STATIC; PRODUCT_NAME = DER; SKIP_INSTALL = YES; }; name = Release; }; 792E01140CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { LIBRARY_STYLE = STATIC; PRODUCT_NAME = DERUtils; SKIP_INSTALL = YES; }; name = Debug; }; 792E01150CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { LIBRARY_STYLE = STATIC; PRODUCT_NAME = DERUtils; SKIP_INSTALL = YES; }; name = Release; }; 792E01160CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseCert; }; name = Debug; }; 792E01170CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseCert; }; name = Release; }; 792E01180CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseCrl; }; name = Debug; }; 792E01190CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = parseCrl; }; name = Release; }; 792E011A0CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; OTHER_CFLAGS = "-DNDEBUG"; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; PRODUCT_NAME = World; SECTORDER_FLAGS = ""; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); }; name = Debug; }; 792E011B0CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; PRODUCT_NAME = World; SECTORDER_FLAGS = ""; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); }; name = Release; }; 792E011C0CBC0CE3007C00A0 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 4C86289E1137D5BE009EAB5A /* iPhoneFamily.xcconfig */; buildSettings = { COPY_PHASE_STRIP = NO; GCC_OPTIMIZATION_LEVEL = 1; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)", "$(SRCROOT)/libDER", ); "HEADER_SEARCH_PATHS[sdk=macosx*][arch=*]" = ( "$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers", "$(HEADER_SEARCH_PATHS)", ); OTHER_CFLAGS = ( "-fconstant-cfstrings", "-fno-inline", ); SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; WARNING_CFLAGS = ( "-Wall", "-Wextra", "-Wno-unused-parameter", "-Wno-missing-field-initializers", ); }; name = Debug; }; 792E011D0CBC0CE3007C00A0 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = 4C86289E1137D5BE009EAB5A /* iPhoneFamily.xcconfig */; buildSettings = { COPY_PHASE_STRIP = YES; GCC_OPTIMIZATION_LEVEL = s; GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)", "$(SRCROOT)/libDER", ); "HEADER_SEARCH_PATHS[sdk=macosx*][arch=*]" = ( "$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers", "$(HEADER_SEARCH_PATHS)", ); OTHER_CFLAGS = "-fconstant-cfstrings"; SDKROOT = iphoneos.internal; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; WARNING_CFLAGS = ( "-Wall", "-Wextra", "-Wno-unused-parameter", "-Wno-missing-field-initializers", ); }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 4C96C8D8113F4165005483E8 /* Build configuration list for PBXNativeTarget "parseTicket" */ = { isa = XCConfigurationList; buildConfigurations = ( 4C96C8D0113F4132005483E8 /* Debug */, 4C96C8D1113F4132005483E8 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A5D09BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "libDER" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E01120CBC0CE3007C00A0 /* Debug */, 792E01130CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A6109BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "libDERUtils" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E01140CBC0CE3007C00A0 /* Debug */, 792E01150CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A6509BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "parseCert" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E01160CBC0CE3007C00A0 /* Debug */, 792E01170CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A6909BE1FD2000A9641 /* Build configuration list for PBXNativeTarget "parseCrl" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E01180CBC0CE3007C00A0 /* Debug */, 792E01190CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A6D09BE1FD2000A9641 /* Build configuration list for PBXAggregateTarget "World" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E011A0CBC0CE3007C00A0 /* Debug */, 792E011B0CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 4CD81A7109BE1FD2000A9641 /* Build configuration list for PBXProject "libDER" */ = { isa = XCConfigurationList; buildConfigurations = ( 792E011C0CBC0CE3007C00A0 /* Debug */, 792E011D0CBC0CE3007C00A0 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 053BA30A091C00A400A7007A /* Project object */; } |
Added Source/libDER/libDER/DER_CertCrl.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | /* Copyright (c) 2005-2009 Apple Inc. All Rights Reserved. */ /* * DER_Cert.c - support for decoding X509 certificates * * Created Nov. 4 2005 by Doug Mitchell. */ #include "DER_Decode.h" #include "DER_CertCrl.h" #include "asn1Types.h" /* * DERItemSpecs for X509 certificates. */ /* top level cert with three components */ const DERItemSpec DERSignedCertCrlItemSpecs[] = { { DER_OFFSET(DERSignedCertCrl, tbs), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS | DER_DEC_SAVE_DER}, { DER_OFFSET(DERSignedCertCrl, sigAlg), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERSignedCertCrl, sig), ASN1_BIT_STRING, DER_DEC_NO_OPTS } }; const DERSize DERNumSignedCertCrlItemSpecs = sizeof(DERSignedCertCrlItemSpecs) / sizeof(DERItemSpec); /* TBS cert */ const DERItemSpec DERTBSCertItemSpecs[] = { { DER_OFFSET(DERTBSCert, version), ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 0, DER_DEC_OPTIONAL }, /* version - EXPLICIT */ { DER_OFFSET(DERTBSCert, serialNum), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCert, tbsSigAlg), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCert, issuer), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCert, validity), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCert, subject), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCert, subjectPubKey), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, /* libsecurity_asn1 has these two as CONSTRUCTED, but the ASN.1 spec * doesn't look that way to me. I don't have any certs that have these * fields.... */ { DER_OFFSET(DERTBSCert, issuerID), ASN1_CONTEXT_SPECIFIC | 1, DER_DEC_OPTIONAL }, { DER_OFFSET(DERTBSCert, subjectID), ASN1_CONTEXT_SPECIFIC | 2, DER_DEC_OPTIONAL }, { DER_OFFSET(DERTBSCert, extensions), ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 3, DER_DEC_OPTIONAL } }; const DERSize DERNumTBSCertItemSpecs = sizeof(DERTBSCertItemSpecs) / sizeof(DERItemSpec); /* DERValidity */ const DERItemSpec DERValidityItemSpecs[] = { { DER_OFFSET(DERValidity, notBefore), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER }, { DER_OFFSET(DERValidity, notAfter), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER } }; const DERSize DERNumValidityItemSpecs = sizeof(DERValidityItemSpecs) / sizeof(DERItemSpec); /* DERAttributeTypeAndValue */ const DERItemSpec DERAttributeTypeAndValueItemSpecs[] = { { DER_OFFSET(DERAttributeTypeAndValue, type), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERAttributeTypeAndValue, value), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER } }; const DERSize DERNumAttributeTypeAndValueItemSpecs = sizeof(DERAttributeTypeAndValueItemSpecs) / sizeof(DERItemSpec); /* DERExtension */ const DERItemSpec DERExtensionItemSpecs[] = { { DER_OFFSET(DERExtension, extnID), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERExtension, critical), ASN1_BOOLEAN, DER_DEC_OPTIONAL }, { DER_OFFSET(DERExtension, extnValue), ASN1_OCTET_STRING, DER_DEC_NO_OPTS } }; const DERSize DERNumExtensionItemSpecs = sizeof(DERExtensionItemSpecs) / sizeof(DERItemSpec); /* DERBasicConstraints */ const DERItemSpec DERBasicConstraintsItemSpecs[] = { { DER_OFFSET(DERBasicConstraints, cA), ASN1_BOOLEAN, DER_DEC_OPTIONAL }, { DER_OFFSET(DERBasicConstraints, pathLenConstraint), ASN1_INTEGER, DER_DEC_OPTIONAL } }; const DERSize DERNumBasicConstraintsItemSpecs = sizeof(DERBasicConstraintsItemSpecs) / sizeof(DERItemSpec); /* DERPrivateKeyUsagePeriod. */ const DERItemSpec DERPrivateKeyUsagePeriodItemSpecs[] = { { DER_OFFSET(DERPrivateKeyUsagePeriod, notBefore), ASN1_CONTEXT_SPECIFIC | 0, DER_DEC_OPTIONAL }, { DER_OFFSET(DERPrivateKeyUsagePeriod, notAfter), ASN1_CONTEXT_SPECIFIC | 1, DER_DEC_OPTIONAL } }; const DERSize DERNumPrivateKeyUsagePeriodItemSpecs = sizeof(DERPrivateKeyUsagePeriodItemSpecs) / sizeof(DERItemSpec); /* DERDistributionPoint. */ const DERItemSpec DERDistributionPointItemSpecs[] = { { DER_OFFSET(DERDistributionPoint, distributionPoint), ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 0, DER_DEC_OPTIONAL }, { DER_OFFSET(DERDistributionPoint, reasons), ASN1_CONTEXT_SPECIFIC | 1, DER_DEC_OPTIONAL }, { DER_OFFSET(DERDistributionPoint, cRLIssuer), ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 2, DER_DEC_OPTIONAL } }; const DERSize DERNumDistributionPointItemSpecs = sizeof(DERDistributionPointItemSpecs) / sizeof(DERItemSpec); /* DERPolicyInformation. */ const DERItemSpec DERPolicyInformationItemSpecs[] = { { DER_OFFSET(DERPolicyInformation, policyIdentifier), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERPolicyInformation, policyQualifiers), ASN1_CONSTR_SEQUENCE, DER_DEC_OPTIONAL } }; const DERSize DERNumPolicyInformationItemSpecs = sizeof(DERPolicyInformationItemSpecs) / sizeof(DERItemSpec); /* DERPolicyQualifierInfo. */ const DERItemSpec DERPolicyQualifierInfoItemSpecs[] = { { DER_OFFSET(DERPolicyQualifierInfo, policyQualifierID), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERPolicyQualifierInfo, qualifier), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER } }; const DERSize DERNumPolicyQualifierInfoItemSpecs = sizeof(DERPolicyQualifierInfoItemSpecs) / sizeof(DERItemSpec); /* DERUserNotice. */ const DERItemSpec DERUserNoticeItemSpecs[] = { { DER_OFFSET(DERUserNotice, noticeRef), ASN1_CONSTR_SEQUENCE, DER_DEC_OPTIONAL }, { DER_OFFSET(DERUserNotice, explicitText), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_OPTIONAL | DER_DEC_SAVE_DER } }; const DERSize DERNumUserNoticeItemSpecs = sizeof(DERUserNoticeItemSpecs) / sizeof(DERItemSpec); /* DERNoticeReference. */ const DERItemSpec DERNoticeReferenceItemSpecs[] = { { DER_OFFSET(DERNoticeReference, organization), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER }, { DER_OFFSET(DERNoticeReference, noticeNumbers), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS } }; const DERSize DERNumNoticeReferenceItemSpecs = sizeof(DERNoticeReferenceItemSpecs) / sizeof(DERItemSpec); /* DERPolicyMapping. */ const DERItemSpec DERPolicyMappingItemSpecs[] = { { DER_OFFSET(DERPolicyMapping, issuerDomainPolicy), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERPolicyMapping, subjectDomainPolicy), ASN1_OBJECT_ID, DER_DEC_NO_OPTS } }; const DERSize DERNumPolicyMappingItemSpecs = sizeof(DERPolicyMappingItemSpecs) / sizeof(DERItemSpec); /* DERAccessDescription. */ const DERItemSpec DERAccessDescriptionItemSpecs[] = { { DER_OFFSET(DERAccessDescription, accessMethod), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERAccessDescription, accessLocation), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER } }; const DERSize DERNumAccessDescriptionItemSpecs = sizeof(DERAccessDescriptionItemSpecs) / sizeof(DERItemSpec); /* DERAuthorityKeyIdentifier. */ const DERItemSpec DERAuthorityKeyIdentifierItemSpecs[] = { { DER_OFFSET(DERAuthorityKeyIdentifier, keyIdentifier), ASN1_CONTEXT_SPECIFIC | 0, DER_DEC_OPTIONAL }, { DER_OFFSET(DERAuthorityKeyIdentifier, authorityCertIssuer), ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 1, DER_DEC_OPTIONAL }, { DER_OFFSET(DERAuthorityKeyIdentifier, authorityCertSerialNumber), ASN1_CONTEXT_SPECIFIC | 2, DER_DEC_OPTIONAL } }; const DERSize DERNumAuthorityKeyIdentifierItemSpecs = sizeof(DERAuthorityKeyIdentifierItemSpecs) / sizeof(DERItemSpec); /* DEROtherName. */ const DERItemSpec DEROtherNameItemSpecs[] = { { DER_OFFSET(DEROtherName, typeIdentifier), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DEROtherName, value), ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 0, DER_DEC_NO_OPTS }, }; const DERSize DERNumOtherNameItemSpecs = sizeof(DEROtherNameItemSpecs) / sizeof(DERItemSpec); /* DERPolicyConstraints. */ const DERItemSpec DERPolicyConstraintsItemSpecs[] = { { DER_OFFSET(DERPolicyConstraints, requireExplicitPolicy), ASN1_CONTEXT_SPECIFIC | 0, DER_DEC_OPTIONAL }, { DER_OFFSET(DERPolicyConstraints, inhibitPolicyMapping), ASN1_CONTEXT_SPECIFIC | 1, DER_DEC_OPTIONAL } }; const DERSize DERNumPolicyConstraintsItemSpecs = sizeof(DERPolicyConstraintsItemSpecs) / sizeof(DERItemSpec); /* DERTBSCrl */ const DERItemSpec DERTBSCrlItemSpecs[] = { { DER_OFFSET(DERTBSCrl, version), ASN1_INTEGER, DER_DEC_OPTIONAL }, { DER_OFFSET(DERTBSCrl, tbsSigAlg), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCrl, issuer), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERTBSCrl, thisUpdate), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER }, { DER_OFFSET(DERTBSCrl, nextUpdate), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER }, { DER_OFFSET(DERTBSCrl, revokedCerts), ASN1_CONSTR_SEQUENCE, DER_DEC_OPTIONAL }, { DER_OFFSET(DERTBSCrl, extensions), ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 0, DER_DEC_OPTIONAL } }; const DERSize DERNumTBSCrlItemSpecs = sizeof(DERTBSCrlItemSpecs) / sizeof(DERItemSpec); /* DERRevokedCert */ const DERItemSpec DERRevokedCertItemSpecs[] = { { DER_OFFSET(DERRevokedCert, serialNum), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERRevokedCert, revocationDate), 0, /* no tag - ANY */ DER_DEC_ASN_ANY | DER_DEC_SAVE_DER }, { DER_OFFSET(DERRevokedCert, extensions), ASN1_CONSTR_SEQUENCE, DER_DEC_OPTIONAL } }; const DERSize DERNumRevokedCertItemSpecs = sizeof(DERRevokedCertItemSpecs) / sizeof(DERItemSpec); |
Added Source/libDER/libDER/DER_CertCrl.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /* Copyright (c) 2005-2009 Apple Inc. All Rights Reserved. */ /* * DER_CertCrl.h - support for decoding X509 certificates and CRLs * * Created Nov. 4 2005 by dmitch */ #ifndef _DER_CERT_CRL_H_ #define _DER_CERT_CRL_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER.h" #include "DER_Decode.h" /* * Top level cert or CRL - the two are identical at this level - three * components. The tbs field is saved in full DER form for sig verify. */ typedef struct { DERItem tbs; /* sequence, DERTBSCert, DER_DEC_SAVE_DER */ DERItem sigAlg; /* sequence, DERAlgorithmId */ DERItem sig; /* bit string */ } DERSignedCertCrl; /* DERItemSpecs to decode into a DERSignedCertCrl */ extern const DERItemSpec DERSignedCertCrlItemSpecs[]; extern const DERSize DERNumSignedCertCrlItemSpecs; /* TBS cert components */ typedef struct { DERItem version; /* integer, optional, EXPLICIT */ DERItem serialNum; /* integer */ DERItem tbsSigAlg; /* sequence, DERAlgorithmId */ DERItem issuer; /* sequence, TBD */ DERItem validity; /* sequence, DERValidity */ DERItem subject; /* sequence, TBD */ DERItem subjectPubKey; /* sequence, DERSubjPubKeyInfo */ DERItem issuerID; /* bit string, optional */ DERItem subjectID; /* bit string, optional */ DERItem extensions; /* sequence, optional, EXPLICIT */ } DERTBSCert; /* DERItemSpecs to decode into a DERTBSCert */ extern const DERItemSpec DERTBSCertItemSpecs[]; extern const DERSize DERNumTBSCertItemSpecs; /* * validity - components can be either UTC or generalized time. * Both are ASN_ANY with DER_DEC_SAVE_DER. */ typedef struct { DERItem notBefore; DERItem notAfter; } DERValidity; /* DERItemSpecs to decode into a DERValidity */ extern const DERItemSpec DERValidityItemSpecs[]; extern const DERSize DERNumValidityItemSpecs; /* AttributeTypeAndValue components. */ typedef struct { DERItem type; DERItem value; } DERAttributeTypeAndValue; /* DERItemSpecs to decode into DERAttributeTypeAndValue */ extern const DERItemSpec DERAttributeTypeAndValueItemSpecs[]; extern const DERSize DERNumAttributeTypeAndValueItemSpecs; /* Extension components */ typedef struct { DERItem extnID; DERItem critical; DERItem extnValue; } DERExtension; /* DERItemSpecs to decode into DERExtension */ extern const DERItemSpec DERExtensionItemSpecs[]; extern const DERSize DERNumExtensionItemSpecs; /* BasicConstraints components. */ typedef struct { DERItem cA; DERItem pathLenConstraint; } DERBasicConstraints; /* DERItemSpecs to decode into DERBasicConstraints */ extern const DERItemSpec DERBasicConstraintsItemSpecs[]; extern const DERSize DERNumBasicConstraintsItemSpecs; /* PrivateKeyUsagePeriod components. */ typedef struct { DERItem notBefore; DERItem notAfter; } DERPrivateKeyUsagePeriod; /* DERItemSpecs to decode into a DERPrivateKeyUsagePeriod */ extern const DERItemSpec DERPrivateKeyUsagePeriodItemSpecs[]; extern const DERSize DERNumPrivateKeyUsagePeriodItemSpecs; /* DistributionPoint components. */ typedef struct { DERItem distributionPoint; DERItem reasons; DERItem cRLIssuer; } DERDistributionPoint; /* DERItemSpecs to decode into a DERDistributionPoint */ extern const DERItemSpec DERDistributionPointItemSpecs[]; extern const DERSize DERNumDistributionPointItemSpecs; /* PolicyInformation components. */ typedef struct { DERItem policyIdentifier; DERItem policyQualifiers; } DERPolicyInformation; /* DERItemSpecs to decode into a DERPolicyInformation */ extern const DERItemSpec DERPolicyInformationItemSpecs[]; extern const DERSize DERNumPolicyInformationItemSpecs; /* PolicyQualifierInfo components. */ typedef struct { DERItem policyQualifierID; DERItem qualifier; } DERPolicyQualifierInfo; /* DERItemSpecs to decode into a DERPolicyQualifierInfo */ extern const DERItemSpec DERPolicyQualifierInfoItemSpecs[]; extern const DERSize DERNumPolicyQualifierInfoItemSpecs; /* UserNotice components. */ typedef struct { DERItem noticeRef; DERItem explicitText; } DERUserNotice; /* DERItemSpecs to decode into a DERUserNotice */ extern const DERItemSpec DERUserNoticeItemSpecs[]; extern const DERSize DERNumUserNoticeItemSpecs; /* NoticeReference components. */ typedef struct { DERItem organization; DERItem noticeNumbers; } DERNoticeReference; /* DERItemSpecs to decode into a DERNoticeReference */ extern const DERItemSpec DERNoticeReferenceItemSpecs[]; extern const DERSize DERNumNoticeReferenceItemSpecs; /* PolicyMapping components. */ typedef struct { DERItem issuerDomainPolicy; DERItem subjectDomainPolicy; } DERPolicyMapping; /* DERItemSpecs to decode into a DERPolicyMapping */ extern const DERItemSpec DERPolicyMappingItemSpecs[]; extern const DERSize DERNumPolicyMappingItemSpecs; /* AccessDescription components. */ typedef struct { DERItem accessMethod; DERItem accessLocation; } DERAccessDescription; /* DERItemSpecs to decode into a DERAccessDescription */ extern const DERItemSpec DERAccessDescriptionItemSpecs[]; extern const DERSize DERNumAccessDescriptionItemSpecs; /* AuthorityKeyIdentifier components. */ typedef struct { DERItem keyIdentifier; DERItem authorityCertIssuer; DERItem authorityCertSerialNumber; } DERAuthorityKeyIdentifier; /* DERItemSpecs to decode into a DERAuthorityKeyIdentifier */ extern const DERItemSpec DERAuthorityKeyIdentifierItemSpecs[]; extern const DERSize DERNumAuthorityKeyIdentifierItemSpecs; /* OtherName components. */ typedef struct { DERItem typeIdentifier; DERItem value; } DEROtherName; /* DERItemSpecs to decode into a DEROtherName */ extern const DERItemSpec DEROtherNameItemSpecs[]; extern const DERSize DERNumOtherNameItemSpecs; /* PolicyConstraints components. */ typedef struct { DERItem requireExplicitPolicy; DERItem inhibitPolicyMapping; } DERPolicyConstraints; /* DERItemSpecs to decode into a DERPolicyConstraints */ extern const DERItemSpec DERPolicyConstraintsItemSpecs[]; extern const DERSize DERNumPolicyConstraintsItemSpecs; /* TBS CRL */ typedef struct { DERItem version; /* integer, optional */ DERItem tbsSigAlg; /* sequence, DERAlgorithmId */ DERItem issuer; /* sequence, TBD */ DERItem thisUpdate; /* ASN_ANY, SAVE_DER */ DERItem nextUpdate; /* ASN_ANY, SAVE_DER */ DERItem revokedCerts; /* sequence of DERRevokedCert, optional */ DERItem extensions; /* sequence, optional, EXPLICIT */ } DERTBSCrl; /* DERItemSpecs to decode into a DERTBSCrl */ extern const DERItemSpec DERTBSCrlItemSpecs[]; extern const DERSize DERNumTBSCrlItemSpecs; typedef struct { DERItem serialNum; /* integer */ DERItem revocationDate; /* time - ASN_ANY, SAVE_DER */ DERItem extensions; /* sequence, optional, EXPLICIT */ } DERRevokedCert; /* DERItemSpecs to decode into a DERRevokedCert */ extern const DERItemSpec DERRevokedCertItemSpecs[]; extern const DERSize DERNumRevokedCertItemSpecs; #ifdef __cplusplus } #endif #endif /* _DER_CERT_CRL_H_ */ |
Added Source/libDER/libDER/DER_Decode.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | /* * Copyright (c) 2005-2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * DER_Decode.c - DER decoding routines */ #include "DER_Decode.h" #include "asn1Types.h" #include "libDER_config.h" #ifndef DER_DECODE_ENABLE #error Please define DER_DECODE_ENABLE. #endif #if DER_DECODE_ENABLE #define DER_DECODE_DEBUG 0 #if DER_DECODE_DEBUG #include <stdio.h> #define derDecDbg(a) printf(a) #define derDecDbg1(a, b) printf(a, b) #define derDecDbg2(a, b, c) printf(a, b, c) #define derDecDbg3(a, b, c, d) printf(a, b, c, d) #else #define derDecDbg(a) #define derDecDbg1(a, b) #define derDecDbg2(a, b, c) #define derDecDbg3(a, b, c, d) #endif /* DER_DECODE_DEBUG */ /* * Basic decoding primitive. Only works with: * * -- definite length encoding * -- one-byte tags * -- max content length fits in a DERSize * * No malloc or copy of the contents is performed; the returned * content->content.data is a pointer into the incoming der data. */ DERReturn DERDecodeItem( const DERItem *der, /* data to decode */ DERDecodedInfo *decoded) /* RETURNED */ { DERByte tag1; /* first tag byte */ DERByte len1; /* first length byte */ DERTag tagNumber; /* tag number without class and method bits */ DERByte *derPtr = der->data; DERSize derLen = der->length; /* The tag decoding below is fully BER complient. We support a max tag value of 2 ^ ((sizeof(DERTag) * 8) - 3) - 1 so for tag size 1 byte we support tag values from 0 - 0x1F. For tag size 2 tag values from 0 - 0x1FFF and for tag size 4 values from 0 - 0x1FFFFFFF. */ if(derLen < 2) { return DR_DecodeError; } /* Grab the first byte of the tag. */ tag1 = *derPtr++; derLen--; tagNumber = tag1 & 0x1F; if(tagNumber == 0x1F) { #ifdef DER_MULTIBYTE_TAGS /* Long tag form: bit 8 of each octet shall be set to one unless it is the last octet of the tag */ const DERTag overflowMask = ((DERTag)0x7F << (sizeof(DERTag) * 8 - 7)); DERByte tagByte; tagNumber = 0; do { if(derLen < 2 || (tagNumber & overflowMask) != 0) { return DR_DecodeError; } tagByte = *derPtr++; derLen--; tagNumber = (tagNumber << 7) | (tagByte & 0x7F); } while((tagByte & 0x80) != 0); /* Check for any of the top 3 reserved bits being set. */ if ((tagNumber & (overflowMask << 4)) != 0) #endif return DR_DecodeError; } /* Returned tag, top 3 bits are class/method remaining bits are number. */ decoded->tag = ((DERTag)(tag1 & 0xE0) << ((sizeof(DERTag) - 1) * 8)) | tagNumber; /* Tag decoding above ensured we have at least one more input byte left. */ len1 = *derPtr++; derLen--; if(len1 & 0x80) { /* long length form - first byte is length of length */ DERSize longLen = 0; /* long form length */ unsigned dex; len1 &= 0x7f; if((len1 > sizeof(DERSize)) || (len1 > derLen)) { /* no can do */ return DR_DecodeError; } for(dex=0; dex<len1; dex++) { longLen <<= 8; longLen |= *derPtr++; derLen--; } if(longLen > derLen) { /* not enough data left for this encoding */ return DR_DecodeError; } decoded->content.data = derPtr; decoded->content.length = longLen; } else { /* short length form, len1 is the length */ if(len1 > derLen) { /* not enough data left for this encoding */ return DR_DecodeError; } decoded->content.data = derPtr; decoded->content.length = len1; } return DR_Success; } /* * Given a BIT_STRING, in the form of its raw content bytes, * obtain the number of unused bits and the raw bit string bytes. */ DERReturn DERParseBitString( const DERItem *contents, DERItem *bitStringBytes, /* RETURNED */ DERByte *numUnusedBits) /* RETURNED */ { if(contents->length < 2) { /* not enough room for actual bits after the unused bits field */ *numUnusedBits = 0; bitStringBytes->data = NULL; bitStringBytes->length = 0; return DR_Success; } *numUnusedBits = contents->data[0]; bitStringBytes->data = contents->data + 1; bitStringBytes->length = contents->length - 1; return DR_Success; } /* * Given a BOOLEAN, in the form of its raw content bytes, * obtain it's value. */ DERReturn DERParseBoolean( const DERItem *contents, bool defaultValue, bool *value) { /* RETURNED */ if (contents->length == 0) { *value = defaultValue; return DR_Success; } if (contents->length != 1 || (contents->data[0] != 0 && contents->data[0] != 0xFF)) return DR_DecodeError; *value = contents->data[0] != 0; return DR_Success; } DERReturn DERParseInteger( const DERItem *contents, uint32_t *result) { /* RETURNED */ DERSize ix, length = contents->length; if (length > 4) return DR_BufOverflow; uint32_t value = 0; for (ix = 0; ix < length; ++ix) { value <<= 8; value += contents->data[ix]; } *result = value; return DR_Success; } /* Sequence/set support */ /* * To decode a set or sequence, call DERDecodeSeqInit once, then * call DERDecodeSeqNext to get each enclosed item. * DERDecodeSeqNext returns DR_EndOfSequence when no more * items are available. */ DERReturn DERDecodeSeqInit( const DERItem *der, /* data to decode */ DERTag *tag, /* RETURNED tag of sequence/set. This will be * either ASN1_CONSTR_SEQUENCE or ASN1_CONSTR_SET. */ DERSequence *derSeq) /* RETURNED, to use in DERDecodeSeqNext */ { DERDecodedInfo decoded; DERReturn drtn; drtn = DERDecodeItem(der, &decoded); if(drtn) { return drtn; } *tag = decoded.tag; switch(decoded.tag) { case ASN1_CONSTR_SEQUENCE: case ASN1_CONSTR_SET: break; default: return DR_UnexpectedTag; } derSeq->nextItem = decoded.content.data; derSeq->end = decoded.content.data + decoded.content.length; return DR_Success; } /* * Use this to start in on decoding a sequence's content, when * the top-level tag and content have already been decoded. */ DERReturn DERDecodeSeqContentInit( const DERItem *content, DERSequence *derSeq) /* RETURNED, to use in DERDecodeSeqNext */ { /* just prepare for decoding items in content */ derSeq->nextItem = content->data; derSeq->end = content->data + content->length; return DR_Success; } DERReturn DERDecodeSeqNext( DERSequence *derSeq, DERDecodedInfo *decoded) /* RETURNED */ { DERReturn drtn; DERItem item; if(derSeq->nextItem >= derSeq->end) { /* normal termination, contents all used up */ return DR_EndOfSequence; } /* decode next item */ item.data = derSeq->nextItem; item.length = derSeq->end - derSeq->nextItem; drtn = DERDecodeItem(&item, decoded); if(drtn) { return drtn; } /* skip over the item we just decoded */ derSeq->nextItem = decoded->content.data + decoded->content.length; return DR_Success; } /* * High level sequence parse, starting with top-level tag and content. * Top level tag must be ASN1_CONSTR_SEQUENCE - if it's not, and that's * OK, use DERParseSequenceContent(). */ DERReturn DERParseSequence( const DERItem *der, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize sizeToZero) /* optional */ { DERReturn drtn; DERDecodedInfo topDecode; drtn = DERDecodeItem(der, &topDecode); if(drtn) { return drtn; } if(topDecode.tag != ASN1_CONSTR_SEQUENCE) { return DR_UnexpectedTag; } return DERParseSequenceContent(&topDecode.content, numItems, itemSpecs, dest, sizeToZero); } /* high level sequence parse, starting with sequence's content */ DERReturn DERParseSequenceContent( const DERItem *content, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize sizeToZero) /* optional */ { DERSequence derSeq; DERReturn drtn; DERShort itemDex; DERByte *currDER; /* full DER encoding of current item */ if(sizeToZero) { DERMemset(dest, 0, sizeToZero); } drtn = DERDecodeSeqContentInit(content, &derSeq); if(drtn) { return drtn; } /* main loop */ for(itemDex=0 ; itemDex<numItems; ) { DERDecodedInfo currDecoded; DERShort i; DERTag foundTag; char foundMatch = 0; /* save this in case of DER_DEC_SAVE_DER */ currDER = derSeq.nextItem; drtn = DERDecodeSeqNext(&derSeq, &currDecoded); if(drtn) { /* * One legal error here is DR_EndOfSequence when * all remaining DERSequenceItems are optional. */ if(drtn == DR_EndOfSequence) { for(i=itemDex; i<numItems; i++) { if(!(itemSpecs[i].options & DER_DEC_OPTIONAL)) { /* unexpected end of sequence */ return DR_IncompleteSeq; } } /* the rest are optional; success */ return DR_Success; } else { /* any other error is fatal */ return drtn; } } /* decode error */ /* * Seek matching tag or ASN_ANY in itemSpecs, skipping * over optional items. */ foundTag = currDecoded.tag; derDecDbg1("--- foundTag 0x%x\n", foundTag); for(i=itemDex; i<numItems; i++) { const DERItemSpec *currItemSpec = &itemSpecs[i]; DERShort currOptions = currItemSpec->options; derDecDbg3("--- currItem %u expectTag 0x%x currOptions 0x%x\n", i, currItemSpec->tag, currOptions); if((currOptions & DER_DEC_ASN_ANY) || (foundTag == currItemSpec->tag)) { /* * We're good with this one. Cook up destination address * as appropriate. */ if(!(currOptions & DER_DEC_SKIP)) { derDecDbg1("--- MATCH at currItem %u\n", i); DERByte *byteDst = (DERByte *)dest + currItemSpec->offset; DERItem *dst = (DERItem *)byteDst; *dst = currDecoded.content; if(currOptions & DER_DEC_SAVE_DER) { /* recreate full DER encoding of this item */ derDecDbg1("--- SAVE_DER at currItem %u\n", i); dst->data = currDER; dst->length += (currDecoded.content.data - currDER); } } /* on to next item */ itemDex = i + 1; /* is this the end? */ if(itemDex == numItems) { /* normal termination */ return DR_Success; } else { /* on to next item */ foundMatch = 1; break; } } /* ASN_ANY, or match */ /* * If current itemSpec isn't optional, abort - else on to * next item */ if(!(currOptions & DER_DEC_OPTIONAL)) { derDecDbg1("--- MISMATCH at currItem %u, !OPTIONAL, abort\n", i); return DR_UnexpectedTag; } /* else this was optional, on to next item */ } /* searching for tag match */ if(foundMatch == 0) { /* * Found an item we couldn't match to any tag spec and we're at * the end. */ derDecDbg("--- TAG NOT FOUND, abort\n"); return DR_UnexpectedTag; } /* else on to next item */ } /* main loop */ /* * If we get here, there appears to be more to process, but we've * given the caller everything they want. */ return DR_Success; } #if 0 /* * High level sequence parse, starting with top-level tag and content. * Top level tag must be ASN1_CONSTR_SEQUENCE - if it's not, and that's * OK, use DERParseSequenceContent(). */ DERReturn DERParseSequenceOf( const DERItem *der, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize *numDestItems) /* output */ { DERReturn drtn; DERDecodedInfo topDecode; drtn = DERDecodeItem(der, &topDecode); if(drtn) { return drtn; } if(topDecode.tag != ASN1_CONSTR_SEQUENCE) { return DR_UnexpectedTag; } return DERParseSequenceContent(&topDecode.content, numItems, itemSpecs, dest, sizeToZero); } /* * High level set of parse, starting with top-level tag and content. * Top level tag must be ASN1_CONSTR_SET - if it's not, and that's * OK, use DERParseSetOrSequenceOfContent(). */ DERReturn DERParseSetOf( const DERItem *der, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize *numDestItems) /* output */ { DERReturn drtn; DERDecodedInfo topDecode; drtn = DERDecodeItem(der, &topDecode); if(drtn) { return drtn; } if(topDecode.tag != ASN1_CONSTR_SET) { return DR_UnexpectedTag; } return DERParseSetOrSequenceOfContent(&topDecode.content, numItems, itemSpecs, dest, numDestItems); } /* High level set of or sequence of parse, starting with set or sequence's content */ DERReturn DERParseSetOrSequenceOfContent( const DERItem *content, void(*itemHandeler)(void *, const DERDecodedInfo *) void *itemHandelerContext); { DERSequence derSeq; DERShort itemDex; drtn = DERDecodeSeqContentInit(content, &derSeq); require_noerr_quiet(drtn, badCert); /* main loop */ for (;;) { DERDecodedInfo currDecoded; DERShort i; DERByte foundTag; char foundMatch = 0; drtn = DERDecodeSeqNext(&derSeq, &currDecoded); if(drtn) { /* The only legal error here is DR_EndOfSequence. */ if(drtn == DR_EndOfSequence) { /* no more items left in the sequence; success */ return DR_Success; } else { /* any other error is fatal */ require_noerr_quiet(drtn, badCert); } } /* decode error */ /* Each element can be anything. */ foundTag = currDecoded.tag; /* * We're good with this one. Cook up destination address * as appropriate. */ DERByte *byteDst = (DERByte *)dest + currItemSpec->offset; DERItem *dst = (DERItem *)byteDst; *dst = currDecoded.content; if(currOptions & DER_DEC_SAVE_DER) { /* recreate full DER encoding of this item */ derDecDbg1("--- SAVE_DER at currItem %u\n", i); dst->data = currDER; dst->length += (currDecoded.content.data - currDER); } /* on to next item */ itemDex = i + 1; /* is this the end? */ if(itemDex == numItems) { /* normal termination */ return DR_Success; } else { /* on to next item */ foundMatch = 1; break; } /* * If current itemSpec isn't optional, abort - else on to * next item */ if(!(currOptions & DER_DEC_OPTIONAL)) { derDecDbg1("--- MISMATCH at currItem %u, !OPTIONAL, abort\n", i); return DR_UnexpectedTag; } /* else this was optional, on to next item */ } /* searching for tag match */ if(foundMatch == 0) { /* * Found an item we couldn't match to any tag spec and we're at * the end. */ derDecDbg("--- TAG NOT FOUND, abort\n"); return DR_UnexpectedTag; } /* else on to next item */ } /* main loop */ /* * If we get here, there appears to be more to process, but we've * given the caller everything they want. */ return DR_Success; } } #endif #endif /* DER_DECODE_ENABLE */ |
Added Source/libDER/libDER/DER_Decode.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | /* * Copyright (c) 2005-2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * DER_Decode.h - DER decoding routines */ #ifndef _DER_DECODE_H_ #define _DER_DECODE_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER.h" #include <stdbool.h> /* * Decoding one item consists of extracting its tag, a pointer * to the actual content, and the length of the content. Those * three are represented by a DERDecodedInfo. */ typedef struct { DERTag tag; DERItem content; } DERDecodedInfo; /* * Basic decoding primitive. Only works with: * * -- definite length encoding * -- one-byte tags * -- max content length fits in a DERSize * * No malloc or copy of the contents is performed; the returned * content->content.data is a pointer into the incoming der data. */ DERReturn DERDecodeItem( const DERItem *der, /* data to decode */ DERDecodedInfo *decoded); /* RETURNED */ /* * Given a BIT_STRING, in the form of its raw content bytes, * obtain the number of unused bits and the raw bit string bytes. */ DERReturn DERParseBitString( const DERItem *contents, DERItem *bitStringBytes, /* RETURNED */ DERByte *numUnusedBits); /* RETURNED */ /* * Given a BOOLEAN, in the form of its raw content bytes, * obtain it's value. */ DERReturn DERParseBoolean( const DERItem *contents, bool defaultValue, bool *value); /* RETURNED */ DERReturn DERParseInteger( const DERItem *contents, uint32_t *value); /* RETURNED */ /* * Sequence/set decode support. */ /* state representing a sequence or set being decoded */ typedef struct { DERByte *nextItem; DERByte *end; } DERSequence; /* * To decode a set or sequence, call DERDecodeSeqInit or * DERDecodeSeqContentInit once, then call DERDecodeSeqNext to * get each enclosed item. * * DERDecodeSeqNext returns DR_EndOfSequence when no more * items are available. */ /* * Use this to parse the top level sequence's tag and content length. */ DERReturn DERDecodeSeqInit( const DERItem *der, /* data to decode */ DERTag *tag, /* RETURNED tag of sequence/set. This will be * either ASN1_CONSTR_SEQUENCE or * ASN1_CONSTR_SET. */ DERSequence *derSeq); /* RETURNED, to use in DERDecodeSeqNext */ /* * Use this to start in on decoding a sequence's content, when * the top-level tag and content have already been decoded. */ DERReturn DERDecodeSeqContentInit( const DERItem *content, DERSequence *derSeq); /* RETURNED, to use in DERDecodeSeqNext */ /* obtain the next decoded item in a sequence or set */ DERReturn DERDecodeSeqNext( DERSequence *derSeq, DERDecodedInfo *decoded); /* RETURNED */ /* * High level sequence decode. */ /* * Per-item decode options. */ /* Explicit default, no options */ #define DER_DEC_NO_OPTS 0x0000 /* This item optional, can be skipped during decode */ #define DER_DEC_OPTIONAL 0x0001 /* Skip the tag check; accept anything. */ #define DER_DEC_ASN_ANY 0x0002 /* Skip item, no write to DERDecodedInfo (but tag check still performed) */ #define DER_DEC_SKIP 0x0004 /* Save full DER encoding in DERDecodedInfo, including tag and length. Normally * only the content is saved. */ #define DER_DEC_SAVE_DER 0x0008 /* * High level sequence parse, starting with top-level tag and content. * Top level tag must be ASN1_CONSTR_SEQUENCE - if it's not, and that's * OK, use DERParseSequenceContent(). * * These never return DR_EndOfSequence - if an *unexpected* end of sequence * occurs, return DR_IncompleteSeq. * * Results of the decoding of one item are placed in a DERItem whose address * is the dest arg plus the offset value in the associated DERItemSpec. * * Items which are optional (DER_DEC_OPTIONAL) and which are not found, * leave their associated DERDecodedInfos unmodified. * * Processing of a sequence ends on detection of any error or after the * last DERItemSpec is processed. * * The sizeToZero argument, if nonzero, indicates the number of bytes * starting at dest to zero before processing the sequence. This is * generally desirable, particularly if there are any DER_DEC_OPTIONAL * items in the sequence; skipped optional items are detected by the * caller via a NULL DERDecodedInfo.content.data; if this hasn't been * explicitly zeroed (generally, by passing a nonzero value of sizeToZero), * skipped items can't be detected. */ DERReturn DERParseSequence( const DERItem *der, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize sizeToZero); /* optional */ /* high level sequence parse, starting with sequence's content */ DERReturn DERParseSequenceContent( const DERItem *content, DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, void *dest, /* DERDecodedInfo(s) here RETURNED */ DERSize sizeToZero); /* optional */ #ifdef __cplusplus } #endif #endif /* _DER_DECODE_H_ */ |
Added Source/libDER/libDER/DER_Digest.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | /* Copyright (c) 2005-2008,2010 Apple Inc. All Rights Reserved. */ /* * DER_Digest.h - DER encode a DigestInfo * * Created Nov. 9 2005 by dmitch */ #include "DER_Digest.h" /* * Create an encoded DigestInfo based on the specified SHA1 digest. * The digest must be 20 bytes long. * * Result is placed in caller's buffer, which must be at least of * length DER_DIGEST_INFO_LEN bytes. * * The *resultLen parameter is the available size in the result * buffer on input, and the actual length of the encoded DigestInfo * on output. * * In the interest of saving code space, this just drops the caller's * digest into an otherwise hard-coded, fixed, encoded SHA1 DigestInfo. * Nothing is variable so we know the whole thing. It looks like this: * * SEQUENCE OF <33> { * SEQUENCE OF <9> { * OID <5>: OID : < 06 05 2B 0E 03 02 1A > * NULL * } * OCTET STRING <20>: * 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 * 55 55 55 55 * } * * * tower.local:digestInfo> hexdump -x /tmp/encodedDigest * 0000000 3021 3009 0605 2b0e 0302 1a05 0004 1455 * 0000010 5555 5555 5555 5555 5555 5555 5555 5555 * * * 0000020 */ static const unsigned char encodedSha1Digest[] = { 0x30, 0x21, /* top level sequence length 33 */ 0x30, 0x09, /* algorithm ID, sequence length 9 */ 0x06, 0x05, /* alg OID, length 5, SHA1 */ 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, /* NULL parameters */ 0x04, 0x14 /* integer length 20 */ /* digest follows */ }; DERReturn DEREncodeSHA1DigestInfo( const DERByte *sha1Digest, DERSize sha1DigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen) /* IN/OUT */ { DERSize totalLen = sizeof(encodedSha1Digest) + DER_SHA1_DIGEST_LEN; if((sha1Digest == NULL) || (sha1DigestLen != DER_SHA1_DIGEST_LEN) || (result == NULL) || (resultLen == NULL)) { return DR_ParamErr; } if(*resultLen < DER_SHA1_DIGEST_INFO_LEN) { return DR_BufOverflow; } DERMemmove(result, encodedSha1Digest, sizeof(encodedSha1Digest)); DERMemmove(result + sizeof(encodedSha1Digest), sha1Digest, DER_SHA1_DIGEST_LEN); *resultLen = totalLen; return DR_Success; } /* joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashAlgs(2) sha256(1) future ones to add: sha384(2) sha512(3) sha224(4) */ static const unsigned char encodedSha256Digest[] = { 0x30, 0x31, /* top level sequence length 49 */ 0x30, 0x0d, /* algorithm ID, sequence length 13 */ 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, /* NULL parameters */ 0x04, 0x20 /* integer length 32 */ /* digest follows */ }; DERReturn DEREncodeSHA256DigestInfo( const DERByte *sha256Digest, DERSize sha256DigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen) /* IN/OUT */ { DERSize totalLen = sizeof(encodedSha256Digest) + DER_SHA256_DIGEST_LEN; if((sha256Digest == NULL) || (sha256DigestLen != DER_SHA256_DIGEST_LEN) || (result == NULL) || (resultLen == NULL)) { return DR_ParamErr; } if(*resultLen < DER_SHA256_DIGEST_INFO_LEN) { return DR_BufOverflow; } DERMemmove(result, encodedSha256Digest, sizeof(encodedSha256Digest)); DERMemmove(result + sizeof(encodedSha256Digest), sha256Digest, DER_SHA256_DIGEST_LEN); *resultLen = totalLen; return DR_Success; } /* Same thing, MD5/MD2 */ static const unsigned char encodedMdDigest[] = { 0x30, 0x20, /* top level sequence length 32 */ 0x30, 0x0c, /* algorithm ID, sequence length 12 */ 0x06, 0x08, /* alg OID, length 8, MD2/MD5 */ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, /* 5 = MD5, 2 = MD2 */ 0x05, 0x00, /* NULL parameters */ 0x04, 0x10 /* integer length 16 */ /* digest follows */ }; #define WHICH_DIGEST_INDEX 13 #define WHICH_DIGEST_MD2 2 #define WHICH_DIGEST_MD5 5 DERReturn DEREncodeMDDigestInfo( WhichDigest whichDigest, const DERByte *mdDigest, DERSize mdDigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen) /* IN/OUT */ { DERSize totalLen = sizeof(encodedMdDigest) + DER_MD_DIGEST_LEN; if((mdDigest == NULL) || (mdDigestLen != DER_MD_DIGEST_LEN) || (result == NULL) || (resultLen == NULL)) { return DR_ParamErr; } if(*resultLen < totalLen) { return DR_BufOverflow; } DERMemmove(result, encodedMdDigest, sizeof(encodedMdDigest)); DERMemmove(result + sizeof(encodedMdDigest), mdDigest, DER_MD_DIGEST_LEN); switch(whichDigest) { case WD_MD2: result[WHICH_DIGEST_INDEX] = WHICH_DIGEST_MD2; break; case WD_MD5: result[WHICH_DIGEST_INDEX] = WHICH_DIGEST_MD5; break; default: return DR_ParamErr; } *resultLen = totalLen; return DR_Success; } |
Added Source/libDER/libDER/DER_Digest.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /* Copyright (c) 2005-2008,2010 Apple Inc. All Rights Reserved. */ /* * DER_Digest.h - DER encode a DigestInfo * * Created Nov. 9 2005 by dmitch */ #ifndef _DER_DIGEST_H_ #define _DER_DIGEST_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER.h" /* * Create an encoded DigestInfo based on the specified SHA1 digest. * The incoming digest must be 20 bytes long. * * Result is placed in caller's buffer, which must be at least of * length DER_SHA1_DIGEST_INFO_LEN bytes. * * The *resultLen parameter is the available size in the result * buffer on input, and the actual length of the encoded DigestInfo * on output. */ #define DER_SHA1_DIGEST_LEN 20 #define DER_SHA1_DIGEST_INFO_LEN 35 DERReturn DEREncodeSHA1DigestInfo( const DERByte *sha1Digest, DERSize sha1DigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen); /* IN/OUT */ #define DER_SHA256_DIGEST_LEN 32 #define DER_SHA256_DIGEST_INFO_LEN 51 DERReturn DEREncodeSHA256DigestInfo( const DERByte *sha256Digest, DERSize sha256DigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen); /* IN/OUT */ /* * Likewise, create an encoded DIgestInfo for specified MD5 or MD2 digest. */ #define DER_MD_DIGEST_LEN 16 #define DER_MD_DIGEST_INFO_LEN 34 typedef enum { WD_MD2 = 1, WD_MD5 = 2 } WhichDigest; DERReturn DEREncodeMDDigestInfo( WhichDigest whichDigest, const DERByte *mdDigest, DERSize mdDigestLen, DERByte *result, /* encoded result RETURNED here */ DERSize *resultLen); /* IN/OUT */ /* max sizes you'll need in the general cases */ #define DER_MAX_DIGEST_LEN DER_SHA256_DIGEST_LEN #define DER_MAX_ENCODED_INFO_LEN DER_SHA256_DIGEST_INFO_LEN #ifdef __cplusplus } #endif #endif /* _DER_DIGEST_H_ */ |
Added Source/libDER/libDER/DER_Encode.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * DER_Encode.h - DER encoding routines * * Created Dec. 2 2005 by dmitch */ #include "DER_Encode.h" #include "asn1Types.h" #include "libDER_config.h" #include "DER_Decode.h" #ifndef DER_ENCODE_ENABLE #error Please define DER_ENCODE_ENABLE. #endif #if DER_ENCODE_ENABLE /* calculate size of encoded tag */ static DERSize DERLengthOfTag( DERTag tag) { DERSize rtn = 1; tag &= ASN1_TAGNUM_MASK; if (tag >= 0x1F) { /* Shift 7-bit digits out of the tag integer until it's zero. */ while(tag != 0) { rtn++; tag >>= 7; } } return rtn; } /* encode tag */ static DERReturn DEREncodeTag( DERTag tag, DERByte *buf, /* encoded length goes here */ DERSize *inOutLen) /* IN/OUT */ { DERSize outLen = DERLengthOfTag(tag); DERTag tagNumber = tag & ASN1_TAGNUM_MASK; DERByte tag1 = (tag >> (sizeof(DERTag) * 8 - 8)) & 0xE0; if(outLen > *inOutLen) { return DR_BufOverflow; } if(outLen == 1) { /* short form */ *buf = tag1 | tagNumber; } else { /* long form */ DERByte *tagBytes = buf + outLen; // l.s. digit of tag *buf = tag1 | 0x1F; // tag class / method indicator *--tagBytes = tagNumber & 0x7F; tagNumber >>= 7; while(tagNumber != 0) { *--tagBytes = (tagNumber & 0x7F) | 0x80; tagNumber >>= 7; } } *inOutLen = outLen; return DR_Success; } /* calculate size of encoded length */ DERSize DERLengthOfLength( DERSize length) { DERSize rtn; if(length < 0x80) { /* short form length */ return 1; } /* long form - one length-of-length byte plus length bytes */ rtn = 1; while(length != 0) { rtn++; length >>= 8; } return rtn; } /* encode length */ DERReturn DEREncodeLength( DERSize length, DERByte *buf, /* encoded length goes here */ DERSize *inOutLen) /* IN/OUT */ { DERByte *lenBytes; DERSize outLen = DERLengthOfLength(length); if(outLen > *inOutLen) { return DR_BufOverflow; } if(length < 0x80) { /* short form */ *buf = (DERByte)length; *inOutLen = 1; return DR_Success; } /* long form */ *buf = (outLen - 1) | 0x80; // length of length, long form indicator lenBytes = buf + outLen - 1; // l.s. digit of length while(length != 0) { *lenBytes-- = (DERByte)length; length >>= 8; } *inOutLen = outLen; return DR_Success; } DERSize DERLengthOfItem( DERTag tag, DERSize length) { return DERLengthOfTag(tag) + DERLengthOfLength(length) + length; } DERReturn DEREncodeItem( DERTag tag, DERSize length, const DERByte *src, DERByte *derOut, /* encoded item goes here */ DERSize *inOutLen) /* IN/OUT */ { DERReturn drtn; DERSize itemLen; DERByte *currPtr = derOut; DERSize bytesLeft = DERLengthOfItem(tag, length); if(bytesLeft > *inOutLen) { return DR_BufOverflow; } *inOutLen = bytesLeft; /* top level tag */ itemLen = bytesLeft; drtn = DEREncodeTag(tag, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; itemLen = bytesLeft; drtn = DEREncodeLength(length, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; DERMemmove(currPtr, src, length); return DR_Success; } static /* calculate the content length of an encoded sequence */ DERSize DERContentLengthOfEncodedSequence( const void *src, /* generally a ptr to a struct full of * DERItems */ DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs) { DERSize contentLen = 0; unsigned dex; DERSize thisContentLen; /* find length of each item */ for(dex=0; dex<numItems; dex++) { const DERItemSpec *currItemSpec = &itemSpecs[dex]; DERShort currOptions = currItemSpec->options; const DERByte *byteSrc = (const DERByte *)src + currItemSpec->offset; const DERItem *itemSrc = (const DERItem *)byteSrc; if(currOptions & DER_ENC_WRITE_DER) { /* easy case - no encode */ contentLen += itemSrc->length; continue; } if ((currOptions & DER_DEC_OPTIONAL) && itemSrc->length == 0) { /* If an optional item isn't present we don't encode a tag and len. */ continue; } /* * length of this item = * tag (one byte) + * length of length + * content length + * optional zero byte for signed integer */ contentLen += DERLengthOfTag(currItemSpec->tag); /* check need for pad byte before calculating lengthOfLength... */ thisContentLen = itemSrc->length; if((currOptions & DER_ENC_SIGNED_INT) && (itemSrc->length != 0)) { if(itemSrc->data[0] & 0x80) { /* insert zero keep it positive */ thisContentLen++; } } contentLen += DERLengthOfLength(thisContentLen); contentLen += thisContentLen; } return contentLen; } DERReturn DEREncodeSequence( DERTag topTag, /* ASN1_CONSTR_SEQUENCE, ASN1_CONSTR_SET */ const void *src, /* generally a ptr to a struct full of * DERItems */ DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, DERByte *derOut, /* encoded data written here */ DERSize *inOutLen) /* IN/OUT */ { const DERByte *endPtr = derOut + *inOutLen; DERByte *currPtr = derOut; DERSize bytesLeft = *inOutLen; DERSize contentLen; DERReturn drtn; DERSize itemLen; unsigned dex; /* top level tag */ itemLen = bytesLeft; drtn = DEREncodeTag(topTag, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; if(currPtr >= endPtr) { return DR_BufOverflow; } /* content length */ contentLen = DERContentLengthOfEncodedSequence(src, numItems, itemSpecs); itemLen = bytesLeft; drtn = DEREncodeLength(contentLen, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; if(currPtr + contentLen > endPtr) { return DR_BufOverflow; } /* we don't have to check for overflow any more */ /* grind thru the items */ for(dex=0; dex<numItems; dex++) { const DERItemSpec *currItemSpec = &itemSpecs[dex]; DERShort currOptions = currItemSpec->options; const DERByte *byteSrc = (const DERByte *)src + currItemSpec->offset; const DERItem *itemSrc = (const DERItem *)byteSrc; int prependZero = 0; if(currOptions & DER_ENC_WRITE_DER) { /* easy case */ DERMemmove(currPtr, itemSrc->data, itemSrc->length); currPtr += itemSrc->length; bytesLeft -= itemSrc->length; continue; } if ((currOptions & DER_DEC_OPTIONAL) && itemSrc->length == 0) { /* If an optional item isn't present we skip it. */ continue; } /* encode one item: first the tag */ itemLen = bytesLeft; drtn = DEREncodeTag(currItemSpec->tag, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; /* do we need to prepend a zero to content? */ contentLen = itemSrc->length; if((currOptions & DER_ENC_SIGNED_INT) && (itemSrc->length != 0)) { if(itemSrc->data[0] & 0x80) { /* insert zero keep it positive */ contentLen++; prependZero = 1; } } /* encode content length */ itemLen = bytesLeft; drtn = DEREncodeLength(contentLen, currPtr, &itemLen); if(drtn) { return drtn; } currPtr += itemLen; bytesLeft -= itemLen; /* now the content, with possible leading zero added */ if(prependZero) { *currPtr++ = 0; bytesLeft--; } DERMemmove(currPtr, itemSrc->data, itemSrc->length); currPtr += itemSrc->length; bytesLeft -= itemSrc->length; } *inOutLen = (currPtr - derOut); return DR_Success; } /* calculate the length of an encoded sequence. */ DERSize DERLengthOfEncodedSequence( DERTag topTag, const void *src, /* generally a ptr to a struct full of * DERItems */ DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs) { DERSize contentLen = DERContentLengthOfEncodedSequence( src, numItems, itemSpecs); return DERLengthOfTag(topTag) + DERLengthOfLength(contentLen) + contentLen; } #endif /* DER_ENCODE_ENABLE */ |
Added Source/libDER/libDER/DER_Encode.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * DER_Encode.h - DER encoding routines * * Created Dec. 2 2005 by dmitch */ #ifndef _DER_ENCCODE_H_ #define _DER_ENCODE_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER.h" /* * Max size of an encoded item given its length. * This includes a possible leading zero prepended to a signed integer * (see DER_ENC_SIGNED_INT below). */ #define DER_MAX_ENCODED_SIZE(len) \ ( 1 + /* tag */ \ 5 + /* max length */ \ 1 + /* possible prepended zero */ \ len) /* calculate size of encoded length */ DERSize DERLengthOfLength( DERSize length); /* encode length */ DERReturn DEREncodeLength( DERSize length, DERByte *buf, /* encoded length goes here */ DERSize *inOutLen); /* IN/OUT */ /* calculate size of encoded length */ DERSize DERLengthOfItem( DERTag tag, DERSize length); /* encode item */ DERReturn DEREncodeItem( DERTag tag, DERSize length, const DERByte *src, DERByte *derOut, /* encoded item goes here */ DERSize *inOutLen); /* IN/OUT */ /* * Per-item encode options. */ /* explicit default, no options */ #define DER_ENC_NO_OPTS 0x0000 /* signed integer check: if incoming m.s. bit is 1, prepend a zero */ #define DER_ENC_SIGNED_INT 0x0100 /* DERItem contains fully encoded item - copy, don't encode */ #define DER_ENC_WRITE_DER 0x0200 /* * High-level sequence or set encode support. * * The outgoing sequence is expressed as an array of DERItemSpecs, each * of which corresponds to one item in the encoded sequence. * * Normally the tag of the encoded item comes from the associated * DERItemSpec, and the content comes from the DERItem whose address is * the src arg plus the offset value in the associated DERItemSpec. * * If the DER_ENC_WRITE_DER option is true for a given DERItemSpec then * no per-item encoding is done; the DER - with tag, length, and content - * is taken en masse from the associated DERItem. */ DERReturn DEREncodeSequence( DERTag topTag, /* ASN1_CONSTR_SEQUENCE, ASN1_CONSTR_SET */ const void *src, /* generally a ptr to a struct full of * DERItems */ DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs, DERByte *derOut, /* encoded data written here */ DERSize *inOutLen); /* IN/OUT */ /* precalculate the length of an encoded sequence. */ DERSize DERLengthOfEncodedSequence( DERTag topTag, /* ASN1_CONSTR_SEQUENCE, ASN1_CONSTR_SET */ const void *src, /* generally a ptr to a struct full of * DERItems */ DERShort numItems, /* size of itemSpecs[] */ const DERItemSpec *itemSpecs); #ifdef __cplusplus } #endif #endif /* _DER_DECODE_H_ */ |
Added Source/libDER/libDER/DER_Keys.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * DER_Cert.c - support for decoding RSA keys * * Created Nov. 8 2005 by Doug Mitchell. */ #include "DER_Decode.h" #include "DER_Encode.h" #include "DER_Keys.h" #include "asn1Types.h" #include "libDER_config.h" #ifndef DER_DECODE_ENABLE #error Please define DER_DECODE_ENABLE. #endif #if DER_DECODE_ENABLE /* * DERItemSpecs for decoding RSA keys. */ /* Algorithm Identifier */ const DERItemSpec DERAlgorithmIdItemSpecs[] = { { DER_OFFSET(DERAlgorithmId, oid), ASN1_OBJECT_ID, DER_DEC_NO_OPTS }, { DER_OFFSET(DERAlgorithmId, params), 0, /* no tag - any */ DER_DEC_ASN_ANY | DER_DEC_OPTIONAL | DER_DEC_SAVE_DER } }; const DERSize DERNumAlgorithmIdItemSpecs = sizeof(DERAlgorithmIdItemSpecs) / sizeof(DERItemSpec); /* X509 SubjectPublicKeyInfo */ const DERItemSpec DERSubjPubKeyInfoItemSpecs[] = { { DER_OFFSET(DERSubjPubKeyInfo, algId), ASN1_CONSTR_SEQUENCE, DER_DEC_NO_OPTS }, { DER_OFFSET(DERSubjPubKeyInfo, pubKey), ASN1_BIT_STRING, DER_DEC_NO_OPTS }, }; const DERSize DERNumSubjPubKeyInfoItemSpecs = sizeof(DERSubjPubKeyInfoItemSpecs) / sizeof(DERItemSpec); /* * RSA private key in CRT format */ const DERItemSpec DERRSAPrivKeyCRTItemSpecs[] = { /* version, n, e, d - skip */ { 0, ASN1_INTEGER, DER_DEC_SKIP }, { 0, ASN1_INTEGER, DER_DEC_SKIP }, { 0, ASN1_INTEGER, DER_DEC_SKIP }, { 0, ASN1_INTEGER, DER_DEC_SKIP }, { DER_OFFSET(DERRSAPrivKeyCRT, p), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERRSAPrivKeyCRT, q), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERRSAPrivKeyCRT, dp), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERRSAPrivKeyCRT, dq), ASN1_INTEGER, DER_DEC_NO_OPTS }, { DER_OFFSET(DERRSAPrivKeyCRT, qInv), ASN1_INTEGER, DER_DEC_NO_OPTS }, /* ignore the (optional) rest */ }; const DERSize DERNumRSAPrivKeyCRTItemSpecs = sizeof(DERRSAPrivKeyCRTItemSpecs) / sizeof(DERItemSpec); #endif /* DER_DECODE_ENABLE */ #if DER_DECODE_ENABLE || DER_ENCODE_ENABLE /* RSA public key in PKCS1 format - encode and decode */ const DERItemSpec DERRSAPubKeyPKCS1ItemSpecs[] = { { DER_OFFSET(DERRSAPubKeyPKCS1, modulus), ASN1_INTEGER, DER_DEC_NO_OPTS | DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAPubKeyPKCS1, pubExponent), ASN1_INTEGER, DER_DEC_NO_OPTS | DER_ENC_SIGNED_INT }, }; const DERSize DERNumRSAPubKeyPKCS1ItemSpecs = sizeof(DERRSAPubKeyPKCS1ItemSpecs) / sizeof(DERItemSpec); /* RSA public key in Apple custome format with reciprocal - encode and decode */ const DERItemSpec DERRSAPubKeyAppleItemSpecs[] = { { DER_OFFSET(DERRSAPubKeyApple, modulus), ASN1_INTEGER, DER_DEC_NO_OPTS | DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAPubKeyApple, reciprocal), ASN1_INTEGER, DER_DEC_NO_OPTS | DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAPubKeyApple, pubExponent), ASN1_INTEGER, DER_DEC_NO_OPTS | DER_ENC_SIGNED_INT }, }; const DERSize DERNumRSAPubKeyAppleItemSpecs = sizeof(DERRSAPubKeyAppleItemSpecs) / sizeof(DERItemSpec); #endif /* DER_DECODE_ENABLE || DER_ENCODE_ENABLE */ #ifndef DER_ENCODE_ENABLE #error Please define DER_ENCODE_ENABLE. #endif #if DER_ENCODE_ENABLE /* RSA Key Pair, encode only */ const DERItemSpec DERRSAKeyPairItemSpecs[] = { { DER_OFFSET(DERRSAKeyPair, version), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, n), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, e), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, d), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, p), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, q), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, dp), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, dq), ASN1_INTEGER, DER_ENC_SIGNED_INT }, { DER_OFFSET(DERRSAKeyPair, qInv), ASN1_INTEGER, DER_ENC_SIGNED_INT }, }; const DERSize DERNumRSAKeyPairItemSpecs = sizeof(DERRSAKeyPairItemSpecs) / sizeof(DERItemSpec); #endif /* DER_ENCODE_ENABLE */ |
Added Source/libDER/libDER/DER_Keys.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * DER_Keys.h - support for decoding RSA keys * * Created Nov. 8 2005 by dmitch */ #ifndef _DER_KEYS_H_ #define _DER_KEYS_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER.h" #include "DER_Decode.h" /* Algorithm Identifier components */ typedef struct { DERItem oid; /* OID */ DERItem params; /* ASN_ANY, optional, DER_DEC_SAVE_DER */ } DERAlgorithmId; /* DERItemSpecs to decode into a DERAlgorithmId */ extern const DERItemSpec DERAlgorithmIdItemSpecs[]; extern const DERSize DERNumAlgorithmIdItemSpecs; /* X509 SubjectPublicKeyInfo */ typedef struct { DERItem algId; /* sequence, DERAlgorithmId */ DERItem pubKey; /* BIT STRING */ } DERSubjPubKeyInfo; /* DERItemSpecs to decode into a DERSubjPubKeyInfo */ extern const DERItemSpec DERSubjPubKeyInfoItemSpecs[]; extern const DERSize DERNumSubjPubKeyInfoItemSpecs; /* * RSA public key in PKCS1 format; this is inside the BIT_STRING in * DERSubjPubKeyInfo.pubKey. */ typedef struct { DERItem modulus; /* n - INTEGER */ DERItem pubExponent; /* e - INTEGER */ } DERRSAPubKeyPKCS1; /* DERItemSpecs to decode/encode into/from a DERRSAPubKeyPKCS1 */ extern const DERItemSpec DERRSAPubKeyPKCS1ItemSpecs[]; extern const DERSize DERNumRSAPubKeyPKCS1ItemSpecs; /* * RSA public key in custom (to this library) format, including * the reciprocal. All fields are integers. */ typedef struct { DERItem modulus; /* n */ DERItem reciprocal; /* reciprocal of modulus */ DERItem pubExponent; /* e */ } DERRSAPubKeyApple; /* DERItemSpecs to decode/encode into/from a DERRSAPubKeyApple */ extern const DERItemSpec DERRSAPubKeyAppleItemSpecs[]; extern const DERSize DERNumRSAPubKeyAppleItemSpecs; /* * RSA Private key, PKCS1 format, CRT option. * All fields are integers. */ typedef struct { DERItem p; /* p * q = n */ DERItem q; DERItem dp; /* d mod (p-1) */ DERItem dq; /* d mod (q-1) */ DERItem qInv; } DERRSAPrivKeyCRT; /* DERItemSpecs to decode into a DERRSAPrivKeyCRT */ extern const DERItemSpec DERRSAPrivKeyCRTItemSpecs[]; extern const DERSize DERNumRSAPrivKeyCRTItemSpecs; /* Fully formed RSA key pair, for generating a PKCS1 private key */ typedef struct { DERItem version; DERItem n; /* modulus */ DERItem e; /* public exponent */ DERItem d; /* private exponent */ DERItem p; /* n = p*q */ DERItem q; DERItem dp; /* d mod (p-1) */ DERItem dq; /* d mod (q-1) */ DERItem qInv; /* q^(-1) mod p */ } DERRSAKeyPair; /* DERItemSpecs to encode a DERRSAKeyPair */ extern const DERItemSpec DERRSAKeyPairItemSpecs[]; extern const DERSize DERNumRSAKeyPairItemSpecs; #ifdef __cplusplus } #endif #endif /* _DER_KEYS_H_ */ |
Added Source/libDER/libDER/asn1Types.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * asn1Types.h - ASN.1/DER #defines - strictly hard coded per the real world * * Created Nov. 4 2005 by dmitch */ #ifndef _ASN1_TYPES_H_ #define _ASN1_TYPES_H_ #ifdef __cplusplus extern "C" { #endif /* copied from libsecurity_asn1 project */ #define ASN1_BOOLEAN 0x01 #define ASN1_INTEGER 0x02 #define ASN1_BIT_STRING 0x03 #define ASN1_OCTET_STRING 0x04 #define ASN1_NULL 0x05 #define ASN1_OBJECT_ID 0x06 #define ASN1_OBJECT_DESCRIPTOR 0x07 /* External type and instance-of type 0x08 */ #define ASN1_REAL 0x09 #define ASN1_ENUMERATED 0x0a #define ASN1_EMBEDDED_PDV 0x0b #define ASN1_UTF8_STRING 0x0c /* 0x0d */ /* 0x0e */ /* 0x0f */ #define ASN1_SEQUENCE 0x10 #define ASN1_SET 0x11 #define ASN1_NUMERIC_STRING 0x12 #define ASN1_PRINTABLE_STRING 0x13 #define ASN1_T61_STRING 0x14 #define ASN1_VIDEOTEX_STRING 0x15 #define ASN1_IA5_STRING 0x16 #define ASN1_UTC_TIME 0x17 #define ASN1_GENERALIZED_TIME 0x18 #define ASN1_GRAPHIC_STRING 0x19 #define ASN1_VISIBLE_STRING 0x1a #define ASN1_GENERAL_STRING 0x1b #define ASN1_UNIVERSAL_STRING 0x1c /* 0x1d */ #define ASN1_BMP_STRING 0x1e #define ASN1_HIGH_TAG_NUMBER 0x1f #define ASN1_TELETEX_STRING ASN1_T61_STRING #ifdef DER_MULTIBYTE_TAGS #define ASN1_TAG_MASK ((DERTag)~0) #define ASN1_TAGNUM_MASK ((DERTag)~((DERTag)7 << (sizeof(DERTag) * 8 - 3))) #define ASN1_METHOD_MASK ((DERTag)1 << (sizeof(DERTag) * 8 - 3)) #define ASN1_PRIMITIVE ((DERTag)0 << (sizeof(DERTag) * 8 - 3)) #define ASN1_CONSTRUCTED ((DERTag)1 << (sizeof(DERTag) * 8 - 3)) #define ASN1_CLASS_MASK ((DERTag)3 << (sizeof(DERTag) * 8 - 2)) #define ASN1_UNIVERSAL ((DERTag)0 << (sizeof(DERTag) * 8 - 2)) #define ASN1_APPLICATION ((DERTag)1 << (sizeof(DERTag) * 8 - 2)) #define ASN1_CONTEXT_SPECIFIC ((DERTag)2 << (sizeof(DERTag) * 8 - 2)) #define ASN1_PRIVATE ((DERTag)3 << (sizeof(DERTag) * 8 - 2)) #else /* DER_MULTIBYTE_TAGS */ #define ASN1_TAG_MASK 0xff #define ASN1_TAGNUM_MASK 0x1f #define ASN1_METHOD_MASK 0x20 #define ASN1_PRIMITIVE 0x00 #define ASN1_CONSTRUCTED 0x20 #define ASN1_CLASS_MASK 0xc0 #define ASN1_UNIVERSAL 0x00 #define ASN1_APPLICATION 0x40 #define ASN1_CONTEXT_SPECIFIC 0x80 #define ASN1_PRIVATE 0xc0 #endif /* !DER_MULTIBYTE_TAGS */ /* sequence and set appear as the following */ #define ASN1_CONSTR_SEQUENCE (ASN1_CONSTRUCTED | ASN1_SEQUENCE) #define ASN1_CONSTR_SET (ASN1_CONSTRUCTED | ASN1_SET) #ifdef __cplusplus } #endif #endif /* _ASN1_TYPES_H_ */ |
Added Source/libDER/libDER/libDER.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * libDER.h - main header for libDER, a ROM-capable DER decoding library. * * Created Nov. 4 2005 by dmitch */ #ifndef _LIB_DER_H_ #define _LIB_DER_H_ #ifdef __cplusplus extern "C" { #endif #include "libDER_config.h" /* * Error returns generated by this library. */ typedef enum { DR_Success, DR_EndOfSequence, /* end of sequence or set */ DR_UnexpectedTag, /* unexpected tag found while decoding */ DR_DecodeError, /* misc. decoding error (badly formatted DER) */ DR_Unimplemented, /* function not implemented in this configuration */ DR_IncompleteSeq, /* incomplete sequence */ DR_ParamErr, /* incoming parameter error */ DR_BufOverflow /* buffer overflow */ /* etc. */ } DERReturn; /* * Primary representation of a block of memory. */ typedef struct { DERByte *data; DERSize length; } DERItem; /* * The structure of a sequence during decode or encode is expressed as * an array of DERItemSpecs. While decoding or encoding a sequence, * each item in the sequence corresponds to one DERItemSpec. */ typedef struct { DERSize offset; /* offset of destination DERItem */ DERTag tag; /* DER tag */ DERShort options; /* DER_DEC_xxx or DER_ENC_xxx */ } DERItemSpec; /* * Macro to obtain offset of a DERDecodedInfo within a struct. * FIXME this is going to need reworking to avoid compiler warnings * on 64-bit compiles. It'll work OK as long as an offset can't be larger * than a DERSize, but the cast from a pointer to a DERSize may * provoke compiler warnings. */ #define DER_OFFSET(type, field) ((DERSize)(&((type *)0)->field)) #ifdef __cplusplus } #endif #endif /* _LIB_DER_H_ */ |
Added Source/libDER/libDER/libDER_config.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * libDER_config.h - platform dependent #defines and typedefs for libDER * * Created Nov. 4 2005 by dmitch */ #ifndef _LIB_DER_CONFIG_H_ #define _LIB_DER_CONFIG_H_ #include <stdint.h> #include <string.h> #ifdef __cplusplus extern "C" { #endif /* * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer */ typedef uint8_t DERByte; typedef uint16_t DERShort; typedef size_t DERSize; /* * Use these #defines of you have memset, memmove, and memcmp; else * write your own equivalents. */ #define DERMemset(ptr, c, len) memset(ptr, c, len) #define DERMemmove(dst, src, len) memmove(dst, src, len) #define DERMemcmp(b1, b2, len) memcmp(b1, b2, len) /*** *** Compile time options to trim size of the library. ***/ /* enable general DER encode */ #define DER_ENCODE_ENABLE 1 /* enable general DER decode */ #define DER_DECODE_ENABLE 1 #ifndef DER_MULTIBYTE_TAGS /* enable multibyte tag support. */ #define DER_MULTIBYTE_TAGS 1 #endif #ifndef DER_TAG_SIZE /* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that tags are still encoded and decoded from a minimally encoded DER represantation. This value determines how big each DERItemSpecs is, we choose 2 since that makes DERItemSpecs 8 bytes wide. */ #define DER_TAG_SIZE 2 #endif /* ---------------------- Do not edit below this line ---------------------- */ /* * Logical representation of a tag (the encoded representation is always in * the minimal number of bytes). The top 3 bits encode class and method * The remaining bits encode the tag value. To obtain smaller DERItemSpecs * sizes, choose the smallest type that fits your needs. Most standard ASN.1 * usage only needs single byte tags, but ocasionally custom applications * require a larger tag namespace. */ #if DER_MULTIBYTE_TAGS #if DER_TAG_SIZE == 1 typedef uint8_t DERTag; #elif DER_TAG_SIZE == 2 typedef uint16_t DERTag; #elif DER_TAG_SIZE == 4 typedef uint32_t DERTag; #elif DER_TAG_SIZE == 8 typedef uint64_t DERTag; #else #error DER_TAG_SIZE invalid #endif #else /* DER_MULTIBYTE_TAGS */ typedef DERByte DERTag; #endif /* !DER_MULTIBYTE_TAGS */ #ifdef __cplusplus } #endif #endif /* _LIB_DER_CONFIG_H_ */ |
Added Source/libDER/libDER/oids.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | /* Copyright (c) 2005-2009 Apple Inc. All Rights Reserved. */ /* * oids.c - OID consts * * Created Nov. 11 2005 by dmitch */ #include "libDER.h" #include "oids.h" #define OID_ISO_CCITT_DIR_SERVICE 85 #define OID_DS OID_ISO_CCITT_DIR_SERVICE #define OID_ATTR_TYPE OID_DS, 4 #define OID_EXTENSION OID_DS, 29 #define OID_ISO_STANDARD 40 #define OID_ISO_MEMBER 42 #define OID_US OID_ISO_MEMBER, 134, 72 #define OID_ISO_IDENTIFIED_ORG 43 #define OID_OSINET OID_ISO_IDENTIFIED_ORG, 4 #define OID_GOSIP OID_ISO_IDENTIFIED_ORG, 5 #define OID_DOD OID_ISO_IDENTIFIED_ORG, 6 #define OID_OIW OID_ISO_IDENTIFIED_ORG, 14 /* From the PKCS Standards */ #define OID_RSA OID_US, 134, 247, 13 #define OID_RSA_HASH OID_RSA, 2 #define OID_RSA_ENCRYPT OID_RSA, 3 #define OID_PKCS OID_RSA, 1 #define OID_PKCS_1 OID_PKCS, 1 #define OID_PKCS_2 OID_PKCS, 2 #define OID_PKCS_3 OID_PKCS, 3 #define OID_PKCS_4 OID_PKCS, 4 #define OID_PKCS_5 OID_PKCS, 5 #define OID_PKCS_6 OID_PKCS, 6 #define OID_PKCS_7 OID_PKCS, 7 #define OID_PKCS_8 OID_PKCS, 8 #define OID_PKCS_9 OID_PKCS, 9 #define OID_PKCS_10 OID_PKCS, 10 #define OID_PKCS_11 OID_PKCS, 11 #define OID_PKCS_12 OID_PKCS, 12 /* ANSI X9.62 */ #define OID_ANSI_X9_62 OID_US, 206, 61 #define OID_PUBLIC_KEY_TYPE OID_ANSI_X9_62, 2 #define OID_EC_SIG_TYPE OID_ANSI_X9_62, 4 #define OID_ECDSA_WITH_SHA2 OID_EC_SIG_TYPE, 3 /* ANSI X9.42 */ #define OID_ANSI_X9_42 OID_US, 206, 62, 2 #define OID_ANSI_X9_42_SCHEME OID_ANSI_X9_42, 3 #define OID_ANSI_X9_42_NAMED_SCHEME OID_ANSI_X9_42, 4 /* DOD IANA Security releated objects. */ #define OID_IANA OID_DOD, 1, 5 /* Kerberos PKINIT */ #define OID_KERBv5 OID_IANA, 2 #define OID_KERBv5_PKINIT OID_KERBv5, 3 /* DOD IANA Mechanisms. */ #define OID_MECHANISMS OID_IANA, 5 /* PKIX */ #define OID_PKIX OID_MECHANISMS, 7 #define OID_PE OID_PKIX, 1 #define OID_QT OID_PKIX, 2 #define OID_KP OID_PKIX, 3 #define OID_OTHER_NAME OID_PKIX, 8 #define OID_PDA OID_PKIX, 9 #define OID_QCS OID_PKIX, 11 #define OID_AD OID_PKIX, 48 #define OID_AD_OCSP OID_AD, 1 #define OID_AD_CAISSUERS OID_AD, 2 /* ISAKMP */ #define OID_ISAKMP OID_MECHANISMS, 8 /* ETSI */ #define OID_ETSI 0x04, 0x00 #define OID_ETSI_QCS 0x04, 0x00, 0x8E, 0x46, 0x01 #define OID_OIW_SECSIG OID_OIW, 3 #define OID_OIW_ALGORITHM OID_OIW_SECSIG, 2 /* NIST defined digest algorithm arc (2, 16, 840, 1, 101, 3, 4, 2) */ #define OID_NIST_HASHALG 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02 /* * Apple-specific OID bases */ /* * apple OBJECT IDENTIFIER ::= * { iso(1) member-body(2) US(840) 113635 } * * BER = 06 06 2A 86 48 86 F7 63 */ #define APPLE_OID OID_US, 0x86, 0xf7, 0x63 /* appleDataSecurity OBJECT IDENTIFIER ::= * { apple 100 } * { 1 2 840 113635 100 } * * BER = 06 07 2A 86 48 86 F7 63 64 */ #define APPLE_ADS_OID APPLE_OID, 0x64 /* * appleTrustPolicy OBJECT IDENTIFIER ::= * { appleDataSecurity 1 } * { 1 2 840 113635 100 1 } * * BER = 06 08 2A 86 48 86 F7 63 64 01 */ #define APPLE_TP_OID APPLE_ADS_OID, 1 /* * appleSecurityAlgorithm OBJECT IDENTIFIER ::= * { appleDataSecurity 2 } * { 1 2 840 113635 100 2 } * * BER = 06 08 2A 86 48 86 F7 63 64 02 */ #define APPLE_ALG_OID APPLE_ADS_OID, 2 /* * appleDotMacCertificate OBJECT IDENTIFIER ::= * { appleDataSecurity 3 } * { 1 2 840 113635 100 3 } */ #define APPLE_DOTMAC_CERT_OID APPLE_ADS_OID, 3 /* * Basis of Policy OIDs for .mac TP requests * * dotMacCertificateRequest OBJECT IDENTIFIER ::= * { appleDotMacCertificate 1 } * { 1 2 840 113635 100 3 1 } */ #define APPLE_DOTMAC_CERT_REQ_OID APPLE_DOTMAC_CERT_OID, 1 /* * Basis of .mac Certificate Extensions * * dotMacCertificateExtension OBJECT IDENTIFIER ::= * { appleDotMacCertificate 2 } * { 1 2 840 113635 100 3 2 } */ #define APPLE_DOTMAC_CERT_EXTEN_OID APPLE_DOTMAC_CERT_OID, 2 /* * Basis of .mac Certificate request OID/value identitifiers * * dotMacCertificateRequestValues OBJECT IDENTIFIER ::= * { appleDotMacCertificate 3 } * { 1 2 840 113635 100 3 3 } */ #define APPLE_DOTMAC_CERT_REQ_VALUE_OID APPLE_DOTMAC_CERT_OID, 3 /* * Basis of Apple-specific extended key usages * * appleExtendedKeyUsage OBJECT IDENTIFIER ::= * { appleDataSecurity 4 } * { 1 2 840 113635 100 4 } */ #define APPLE_EKU_OID APPLE_ADS_OID, 4 /* * Basis of Apple Code Signing extended key usages * appleCodeSigning OBJECT IDENTIFIER ::= * { appleExtendedKeyUsage 1 } * { 1 2 840 113635 100 4 1} */ #define APPLE_EKU_CODE_SIGNING APPLE_EKU_OID, 1 #define APPLE_EKU_APPLE_ID APPLE_EKU_OID, 7 /* * Basis of Apple-specific Certific Policy IDs. * appleCertificatePolicies OBJECT IDENTIFIER ::= * { appleDataSecurity 5 } * { 1 2 840 113635 100 5 } */ #define APPLE_CERT_POLICIES APPLE_ADS_OID, 5 /* * Basis of Apple-specific Signing extensions * { appleDataSecurity 6 } */ #define APPLE_CERT_EXT APPLE_ADS_OID, 6 /* Apple Intermediate Marker OIDs */ #define APPLE_CERT_EXT_INTERMEDIATE_MARKER APPLE_CERT_EXT, 2 /* Apple Apple ID Intermediate Marker */ #define APPLE_CERT_EXT_INTERMEDIATE_MARKER_APPLEID APPLE_CERT_EXT_INTERMEDIATE_MARKER, 3 /* Secure Boot Embedded Image3 value, co-opted by desktop for "Apple Released Code Signature", without value */ #define APPLE_SBOOT_CERT_EXTEN_SBOOT_SPEC_OID APPLE_ADS_OID, 6, 1, 1 /* iPhone Provisioning Profile Signing leaf */ #define APPLE_PROVISIONING_PROFILE_OID APPLE_ADS_OID, 6, 2, 2, 1 /* iPhone Application Signing leaf */ #define APPLE_APP_SIGINING_OID APPLE_ADS_OID, 6, 1, 3 /* * Netscape OIDs. */ #define NETSCAPE_BASE_OID 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42 /* * Netscape cert extension. * * netscape-cert-extension OBJECT IDENTIFIER ::= * { 2 16 840 1 113730 1 } * * BER = 06 08 60 86 48 01 86 F8 42 01 */ #define NETSCAPE_CERT_EXTEN NETSCAPE_BASE_OID, 0x01 #define NETSCAPE_CERT_POLICY NETSCAPE_BASE_OID, 0x04 /* Entrust OIDs. */ #define ENTRUST_BASE_OID OID_US, 0x86, 0xf6, 0x7d /* * Entrust cert extension. * * entrust-cert-extension OBJECT IDENTIFIER ::= * { 1 2 840 113533 7 65 } * * BER = 06 08 2A 86 48 86 F6 7D 07 41 */ #define ENTRUST_CERT_EXTEN ENTRUST_BASE_OID, 0x07, 0x41 /* Microsfot OIDs. */ #define MICROSOFT_BASE_OID OID_DOD, 0x01, 0x04, 0x01, 0x82, 0x37 #define MICROSOFT_ENROLLMENT_OID MICROSOFT_BASE_OID, 0x14 /* Algorithm OIDs. */ static const DERByte _oidRsa[] = { OID_PKCS_1, 1 }, _oidMd2Rsa[] = { OID_PKCS_1, 2 }, _oidMd5Rsa[] = { OID_PKCS_1, 4 }, _oidSha1Rsa[] = { OID_PKCS_1, 5 }, _oidSha256Rsa[] = { OID_PKCS_1, 11 }, _oidEcPubKey[] = { OID_PUBLIC_KEY_TYPE, 1 }, _oidSha1Ecdsa[] = { OID_EC_SIG_TYPE, 1 }, /* rfc3279 */ _oidSha224Ecdsa[] = { OID_ECDSA_WITH_SHA2, 1 }, /* rfc5758 */ _oidSha256Ecdsa[] = { OID_ECDSA_WITH_SHA2, 2 }, /* rfc5758 */ _oidSha384Ecdsa[] = { OID_ECDSA_WITH_SHA2, 3 }, /* rfc5758 */ _oidSha512Ecdsa[] = { OID_ECDSA_WITH_SHA2, 4 }, /* rfc5758 */ _oidMd2[] = { OID_RSA_HASH, 2 }, _oidMd4[] = { OID_RSA_HASH, 4 }, _oidMd5[] = { OID_RSA_HASH, 5 }, _oidSha1[] = { OID_OIW_ALGORITHM, 26 }, _oidSha256[] = { OID_NIST_HASHALG, 1 }, _oidSha384[] = { OID_NIST_HASHALG, 2 }, _oidSha512[] = { OID_NIST_HASHALG, 3 }, _oidSha224[] = { OID_NIST_HASHALG, 4 }; const DERItem oidRsa = { (DERByte *)_oidRsa, sizeof(_oidRsa) }, oidMd2Rsa = { (DERByte *)_oidMd2Rsa, sizeof(_oidMd2Rsa) }, oidMd5Rsa = { (DERByte *)_oidMd5Rsa, sizeof(_oidMd5Rsa) }, oidSha1Rsa = { (DERByte *)_oidSha1Rsa, sizeof(_oidSha1Rsa) }, oidSha256Rsa = { (DERByte *)_oidSha256Rsa, sizeof(_oidSha256Rsa) }, oidEcPubKey = { (DERByte *)_oidEcPubKey, sizeof(_oidEcPubKey) }, oidSha1Ecdsa = { (DERByte *)_oidSha1Ecdsa, sizeof(_oidSha1Ecdsa) }, oidSha224Ecdsa = { (DERByte *)_oidSha224Ecdsa, sizeof(_oidSha224Ecdsa) }, oidSha256Ecdsa = { (DERByte *)_oidSha256Ecdsa, sizeof(_oidSha256Ecdsa) }, oidSha384Ecdsa = { (DERByte *)_oidSha384Ecdsa, sizeof(_oidSha384Ecdsa) }, oidSha512Ecdsa = { (DERByte *)_oidSha512Ecdsa, sizeof(_oidSha512Ecdsa) }, oidMd2 = { (DERByte *)_oidMd2, sizeof(_oidMd2) }, oidMd4 = { (DERByte *)_oidMd4, sizeof(_oidMd4) }, oidMd5 = { (DERByte *)_oidMd5, sizeof(_oidMd5) }, oidSha1 = { (DERByte *)_oidSha1, sizeof(_oidSha1) }, oidSha256 = { (DERByte *)_oidSha256, sizeof(_oidSha256) }, oidSha384 = { (DERByte *)_oidSha384, sizeof(_oidSha384) }, oidSha512 = { (DERByte *)_oidSha512, sizeof(_oidSha512) }, oidSha224 = { (DERByte *)_oidSha224, sizeof(_oidSha224) }; /* Extension OIDs. */ static const DERByte _oidSubjectKeyIdentifier[] = { OID_EXTENSION, 14 }, _oidKeyUsage[] = { OID_EXTENSION, 15 }, _oidPrivateKeyUsagePeriod[] = { OID_EXTENSION, 16 }, _oidSubjectAltName[] = { OID_EXTENSION, 17 }, _oidIssuerAltName[] = { OID_EXTENSION, 18 }, _oidBasicConstraints[] = { OID_EXTENSION, 19 }, _oidCrlDistributionPoints[] = { OID_EXTENSION, 31 }, _oidCertificatePolicies[] = { OID_EXTENSION, 32 }, _oidAnyPolicy[] = { OID_EXTENSION, 32, 0 }, _oidPolicyMappings[] = { OID_EXTENSION, 33 }, _oidAuthorityKeyIdentifier[] = { OID_EXTENSION, 35 }, _oidPolicyConstraints[] = { OID_EXTENSION, 36 }, _oidExtendedKeyUsage[] = { OID_EXTENSION, 37 }, _oidAnyExtendedKeyUsage[] = { OID_EXTENSION, 37, 0 }, _oidInhibitAnyPolicy[] = { OID_EXTENSION, 54 }, _oidAuthorityInfoAccess[] = { OID_PE, 1 }, _oidSubjectInfoAccess[] = { OID_PE, 11 }, _oidAdOCSP[] = { OID_AD_OCSP }, _oidAdCAIssuer[] = { OID_AD_CAISSUERS }, _oidNetscapeCertType[] = { NETSCAPE_CERT_EXTEN, 1 }, _oidEntrustVersInfo[] = { ENTRUST_CERT_EXTEN, 0 }, _oidMSNTPrincipalName[] = { MICROSOFT_ENROLLMENT_OID, 2, 3 }, /* Policy Qualifier IDs for Internet policy qualifiers. */ _oidQtCps[] = { OID_QT, 1 }, _oidQtUNotice[] = { OID_QT, 2 }, /* X.501 Name IDs. */ _oidCommonName[] = { OID_ATTR_TYPE, 3 }, _oidCountryName[] = { OID_ATTR_TYPE, 6 }, _oidLocalityName[] = { OID_ATTR_TYPE, 7 }, _oidStateOrProvinceName[] = { OID_ATTR_TYPE, 8 }, _oidOrganizationName[] = { OID_ATTR_TYPE, 10 }, _oidOrganizationalUnitName[] = { OID_ATTR_TYPE, 11 }, _oidDescription[] = { OID_ATTR_TYPE, 13 }, _oidEmailAddress[] = { OID_PKCS_9, 1 }, _oidFriendlyName[] = { OID_PKCS_9, 20 }, _oidLocalKeyId[] = { OID_PKCS_9, 21 }, _oidExtendedKeyUsageServerAuth[] = { OID_KP, 1 }, _oidExtendedKeyUsageClientAuth[] = { OID_KP, 2 }, _oidExtendedKeyUsageCodeSigning[] = { OID_KP, 3 }, _oidExtendedKeyUsageEmailProtection[] = { OID_KP, 4 }, _oidExtendedKeyUsageOCSPSigning[] = { OID_KP, 9 }, _oidExtendedKeyUsageIPSec[] = { OID_ISAKMP, 2, 2 }, _oidExtendedKeyUsageMicrosoftSGC[] = { MICROSOFT_BASE_OID, 10, 3, 3 }, _oidExtendedKeyUsageNetscapeSGC[] = { NETSCAPE_CERT_POLICY, 1 }, _oidAppleSecureBootCertSpec[] = { APPLE_SBOOT_CERT_EXTEN_SBOOT_SPEC_OID }, _oidAppleProvisioningProfile[] = {APPLE_PROVISIONING_PROFILE_OID }, _oidAppleApplicationSigning[] = { APPLE_APP_SIGINING_OID }, _oidAppleExtendedKeyUsageAppleID[] = { APPLE_EKU_APPLE_ID }, _oidAppleIntmMarkerAppleID[] = { APPLE_CERT_EXT_INTERMEDIATE_MARKER_APPLEID }; const DERItem oidSubjectKeyIdentifier = { (DERByte *)_oidSubjectKeyIdentifier, sizeof(_oidSubjectKeyIdentifier) }, oidKeyUsage = { (DERByte *)_oidKeyUsage, sizeof(_oidKeyUsage) }, oidPrivateKeyUsagePeriod = { (DERByte *)_oidPrivateKeyUsagePeriod, sizeof(_oidPrivateKeyUsagePeriod) }, oidSubjectAltName = { (DERByte *)_oidSubjectAltName, sizeof(_oidSubjectAltName) }, oidIssuerAltName = { (DERByte *)_oidIssuerAltName, sizeof(_oidIssuerAltName) }, oidBasicConstraints = { (DERByte *)_oidBasicConstraints, sizeof(_oidBasicConstraints) }, oidCrlDistributionPoints = { (DERByte *)_oidCrlDistributionPoints, sizeof(_oidCrlDistributionPoints) }, oidCertificatePolicies = { (DERByte *)_oidCertificatePolicies, sizeof(_oidCertificatePolicies) }, oidAnyPolicy = { (DERByte *)_oidAnyPolicy, sizeof(_oidAnyPolicy) }, oidPolicyMappings = { (DERByte *)_oidPolicyMappings, sizeof(_oidPolicyMappings) }, oidAuthorityKeyIdentifier = { (DERByte *)_oidAuthorityKeyIdentifier, sizeof(_oidAuthorityKeyIdentifier) }, oidPolicyConstraints = { (DERByte *)_oidPolicyConstraints, sizeof(_oidPolicyConstraints) }, oidExtendedKeyUsage = { (DERByte *)_oidExtendedKeyUsage, sizeof(_oidExtendedKeyUsage) }, oidAnyExtendedKeyUsage = { (DERByte *)_oidAnyExtendedKeyUsage, sizeof(_oidAnyExtendedKeyUsage) }, oidInhibitAnyPolicy = { (DERByte *)_oidInhibitAnyPolicy, sizeof(_oidInhibitAnyPolicy) }, oidAuthorityInfoAccess = { (DERByte *)_oidAuthorityInfoAccess, sizeof(_oidAuthorityInfoAccess) }, oidSubjectInfoAccess = { (DERByte *)_oidSubjectInfoAccess, sizeof(_oidSubjectInfoAccess) }, oidAdOCSP = { (DERByte *)_oidAdOCSP, sizeof(_oidAdOCSP) }, oidAdCAIssuer = { (DERByte *)_oidAdCAIssuer, sizeof(_oidAdCAIssuer) }, oidNetscapeCertType = { (DERByte *)_oidNetscapeCertType, sizeof(_oidNetscapeCertType) }, oidEntrustVersInfo = { (DERByte *)_oidEntrustVersInfo, sizeof(_oidEntrustVersInfo) }, oidMSNTPrincipalName = { (DERByte *)_oidMSNTPrincipalName, sizeof(_oidMSNTPrincipalName) }, /* Policy Qualifier IDs for Internet policy qualifiers. */ oidQtCps = { (DERByte *)_oidQtCps, sizeof(_oidQtCps) }, oidQtUNotice = { (DERByte *)_oidQtUNotice, sizeof(_oidQtUNotice) }, /* X.501 Name IDs. */ oidCommonName = { (DERByte *)_oidCommonName, sizeof(_oidCommonName) }, oidCountryName = { (DERByte *)_oidCountryName, sizeof(_oidCountryName) }, oidLocalityName = { (DERByte *)_oidLocalityName, sizeof(_oidLocalityName) }, oidStateOrProvinceName = { (DERByte *)_oidStateOrProvinceName, sizeof(_oidStateOrProvinceName) }, oidOrganizationName = { (DERByte *)_oidOrganizationName, sizeof(_oidOrganizationName) }, oidOrganizationalUnitName = { (DERByte *)_oidOrganizationalUnitName, sizeof(_oidOrganizationalUnitName) }, oidDescription = { (DERByte *)_oidDescription, sizeof(_oidDescription) }, oidEmailAddress = { (DERByte *)_oidEmailAddress, sizeof(_oidEmailAddress) }, oidFriendlyName = { (DERByte *)_oidFriendlyName, sizeof(_oidFriendlyName) }, oidLocalKeyId = { (DERByte *)_oidLocalKeyId, sizeof(_oidLocalKeyId) }, oidExtendedKeyUsageServerAuth = { (DERByte *)_oidExtendedKeyUsageServerAuth, sizeof(_oidExtendedKeyUsageServerAuth) }, oidExtendedKeyUsageClientAuth = { (DERByte *)_oidExtendedKeyUsageClientAuth, sizeof(_oidExtendedKeyUsageClientAuth) }, oidExtendedKeyUsageCodeSigning = { (DERByte *)_oidExtendedKeyUsageCodeSigning, sizeof(_oidExtendedKeyUsageCodeSigning) }, oidExtendedKeyUsageEmailProtection = { (DERByte *)_oidExtendedKeyUsageEmailProtection, sizeof(_oidExtendedKeyUsageEmailProtection) }, oidExtendedKeyUsageOCSPSigning = { (DERByte *)_oidExtendedKeyUsageOCSPSigning, sizeof(_oidExtendedKeyUsageOCSPSigning) }, oidExtendedKeyUsageIPSec = { (DERByte *)_oidExtendedKeyUsageIPSec, sizeof(_oidExtendedKeyUsageIPSec) }, oidExtendedKeyUsageMicrosoftSGC = { (DERByte *)_oidExtendedKeyUsageMicrosoftSGC, sizeof(_oidExtendedKeyUsageMicrosoftSGC) }, oidExtendedKeyUsageNetscapeSGC = { (DERByte *)_oidExtendedKeyUsageNetscapeSGC, sizeof(_oidExtendedKeyUsageNetscapeSGC) }, oidAppleSecureBootCertSpec = { (DERByte *)_oidAppleSecureBootCertSpec, sizeof(_oidAppleSecureBootCertSpec) }, oidAppleProvisioningProfile = { (DERByte *)_oidAppleProvisioningProfile, sizeof(_oidAppleProvisioningProfile) }, oidAppleApplicationSigning = { (DERByte *)_oidAppleApplicationSigning, sizeof(_oidAppleApplicationSigning) }, oidAppleExtendedKeyUsageAppleID = { (DERByte *)_oidAppleExtendedKeyUsageAppleID, sizeof(_oidAppleExtendedKeyUsageAppleID) }, oidAppleIntmMarkerAppleID = { (DERByte *)_oidAppleIntmMarkerAppleID, sizeof(_oidAppleIntmMarkerAppleID) }; bool DEROidCompare(const DERItem *oid1, const DERItem *oid2) { if ((oid1 == NULL) || (oid2 == NULL)) { return false; } if (oid1->length != oid2->length) { return false; } if (!DERMemcmp(oid1->data, oid2->data, oid1->length)) { return true; } else { return false; } } |
Added Source/libDER/libDER/oids.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /* Copyright (c) 2005-2009 Apple Inc. All Rights Reserved. */ /* * oids.h - declaration of OID consts * * Created Nov. 11 2005 by dmitch */ #ifndef _LIB_DER_OIDS_H_ #define _LIB_DER_OIDS_H_ #include "libDER.h" #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif /* Algorithm oids. */ extern const DERItem oidRsa, /* PKCS1 RSA encryption, used to identify RSA keys */ oidMd2Rsa, /* PKCS1 md2withRSAEncryption signature alg */ oidMd5Rsa, /* PKCS1 md5withRSAEncryption signature alg */ oidSha1Rsa, /* PKCS1 sha1withRSAEncryption signature alg */ oidSha256Rsa, /* PKCS1 sha256WithRSAEncryption signature alg */ oidEcPubKey, /* ECDH or ECDSA public key in a certificate */ oidSha1Ecdsa, /* ECDSA with SHA1 signature alg */ oidSha224Ecdsa, /* ECDSA with SHA224 signature alg */ oidSha256Ecdsa, /* ECDSA with SHA256 signature alg */ oidSha384Ecdsa, /* ECDSA with SHA384 signature alg */ oidSha512Ecdsa, /* ECDSA with SHA512 signature alg */ oidMd2, /* OID_RSA_HASH 2 */ oidMd4, /* OID_RSA_HASH 4 */ oidMd5, /* OID_RSA_HASH 5 */ oidSha1, /* OID_OIW_ALGORITHM 26 */ oidSha256, /* OID_NIST_HASHALG 1 */ oidSha384, /* OID_NIST_HASHALG 2 */ oidSha512, /* OID_NIST_HASHALG 3 */ oidSha224; /* OID_NIST_HASHALG 4 */ /* Standard X.509 Cert and CRL extensions. */ extern const DERItem oidSubjectKeyIdentifier, oidKeyUsage, oidPrivateKeyUsagePeriod, oidSubjectAltName, oidIssuerAltName, oidBasicConstraints, oidCrlDistributionPoints, oidCertificatePolicies, oidAnyPolicy, oidPolicyMappings, oidAuthorityKeyIdentifier, oidPolicyConstraints, oidExtendedKeyUsage, oidAnyExtendedKeyUsage, oidInhibitAnyPolicy, oidAuthorityInfoAccess, oidSubjectInfoAccess, oidAdOCSP, oidAdCAIssuer, oidNetscapeCertType, oidEntrustVersInfo, oidMSNTPrincipalName, /* Policy Qualifier IDs for Internet policy qualifiers. */ oidQtCps, oidQtUNotice, /* X.501 Name IDs. */ oidCommonName, oidCountryName, oidLocalityName, oidStateOrProvinceName, oidOrganizationName, oidOrganizationalUnitName, oidDescription, oidEmailAddress, oidFriendlyName, oidLocalKeyId, oidExtendedKeyUsageServerAuth, oidExtendedKeyUsageClientAuth, oidExtendedKeyUsageCodeSigning, oidExtendedKeyUsageEmailProtection, oidExtendedKeyUsageOCSPSigning, oidExtendedKeyUsageIPSec, oidExtendedKeyUsageMicrosoftSGC, oidExtendedKeyUsageNetscapeSGC, /* Secure Boot Spec oid */ oidAppleSecureBootCertSpec, oidAppleProvisioningProfile, oidAppleApplicationSigning, oidAppleExtendedKeyUsageAppleID, oidAppleIntmMarkerAppleID; /* Compare two decoded OIDs. Returns true iff they are equivalent. */ bool DEROidCompare(const DERItem *oid1, const DERItem *oid2); #ifdef __cplusplus } #endif #endif /* _LIB_DER_UTILS_H_ */ |
Added Source/libDER/libDERUtils/fileIo.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* * Copyright (c) 2005-2007,2010 Apple Inc. All Rights Reserved. */ #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include "fileIo.h" int writeFile( const char *fileName, const unsigned char *bytes, unsigned numBytes) { int rtn; int fd; fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600); if(fd <= 0) { return errno; } rtn = write(fd, bytes, (size_t)numBytes); if(rtn != (int)numBytes) { if(rtn >= 0) { fprintf(stderr, "writeFile: short write\n"); } rtn = EIO; } else { rtn = 0; } close(fd); return rtn; } /* * Read entire file. */ int readFile( const char *fileName, unsigned char **bytes, // mallocd and returned unsigned *numBytes) // returned { int rtn; int fd; char *buf; struct stat sb; size_t size; *numBytes = 0; *bytes = NULL; fd = open(fileName, O_RDONLY, 0); if(fd <= 0) { return errno; } rtn = fstat(fd, &sb); if(rtn) { goto errOut; } size = (size_t) sb.st_size; buf = (char *)malloc(size); if(buf == NULL) { rtn = ENOMEM; goto errOut; } rtn = read(fd, buf, (size_t)size); if(rtn != (int)size) { if(rtn >= 0) { fprintf(stderr, "readFile: short read\n"); } rtn = EIO; } else { rtn = 0; *bytes = (unsigned char *)buf; *numBytes = size; } errOut: close(fd); return rtn; } |
Added Source/libDER/libDERUtils/fileIo.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2005-2007,2010 Apple Inc. All Rights Reserved. */ #ifndef _DER_FILE_IO_H_ #define _DER_FILE_IO_H_ /* * Read entire file. */ #ifdef __cplusplus extern "C" { #endif int readFile( const char *fileName, unsigned char **bytes, // mallocd and returned unsigned *numBytes); // returned int writeFile( const char *fileName, const unsigned char *bytes, unsigned numBytes); #ifdef __cplusplus } #endif #endif /* _DER_FILE_IO_H_ */ |
Added Source/libDER/libDERUtils/libDERUtils.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * libDERUtils.c - support routines for libDER tests & examples * * Created Nov. 7 2005 by dmitch */ #include <libDERUtils/libDERUtils.h> #include <stdio.h> const char *DERReturnString( DERReturn drtn) { static char unknown[128]; switch(drtn) { case DR_Success: return "DR_Success"; case DR_EndOfSequence: return "DR_EndOfSequence"; case DR_UnexpectedTag: return "DR_UnexpectedTag"; case DR_DecodeError: return "DR_DecodeError"; case DR_Unimplemented: return "DR_Unimplemented"; case DR_IncompleteSeq: return "DR_IncompleteSeq"; default: sprintf(unknown, "Unknown error (%d)", (int)drtn); return unknown; } } void DERPerror( const char *op, DERReturn drtn) { fprintf(stderr, "*** %s: %s\n", op, DERReturnString(drtn)); } |
Added Source/libDER/libDERUtils/libDERUtils.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * libDERUtils.h - support routines for libDER tests & examples * * Created Nov. 7 2005 by dmitch */ #ifndef _LIB_DER_UTILS_H_ #define _LIB_DER_UTILS_H_ #ifdef __cplusplus extern "C" { #endif #include <libDER/libDER.h> const char *DERReturnString( DERReturn drtn); void DERPerror( const char *op, DERReturn rtn); #ifdef __cplusplus } #endif #endif /* _LIB_DER_UTILS_H_ */ |
Added Source/libDER/libDERUtils/printFields.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * printFeilds.h - print various DER objects * * Created Nov. 9 2005 by dmitch */ #include <libDERUtils/printFields.h> #include <libDER/DER_Decode.h> #include <libDER/asn1Types.h> #include <libDER/DER_Keys.h> #include <libDERUtils/libDERUtils.h> #include <stdlib.h> #include <strings.h> #include <stdio.h> static int indentLevel = 0; void doIndent() { int i; for (i = 0; i<indentLevel; i++) { putchar(' '); } } /* indent */ void incrIndent() { indentLevel += 3; } void decrIndent() { indentLevel -= 3; } #define TO_PRINT_MAX 12 void printHex( DERItem *item) { unsigned dex; unsigned toPrint = item->length; printf("<%u> ", item->length); if(toPrint > TO_PRINT_MAX) { toPrint = TO_PRINT_MAX; } for(dex=0; dex<toPrint; dex++) { printf("%02x ", item->data[dex]); } if(item->length > TO_PRINT_MAX) { printf("..."); } printf("\n"); } void printBitString( DERItem *item) { unsigned dex; unsigned toPrint = item->length; DERItem bitStringBytes; DERByte numUnused; DERReturn drtn; drtn = DERParseBitString(item, &bitStringBytes, &numUnused); if(drtn) { DERPerror("DERParseBitString", drtn); return; } printf("<%u, %u> ", bitStringBytes.length, numUnused); toPrint = bitStringBytes.length; if(toPrint > TO_PRINT_MAX) { toPrint = TO_PRINT_MAX; } for(dex=0; dex<toPrint; dex++) { printf("%02x ", bitStringBytes.data[dex]); } if(item->length > TO_PRINT_MAX) { printf("..."); } printf("\n"); } void printString( DERItem *item) { unsigned dex; char *cp = (char *)item->data; printf("'"); for(dex=0; dex<item->length; dex++) { putchar(*cp++); } printf("'\n"); } #define COLON_COLUMN 20 /* * Print line header, with current indent, followed by specified label, followed * by a ':' in column COLON_COLUMN, followed by one space. */ void printHeader( const char *label) { unsigned numPrinted; doIndent(); printf("%s", label); numPrinted = indentLevel + strlen(label); if(numPrinted < COLON_COLUMN) { unsigned numSpaces = COLON_COLUMN - numPrinted; unsigned dex; for(dex=0; dex<numSpaces; dex++) { putchar(' '); } } printf(": "); } void printItem( const char *label, ItemType itemType, int verbose, DERTag tag, // maybe from decoding, maybe the real tag underlying // an implicitly tagged item DERItem *item) // content { DERTag tagClass = tag & ASN1_CLASS_MASK; DERTag tagNum = tag & ASN1_TAGNUM_MASK; char printable = 0; char *asnType = NULL; printHeader(label); if((itemType == IT_Branch) && !verbose) { printf("\n"); return; } switch(tagClass) { case ASN1_UNIVERSAL: break; // proceed with normal tags */ case ASN1_APPLICATION: printf("APPLICATION (tag %u) ", tagNum); printHex(item); return; case ASN1_CONTEXT_SPECIFIC: printf("CONTEXT SPECIFIC (tag %u) ", tagNum); printHex(item); return; case ASN1_PRIVATE: printf("PRIVATE (tag %u) ", tagNum); printHex(item); return; } switch(tagNum) { case ASN1_BOOLEAN: asnType = "BOOLEAN"; break; case ASN1_INTEGER: asnType = "INTEGER"; break; case ASN1_BIT_STRING: /* special case here... */ printf("BIT STRING "); printBitString(item); return; case ASN1_OCTET_STRING: asnType = "OCTET STRING"; break; case ASN1_NULL: asnType = "NULL"; break; case ASN1_OBJECT_ID: asnType = "OID"; break; case ASN1_OBJECT_DESCRIPTOR: asnType = "OBJECT_DESCRIPTOR"; break; case ASN1_REAL: asnType = "REAL"; break; case ASN1_ENUMERATED: asnType = "ENUM"; break; case ASN1_EMBEDDED_PDV: asnType = "EMBEDDED_PDV"; break; case ASN1_UTF8_STRING: asnType = "UTF8 STRING"; /* FIXME print these too */ break; case ASN1_SEQUENCE: asnType = "SEQ"; break; case ASN1_SET: asnType = "SET"; break; case ASN1_NUMERIC_STRING: asnType = "NUMERIC_STRING"; break; case ASN1_PRINTABLE_STRING: asnType = "PRINTABLE_STRING"; printable = 1; break; case ASN1_T61_STRING: asnType = "T61_STRING"; printable = 1; break; case ASN1_VIDEOTEX_STRING: asnType = "VIDEOTEX_STRING"; printable = 1; break; case ASN1_IA5_STRING: asnType = "IA5_STRING"; printable = 1; break; case ASN1_UTC_TIME: asnType = "UTC_TIME"; printable = 1; break; case ASN1_GENERALIZED_TIME: asnType = "GENERALIZED_TIME"; printable = 1; break; case ASN1_GRAPHIC_STRING: asnType = "GRAPHIC_STRING"; break; case ASN1_VISIBLE_STRING: asnType = "VISIBLE_STRING"; break; case ASN1_GENERAL_STRING: asnType = "GENERAL_STRING"; break; case ASN1_UNIVERSAL_STRING: asnType = "UNIVERSAL_STRING"; break; case ASN1_BMP_STRING: asnType = "BMP_STRING"; break; default: asnType = "[unknown]"; break; } printf("%s ", asnType); if(printable) { printString(item); } else { printHex(item); } } void printAlgId( const DERItem *content, int verbose) { DERReturn drtn; DERAlgorithmId algId; drtn = DERParseSequenceContent(content, DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs, &algId, sizeof(algId)); if(drtn) { DERPerror("DERParseSequenceContent(algId)", drtn); return; } printItem("alg", IT_Leaf, verbose, ASN1_OBJECT_ID, &algId.oid); if(algId.params.data) { printItem("params", IT_Leaf, verbose, algId.params.data[0], &algId.params); } } void printSubjPubKeyInfo( const DERItem *content, int verbose) { DERReturn drtn; DERSubjPubKeyInfo pubKeyInfo; DERRSAPubKeyPKCS1 pkcs1Key; DERItem bitStringContents; DERByte numUnused; drtn = DERParseSequenceContent(content, DERNumSubjPubKeyInfoItemSpecs, DERSubjPubKeyInfoItemSpecs, &pubKeyInfo, sizeof(pubKeyInfo)); if(drtn) { DERPerror("DERParseSequenceContent(pubKeyInfo)", drtn); return; } printItem("algId", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &pubKeyInfo.algId); incrIndent(); printAlgId(&pubKeyInfo.algId, verbose); decrIndent(); printItem("pubKey", IT_Branch, verbose, ASN1_BIT_STRING, &pubKeyInfo.pubKey); /* * The contents of that bit string are a PKCS1 format RSA key. */ drtn = DERParseBitString(&pubKeyInfo.pubKey, &bitStringContents, &numUnused); if(drtn) { DERPerror("DERParseBitString(pubKeyInfo.pubKey)", drtn); decrIndent(); return; } drtn = DERParseSequence(&bitStringContents, DERNumRSAPubKeyPKCS1ItemSpecs, DERRSAPubKeyPKCS1ItemSpecs, &pkcs1Key, sizeof(pkcs1Key)); if(drtn) { DERPerror("DERParseSequenceContent(pubKeyBits)", drtn); decrIndent(); return; } incrIndent(); printItem("modulus", IT_Leaf, verbose, ASN1_INTEGER, &pkcs1Key.modulus); printItem("pubExponent", IT_Leaf, verbose, ASN1_INTEGER, &pkcs1Key.pubExponent); decrIndent(); } /* decode one item and print it */ void decodePrintItem( const char *label, ItemType itemType, int verbose, DERItem *derItem) { DERDecodedInfo decoded; DERReturn drtn; drtn = DERDecodeItem(derItem, &decoded); if(drtn) { DERPerror("DERDecodeItem()", drtn); return; } printItem(label, IT_Leaf, 0, decoded.tag, &decoded.content); } |
Added Source/libDER/libDERUtils/printFields.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* Copyright (c) 2005-2007 Apple Inc. All Rights Reserved. */ /* * printFeilds.h - print various DER objects * * Created Nov. 9 2005 by dmitch */ #ifndef _PRINT_FIELDS_H_ #define _PRINT_FIELDS_H_ #include <libDER/libDER.h> #ifdef __cplusplus extern "C" { #endif void doIndent(); void incrIndent(); void decrIndent(); void printHex(DERItem *item); void printBitString(DERItem *item); void printString(DERItem *item); void printHeader(const char *label); typedef enum { IT_Leaf, // leaf; always print contents IT_Branch // branch; print contents iff verbose } ItemType; void printItem( const char *label, ItemType itemType, int verbose, DERTag tag, // maybe from decoding, maybe the real tag underlying // an implicitly tagged item DERItem *item); // content void printAlgId( const DERItem *content, int verbose); void printSubjPubKeyInfo( const DERItem *content, int verbose); /* decode one item and print it */ void decodePrintItem( const char *label, ItemType itemType, int verbose, DERItem *derItem); #ifdef __cplusplus } #endif #endif /* _PRINT_FIELDS_H_ */ |
Deleted Source/libtomcrypt/doc/footer.html.
|
| < < < < < < < < < < |
Deleted Source/libtomcrypt/doc/header.html.
|
| < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/RC4/rc4.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/RC4/rc4_enc.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/RC4/rc4_skey.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/AES.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/Context.h.
|
| < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/Data.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/EncryptDecrypt.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/ExpandKeyForDecryption.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/ExpandKeyForEncryption.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/Setup/Data.mk.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/Setup/MakeData.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/Setup/ReadMe.txt.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aes_crypt_hw.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aes_key_hw.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aes_modes_asm.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aes_modes_hw.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesedp.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesedp.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesedpPriv.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesxts.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesxts.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/aesedpport/aesxts_asm.s.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/cast5.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/des.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/ltc_aes/aes.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/ltc_aes/aes_tab.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/ltc_aes/ltc_aes.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/rc2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/ciphers/rc5.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/helper/hash_file.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/helper/hash_filehandle.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/helper/hash_memory.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/helper/hash_memory_multi.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/md2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/md4.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/md5.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/rmd128.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/rmd160.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/rmd256.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/rmd320.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/sha1.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/sha2/sha224.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/sha2/sha256.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/sha2/sha384.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/sha2/sha512.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/SHA3api_ref.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/SHA3api_ref.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/brg_endian.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/brg_types.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_block.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_debug.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_debug.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_dropin.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_dropin.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_iv.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein/Optimized_64bit/skein_port.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein_ltc.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/hashes/skein_ltc.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_argchk.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_cfg.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_cipher.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_custom.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_hash.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_mac.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_macros.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_math.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_misc.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_mode.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_pk.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_pkcs.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/headers/tomcrypt_prng.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/base64/base64_decode.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/base64/base64_encode.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/burn_stack.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_argchk.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_cipher_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_cipher_is_valid.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_cipher.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_cipher_any.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_cipher_id.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_hash.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_hash_any.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_hash_id.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_hash_oid.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_find_prng.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_fsa.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_ltc_mp_descriptor.c.
|
| < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_mode_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_register_cipher.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_register_hash.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_register_prng.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_unregister_cipher.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_unregister_hash.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/crypt/crypt_unregister_prng.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/error_to_string.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/pkcs5/pkcs_5_1.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/pkcs5/pkcs_5_2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/misc/zeromem.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_getiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_setiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cbc/cbc_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_getiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_setiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb/cfb_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_getiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_setiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/cfb8/cfb8_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_getiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_setiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ctr/ctr_test.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ecb/ecb_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ecb/ecb_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ecb/ecb_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ecb/ecb_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ecb/ecb_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_getiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_setiv.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/ofb/ofb_start.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/rc4_stream.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/unimplemented.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_decrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_descriptor.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_done.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_encrypt.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_init.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_mult_x.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/modes/xts/xts_test.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/ansix923/ansi923pad.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/ansix923/ansi923pad.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/iso10126/iso10126pad.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/iso10126/iso10126pad.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/nopadding/nopad.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/nopadding/nopad.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/pkcs7/pkcs7pad.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Source/libtomcrypt/src/padding/pkcs7/pkcs7pad.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/CCMemoryHandler.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/CCMemoryHandler.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/CommonCryptoUnitTests-Info.plist.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/CommonCryptoUnitTests.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/CommonCryptoUnitTests.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/DigestTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/DigestTest.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/EncryptionTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/EncryptionTest.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/HMACTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/HMACTest.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/PBKDFTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/PBKDFTest.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/RandomNumberService.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/RandomNumberService.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/SymmetricWrapTest.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/SymmetricWrapTest.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/TestToolProtocol.h.
|
| < < < < < < < < < < < < < < < < |
Deleted UnitTestSource/main.mm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/CCCalibratePBKDF.3cc.
|
| < |
Deleted doc/CCCommonKeyDerivation.3cc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/CCKeyDerivationPBKDF.3cc.
|
| < |
Deleted doc/CCSymmetricKeyUnwrap.3cc.
|
| < |
Deleted doc/CCSymmetricKeyWrap.3cc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/CCSymmetricUnwrappedSize.3cc.
|
| < |
Deleted doc/CCSymmetricWrappedSize.3cc.
|
| < |
Changes to doc/CommonCrypto.plist.
1 | <?xml version="1.0" encoding="UTF-8"?> | | | < < | | | | | < < < < < < < < < < < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>OpenSourceLicense</key> <string>Eric Young</string> <key>OpenSourceLicenseFile</key> <string>CommonCrypto.txt</string> <key>OpenSourceModifications</key> <string>Extensive customization for OS X</string> <key>OpenSourceProject</key> <string>openssl</string> <key>OpenSourceURL</key> <string>http://www.openssl.org/source/openssl-0.9.6.tar.gz</string> <key>OpenSourceVersion</key> <string>openssl-0.9.6</string> <key>OpenSourceWebsiteURL</key> <string>http://www.openssl.org/</string> </dict> <dict> <key>OpenSourceImportDate</key> <string>2004-04-07</string> <key>OpenSourceLicense</key> <string>Brian Gladman</string> <key>OpenSourceLicenseFile</key> <string>CommonCrypto.txt</string> <key>OpenSourceModifications</key> <string>Customization for OS X</string> <key>OpenSourceProject</key> <string>Gladman AES</string> <key>OpenSourceURL</key> <string>http://fp.gladman.plus.com/AES/aesfull.zip</string> <key>OpenSourceVersion</key> <string>aes-src-26-08-05</string> <key>OpenSourceWebsiteURL</key> <string>http://fp.gladman.plus.com/AES/index.htm</string> </dict> <dict> <key>OpenSourceImportDate</key> <string>2005-09-02</string> <key>OpenSourceLicense</key> <string>Brian Gladman</string> <key>OpenSourceLicenseFile</key> <string>CommonCrypto.txt</string> <key>OpenSourceModifications</key> <string>Customization for OS X</string> <key>OpenSourceProject</key> <string>Gladman SHA2</string> <key>OpenSourceURL</key> <string>http://fp.gladman.plus.com/cryptography_technology/sha/sha-26-08-05.zip</string> <key>OpenSourceVersion</key> <string>sha-26-08-05</string> <key>OpenSourceWebsiteURL</key> <string>http://fp.gladman.plus.com/cryptography_technology/sha/index.htm</string> </dict> </array> </plist> |
Changes to doc/CommonCrypto.txt.
︙ | ︙ | |||
114 115 116 117 118 119 120 | in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. | < < < < < < < < < < < < < | 114 115 116 117 118 119 120 | in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. |
Added xcodescripts/convert-launchd-plists-to-binary.sh.
> > > > > > | 1 2 3 4 5 6 | /bin/sh set -e mkdir -p "$DSTROOT"/System/Library/LaunchDaemons for plist in "$SRCROOT"/cc_fips_test/*.plist; do plutil -convert binary1 "$plist" -o "$DSTROOT"/System/Library/LaunchDaemons/$(basename "$plist") done |