This sample requires an SWYS device to succeed (SWAT reader).
As soon the sample starts, the user must enter the PIN on the SWYS device pad.
A private key is required on the smartcard to operate the ETC_SignEx function.
This is a common C_FindObjects function invocation with a special attribute used to obtain the characteristics of the reader/token.
var sessionHandle = 222222;
var certificateCategory = 2; // Search for CA certificates
var callback = {
success: function (status, data) {
alert(`The function returned the following information: ${JSON.stringify(data)}`);
},
error: function (errorCode) {
alert(`The function failed with code ${errorCode}`);
}
};
theObjectPKCS11.ETC_GetDeviceCertificates(sessionHandle, certificateCategory, callback);
Click the button to invoke the function.
Signs data in a single part using CKM_RSA_PKCS as signature mechanism and CKM_SHA256 as hash mechanism.
var sessionHandle = 22222222;
var keyObjectHandle = 3333333;
var data = [67,111,111,108,32,116,114,97,110,115,97,99,116,105,111,110,32,116,111,32,99,111,110,102,105,114,109];
var certificateObjectHandle = 77777;
var signaturePKI = 1;
var hidden = [68,101,102,97,117,108,116,32,72,105,100,100,101,110,32,68,97,116,97];
var hash = [48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32,56,48,192,134,9,194,189,215,54,240,119,18,31,183,75,16,229,220,77,26,14,197,49,205,147,100,253,210,145,117,114,24];
var callback = {
success: function (status, data) {
// The returned 'data' object contains the properties 'signatureDevice' and 'signatureCard
alert(`The function returned the following the signature: ${JSON.stringify(data.buffer)}`);
},
error: function (errorCode) {
alert(`The function failed with code ${errorCode}`);
}
};
theObjectPKCS11.ETC_SignEx(sessionHandle, keyObjectHandle, data, certificateObjectHandle, hidden, hash, signaturePKI, callback);
Click the button to invoke the function.