summaryrefslogtreecommitdiff
path: root/lib/x509/privkey_pkcs8.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-20 16:43:18 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-21 14:25:01 +0200
commita761afe3dce139beffa7857c10c7136f83320c3d (patch)
tree174324da45f138d68e7cf973a31012298277bcee /lib/x509/privkey_pkcs8.c
parentfae0a53388115ea429c752c1a958db85dbc402bb (diff)
downloadgnutls-a761afe3dce139beffa7857c10c7136f83320c3d.tar.gz
Ensure that public key parameters are initialized on import
Previously we depended on initialization during the _init() call, however, there can be cases where this re-initialization is needed (e.g., on multiple tries to load a key). Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/x509/privkey_pkcs8.c')
-rw-r--r--lib/x509/privkey_pkcs8.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c
index e5d14a7c8d..23b27ec8c3 100644
--- a/lib/x509/privkey_pkcs8.c
+++ b/lib/x509/privkey_pkcs8.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003-2016 Free Software Foundation, Inc.
- * Copyright (C) 2014-2016 Red Hat
+ * Copyright (C) 2014-2017 Red Hat
* Copyright (C) 2014-2016 Nikos Mavrogiannopoulos
*
* Author: Nikos Mavrogiannopoulos
@@ -1042,6 +1042,8 @@ _decode_pkcs8_eddsa_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey, const c
gnutls_ecc_curve_t curve = GNUTLS_ECC_CURVE_INVALID;
const gnutls_ecc_curve_entry_st *ce;
+ gnutls_pk_params_init(&pkey->params);
+
curve = gnutls_oid_to_ecc_curve(oid);
if (curve == GNUTLS_ECC_CURVE_INVALID) {
_gnutls_debug_log("PKCS#8: unknown curve OID %s\n", oid);
@@ -1081,6 +1083,8 @@ _decode_pkcs8_dsa_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey)
int ret;
gnutls_datum_t tmp;
+ gnutls_pk_params_init(&pkey->params);
+
ret = _gnutls_x509_read_value(pkcs8_asn, "privateKey", &tmp);
if (ret < 0) {
gnutls_assert();