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
|