Check-in [9aa715ce7f]
Overview
Comment:Corrected issue with sign/decrypt buffer sizes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9aa715ce7f241007157b934596785c8b700d3ffa
User & Date: rkeene on 2010-05-17 21:50:55
Other Links: manifest | tags
Context
2010-05-17
22:22
Updated to support unpadding check-in: ebeffd66b4 user: rkeene tags: trunk
21:50
Corrected issue with sign/decrypt buffer sizes check-in: 9aa715ce7f user: rkeene tags: trunk
21:39
Updated to deal with reads of unknown size check-in: a42647e45a user: rkeene tags: trunk
Changes

Modified cackey.c from [ace314276a] to [6f8796b70d].

1840
1841
1842
1843
1844
1845
1846

1847

1848
1849
1850
1851
1852
1853
1854
1840
1841
1842
1843
1844
1845
1846
1847

1848
1849
1850
1851
1852
1853
1854
1855







+
-
+







 *
 */
static ssize_t cackey_signdecrypt(struct cackey_slot *slot, struct cackey_identity *identity, unsigned char *buf, size_t buflen, unsigned char *outbuf, size_t outbuflen) {
	unsigned char *tmpbuf, *tmpbuf_s;
	unsigned char bytes_to_send, p1;
	cackey_ret send_ret;
	uint16_t respcode;
	ssize_t retval;
	size_t tmpbuflen, padlen;
	size_t tmpbuflen, padlen, tmpoutbuflen;
	int free_tmpbuf = 0;
	int le;

	CACKEY_DEBUG_PRINTF("Called.");

	if (buflen > 255) {
		CACKEY_DEBUG_PRINTF("Error.  buflen is greater than 255 (buflen = %lu)", (unsigned long) buflen);
1947
1948
1949
1950
1951
1952
1953


1954

1955
1956
1957
1958
1959
1960
1961
1948
1949
1950
1951
1952
1953
1954
1955
1956

1957
1958
1959
1960
1961
1962
1963
1964







+
+
-
+







			le = 0x00;
		} else {
			bytes_to_send = tmpbuflen;
			p1 = 0x00;
			le = 0x00;
		}

		tmpoutbuflen = outbuflen;

		send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &outbuflen);
		send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &tmpoutbuflen);
		if (send_ret != CACKEY_PCSC_S_OK) {
			CACKEY_DEBUG_PRINTF("ADPU Sending Failed -- returning in error.");

			if (respcode == 0x6982) {
				CACKEY_DEBUG_PRINTF("Security status not satisified.");
			}

1969
1970
1971
1972
1973
1974
1975




1976
1977
1978
1979
1980
1981
1982
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989







+
+
+
+







			cackey_end_transaction(slot);

			return(-1);
		}

		tmpbuf += bytes_to_send;
		tmpbuflen -= bytes_to_send;

		outbuf += tmpoutbuflen;
		outbuflen -= tmpoutbuflen;
		retval += tmpoutbuflen;
	}

	if (free_tmpbuf) {
		if (tmpbuf_s) {
			free(tmpbuf_s);
		}
	}
1992
1993
1994
1995
1996
1997
1998
1999

2000
2001
2002
2003
2004
2005
2006
1999
2000
2001
2002
2003
2004
2005

2006
2007
2008
2009
2010
2011
2012
2013







-
+







		return(-1);
	}
#  endif
#endif

	CACKEY_DEBUG_PRINTF("Returning in success.");

	return(outbuflen);
	return(retval);
}

/*
 * SYNPOSIS
 *     ...
 *
 * ARGUMENTS