Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RSA-PSS signatures in pkcs11-tool #1146

Merged
merged 20 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a7a4e6c
Add missing SHA224 RSA algorithms
Jakuje Sep 6, 2017
811a6b9
Fix wrong replacement in pkcs11-tool manual page
Jakuje Sep 6, 2017
6d37b6c
Add MGF and PSS_PARAMS definitions in PKCS#11 header file
Jakuje Sep 6, 2017
89309a5
Inspect PSS signature parameters in pkcs11-spy
Jakuje Sep 6, 2017
1efb774
Enable RSA-PSS signatures in pkcs11-tool
Jakuje Sep 6, 2017
c2d8ee5
Added short names to RSA-PSS methods
Sep 7, 2017
ec8dd42
Change RSA-PSS salt length default to OpenSSL-compatible, aka digest …
Sep 7, 2017
aaecfdb
Fixed hashAlg but in pkcs11-tool for RSA-PSS
Sep 7, 2017
da9bae0
CHanged opt_salt to salt_len
mouse07410 Sep 8, 2017
7513ec2
Fixed type of salt length from unsigned long to long
mouse07410 Sep 9, 2017
cedbd3e
RSA-PSS: made sure special values for salt length from OpenSSL ("-1" …
mouse07410 Sep 9, 2017
0b7e5f0
Refactored dealing with salt length, and added input check
mouse07410 Sep 10, 2017
f2f53c1
Fix introduced incompatibility with C90 standard (declaration of vari…
mouse07410 Sep 11, 2017
ebd3ca2
Whitespace cleanup of mouse07410 commits
Jakuje Sep 11, 2017
55f0616
Add SHA-224 hash algorithm for RSA-PSS
Jakuje Sep 11, 2017
15659fb
Do not fallback to zero-length salt on unknown hash algorithms
Jakuje Sep 11, 2017
375e1c2
Add SHA224 definitions in pkcs11.h (for completenes)
Jakuje Sep 11, 2017
4450c2c
Reintroduce portable NORETURN indication for functions and use it to …
Jakuje Sep 13, 2017
e870706
Use default SHA-1 mechanisms, use --salt-len, improve wording of docu…
Jakuje Sep 15, 2017
63ae2f9
Check the mechanism type before dereferencing generic parameter
Jakuje Sep 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Inspect PSS signature parameters in pkcs11-spy
  • Loading branch information
Jakuje committed Sep 13, 2017
commit 89309a56b8f0a804caf123aae1a4bea013a7bd0b
9 changes: 9 additions & 0 deletions src/pkcs11/pkcs11-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ static enum_specs ck_mec_s[] = {
{ CKM_VENDOR_DEFINED , "CKM_VENDOR_DEFINED " }
};

static enum_specs ck_mgf_s[] = {
{ CKG_MGF1_SHA1 , "CKG_MGF1_SHA1 " },
{ CKG_MGF1_SHA224, "CKG_MGF1_SHA224" },
{ CKG_MGF1_SHA256, "CKG_MGF1_SHA256" },
{ CKG_MGF1_SHA384, "CKG_MGF1_SHA384" },
{ CKG_MGF1_SHA512, "CKG_MGF1_SHA512" },
};

static enum_specs ck_err_s[] = {
{ CKR_OK, "CKR_OK" },
{ CKR_CANCEL, "CKR_CANCEL" },
Expand Down Expand Up @@ -630,6 +638,7 @@ enum_spec ck_types[] = {
{ KEY_T, ck_key_s, sizeof(ck_key_s) / SZ_SPECS, "CK_KEY_TYPE" },
{ CRT_T, ck_crt_s, sizeof(ck_crt_s) / SZ_SPECS, "CK_CERTIFICATE_TYPE" },
{ MEC_T, ck_mec_s, sizeof(ck_mec_s) / SZ_SPECS, "CK_MECHANISM_TYPE" },
{ MGF_T, ck_mgf_s, sizeof(ck_mgf_s) / SZ_SPECS, "CK_RSA_PKCS_MGF_TYPE"},
{ USR_T, ck_usr_s, sizeof(ck_usr_s) / SZ_SPECS, "CK_USER_TYPE" },
{ STA_T, ck_sta_s, sizeof(ck_sta_s) / SZ_SPECS, "CK_STATE" },
{ RV_T, ck_err_s, sizeof(ck_err_s) / SZ_SPECS, "CK_RV" },
Expand Down
1 change: 1 addition & 0 deletions src/pkcs11/pkcs11-display.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum ck_type{
KEY_T,
CRT_T,
MEC_T,
MGF_T,
USR_T,
STA_T,
RV_T
Expand Down
9 changes: 9 additions & 0 deletions src/pkcs11/pkcs11-spy.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,15 @@ C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HA
enter("C_SignInit");
spy_dump_ulong_in("hSession", hSession);
fprintf(spy_output, "pMechanism->type=%s\n", lookup_enum(MEC_T, pMechanism->mechanism));
if (pMechanism->pParameter != NULL) { /* XXX assuming PSS parameter */
CK_RSA_PKCS_PSS_PARAMS *param =
(CK_RSA_PKCS_PSS_PARAMS *) pMechanism->pParameter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test for the actual parameter type? casting here and dereferencing later may lead to unexpected behavior...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should. But since this was the first mechanism using parameter, I wanted to avoid listing all the PSS mechanisms. But as we will have OEAP too, we should certainly do that. I will submit an update tomorrow. It is quite late here in Europe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other parameter types are possible in C_SignInit? Certainly not OAEP (which belongs to C_DecryptInit).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ... my bad. It was very late yesterday. But reading through the PKCS#11 mechanisms specification, we can see that for example 2.8.9 General-length AES-MAC is a mechanism that has parameters and is using/can use the C_Sign interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks. Understood. Made the same change for OAEP in ...spy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI done. All checks passed.

fprintf(spy_output, "pMechanism->pParameter->hashAlg=%s\n",
lookup_enum(MEC_T, param->hashAlg));
fprintf(spy_output, "pMechanism->pParameter->mgf=%s\n",
lookup_enum(MGF_T, param->mgf));
fprintf(spy_output, "pMechanism->pParameter->sLen=%lu\n", param->sLen);
}
spy_dump_ulong_in("hKey", hKey);
rv = po->C_SignInit(hSession, pMechanism, hKey);
return retne(rv);
Expand Down