[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnutls-dev] sign callback for certificate authentication
From: |
Ludovic Courtès |
Subject: |
Re: [gnutls-dev] sign callback for certificate authentication |
Date: |
Mon, 16 Apr 2007 14:15:22 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Hi,
"Jacob Berkman" <address@hidden> writes:
> I've attached a patch to gnutls which adds a callback for the signing
> step of certificate-based authentication. This was needed because
> some smart card policies do not allow private keys to be read/exported
> from them. They implement signing directly on the card.
I think this is a very good idea.
However, in your patch, you defined signing functions as:
typedef int gnutls_certificate_client_sign_function (gnutls_session_t session,
gnutls_datum_t * cert,
gnutls_certificate_type_t cert_type,
const gnutls_datum_t
*hash_concat,
gnutls_datum_t *
signature);
I think this suffers from the same shortcomings as most call-backs
defined in GnuTLS: one cannot attach additional data to be passed along
to the sign function.
Thus, I would instead recommend adding a `void *' parameter to
`gnutls_certificate_client_sign_function'; the
`gnutls_certificate_client_set_sign_function ()' needs to be modified
accordingly:
void gnutls_certificate_client_set_sign_function
(gnutls_certificate_credentials_t cred,
gnutls_certificate_client_sign_function * func,
void *user_data);
This way, USER_DATA would be passed as the last argument of FUNC each
time it is called.
Call-back APIs that fail to provide this make it hard to communicate
information to call-backs in a "safe" way: one has to resort to global
variables or some such, which makes code harder to read and is not
recommended in multi-threaded applications. Likewise, it makes it hard
to implement bindings for higher-level languages.
Thanks,
Ludovic.