diff options
author | Nikos <nmav@crystal.(none)> | 2008-04-04 21:58:27 +0300 |
---|---|---|
committer | Nikos <nmav@crystal.(none)> | 2008-04-04 21:58:27 +0300 |
commit | 110570ed572338e63ada7ad06b1b40e048b98041 (patch) | |
tree | 5c1ea5f3571864783b5e268d2862d21dcb3c61e2 | |
parent | e260521f5c9954d0a03855e283fd625a157f3df7 (diff) | |
download | gnutls-110570ed572338e63ada7ad06b1b40e048b98041.tar.gz |
Fail at import stage if a non proper certificate is loaded.
-rw-r--r-- | lib/openpgp/pgp.c | 13 | ||||
-rw-r--r-- | lib/openpgp/privkey.c | 11 |
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/openpgp/pgp.c b/lib/openpgp/pgp.c index 2646d0fe8a..2c085b1bfa 100644 --- a/lib/openpgp/pgp.c +++ b/lib/openpgp/pgp.c @@ -89,7 +89,8 @@ gnutls_openpgp_crt_import (gnutls_openpgp_crt_t key, const gnutls_datum_t * data, gnutls_openpgp_crt_fmt_t format) { - cdk_stream_t inp; + cdk_stream_t inp; + cdk_packet_t pkt; int rc; if (format == GNUTLS_OPENPGP_FMT_RAW) @@ -115,7 +116,15 @@ gnutls_openpgp_crt_import (gnutls_openpgp_crt_t key, return rc; } } - + + /* Test if the import was successful. */ + pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); + if (pkt == NULL) + { + gnutls_assert(); + return GNUTLS_E_OPENPGP_GETKEY_FAILED; + } + return 0; } diff --git a/lib/openpgp/privkey.c b/lib/openpgp/privkey.c index aa9c82be04..57d034223e 100644 --- a/lib/openpgp/privkey.c +++ b/lib/openpgp/privkey.c @@ -93,7 +93,8 @@ gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key, gnutls_openpgp_crt_fmt_t format, const char *pass, unsigned int flags) { - cdk_stream_t inp; + cdk_stream_t inp; + cdk_packet_t pkt; int rc; if (format == GNUTLS_OPENPGP_FMT_RAW) @@ -119,6 +120,14 @@ gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key, return rc; } } + + /* Test if the import was successful. */ + pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_SECRET_KEY); + if (pkt == NULL) + { + gnutls_assert(); + return GNUTLS_E_OPENPGP_GETKEY_FAILED; + } return 0; } |