diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-04-15 11:47:39 +0300 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2015-04-15 11:47:39 +0300 |
commit | 647002913d6043fb1658d8c8dcb50251c609aff4 (patch) | |
tree | 04f584d0f17d36ebcd1e6358df333c06159c004b | |
parent | bfa105cf08a8274669c0f456a65955cb07548aec (diff) | |
download | gnutls-647002913d6043fb1658d8c8dcb50251c609aff4.tar.gz |
gnutls_x509_crt_get_pk_* are based on gnutls_pubkey_export_*
-rw-r--r-- | lib/x509/x509.c | 87 |
1 files changed, 20 insertions, 67 deletions
diff --git a/lib/x509/x509.c b/lib/x509/x509.c index b0dff5a80e..575cd791ad 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -3033,42 +3033,31 @@ gnutls_x509_crt_get_pk_rsa_raw(gnutls_x509_crt_t crt, gnutls_datum_t * m, gnutls_datum_t * e) { int ret; - gnutls_pk_params_st params; + gnutls_pubkey_t pubkey; if (crt == NULL) { gnutls_assert(); return GNUTLS_E_INVALID_REQUEST; } - ret = gnutls_x509_crt_get_pk_algorithm(crt, NULL); - if (ret != GNUTLS_PK_RSA) { - gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; - } - - ret = _gnutls_x509_crt_get_mpis(crt, ¶ms); - if (ret < 0) { - gnutls_assert(); - return ret; - } + ret = gnutls_pubkey_init(&pubkey); + if (ret < 0) + return gnutls_assert_val(ret); - ret = _gnutls_mpi_dprint_lz(params.params[0], m); - if (ret < 0) { + ret = gnutls_pubkey_import_x509(pubkey, crt, 0); + if (ret < 0) { gnutls_assert(); goto cleanup; } - ret = _gnutls_mpi_dprint_lz(params.params[1], e); - if (ret < 0) { + ret = gnutls_pubkey_export_rsa_raw(pubkey, m, e); + if (ret < 0) { gnutls_assert(); - _gnutls_free_datum(m); goto cleanup; } - ret = 0; - - cleanup: - gnutls_pk_params_release(¶ms); + cleanup: + gnutls_pubkey_deinit(pubkey); return ret; } @@ -3139,68 +3128,32 @@ gnutls_x509_crt_get_pk_dsa_raw(gnutls_x509_crt_t crt, gnutls_datum_t * g, gnutls_datum_t * y) { int ret; - gnutls_pk_params_st params; + gnutls_pubkey_t pubkey; if (crt == NULL) { gnutls_assert(); return GNUTLS_E_INVALID_REQUEST; } - ret = gnutls_x509_crt_get_pk_algorithm(crt, NULL); - if (ret != GNUTLS_PK_DSA) { - gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; - } - - ret = _gnutls_x509_crt_get_mpis(crt, ¶ms); - if (ret < 0) { - gnutls_assert(); - return ret; - } - - - /* P */ - ret = _gnutls_mpi_dprint_lz(params.params[0], p); - if (ret < 0) { - gnutls_assert(); - goto cleanup; - } - - /* Q */ - ret = _gnutls_mpi_dprint_lz(params.params[1], q); - if (ret < 0) { - gnutls_assert(); - _gnutls_free_datum(p); - goto cleanup; - } - + ret = gnutls_pubkey_init(&pubkey); + if (ret < 0) + return gnutls_assert_val(ret); - /* G */ - ret = _gnutls_mpi_dprint_lz(params.params[2], g); - if (ret < 0) { + ret = gnutls_pubkey_import_x509(pubkey, crt, 0); + if (ret < 0) { gnutls_assert(); - _gnutls_free_datum(p); - _gnutls_free_datum(q); goto cleanup; } - - /* Y */ - ret = _gnutls_mpi_dprint_lz(params.params[3], y); - if (ret < 0) { + ret = gnutls_pubkey_export_dsa_raw(pubkey, p, q, g, y); + if (ret < 0) { gnutls_assert(); - _gnutls_free_datum(p); - _gnutls_free_datum(g); - _gnutls_free_datum(q); goto cleanup; } - ret = 0; - - cleanup: - gnutls_pk_params_release(¶ms); + cleanup: + gnutls_pubkey_deinit(pubkey); return ret; - } /** |