Check-in [4f5638aabf]
Overview
Comment:Updated to use fewer APDUs when signing/decrypting
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4f5638aabf730b4e68e424f84c7b31c1f67c1d7e
User & Date: rkeene on 2015-03-05 17:40:19
Other Links: manifest | tags
Context
2015-03-05
17:49
Updated to set the output size after decompressing a certificate check-in: bc60cf4dca user: rkeene tags: trunk
17:40
Updated to use fewer APDUs when signing/decrypting check-in: 4f5638aabf user: rkeene tags: trunk
16:20
Updated ignores to ignore downloaded certificates and test driver check-in: d36685d176 user: rkeene tags: trunk
Changes

Modified cackey.c from [6ee4372cd9] to [a840779390].

  2750   2750    *
  2751   2751    * NOTES
  2752   2752    *     ...
  2753   2753    *
  2754   2754    */
  2755   2755   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, int padInput, int unpadOutput) {
  2756   2756   	cackey_pcsc_id_type id_type;
  2757         -	unsigned char dyn_auth_template[10];
         2757  +	unsigned char dyn_auth_template[10], *dyn_auth_tmpbuf;
  2758   2758   	unsigned char *tmpbuf, *tmpbuf_s, *outbuf_s, *outbuf_p;
  2759   2759   	unsigned char bytes_to_send, p1, class;
  2760   2760   	unsigned char blocktype;
  2761   2761   	cackey_ret send_ret;
  2762   2762   	uint16_t respcode;
  2763   2763   	ssize_t retval = 0, unpadoffset;
  2764   2764   	size_t tmpbuflen, padlen, tmpoutbuflen, outbuf_len;
................................................................................
  2885   2885   			dyn_auth_template[4] = 0x82;
  2886   2886   			dyn_auth_template[5] = 0x00;
  2887   2887   			dyn_auth_template[6] = 0x81;
  2888   2888   			dyn_auth_template[7] = 0x82;
  2889   2889   			dyn_auth_template[8] = (tmpbuflen & 0xff00) >> 8;
  2890   2890   			dyn_auth_template[9] = tmpbuflen & 0x00ff;
  2891   2891   
  2892         -			send_ret = cackey_send_apdu(slot, 0x10, NISTSP800_73_3_INSTR_GENAUTH, NISTSP800_78_3_ALGO_RSA2048, identity->pcsc_identity->card.piv.key_id, sizeof(dyn_auth_template), dyn_auth_template, 0x00, NULL, NULL, NULL);
         2892  +			dyn_auth_tmpbuf = malloc(tmpbuflen + sizeof(dyn_auth_template));
         2893  +			memcpy(dyn_auth_tmpbuf, dyn_auth_template, sizeof(dyn_auth_template));
         2894  +			memcpy(dyn_auth_tmpbuf + sizeof(dyn_auth_template), tmpbuf, tmpbuflen);
         2895  +
         2896  +			if (free_tmpbuf) {
         2897  +				free(tmpbuf);
         2898  +			}
         2899  +
         2900  +			tmpbuflen += sizeof(dyn_auth_template);
         2901  +			tmpbuf = dyn_auth_tmpbuf;
         2902  +			free_tmpbuf = 1;
         2903  +
  2893   2904   			break;
  2894   2905   		case CACKEY_ID_TYPE_CERT_ONLY:
  2895   2906   			break;
  2896   2907   	}
  2897   2908   
  2898   2909   	tmpbuf_s = tmpbuf;
  2899   2910   	outbuf_s = outbuf;