Overview
Comment: | Updated to decompress certificates
Updated to correctly process TLV elements -- fixes bug where iterated past them when processing Updated to correclty process TLV element total length |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | b9e3c7741b58ed6b07940ffa457ed38a61512d91 |
User & Date: | rkeene on 2010-05-14 06:08:46 |
Other Links: | manifest | tags |
Context
2010-05-14
| ||
20:49 | Added function to convert X.509 DN to string representation check-in: f89918d4df user: rkeene tags: trunk | |
06:08 |
Updated to decompress certificates
Updated to correctly process TLV elements -- fixes bug where iterated past them when processing Updated to correclty process TLV element total length check-in: b9e3c7741b user: rkeene tags: trunk | |
03:32 | Updated transaction support check-in: c2e40da095 user: rkeene tags: trunk | |
Changes
Modified cackey.c from [884439a73b] to [941bf5cf9b].
22 22 #endif 23 23 #ifdef HAVE_STRING_H 24 24 # include <string.h> 25 25 #endif 26 26 #ifdef HAVE_PTHREAD_H 27 27 # include <pthread.h> 28 28 #endif 29 +#ifdef HAVE_ZLIB_H 30 +# ifdef HAVE_LIBZ 31 +# include <zlib.h> 32 +# endif 33 +#else 34 +# ifdef HAVE_LIBZ 35 +# undef HAVE_LIBZ 36 +# endif 37 +#endif 29 38 30 39 #define CK_PTR * 31 40 #define CK_DEFINE_FUNCTION(returnType, name) returnType name 32 41 #define CK_DECLARE_FUNCTION(returnType, name) returnType name 33 42 #define CK_DECLARE_FUNCTION_POINTER(returnType, name) returnType (* name) 34 43 #define CK_CALLBACK_FUNCTION(returnType, name) returnType (* name) 35 44 #ifndef NULL_PTR ................................................................................ 1361 1370 unsigned char vlen_buf[2], vval_buf[8192], *vval; 1362 1371 unsigned char *tmpbuf; 1363 1372 ssize_t tlen, vlen; 1364 1373 ssize_t read_ret; 1365 1374 size_t offset_t = 0, offset_v = 0; 1366 1375 unsigned char tag; 1367 1376 size_t length; 1377 + uLongf tmpbuflen; 1378 + int uncompress_ret; 1368 1379 1369 1380 CACKEY_DEBUG_PRINTF("Called."); 1370 1381 1371 1382 read_ret = cackey_read_buffer(slot, tlen_buf, sizeof(tlen_buf), 1, offset_t); 1372 1383 if (read_ret != sizeof(tlen_buf)) { 1373 1384 CACKEY_DEBUG_PRINTF("Read failed, returning in failure"); 1374 1385 ................................................................................ 1384 1395 return(NULL); 1385 1396 } 1386 1397 1387 1398 vlen = (vlen_buf[1] << 8) | vlen_buf[0]; 1388 1399 1389 1400 CACKEY_DEBUG_PRINTF("Tag Length = %i, Value Length = %i", tlen, vlen); 1390 1401 1391 - tlen -= 2; 1392 1402 offset_t += 2; 1393 - 1394 - vlen -= 2; 1395 1403 offset_v += 2; 1396 1404 1397 1405 if (tlen > sizeof(tval_buf)) { 1398 1406 CACKEY_DEBUG_PRINTF("Tag length is too large, returning in failure"); 1399 1407 1400 1408 return(NULL); 1401 1409 } ................................................................................ 1435 1443 length = *tval; 1436 1444 tval++; 1437 1445 tlen--; 1438 1446 } 1439 1447 1440 1448 CACKEY_DEBUG_PRINTF("Tag: %s (%02x)", CACKEY_DEBUG_FUNC_TAG_TO_STR(tag), (unsigned int) tag); 1441 1449 CACKEY_DEBUG_PRINTBUF("Value:", vval, length); 1442 - vval += length; 1443 - vlen -= length; 1444 1450 1445 1451 curr_entity = NULL; 1446 1452 switch (tag) { 1447 1453 case GSCIS_TAG_CARDURL: 1448 1454 curr_entity = malloc(sizeof(*curr_entity)); 1449 1455 curr_entity->value_cardurl = malloc(sizeof(*curr_entity->value_cardurl)); 1450 1456 ................................................................................ 1467 1473 curr_entity->length = length; 1468 1474 curr_entity->value = tmpbuf; 1469 1475 curr_entity->_next = NULL; 1470 1476 1471 1477 break; 1472 1478 case GSCIS_TAG_CERTIFICATE: 1473 1479 curr_entity = malloc(sizeof(*curr_entity)); 1474 - tmpbuf = malloc(length); 1475 1480 1481 + tmpbuflen = length * 2; 1482 + tmpbuf = malloc(tmpbuflen); 1483 + 1484 +#ifdef HAVE_LIBZ 1485 + CACKEY_DEBUG_PRINTBUF("Decompressing:", vval, length); 1486 + uncompress_ret = uncompress(tmpbuf, &tmpbuflen, vval, length); 1487 + if (uncompress_ret != Z_OK) { 1488 + CACKEY_DEBUG_PRINTF("Failed to decompress, uncompress() returned %i -- resorting to direct copy", uncompress_ret); 1489 + 1490 + tmpbuflen = length; 1491 + memcpy(tmpbuf, vval, length); 1492 + } 1493 + 1494 + CACKEY_DEBUG_PRINTBUF("Decompressed to:", tmpbuf, tmpbuflen); 1495 +#else 1496 + CACKEY_DEBUG_PRINTF("Missing ZLIB Support, this certificate is likely useless..."); 1497 + 1498 + tmpbuflen = length; 1476 1499 memcpy(tmpbuf, vval, length); 1500 +#endif 1477 1501 1478 1502 curr_entity->tag = tag; 1479 - curr_entity->length = length; 1503 + curr_entity->length = tmpbuflen; 1480 1504 curr_entity->value = tmpbuf; 1481 1505 curr_entity->_next = NULL; 1482 1506 1483 1507 break; 1484 1508 case GSCIS_TAG_PKCS15: 1485 1509 curr_entity = malloc(sizeof(*curr_entity)); 1486 1510 1487 1511 curr_entity->tag = tag; 1488 1512 curr_entity->value_byte = vval[0]; 1489 1513 curr_entity->_next = NULL; 1490 1514 1491 1515 break; 1492 1516 } 1517 + 1518 + vval += length; 1519 + vlen -= length; 1493 1520 1494 1521 if (curr_entity != NULL) { 1495 1522 if (root == NULL) { 1496 1523 root = curr_entity; 1497 1524 } 1498 1525 1499 1526 if (last != NULL) {
Modified configure.ac from [4d0c0e3f42] to [ebb33ac593].
18 18 ]) 19 19 20 20 dnl Determine how to create static archives on this platform 21 21 AC_CHECK_TOOL(AR, ar) 22 22 AC_CHECK_TOOL(RANLIB, ranlib) 23 23 24 24 dnl Check for all required headers 25 -AC_CHECK_HEADERS(arpa/inet.h inttypes.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/socket.h sys/types.h sys/un.h unistd.h pthread.h,,[ 25 +AC_CHECK_HEADERS(arpa/inet.h inttypes.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/socket.h sys/types.h sys/un.h unistd.h pthread.h zlib.h,,[ 26 26 AC_WARN([Required header missing, compilation will likely fail.]) 27 27 ], [ 28 28 #ifdef HAVE_ARPA_INET_H 29 29 # include <arpa/inet.h> 30 30 #endif 31 31 #ifdef HAVE_INTTYPES_H 32 32 # include <inttypes.h> ................................................................................ 57 57 #endif 58 58 #ifdef HAVE_UNISTD_H 59 59 # include <unistd.h> 60 60 #endif 61 61 #ifdef HAVE_PTHREAD_H 62 62 # include <pthread.h> 63 63 #endif 64 +#ifdef HAVE_ZLIB_H 65 +# include <zlib.h> 66 +#endif 64 67 ]) 65 68 66 69 dnl Check for PC/SC headers and libraries 67 70 DC_PCSC 71 + 72 +dnl Check for ZLIB libraries 73 +AC_CHECK_LIB(z, uncompress) 68 74 69 75 dnl Upate LDFLAGS to include setting the run-time linker path to the same as our compile-time linker 70 76 DC_SYNC_RPATH 71 77 72 78 dnl If we updated LIBOBJS, update SHLIBOBJS -- must be last. 73 79 DC_SYNC_SHLIBOBJS 74 80 75 81 dnl Produce Makefile 76 82 AC_OUTPUT(Makefile)