All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
       [not found] <CAM1xzG1X-iERU2ZXFS_m_VqCKOwjt_gD8oi0F8J5h38Xx+FQ9A@...278...>
@ 2019-04-10 15:58 ` Selva Nair
  2019-04-10 16:58   ` Jan Just Keijser
  2019-04-10 21:46   ` David Sommerseth
  0 siblings, 2 replies; 11+ messages in thread
From: Selva Nair @ 2019-04-10 15:58 UTC (permalink / raw)
  To: Francois Gelis <francois.gelis@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 2925 bytes --]

Hi,

This is more relevant to OpenVPN than OpenSSL, so copying to the
openvpn-devel list.

On Wed, Apr 10, 2019 at 10:11 AM Francois Gelis <francois.gelis@...277...>
wrote:

> Hi all,
>
> I have a working openvpn setup with client certificate and private key
> stored on my laptop. Then, I have loaded them into a smartcard (Yubico 5
> NFC), and modified accordingly the openvpn client config. But running the
> openvpn client now fails with an error that seems to originate inside
> openssl. Here is a verbose openvpn log (only the portion that seems
> relevant for this error, but I have the full log if useful):
>
> Sat Apr  6 15:57:20 2019 us=467260 Incoming Ciphertext -> TLS
> Sat Apr  6 15:57:20 2019 us=467271 SSL state (connect): SSLv3/TLS read
> server hello
> Sat Apr  6 15:57:20 2019 us=467468 VERIFY OK: depth=1, CN=FG-CA
> Sat Apr  6 15:57:20 2019 us=467598 VERIFY KU OK
> Sat Apr  6 15:57:20 2019 us=467609 Validating certificate extended key
> usage
> Sat Apr  6 15:57:20 2019 us=467615 ++ Certificate has EKU (str) TLS Web
> Server Authentication, expects TLS Web Server Authentication
> Sat Apr  6 15:57:20 2019 us=467620 VERIFY EKU OK
> Sat Apr  6 15:57:20 2019 us=467625 VERIFY OK: depth=0, CN=tx2
> Sat Apr  6 15:57:20 2019 us=467650 SSL state (connect): SSLv3/TLS read
> server certificate
> Sat Apr  6 15:57:20 2019 us=467735 SSL state (connect): SSLv3/TLS read
> server key exchange
> Sat Apr  6 15:57:20 2019 us=467763 SSL state (connect): SSLv3/TLS read
> server certificate request
> Sat Apr  6 15:57:20 2019 us=467771 SSL state (connect): SSLv3/TLS read
> server done
> Sat Apr  6 15:57:20 2019 us=467845 SSL state (connect): SSLv3/TLS write
> client certificate
> Sat Apr  6 15:57:20 2019 us=468012 SSL state (connect): SSLv3/TLS write
> client key exchange
> Sat Apr  6 15:57:20 2019 us=468053 PKCS#11: __pkcs11h_openssl_rsa_enc
> entered - flen=256, from=0x559d078d6e70, to=0x559d078d6bc0,
> rsa=0x559d078b3630, padding=3
> Sat Apr  6 15:57:20 2019 us=468060 PKCS#11: __pkcs11h_openssl_rsa_enc -
> return rv=112-'CKR_MECHANISM_INVALID'
> Sat Apr  6 15:57:20 2019 us=468070 SSL alert (write): fatal: internal error
> Sat Apr  6 15:57:20 2019 us=468085 OpenSSL: error:141F0006:SSL
> routines:tls_construct_cert_verify:EVP lib
> Sat Apr  6 15:57:20 2019 us=468092 TLS_ERROR: BIO read tls_read_plaintext
> error
> Sat Apr  6 15:57:20 2019 us=468097 TLS Error: TLS object -> incoming
> plaintext read error
> Sat Apr  6 15:57:20 2019 us=468101 TLS Error: TLS handshake failed
>
> Somehow, it seems that __pkcs11h_openssl_rsa_enc was called with an
> unexpected padding. Any ideas on what might be the cause of this?
>
>
As I replied to the openssl-users list[*], pkcs11-helper only supports
PKCS1 signatures, not raw signature needed in this case.

We have to either patch pkcs11-helper or switch to something else.

Selva

[*] https://mta.openssl.org/pipermail/openssl-users/2019-April/010266.html

[-- Attachment #2: Type: text/html, Size: 3735 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-10 15:58 ` [Openvpn-devel] Issue with smartcard authentication for openvpn Selva Nair
@ 2019-04-10 16:58   ` Jan Just Keijser
  2019-04-10 17:09     ` Selva Nair
  2019-04-10 21:46   ` David Sommerseth
  1 sibling, 1 reply; 11+ messages in thread
From: Jan Just Keijser @ 2019-04-10 16:58 UTC (permalink / raw)
  To: Selva Nair <selva.nair@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 3348 bytes --]

On 10/04/19 17:58, Selva Nair wrote:
> Hi,
>
> This is more relevant to OpenVPN than OpenSSL, so copying to the 
> openvpn-devel list.
>
> On Wed, Apr 10, 2019 at 10:11 AM Francois Gelis 
> <francois.gelis@...277... <mailto:francois.gelis@...277...>> wrote:
>
>     Hi all,
>
>     I have a working openvpn setup with client certificate and private
>     key stored on my laptop. Then, I have loaded them into a smartcard
>     (Yubico 5 NFC), and modified accordingly the openvpn client
>     config. But running the openvpn client now fails with an error
>     that seems to originate inside openssl. Here is a verbose openvpn
>     log (only the portion that seems relevant for this error, but I
>     have the full log if useful):
>
>     Sat Apr  6 15:57:20 2019 us=467260 Incoming Ciphertext -> TLS
>     Sat Apr  6 15:57:20 2019 us=467271 SSL state (connect): SSLv3/TLS
>     read server hello
>     Sat Apr  6 15:57:20 2019 us=467468 VERIFY OK: depth=1, CN=FG-CA
>     Sat Apr  6 15:57:20 2019 us=467598 VERIFY KU OK
>     Sat Apr  6 15:57:20 2019 us=467609 Validating certificate extended
>     key usage
>     Sat Apr  6 15:57:20 2019 us=467615 ++ Certificate has EKU (str)
>     TLS Web Server Authentication, expects TLS Web Server Authentication
>     Sat Apr  6 15:57:20 2019 us=467620 VERIFY EKU OK
>     Sat Apr  6 15:57:20 2019 us=467625 VERIFY OK: depth=0, CN=tx2
>     Sat Apr  6 15:57:20 2019 us=467650 SSL state (connect): SSLv3/TLS
>     read server certificate
>     Sat Apr  6 15:57:20 2019 us=467735 SSL state (connect): SSLv3/TLS
>     read server key exchange
>     Sat Apr  6 15:57:20 2019 us=467763 SSL state (connect): SSLv3/TLS
>     read server certificate request
>     Sat Apr  6 15:57:20 2019 us=467771 SSL state (connect): SSLv3/TLS
>     read server done
>     Sat Apr  6 15:57:20 2019 us=467845 SSL state (connect): SSLv3/TLS
>     write client certificate
>     Sat Apr  6 15:57:20 2019 us=468012 SSL state (connect): SSLv3/TLS
>     write client key exchange
>     Sat Apr  6 15:57:20 2019 us=468053 PKCS#11:
>     __pkcs11h_openssl_rsa_enc entered - flen=256, from=0x559d078d6e70,
>     to=0x559d078d6bc0, rsa=0x559d078b3630, padding=3
>     Sat Apr  6 15:57:20 2019 us=468060 PKCS#11:
>     __pkcs11h_openssl_rsa_enc - return rv=112-'CKR_MECHANISM_INVALID'
>     Sat Apr  6 15:57:20 2019 us=468070 SSL alert (write): fatal:
>     internal error
>     Sat Apr  6 15:57:20 2019 us=468085 OpenSSL: error:141F0006:SSL
>     routines:tls_construct_cert_verify:EVP lib
>     Sat Apr  6 15:57:20 2019 us=468092 TLS_ERROR: BIO read
>     tls_read_plaintext error
>     Sat Apr  6 15:57:20 2019 us=468097 TLS Error: TLS object ->
>     incoming plaintext read error
>     Sat Apr  6 15:57:20 2019 us=468101 TLS Error: TLS handshake failed
>
>     Somehow, it seems that __pkcs11h_openssl_rsa_enc was called with
>     an unexpected padding. Any ideas on what might be the cause of this?
>
>
> As I replied to the openssl-users list[*], pkcs11-helper only supports 
> PKCS1 signatures, not raw signature needed in this case.
>
> We have to either patch pkcs11-helper or switch to something else.
>
>
patching pkcs11-helper does not seem too difficult for this particular 
case - but how can we test it? I have access to hw tokens but I don't 
know how to trigger the "raw signature" bit.

JJK


[-- Attachment #2: Type: text/html, Size: 6171 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-10 16:58   ` Jan Just Keijser
@ 2019-04-10 17:09     ` Selva Nair
  2019-04-17 14:45       ` Jan Just Keijser
  0 siblings, 1 reply; 11+ messages in thread
From: Selva Nair @ 2019-04-10 17:09 UTC (permalink / raw)
  To: Francois Gelis <francois.gelis@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 3653 bytes --]

On Wed, Apr 10, 2019 at 12:59 PM Jan Just Keijser <janjust@...1147...> wrote:

> On 10/04/19 17:58, Selva Nair wrote:
>
> Hi,
>
> This is more relevant to OpenVPN than OpenSSL, so copying to the
> openvpn-devel list.
>
> On Wed, Apr 10, 2019 at 10:11 AM Francois Gelis <francois.gelis@...277...>
> wrote:
>
>> Hi all,
>>
>> I have a working openvpn setup with client certificate and private key
>> stored on my laptop. Then, I have loaded them into a smartcard (Yubico 5
>> NFC), and modified accordingly the openvpn client config. But running the
>> openvpn client now fails with an error that seems to originate inside
>> openssl. Here is a verbose openvpn log (only the portion that seems
>> relevant for this error, but I have the full log if useful):
>>
>> Sat Apr  6 15:57:20 2019 us=467260 Incoming Ciphertext -> TLS
>> Sat Apr  6 15:57:20 2019 us=467271 SSL state (connect): SSLv3/TLS read
>> server hello
>> Sat Apr  6 15:57:20 2019 us=467468 VERIFY OK: depth=1, CN=FG-CA
>> Sat Apr  6 15:57:20 2019 us=467598 VERIFY KU OK
>> Sat Apr  6 15:57:20 2019 us=467609 Validating certificate extended key
>> usage
>> Sat Apr  6 15:57:20 2019 us=467615 ++ Certificate has EKU (str) TLS Web
>> Server Authentication, expects TLS Web Server Authentication
>> Sat Apr  6 15:57:20 2019 us=467620 VERIFY EKU OK
>> Sat Apr  6 15:57:20 2019 us=467625 VERIFY OK: depth=0, CN=tx2
>> Sat Apr  6 15:57:20 2019 us=467650 SSL state (connect): SSLv3/TLS read
>> server certificate
>> Sat Apr  6 15:57:20 2019 us=467735 SSL state (connect): SSLv3/TLS read
>> server key exchange
>> Sat Apr  6 15:57:20 2019 us=467763 SSL state (connect): SSLv3/TLS read
>> server certificate request
>> Sat Apr  6 15:57:20 2019 us=467771 SSL state (connect): SSLv3/TLS read
>> server done
>> Sat Apr  6 15:57:20 2019 us=467845 SSL state (connect): SSLv3/TLS write
>> client certificate
>> Sat Apr  6 15:57:20 2019 us=468012 SSL state (connect): SSLv3/TLS write
>> client key exchange
>> Sat Apr  6 15:57:20 2019 us=468053 PKCS#11: __pkcs11h_openssl_rsa_enc
>> entered - flen=256, from=0x559d078d6e70, to=0x559d078d6bc0,
>> rsa=0x559d078b3630, padding=3
>> Sat Apr  6 15:57:20 2019 us=468060 PKCS#11: __pkcs11h_openssl_rsa_enc -
>> return rv=112-'CKR_MECHANISM_INVALID'
>> Sat Apr  6 15:57:20 2019 us=468070 SSL alert (write): fatal: internal
>> error
>> Sat Apr  6 15:57:20 2019 us=468085 OpenSSL: error:141F0006:SSL
>> routines:tls_construct_cert_verify:EVP lib
>> Sat Apr  6 15:57:20 2019 us=468092 TLS_ERROR: BIO read tls_read_plaintext
>> error
>> Sat Apr  6 15:57:20 2019 us=468097 TLS Error: TLS object -> incoming
>> plaintext read error
>> Sat Apr  6 15:57:20 2019 us=468101 TLS Error: TLS handshake failed
>>
>> Somehow, it seems that __pkcs11h_openssl_rsa_enc was called with an
>> unexpected padding. Any ideas on what might be the cause of this?
>>
>>
> As I replied to the openssl-users list[*], pkcs11-helper only supports
> PKCS1 signatures, not raw signature needed in this case.
>
> We have to either patch pkcs11-helper or switch to something else.
>
>
> patching pkcs11-helper does not seem too difficult for this particular
> case - but how can we test it? I have access to hw tokens but I don't know
> how to trigger the "raw signature" bit.
>

If both server and client are built with OpenSSL 1.1.1 and TLS version is
>= 1.2, PSS padding will get used and trigger this. OpenSSL does PSS
padding internally and passes the padded data to the rsa_priv_enc calback
for raw signature.

This is based on my tests for our Windows cryptoapi and
management-external-key patches for the same -- never tried this using
pkcs11-helper, but I expect the same behaviour.

Selva

[-- Attachment #2: Type: text/html, Size: 6894 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-10 15:58 ` [Openvpn-devel] Issue with smartcard authentication for openvpn Selva Nair
  2019-04-10 16:58   ` Jan Just Keijser
@ 2019-04-10 21:46   ` David Sommerseth
  2019-04-11  1:58     ` Selva Nair
  1 sibling, 1 reply; 11+ messages in thread
From: David Sommerseth @ 2019-04-10 21:46 UTC (permalink / raw)
  To: Selva Nair <selva.nair@; +Cc: openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 930 bytes --]

On 10/04/2019 17:58, Selva Nair wrote:
> 
> As I replied to the openssl-users list[*], pkcs11-helper only supports PKCS1
> signatures, not raw signature needed in this case.
> 
> We have to either patch pkcs11-helper or switch to something else.

It would be wonderful to switch it for something else.  Unfortunately, it does
a lot of gluing between the lower-level operations (similarly available via
p11-kit) and the interfaces implemented in OpenVPN is fairly high-level.  So
this "glue code" which pkcs11-helper is, is not that trivial and last time I
checked the alternatives were scarce :(

Is this a Windows only issue?  Or is it present on other platforms as well?
If it's Windows only, I think we can get around it by patching it and ensuring
upstream is aware of this.  But if it is more platforms, patching
pkcs11-helper gets nasty quickly.


-- 
kind regards,

David Sommerseth
OpenVPN Inc



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-10 21:46   ` David Sommerseth
@ 2019-04-11  1:58     ` Selva Nair
  0 siblings, 0 replies; 11+ messages in thread
From: Selva Nair @ 2019-04-11  1:58 UTC (permalink / raw)
  To: David Sommerseth <openvpn@; +Cc: Francois Gelis <francois.gelis@

[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]

Hi,


On Wed, Apr 10, 2019 at 6:00 PM David Sommerseth <
openvpn@...2080...> wrote:

> On 10/04/2019 17:58, Selva Nair wrote:
> >
> > As I replied to the openssl-users list[*], pkcs11-helper only supports
> PKCS1
> > signatures, not raw signature needed in this case.
> >
> > We have to either patch pkcs11-helper or switch to something else.
>
> It would be wonderful to switch it for something else.  Unfortunately, it
> does
> a lot of gluing between the lower-level operations (similarly available via
> p11-kit) and the interfaces implemented in OpenVPN is fairly high-level.
> So
> this "glue code" which pkcs11-helper is, is not that trivial and last time
> I
> checked the alternatives were scarce :(
>
> Is this a Windows only issue?  Or is it present on other platforms as well?
> If it's Windows only, I think we can get around it by patching it and
> ensuring
> upstream is aware of this.  But if it is more platforms, patching
> pkcs11-helper gets nasty quickly.
>

This has nothing to do with Windows. This is a limitation of pkcs11-helper
no matter what OS its used in. In fact on Windows we have an alternative
option to use hardware tokens through cryptoapicert, but on other OSes we
are dependent on pkcs11-helper.

So this has everything non-Windows written on it.

Selva

[-- Attachment #2: Type: text/html, Size: 1750 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-10 17:09     ` Selva Nair
@ 2019-04-17 14:45       ` Jan Just Keijser
  2019-04-17 15:52         ` Selva Nair
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Just Keijser @ 2019-04-17 14:45 UTC (permalink / raw)
  To: Selva Nair <selva.nair@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 4532 bytes --]

Hi Selva,

On 10/04/19 19:09, Selva Nair wrote:
>
>
> On Wed, Apr 10, 2019 at 12:59 PM Jan Just Keijser <janjust@...1147... 
> <mailto:janjust@...1147...>> wrote:
>
>     On 10/04/19 17:58, Selva Nair wrote:
>>     Hi,
>>
>>     This is more relevant to OpenVPN than OpenSSL, so copying to the
>>     openvpn-devel list.
>>
>>     On Wed, Apr 10, 2019 at 10:11 AM Francois Gelis
>>     <francois.gelis@...277... <mailto:francois.gelis@...277...>> wrote:
>>
>>         Hi all,
>>
>>         I have a working openvpn setup with client certificate and
>>         private key stored on my laptop. Then, I have loaded them
>>         into a smartcard (Yubico 5 NFC), and modified accordingly the
>>         openvpn client config. But running the openvpn client now
>>         fails with an error that seems to originate inside openssl.
>>         Here is a verbose openvpn log (only the portion that seems
>>         relevant for this error, but I have the full log if useful):
>>
>>         Sat Apr  6 15:57:20 2019 us=467260 Incoming Ciphertext -> TLS
>>         Sat Apr  6 15:57:20 2019 us=467271 SSL state (connect):
>>         SSLv3/TLS read server hello
>>         Sat Apr  6 15:57:20 2019 us=467468 VERIFY OK: depth=1, CN=FG-CA
>>         Sat Apr  6 15:57:20 2019 us=467598 VERIFY KU OK
>>         Sat Apr  6 15:57:20 2019 us=467609 Validating certificate
>>         extended key usage
>>         Sat Apr  6 15:57:20 2019 us=467615 ++ Certificate has EKU
>>         (str) TLS Web Server Authentication, expects TLS Web Server
>>         Authentication
>>         Sat Apr  6 15:57:20 2019 us=467620 VERIFY EKU OK
>>         Sat Apr  6 15:57:20 2019 us=467625 VERIFY OK: depth=0, CN=tx2
>>         Sat Apr  6 15:57:20 2019 us=467650 SSL state (connect):
>>         SSLv3/TLS read server certificate
>>         Sat Apr  6 15:57:20 2019 us=467735 SSL state (connect):
>>         SSLv3/TLS read server key exchange
>>         Sat Apr  6 15:57:20 2019 us=467763 SSL state (connect):
>>         SSLv3/TLS read server certificate request
>>         Sat Apr  6 15:57:20 2019 us=467771 SSL state (connect):
>>         SSLv3/TLS read server done
>>         Sat Apr  6 15:57:20 2019 us=467845 SSL state (connect):
>>         SSLv3/TLS write client certificate
>>         Sat Apr  6 15:57:20 2019 us=468012 SSL state (connect):
>>         SSLv3/TLS write client key exchange
>>         Sat Apr  6 15:57:20 2019 us=468053 PKCS#11:
>>         __pkcs11h_openssl_rsa_enc entered - flen=256,
>>         from=0x559d078d6e70, to=0x559d078d6bc0, rsa=0x559d078b3630,
>>         padding=3
>>         Sat Apr  6 15:57:20 2019 us=468060 PKCS#11:
>>         __pkcs11h_openssl_rsa_enc - return rv=112-'CKR_MECHANISM_INVALID'
>>         Sat Apr  6 15:57:20 2019 us=468070 SSL alert (write): fatal:
>>         internal error
>>         Sat Apr  6 15:57:20 2019 us=468085 OpenSSL:
>>         error:141F0006:SSL routines:tls_construct_cert_verify:EVP lib
>>         Sat Apr  6 15:57:20 2019 us=468092 TLS_ERROR: BIO read
>>         tls_read_plaintext error
>>         Sat Apr  6 15:57:20 2019 us=468097 TLS Error: TLS object ->
>>         incoming plaintext read error
>>         Sat Apr  6 15:57:20 2019 us=468101 TLS Error: TLS handshake
>>         failed
>>
>>         Somehow, it seems that __pkcs11h_openssl_rsa_enc was called
>>         with an unexpected padding. Any ideas on what might be the
>>         cause of this?
>>
>>
>>     As I replied to the openssl-users list[*], pkcs11-helper only
>>     supports PKCS1 signatures, not raw signature needed in this case.
>>
>>     We have to either patch pkcs11-helper or switch to something else.
>>
>>
>     patching pkcs11-helper does not seem too difficult for this
>     particular case - but how can we test it? I have access to hw
>     tokens but I don't know how to trigger the "raw signature" bit.
>
>
> If both server and client are built with OpenSSL 1.1.1 and TLS version 
> is >= 1.2, PSS padding will get used and trigger this. OpenSSL does 
> PSS padding internally and passes the padded data to the rsa_priv_enc 
> calback for raw signature.
>
> This is based on my tests for our Windows cryptoapi and 
> management-external-key patches for the same -- never tried this using 
> pkcs11-helper, but I expect the same behaviour.
>
>
The good news: I can reproduce this with
- openvpn 2.4.7
- openssl 1.1.1b
- pkcs11helper 1.25.1
- Safenet etoken
- client+server CentOS 7

The bad news: I don't have a fix yet.

I will keep the list posted on any progress I make,

JJK


[-- Attachment #2: Type: text/html, Size: 9682 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-17 14:45       ` Jan Just Keijser
@ 2019-04-17 15:52         ` Selva Nair
  2019-04-19 13:12           ` Jan Just Keijser
  0 siblings, 1 reply; 11+ messages in thread
From: Selva Nair @ 2019-04-17 15:52 UTC (permalink / raw)
  To: Jan Just Keijser <janjust@; +Cc: openvpn-devel


[-- Attachment #1.1: Type: text/plain, Size: 1306 bytes --]

Hi JJK,

On Wed, Apr 17, 2019 at 10:50 AM Jan Just Keijser <janjust@...1147...> wrote:

> Hi Selva,
>
> On 10/04/19 19:09, Selva Nair wrote:
>
>
>
> On Wed, Apr 10, 2019 at 12:59 PM Jan Just Keijser <janjust@...1147...>
> wrote:
>
>
snipped...


> patching pkcs11-helper does not seem too difficult for this particular
>> case - but how can we test it? I have access to hw tokens but I don't know
>> how to trigger the "raw signature" bit.
>>
>
> If both server and client are built with OpenSSL 1.1.1 and TLS version is
> >= 1.2, PSS padding will get used and trigger this. OpenSSL does PSS
> padding internally and passes the padded data to the rsa_priv_enc calback
> for raw signature.
>
> This is based on my tests for our Windows cryptoapi and
> management-external-key patches for the same -- never tried this using
> pkcs11-helper, but I expect the same behaviour.
>
>
> The good news: I can reproduce this with
> - openvpn 2.4.7
> - openssl 1.1.1b
> - pkcs11helper 1.25.1
> - Safenet etoken
> - client+server CentOS 7
>
> The bad news: I don't have a fix yet.
>

What I has in mind was a very simple patch like the one attached (totally
untested).
But I guess you tried that already and it doesn't work? Is it because the
token
does not support raw signature (not all do) or something else?

Selva

[-- Attachment #1.2: Type: text/html, Size: 3030 bytes --]

[-- Attachment #2: 0001-Support-raw-RSA-signature.patch --]
[-- Type: text/x-patch, Size: 968 bytes --]

From 547c58ce24e76598b504c9062820dae43fa9cc38 Mon Sep 17 00:00:00 2001
From: Selva Nair <selva.nair@gmail.com>
Date: Wed, 17 Apr 2019 11:26:40 -0400
Subject: [PATCH] Support raw RSA signature

Signed-off-by: Selva Nair <selva.nair@gmail.com>
---
 lib/pkcs11h-openssl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/pkcs11h-openssl.c b/lib/pkcs11h-openssl.c
index 4ebc211..6a396bb 100644
--- a/lib/pkcs11h-openssl.c
+++ b/lib/pkcs11h-openssl.c
@@ -567,7 +567,13 @@ __pkcs11h_openssl_rsa_enc (
 		padding
 	);
 
-	if (padding != RSA_PKCS1_PADDING) {
+	if (padding == RSA_PKCS1_PADDING) {
+		padding = CKM_RSA_PKCS;
+	}
+	else if (padding == RSA_NO_PADDING) {
+		padding = CKM_RSA_X_509;
+	}
+	else {
 		rv = CKR_MECHANISM_INVALID;
 		goto cleanup;
 	}
@@ -587,7 +593,7 @@ __pkcs11h_openssl_rsa_enc (
 	if (
 		(rv = pkcs11h_certificate_signAny (
 			certificate,
-			CKM_RSA_PKCS,
+			padding,
 			from,
 			flen,
 			to,
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-17 15:52         ` Selva Nair
@ 2019-04-19 13:12           ` Jan Just Keijser
  2019-04-19 19:03             ` Selva Nair
  2019-04-19 19:15             ` Gert Doering
  0 siblings, 2 replies; 11+ messages in thread
From: Jan Just Keijser @ 2019-04-19 13:12 UTC (permalink / raw)
  To: Selva Nair <selva.nair@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 2096 bytes --]

Hi Selva,

On 17/04/19 17:52, Selva Nair wrote:
>
> On Wed, Apr 17, 2019 at 10:50 AM Jan Just Keijser <janjust@...1147... 
> <mailto:janjust@...1147...>> wrote:
>
>
>     On 10/04/19 19:09, Selva Nair wrote:
>>
>>
>>     On Wed, Apr 10, 2019 at 12:59 PM Jan Just Keijser
>>     <janjust@...1147... <mailto:janjust@...1147...>> wrote:
>
>
> snipped...
>
>>         patching pkcs11-helper does not seem too difficult for this
>>         particular case - but how can we test it? I have access to hw
>>         tokens but I don't know how to trigger the "raw signature" bit.
>>
>>
>>     If both server and client are built with OpenSSL 1.1.1 and TLS
>>     version is >= 1.2, PSS padding will get used and trigger this.
>>     OpenSSL does PSS padding internally and passes the padded data to
>>     the rsa_priv_enc calback for raw signature.
>>
>>     This is based on my tests for our Windows cryptoapi and
>>     management-external-key patches for the same -- never tried this
>>     using pkcs11-helper, but I expect the same behaviour.
>>
>>
>     The good news: I can reproduce this with
>     - openvpn 2.4.7
>     - openssl 1.1.1b
>     - pkcs11helper 1.25.1
>     - Safenet etoken
>     - client+server CentOS 7
>
>     The bad news: I don't have a fix yet.
>
>
> What I has in mind was a very simple patch like the one attached 
> (totally untested).
> But I guess you tried that already and it doesn't work? Is it because 
> the token
> does not support raw signature (not all do) or something else?
>
>
I had not written a patch when I wrote my earlier email, but your patch 
is exactly what I had in mind; getting it all to compile and run with 
OpenSSL 1.1.1b + OpenVPN 2.4.7 was a bit of a challenge, but I finally 
managed...

and yes, your patch works admirably - I can connect again using TLSv1.3 
+ token.  If I comment out your patch, do a rebuild of 
libpkcs11helper.so then it fails again, proving your patch works.

Can you do a pull request for your pkcs11-helper patch on the 
pkcs11helper github page?  or shall we simply patch pkcs11-helper ourselves?

cheers,

JJK


[-- Attachment #2: Type: text/html, Size: 5209 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-19 13:12           ` Jan Just Keijser
@ 2019-04-19 19:03             ` Selva Nair
  2019-04-19 19:15             ` Gert Doering
  1 sibling, 0 replies; 11+ messages in thread
From: Selva Nair @ 2019-04-19 19:03 UTC (permalink / raw)
  To: Jan Just Keijser <janjust@; +Cc: Francois Gelis <francois.gelis@

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

Hi,

On Fri, Apr 19, 2019 at 9:13 AM Jan Just Keijser <janjust@...1147...> wrote:

> Hi Selva,I had not written a patch when I wrote my earlier email, but your
> patch is exactly what I had in mind; getting it all to compile and run with
> OpenSSL 1.1.1b + OpenVPN 2.4.7 was a bit of a challenge, but I finally
> managed...
>
> and yes, your patch works admirably - I can connect again using TLSv1.3 +
> token.  If I comment out your patch, do a rebuild of libpkcs11helper.so
> then it fails again, proving your patch works.
>

Good to know.


>
> Can you do a pull request for your pkcs11-helper patch on the pkcs11helper
> github page?  or shall we simply patch pkcs11-helper ourselves?
>

Getting this upstream is better for us, so let's first try a PR.

Regards,

Selva

[-- Attachment #2: Type: text/html, Size: 1668 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-19 13:12           ` Jan Just Keijser
  2019-04-19 19:03             ` Selva Nair
@ 2019-04-19 19:15             ` Gert Doering
  2019-04-22  1:04               ` Selva Nair
  1 sibling, 1 reply; 11+ messages in thread
From: Gert Doering @ 2019-04-19 19:15 UTC (permalink / raw)
  To: Jan Just Keijser <janjust@; +Cc: Selva Nair <selva.nair@

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

Hi,

On Fri, Apr 19, 2019 at 03:12:49PM +0200, Jan Just Keijser wrote:
> Can you do a pull request for your pkcs11-helper patch on the 
> pkcs11helper github page?  or shall we simply patch pkcs11-helper ourselves?

I agree with Selva that it should go upstream - since this is not about
windows, we do not provide our own pkcs11-helper builds anywhere, so
either we get the distribution maintainers involved (lots...) or
upstream.

(On *windows* we could just patch whatever library we use for our builds)

gert


-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             gert@...1296...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 630 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Openvpn-devel] Issue with smartcard authentication for openvpn
  2019-04-19 19:15             ` Gert Doering
@ 2019-04-22  1:04               ` Selva Nair
  0 siblings, 0 replies; 11+ messages in thread
From: Selva Nair @ 2019-04-22  1:04 UTC (permalink / raw)
  To: Gert Doering <gert@; +Cc: Jan Just Keijser <janjust@

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

Hi,

On Fri, Apr 19, 2019 at 3:15 PM Gert Doering <gert@...1296...> wrote:

> Hi,
>
> On Fri, Apr 19, 2019 at 03:12:49PM +0200, Jan Just Keijser wrote:
> > Can you do a pull request for your pkcs11-helper patch on the
> > pkcs11helper github page?  or shall we simply patch pkcs11-helper
> ourselves?
>
> I agree with Selva that it should go upstream - since this is not about
> windows, we do not provide our own pkcs11-helper builds anywhere, so
> either we get the distribution maintainers involved (lots...) or
> upstream.
>
> (On *windows* we could just patch whatever library we use for our builds)
>
>
I've submitted a PR upstream:
https://github.com/OpenSC/pkcs11-helper/pull/22

Selva

[-- Attachment #2: Type: text/html, Size: 1183 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-04-22  1:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAM1xzG1X-iERU2ZXFS_m_VqCKOwjt_gD8oi0F8J5h38Xx+FQ9A@...278...>
2019-04-10 15:58 ` [Openvpn-devel] Issue with smartcard authentication for openvpn Selva Nair
2019-04-10 16:58   ` Jan Just Keijser
2019-04-10 17:09     ` Selva Nair
2019-04-17 14:45       ` Jan Just Keijser
2019-04-17 15:52         ` Selva Nair
2019-04-19 13:12           ` Jan Just Keijser
2019-04-19 19:03             ` Selva Nair
2019-04-19 19:15             ` Gert Doering
2019-04-22  1:04               ` Selva Nair
2019-04-10 21:46   ` David Sommerseth
2019-04-11  1:58     ` Selva Nair

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.