openvpn, smartcards and PKCS#11
Quoted 79 lines · Alon Bar-Lev
Hello,
I've seen some corresponding regarding this issue... But could not understand the formal position of the development team.
It seems that currently openvpn does not support smartcards.
I've noticed that a patch is available from Fritz Elfert that enables the use of openvpn and opensc smartcards.
http://openvpn.net/archive/openvpn-devel/2005-02/msg00000.htmlI could not find any roadmap or document that describes future intension of adding smartcard support for openvpn.
The usage of smartcard is very important since the inability to duplicate them and the fact that they are locked after X failed attempt to access them, makes them idle for identification.
Although the in the past opensc (www.opensc.com <http://www.opensc.com/>)
tried to
suggest a standard API to access smartcards, the most commonly adopted and supported is PKCS#11.PKCS#11 is a high-level API specification that allows a
software to access objects on cryptographic token and perform
cryptographic operation using none extractable keys located
on that token.
Usually, an application may extract X.509 certificates from
the tokens and perform RSA operation using the private key on
the token.
Most vendors provides a PKCS#11 library to be used by
application to access their devices.
More information may be found at www.rsasecurity.com/rsalabs/pkcs/pkcs-11/index.html<http://www.rsasecurity.com/rsalabs/pkcs/pkcs-11/index.html>Many applications are using PKCS#11, including Mozilla Firefox, Mozilla Thunderbird, Opera, Java and more...
PKCS#11 is also cross platform, so the same implementation can be run on Unix and Windows platform.
Currently, openvpn supports openssl engine for cipher operations.
There is an opensc PKCS#11 engine for openssl, that can be loaded dynamically, for example:
$ openssl OpenSSL> engine dynamic(quoted diff) +0
-5-pre SO_PATH:/usr/lib/opensc/engine _pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/local/lib/XXX.so(dynamic) Dynamic engine loading support [Success]: SO_PATH:/usr/lib/opensc/engine_pkcs11.so [Success]: ID:pkcs11
[Success]: LIST_ADD:1
[Success]: LOAD
[Success]: MODULE_PATH:/usr/local/lib/XXX.so
Loaded: (pkcs11) pkcs11 engine
OpenSSL>The above adds a new engine for the openssl to use, the new engine is called pkcs11 and is using the
/usr/local/lib/XXX.soPKCS#11 library that is provided by the cryptographic token provider, then a key can be accessed using fake file name in the form of slot_[#]-id_[#]The engine approach can be used as a first simple stage of supporting keys that available on smartcards. the problem is that this engine cannot fetch X.509 certificate from the token, and cannot enum keys, as expected from PKI application.
For this steep, I guess a new configuration options should be added:
1. load-engine - load new engines getting all the arguments required.
2. tls-engine - a separate engine to be used during tls negotiations.
Quoted 2 lines
For the long term, directly supporting PKCS#11 API specification is the right way to go.
Alon,
Thanks for the interesting information on PKCS#11, OpenSSL, and smartcards.
Any rough idea on what percentage of the cheaply available smartcards out there can talk to OpenSSL via PKCS#11?
Is this part of the OpenSC effort and/or does it obsolete it?
Is this capability of using OpenSSL + PKCS#11 something which is intended to provide access to smartcards on *nix systems only, or does it work on Windows as well?
So from what you are saying, I take it that PKCS#11 smartcard support is easily accessible from OpenVPN, if only the new directives load-engine and tls-engine are coded?
If this is the case, I would be happy to accept a patch which adds these directives. If you don't feel like coding it, it would be helpful if you could point us at some sample code which shows the appropriate OpenSSL calls.
James
Quoted 1 line · James Yonan
Thanks for the interesting information on PKCS#11, OpenSSL, and
smartcards.
You are welcome... I now doing a phase on all open-source projects that uses cryptographic but do not use smartcards... In a standard way... :)
Quoted 1 line
Any rough idea on what percentage of the cheaply available smartcards out
there can talk to OpenSSL via PKCS#11?
It depends on what cheap is for you... It can be rage from $12 in large numbers to $40 in ones...
Aladdin USB token (www.ealaddin.com) is about $40 for one, but it does not need a reader.
Athana smartcards (www.athena-scs.com) is about $17 for ones but it requires a reader that is about $20.
Both works well...
Aladdin uses opensc and there is opensc-pkcs#11 provider. Athena provides PKCS#11 library.
Quoted 1 line
Is this part of the OpenSC effort and/or does it obsolete it?
Opensc is an effort to produce open smartcard interface... But it failed. Currently there are two interfaces to access smartcards:
1. PKCS#11 of RSA Security (www.rsasecurity.com/rsalabs/node.asp?id=2133) - cross-platform free API.
2. Microsoft Cryptographic Service Provider (CSP) - Microsoft specific interface.
There is a PKCS#11 provider for opensc, so that if you have opensc card you can use it with applications that uses PKCS#11.
Quoted 1 line
Is this capability of using OpenSSL + PKCS#11 something which is intended
to provide access to smartcards on *nix systems only, or does
Quoted 1 line
it work on Windows as well?
Alon
maybe I am completely off topic but I am using an ikey 1000 on a Windoze box with standard openvpn. AFAIK the ikey 1000 provides a PKCS#11 interface which (at least on windoze) is handled by the proprietary driver.
This token only handles storage of the keys. I believe the engine is only required when you want to run crypto operations on the card.
Erich
Quoted 1 line · Erich Titl
maybe I am completely off topic but I am using an ikey 1000 on a Windoze
box with standard openvpn. AFAIK the ikey 1000 provides a
Quoted 1 line
PKCS#11 interface which (at least on windoze) is handled by the
proprietary driver.
Quoted 1 line
This token only handles storage of the keys. I believe the engine is only
required when you want to run crypto operations on the card.
Hello Erich,
In terms of security, there is no point of using a device that store keys only to be extracted by applications.
In order to secure your identity you must use a device that cannot be duplicated.
This can be implemented only if the device does not allow the private key to be extracted from it.
In order to make use of this none extractable key, the device must perform the cryptographic operations and not the software.
What you describe is somewhat like putting the private key on USB Storage device... This is very low security level.
Best Regards,
Alon Bar-Lev.
Alon
Quoted 1 line · Alon Bar-Lev
...
Quoted 7 lines
In terms of security, there is no point of using a device that store keys only to be extracted by applications.
In order to secure your identity you must use a device that cannot be duplicated.
This can be implemented only if the device does not allow the private key to be extracted from it.
This is the case for the ikey 1000. The device _should_ not allow duplication.
Quoted 2 lines
In order to make use of this none extractable key, the device must perform the cryptographic operations and not the software.
Which implies that you send cleartext to the device and get cyphertext back. So the easiest way to tamper the message is to intercept it at the
smartcard driver level :-) and modify it on the fly. If someone is
smart enough to fetch the key contents from memory while it is being used by the crypto software, he is smart enough to intercept the cleartext message.
Quoted 3 lines
What you describe is somewhat like putting the private key on USB Storage device... This is very low security level.
This device at least protects its contents against tampering, and does not yield the key without authentication. And this authentication is done on the device itself.
cheers
Erich
Quoted 1 line · Erich Titl
Which implies that you send cleartext to the device and get cyphertext
back. So the easiest way to tamper the message is to intercept it at
Quoted 1 line
the smartcard driver level :-) and modify it on the fly. If someone is
smart enough to fetch the key contents from memory while it is being used by
Quoted 1 line
the crypto software, he is smart enough to intercept the cleartext
message.
The issue is not whether someone can see your messages, the issue is whether I can steal your private key!
Quoted 1 line
This device at least protects its contents against tampering, and does not
yield the key without authentication. And this authentication is done
Quoted 1 line
on the device itself.
Most USB devices now require password before allow to access... And if you put your private key encrypted on such device, it is more or less the same security level.
If you like to upgrade your security, you should buy a device that implements smartcard... And replace your memory card.
Best Regards,
Alon Bar-Lev.