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
Pkcs11 Edwards support #230
base: master
Are you sure you want to change the base?
Conversation
| if (pObj != NULL) { | ||
| int nid = OBJ_obj2nid(pObj); | ||
| ASN1_OBJECT_free(pObj); | ||
| return (nid == NID_ED25519) ? (0) : (-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, after getting the PKCS#11 3.0 out, there was a bit unclear whether the parameters should be DER encoded OID or printableString "edwards25519". For that reason I was changing this in softhsm in the following PR:
I think the applications should ideally accept both of the versions to avoid unexpected failures. The above place is how I handled that in SoftHSM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Implemented in a similar way, will be pushed soon
bff4208
to
c40d146
Compare
|
Force-pushed changes related to build without openssl and related to the comments by @Jakuje Don't see the MasOS output so can't do anything with it :( |
|
I reached out to Jakub about having trouble converting OPENSSL Ed25519 key to OPENSSH format when he pointed me out to the commit "Allow import Edwards keys from OpenSSL". I tried those changes by cloning the pkcs11_edwards branch and the conversion worked for me. $ openssl genpkey -algorithm Ed25519 -out ed25519key.pem NOW USING branch: pkcs11_edwards Thanks for the help Jakub. |
|
Hi Dmitry, Thanks, |
|
Hi Dmitry, debug2: ssh_ed25519_verify: crypto_sign_ed25519_open failed: -1 Thanks, |
|
No clues. Which token do you use? |
|
this PR exposes ssh-add's 1024-byte signature test's incompatibility with OpenSC's 512-byte internal limit, since the data to be signed is passed to OpenSC undigested (consequently, |
Hmm. Did not know about this feature of |
|
Hi Dmitry, firepower-2110:~# cat /mnt/disk0/.private/lina_sshd/ctxt0/ssh_host_eddsa_key.pub firepower-2110:~# cat /mnt/disk0/.private/lina_sshd/ctxt0/ssh_host_eddsa_key // input PEM CLIENT: A private ed25519 key on a normal linux host looks larger than the one generated from PEM above-- linux:~# cat /etc/ssh/ssh_host_ed25519_key Is there something amiss in the pair that ssh-keygen generated from the PEM I provided ? Thanks, |
|
Hello Nitin First of all I hope you didn't publish your real keys, just experimental ones. I'll try to check but not immediately |
|
Note the headers:
and
The first one is OpenSSH format and the other is PEM. The PEM file looks fine: But for some reason, the values in the OpenSSH format look different I was looking into the following part, which should be a public key so indeed if the PEM key was generated from this OpenSSH keye, there is probably something wrong as the values do not match |
|
I will check as the self-tests passed with my patch. |
|
After extracting the pubkey with locally built openssh via Decoding the value, I get that are exactly the same bytes. |
|
@martelletto would you mind to test the attached patch with opensc? |
|
@beldmit The diff works and looks good at a glance. I will give it a closer look early next week. |
|
Great! |
|
@beldmit Just like we call
|
May I ask you to commit it against the top of my patch? Totally missed it.
I tested it against SoftHSM as it was the only available implementation I had.
Unfortunately yes. For RSA and ECDSA this information is cached via the RSA_METHOD/EC_KEY_METHOD structures. |
I've placed a commit with suggestions here: martelletto@afe336c. I couldn't push to your branch (permission denied). Please feel free to squash/cherry-pick/modify as you see fit.
I was a bit puzzled by this, so I had a look. There's a difference in the way ECDSA and EDDSA keys are imported by SoftHSM2's softhsm2-util: ECDSA keys have their CKA_EC_POINT attribute set to an DER-encoded blob, while EDDSA keys have their CKA_EC_POINT attribute set to a raw octet string. AFAICT, the PKCS#11 3.0 spec is clear: |
|
@martelletto, do you have any contact with SoftHSM developers? |
|
@beldmit No. :( |
|
Hi @beldmit , Have you tried importing an Ed25519 PEM key or mine on your sshd, followed by testing a client connecting to it ? |
| goto send; | ||
|
|
||
| if ((sshkey_type_plain(id->key->type) == KEY_ED25519) && (id->key->flags & SSHKEY_FLAG_EXT)) { | ||
| if ((r = sshkey_sign_pkcs11(id->key, &signature, &slen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to add this function? RSA and ECDSA do not need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both RSA and ECDSA refer to the custom OpenSSL method so offload to pkcs11 happens implicitly. EdDSA does not have such API on the OpenSSL level so I had to offload it explicitly.
This patch provides basic support of Ed25519 keys via PKCS#11 tokens