Skip to contentSkip to conversation

openvpn - support PKCS#11 smartcards

Openvpn-devel C. Ruiz, Ivan 2 participants 2 messages Sep 13, 2005

lore
Share & tools
lore
#0 lore raw

Hello,

it works fine when you specify the "sign" method. If you leave it with the default (auto) OpenSC tricks your code to think that it supports SignRecover and it fails.

OpenSC says that the private key supports SignRecover (CKA_SIGN_RECOVER) when you ask it (see function pkcs15_prkey_get_attribute in http://www.opensc.org/opensc/file/releases/opensc-0.9.6/src/pkcs11/framework-pkcs15.c), but the problem is that OpenSC itself doesn't implement the function C_SignRecover and C_SignRecoverInit.

The problem is clearly on OpenSC pkcs#11 implementation, but with the option --pkcs11-sign-mode you have included we can workarround it!

I agree to drop support for OpenSC. The PKCS#11 approach works well with OpenSC and it will broad the support for other PKCS#11-aware smartcards/libraries.

One suggestion. I have noticed that if you don't give the argument --askpass to OpenVPN it will not start (doesn't have the PIN to the smartcard), giving a bit confusing message:
"Cannot set PKCS#11 parameters 7-CKR_ARGUMENTS_BAD".

Can the code check wether there's a PIN specified by the user before calling pkcs11_openSession and give a message like "You need to specify a PIN to access the smartcard."?

Iván Casado Ruiz
SADIEL, S.A.

-----Mensaje original-----
De: [email protected] [mailto:[email protected]]En nombre de Alon Bar-Lev
Enviado el: lunes, 12 de septiembre de 2005 22:40
Para: [email protected]
Asunto: [Openvpn-devel] openvpn - support PKCS#11 smartcards

Hello,

Quoted 3 lines · Ivan

I only changed C_SignRecover to C_Sign and C_SignRecoverInit to C_SignInit (pkcs11.c) and
it worked for me with OpenSC. Can you test if it's OK for you with this minor change?

Hmmm... It should be SignRecover... strange they don't support it... Anyway, please check the new patch... I've added a new argument:

--pkcs11-sign-mode mode
auto (default) - try to find out which to use. recover - use sign recover.
sign - use sign.

Please tell me if the default works.

Quoted 2 lines

Apart from this i've tested that I can specify certs both by label and by id <- OK!

I am very glad!!!

Quoted 3 lines

Not been able to test under Windows as I don't have the compiler for this platform.

I hope someone will check it out...

So... Can we drop the request for OpenSC support and focus on PKCS#11?

Best Regards,
Alon Bar-Lev.

#1 lore raw
Quoted 1 line · Ivan

The problem is clearly on OpenSC pkcs#11 implementation, but with the

option --pkcs11-sign-mode

Quoted 1 line

you have included we can workarround it!

OK... So we can close this issue.

Quoted 1 line

I agree to drop support for OpenSC. The PKCS#11 approach works well with

OpenSC and it will

Quoted 1 line

broad the support for other PKCS#11-aware smartcards/libraries.

Great... So we continue with request to merge the PKCS#11 code into openvpn.

Quoted 1 line

Can the code check wether there's a PIN specified by the user before

calling pkcs11_openSession and

Quoted 1 line

give a message like "You need to specify a PIN to access the smartcard."?

OK... I've already added --pkcs11-protected-authentication in the last patch... So if it is not given and there is no --askpass - I will add a failure.

One more task for me is to support more than one PKCS#11 provider... I will do this in the next weekend.

Best Regards,
Alon Bar-Lev.