@@ -1842,11 +1842,12 @@ 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; - size_t tmpbuflen, padlen; + ssize_t retval; + size_t tmpbuflen, padlen, tmpoutbuflen; int free_tmpbuf = 0; int le; CACKEY_DEBUG_PRINTF("Called."); @@ -1949,11 +1950,13 @@ bytes_to_send = tmpbuflen; p1 = 0x00; le = 0x00; } - send_ret = cackey_send_apdu(slot, GSCIS_CLASS_GLOBAL_PLATFORM, GSCIS_INSTR_SIGNDECRYPT, p1, 0x00, bytes_to_send, tmpbuf, le, &respcode, outbuf, &outbuflen); + tmpoutbuflen = 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."); @@ -1971,10 +1974,14 @@ 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); @@ -1994,11 +2001,11 @@ # endif #endif CACKEY_DEBUG_PRINTF("Returning in success."); - return(outbuflen); + return(retval); } /* * SYNPOSIS * ...