Warning !

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.

ETC_GetDeviceCertificates

This is a common C_FindObjects function invocation with a special attribute used to obtain the characteristics of the reader/token.

Parameters:

sessionHandle (number): PKCS#11 session handle.
certificateCategory (number): Defines the certificate type targeted by the search. As described into the PKCS11 specification for values of the CKA_CERTIFICATE_TYPE attribute, the certificate category can be: 0 = unspecified (default value), 2 = authority (CA certificates).
error callback (function): Called if the operation has failed. Receives the parameter 'code' (number): Error code
success callback (function): Called if the operation was successful. Receives the parameters 'status' (string) and 'data' (array Obj): An array of certificate object handles found in the device.

                                
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);
                                
                            

Try it!

Click the button to invoke the function.

 

ETC_SignEx

Signs data in a single part using CKM_RSA_PKCS as signature mechanism and CKM_SHA256 as hash mechanism.


This function invokes internally the C_SignInit and ETC_SignEx functions and sends back the result.

sessionHandle (number): PKCS#11 session handle.
keyObjectHandle (number): Object handle of the key that is used for the signature.
data (byte array): Contains the cleartext buffer for signing, shown to the end user for verification.
certificateObjectHandle (number): Terminal certificate object handle used for the terminal signature.
hidden (byte array): Buffer to add to the signature, not shown to the end user for verification.
hash (byte array): Hashed data to be signed by the card.
signaturePKI (boolean): Set to true to use the PKI signature, or false to use the OTP signature.

Returns a 'data' object with properties:

signatureDevice (byte array): Contains the signature provided by the terminal.
signatureCard (byte array): Contains the signature provided by the smart card.
                                
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);                                        
                                
                            

Try it!

Click the button to invoke the function.

 

Click here to try WebConnect!

Web Connect Notification

Please select a slot (card reader):