Works for ECDSA, RSASSA-PKCS1-v1_5, RSA-PSS, and RSA-OAEP algorithms
Crypto
// Adds AlwaysAuthenticateHandler to `crypto` object
// App uses returned string value for `C_Login(pin, CKU_CONTEXT_SPECIFIC)` calling imideatly after C_SignInit/C_DecryptInit functions
crypto.onAlwaysAuthenticate = (key, container) => {
return pin;
}
If AlwaysAuthenticateHandler returns null app skips C_Login function and PKCS#11 provider returns CKR_USER_NOT_LOGGED_IN status code
If onAlwaysAuthenticate is undefined and the private key has enabled CKA_ALWAYS_AUTHENTICATE the app throws the error on sign/decrypt operations - Crypto key requires re-authentication, but Crypto doesn't have 'onAlwaysAuthenticate' method
Coverage increased (+0.6%) to 87.484% when pulling 9a6445c05549b89550ef6dd109a30a4c0cfa829c on always-auth into 462187f875414de6688e2ea3cf6ca46f2d346cba on master.
API changes
Works for
ECDSA
,RSASSA-PKCS1-v1_5
,RSA-PSS
, andRSA-OAEP
algorithmsCrypto
If
AlwaysAuthenticateHandler
returnsnull
app skipsC_Login
function and PKCS#11 provider returnsCKR_USER_NOT_LOGGED_IN
status codeIf
onAlwaysAuthenticate
is undefined and the private key has enabledCKA_ALWAYS_AUTHENTICATE
the app throws the error on sign/decrypt operations -Crypto key requires re-authentication, but Crypto doesn't have 'onAlwaysAuthenticate' method
Generate key
Import key
Crypto key
Private crypto key includes the
alwaysAuthenticate
boolean field, which represents theCKA_ALWAYS_AUTHENTICATE
attribute of PKCS#11 private key