Skip to content

Commit

Permalink
test_asymetric.py: use a correct size for RSA_PSS_Mechanism.sLen
Browse files Browse the repository at this point in the history
All PSS mechanisms require to provide the PSS parameters in appropriate
C_XXXInit() APIs. The PKCS#11 recommends to use salt length equal to
appropriate hash length.

For SHA1: salt length = 20 bytes
For SHA256: salt length = 32 bytes
  • Loading branch information
LudovicRousseau committed Mar 9, 2020
1 parent 0ba7678 commit 777ff49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/test_asymetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def test_RSA_PSS_SHA1(self):
toSign = "test_RSA_sign_PSS SHA1"

mech = PyKCS11.RSA_PSS_Mechanism(
PyKCS11.CKM_SHA1_RSA_PKCS_PSS, PyKCS11.CKM_SHA_1, PyKCS11.CKG_MGF1_SHA1, 0
PyKCS11.CKM_SHA1_RSA_PKCS_PSS,
PyKCS11.CKM_SHA_1,
PyKCS11.CKG_MGF1_SHA1,
20 # size of SHA1 result
)
signature = self.session.sign(self.privKey, toSign, mech)
result = self.session.verify(self.pubKey, toSign, signature, mech)
Expand All @@ -177,7 +180,7 @@ def test_RSA_PSS_SHA256(self):
PyKCS11.CKM_SHA256_RSA_PKCS_PSS,
PyKCS11.CKM_SHA256,
PyKCS11.CKG_MGF1_SHA256,
0,
32 # size of SHA256 result
)
signature = self.session.sign(self.privKey, toSign, mech)
result = self.session.verify(self.pubKey, toSign, signature, mech)
Expand Down

0 comments on commit 777ff49

Please sign in to comment.