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   1840    *
  1841   1841    */
  1842   1842   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) {
  1843   1843   	unsigned char *tmpbuf, *tmpbuf_s;
  1844   1844   	unsigned char bytes_to_send, p1;
  1845   1845   	cackey_ret send_ret;
  1846   1846   	uint16_t respcode;
  1847         -	size_t tmpbuflen, padlen;
         1847  +	ssize_t retval;
         1848  +	size_t tmpbuflen, padlen, tmpoutbuflen;
  1848   1849   	int free_tmpbuf = 0;
  1849   1850   	int le;
  1850   1851   
  1851   1852   	CACKEY_DEBUG_PRINTF("Called.");
  1852   1853   
  1853   1854   	if (buflen > 255) {
  1854   1855   		CACKEY_DEBUG_PRINTF("Error.  buflen is greater than 255 (buflen = %lu)", (unsigned long) buflen);
................................................................................
  1947   1948   			le = 0x00;
  1948   1949   		} else {
  1949   1950   			bytes_to_send = tmpbuflen;
  1950   1951   			p1 = 0x00;
  1951   1952   			le = 0x00;
  1952   1953   		}
  1953   1954   
  1954         -		send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &outbuflen);
         1955  +		tmpoutbuflen = outbuflen;
         1956  +
         1957  +		send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &tmpoutbuflen);
  1955   1958   		if (send_ret != CACKEY_PCSC_S_OK) {
  1956   1959   			CACKEY_DEBUG_PRINTF("ADPU Sending Failed -- returning in error.");
  1957   1960   
  1958   1961   			if (respcode == 0x6982) {
  1959   1962   				CACKEY_DEBUG_PRINTF("Security status not satisified.");
  1960   1963   			}
  1961   1964   
................................................................................
  1969   1972   			cackey_end_transaction(slot);
  1970   1973   
  1971   1974   			return(-1);
  1972   1975   		}
  1973   1976   
  1974   1977   		tmpbuf += bytes_to_send;
  1975   1978   		tmpbuflen -= bytes_to_send;
         1979  +
         1980  +		outbuf += tmpoutbuflen;
         1981  +		outbuflen -= tmpoutbuflen;
         1982  +		retval += tmpoutbuflen;
  1976   1983   	}
  1977   1984   
  1978   1985   	if (free_tmpbuf) {
  1979   1986   		if (tmpbuf_s) {
  1980   1987   			free(tmpbuf_s);
  1981   1988   		}
  1982   1989   	}
................................................................................
  1992   1999   		return(-1);
  1993   2000   	}
  1994   2001   #  endif
  1995   2002   #endif
  1996   2003   
  1997   2004   	CACKEY_DEBUG_PRINTF("Returning in success.");
  1998   2005   
  1999         -	return(outbuflen);
         2006  +	return(retval);
  2000   2007   }
  2001   2008   
  2002   2009   /*
  2003   2010    * SYNPOSIS
  2004   2011    *     ...
  2005   2012    *
  2006   2013    * ARGUMENTS