summaryrefslogtreecommitdiff
path: root/lib/tpm.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-07-17 01:15:17 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-07-17 01:15:17 +0200
commit4c3db964f976389c0545abb32f1e64ab2f61b037 (patch)
treeaf6b8b4a4ae19cf426fb1646c988484738647406 /lib/tpm.c
parent8b61dcc7715562707e4c0ce6406ad820c6cad127 (diff)
downloadgnutls-4c3db964f976389c0545abb32f1e64ab2f61b037.tar.gz
Callbacks are being called even if a global PIN functions is not set.
Diffstat (limited to 'lib/tpm.c')
-rw-r--r--lib/tpm.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/tpm.c b/lib/tpm.c
index 1bf57c95e7..c6d22d0bc5 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -205,8 +205,11 @@ int ret;
if (pin_info && pin_info->cb)
ret = pin_info->cb(pin_info->data, attempts, "TPM", label, flags, pin, pin_size);
- else
+ else if (_gnutls_pin_func)
ret = _gnutls_pin_func(_gnutls_pin_data, attempts, "TPM", label, flags, pin, pin_size);
+ else
+ ret = gnutls_assert_val(GNUTLS_E_TPM_KEY_PASSWORD_ERROR); /* doesn't really matter */
+
if (ret < 0)
{
gnutls_assert();
@@ -311,13 +314,10 @@ static void tpm_close_session(struct tpm_ctx_st *s)
}
static int
-import_tpm_key_cb (gnutls_privkey_t pkey,
- const gnutls_datum_t * fdata,
- gnutls_x509_crt_fmt_t format,
- TSS_UUID *uuid,
- TSS_FLAG storage,
- const char *srk_password,
- const char *key_password)
+import_tpm_key_cb (gnutls_privkey_t pkey, const gnutls_datum_t * fdata,
+ gnutls_x509_crt_fmt_t format, TSS_UUID *uuid,
+ TSS_FLAG storage, const char *srk_password,
+ const char *key_password)
{
unsigned int attempts = 0;
char pin1[GNUTLS_PKCS11_MAX_PIN_LEN];
@@ -328,7 +328,7 @@ int ret, ret2;
{
ret = import_tpm_key(pkey, fdata, format, uuid, storage, srk_password, key_password);
- if (attempts > 3 || _gnutls_pin_func == NULL)
+ if (attempts > 3)
break;
if (ret == GNUTLS_E_TPM_SRK_PASSWORD_ERROR)
@@ -996,7 +996,7 @@ int ret;
{
ret = import_tpm_pubkey(pkey, fdata, format, uuid, storage, srk_password);
- if (attempts > 3 || _gnutls_pin_func == NULL)
+ if (attempts > 3)
break;
if (ret == GNUTLS_E_TPM_SRK_PASSWORD_ERROR)