Check-in [2f0a97a3f1]
Overview
Comment:Added support for reading label from CAC as string
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2f0a97a3f106fefebda0a578c2cfaea489cee984
User & Date: rkeene on 2010-05-14 20:50:45
Other Links: manifest | tags
Context
2010-05-14
22:10
Wrote function for freeing identities

Wrote function for determining label from identity

Consolidated freeing of identities to use new function

Consolidated label lookups to use new function

Fixed bug with releasing identities, but not reducing the number of identities check-in: 1b3d82054b user: rkeene tags: trunk

20:50
Added support for reading label from CAC as string check-in: 2f0a97a3f1 user: rkeene tags: trunk
20:49
Added function to convert X.509 DN to string representation check-in: f89918d4df user: rkeene tags: trunk
Changes

Modified cackey.c from [941bf5cf9b] to [be5fbbbf72].

1370
1371
1372
1373
1374
1375
1376

1377
1378

1379
1380
1381
1382
1383
1384
1385
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387







+


+







	unsigned char vlen_buf[2], vval_buf[8192], *vval;
	unsigned char *tmpbuf;
	ssize_t tlen, vlen;
	ssize_t read_ret;
	size_t offset_t = 0, offset_v = 0;
	unsigned char tag;
	size_t length;
#ifdef HAVE_LIBZ
	uLongf tmpbuflen;
	int uncompress_ret;
#endif

	CACKEY_DEBUG_PRINTF("Called.");

	read_ret = cackey_read_buffer(slot, tlen_buf, sizeof(tlen_buf), 1, offset_t);
	if (read_ret != sizeof(tlen_buf)) {
		CACKEY_DEBUG_PRINTF("Read failed, returning in failure");

1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1480
1481
1482
1483
1484
1485
1486

1487
1488
1489
1490
1491
1492
1493







-







			case GSCIS_TAG_CERTIFICATE:
				curr_entity = malloc(sizeof(*curr_entity));

				tmpbuflen = length * 2;
				tmpbuf = malloc(tmpbuflen);

#ifdef HAVE_LIBZ
				CACKEY_DEBUG_PRINTBUF("Decompressing:", vval, length);
				uncompress_ret = uncompress(tmpbuf, &tmpbuflen, vval, length);
				if (uncompress_ret != Z_OK) {
					CACKEY_DEBUG_PRINTF("Failed to decompress, uncompress() returned %i -- resorting to direct copy", uncompress_ret);

					tmpbuflen = length;
					memcpy(tmpbuf, vval, length);
				}
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026

















2027
2028
2029
2030
2031
2032
2033
2017
2018
2019
2020
2021
2022
2023




2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047







-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







				break;
			case CKA_LABEL:
				CACKEY_DEBUG_PRINTF("Requesting attribute CKA_LABEL (0x%08lx) ...", (unsigned long) curr_attr_type);

				/* Determine name */
				if (certificate_len >= 0) {
					x509_read_ret = x509_to_subject(certificate, certificate_len, &pValue);
					if (x509_read_ret < 0) {
						pValue = NULL;
					} else {
						ulValueLen = x509_read_ret;
					if (x509_read_ret > 0) {
						x509_read_ret = x509_dn_to_string(pValue, x509_read_ret, (char *) ucTmpBuf, sizeof(ucTmpBuf), "CN");
						if (x509_read_ret <= 0) {
							x509_read_ret = x509_dn_to_string(pValue, x509_read_ret, (char *) ucTmpBuf, sizeof(ucTmpBuf), NULL);

							if (x509_read_ret <= 0) {
								pValue = NULL;
							} else {
								pValue = ucTmpBuf;
								ulValueLen = x509_read_ret;
							}
						} else {
							pValue = ucTmpBuf;
							ulValueLen = x509_read_ret;
						}
					} else {
						pValue = NULL;
					}
				}

				CACKEY_DEBUG_PRINTF(" ... returning (%p/%lu)", pValue, (unsigned long) ulValueLen);

				break;
			case CKA_VALUE: