Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -8,9 +8,13 @@ config.log/* config.status config.status/* configure configure/* +tclpkcs11.dll tclpkcs11.dll.a tclpkcs11.dll.a/* tclpkcs11.dll.def tclpkcs11.dll.def/* +tclpkcs11.dll/* +tclpkcs11.so +tclpkcs11.so/* Index: tclpkcs11.c ================================================================== --- tclpkcs11.c +++ tclpkcs11.c @@ -238,22 +238,25 @@ return(Tcl_NewStringObj("PKCS11_ERROR UNKNOWN", -1)); } MODULE_SCOPE Tcl_Obj *tclpkcs11_bytearray_to_string(const unsigned char *data, unsigned long datalen) { - unsigned long idx; + static char alphabet[] = "0123456789abcdef"; + unsigned long idx, bufidx; Tcl_Obj *retval; - - retval = Tcl_NewObj(); + char buf[1024]; if (data == NULL) { return(retval); } - for (idx = 0; idx < datalen; idx++) { - Tcl_AppendObjToObj(retval, Tcl_ObjPrintf("%02x", data[idx])); + for (bufidx = idx = 0; (idx < datalen) && (bufidx < sizeof(buf)); idx++) { + buf[bufidx++] = (data[idx] >> 4) & 0xf; + buf[bufidx++] = data[idx] & 0xf; } + + retval = Tcl_NewByteArrayObj(buf, bufidx); return(retval); } MODULE_SCOPE unsigned long tclpkcs11_string_to_bytearray(Tcl_Obj *data, unsigned char *outbuf, unsigned long outbuflen) { @@ -554,11 +557,12 @@ return(TCL_ERROR); } interpdata = (struct tclpkcs11_interpdata *) cd; - tcl_handle = Tcl_ObjPrintf("pkcsmod%lu", interpdata->handles_idx); + tcl_handle = Tcl_NewStringObj("pkcsmod", -1); + Tcl_AppendObjToObj(tcl_handle, Tcl_NewLongObj(interpdata->handles_idx)); (interpdata->handles_idx)++; tcl_handle_entry = Tcl_CreateHashEntry(&interpdata->handles, (const char *) tcl_handle, &is_new_entry); if (!tcl_handle_entry) { Tcl_SetObjResult(interp, Tcl_NewStringObj("unable to create new hash entry", -1));