/** * gnutls_openpgp_privkey_export_subkey_dsa_raw: * @pkey: Holds the certificate * @idx: Is the subkey index * @p: will hold the p * @q: will hold the q * @g: will hold the g * @y: will hold the y * @x: will hold the x * * This function will export the DSA private key's parameters found * in the given certificate. The new parameters will be allocated * using gnutls_malloc() and will be stored in the appropriate datum. * * Returns: %GNUTLS_E_SUCCESS on success, otherwise a negative error code. * * Since: 2.4.0 **/ int gnutls_openpgp_privkey_export_subkey_dsa_raw(gnutls_openpgp_privkey_t pkey, unsigned int idx, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g, gnutls_datum_t * y, gnutls_datum_t * x) { uint8_t keyid[GNUTLS_OPENPGP_KEYID_SIZE]; int ret; if (idx == GNUTLS_OPENPGP_MASTER_KEYID_IDX) ret = gnutls_openpgp_privkey_get_key_id(pkey, keyid); else ret = gnutls_openpgp_privkey_get_subkey_id(pkey, idx, keyid); if (ret < 0) { gnutls_assert(); return ret; } return _get_sk_dsa_raw(pkey, keyid, p, q, g, y, x); }
static void check_loaded_key(gnutls_certificate_credentials_t cred) { int err; gnutls_openpgp_privkey_t key; gnutls_openpgp_crt_t *crts; unsigned n_crts; gnutls_openpgp_keyid_t keyid; unsigned i; /* check that the getter functions for openpgp keys of * gnutls_certificate_credentials_t work and deliver the * expected key ID. */ err = gnutls_certificate_get_openpgp_key(cred, 0, &key); if (err != 0) fail("get openpgp key %s\n", gnutls_strerror(err)); gnutls_openpgp_privkey_get_subkey_id(key, 0, keyid); if (keyid[0] != 0xf3 || keyid[1] != 0x0f || keyid[2] != 0xd4 || keyid[3] != 0x23 || keyid[4] != 0xc1 || keyid[5] != 0x43 || keyid[6] != 0xe7 || keyid[7] != 0xba) fail("incorrect key id (privkey)\n"); err = gnutls_certificate_get_openpgp_crt(cred, 0, &crts, &n_crts); if (err != 0) fail("get openpgp crts %s\n", gnutls_strerror(err)); if (n_crts != 1) fail("openpgp n_crts != 1\n"); gnutls_openpgp_crt_get_subkey_id(crts[0], 0, keyid); if (keyid[0] != 0xf3 || keyid[1] != 0x0f || keyid[2] != 0xd4 || keyid[3] != 0x23 || keyid[4] != 0xc1 || keyid[5] != 0x43 || keyid[6] != 0xe7 || keyid[7] != 0xba) fail("incorrect key id (pubkey)\n"); for (i = 0; i < n_crts; ++i) gnutls_openpgp_crt_deinit(crts[i]); gnutls_free(crts); gnutls_openpgp_privkey_deinit(key); }
/** * gnutls_openpgp_privkey_export_subkey_dsa_raw: * @pkey: Holds the certificate * @idx: Is the subkey index * @p: will hold the p * @q: will hold the q * @g: will hold the g * @y: will hold the y * @x: will hold the x * * This function will export the DSA private key's parameters found * in the given certificate. The new parameters will be allocated * using gnutls_malloc() and will be stored in the appropriate datum. * * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error. * * Since: 2.4.0 **/ int gnutls_openpgp_privkey_export_subkey_dsa_raw (gnutls_openpgp_privkey_t pkey, unsigned int idx, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g, gnutls_datum_t * y, gnutls_datum_t * x) { gnutls_openpgp_keyid_t keyid; int ret; ret = gnutls_openpgp_privkey_get_subkey_id (pkey, idx, keyid); if (ret < 0) { gnutls_assert (); return ret; } return _get_sk_dsa_raw (pkey, keyid, p, q, g, y, x); }
/** * gnutls_openpgp_privkey_export_subkey_rsa_raw: * @pkey: Holds the certificate * @idx: Is the subkey index * @m: will hold the modulus * @e: will hold the public exponent * @d: will hold the private exponent * @p: will hold the first prime (p) * @q: will hold the second prime (q) * @u: will hold the coefficient * * This function will export the RSA private key's parameters found in * the given structure. The new parameters will be allocated using * gnutls_malloc() and will be stored in the appropriate datum. * * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error. * * Since: 2.4.0 **/ int gnutls_openpgp_privkey_export_subkey_rsa_raw (gnutls_openpgp_privkey_t pkey, unsigned int idx, gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u) { gnutls_openpgp_keyid_t keyid; int ret; ret = gnutls_openpgp_privkey_get_subkey_id (pkey, idx, keyid); if (ret < 0) { gnutls_assert (); return ret; } return _get_sk_rsa_raw (pkey, keyid, m, e, d, p, q, u); }