mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Rework ECC support and add experimental support for Ed25519.
* agent/findkey.c (key_parms_from_sexp): Add algo name "ecc". (agent_is_dsa_key): Ditto. (agent_is_eddsa_key): New. Not finished, though. * agent/pksign.c (do_encode_eddsa): New. (agent_pksign_do): Use gcry_log_debug functions. * agent/protect.c (agent_protect): Parse a flags parameter. * g10/keygen.c (gpg_curve_to_oid): Move to ... * common/openpgp-oid.c (openpgp_curve_to_oid): here and rename. (oid_ed25519): New. (openpgp_oid_is_ed25519): New. (openpgp_oid_to_curve): New. * common/t-openpgp-oid.c (test_openpgp_oid_is_ed25519): New. * g10/build-packet.c (gpg_mpi_write): Write the length header also for opaque MPIs. (gpg_mpi_write_nohdr): New. (do_key): Use gpg_mpi_write_nohdr depending on algorithm. (do_pubkey_enc): Ditto. * g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Use gpg_mpi_write_nohdr. * g10/export.c (transfer_format_to_openpgp): * g10/keygen.c (ecckey_from_sexp): Return the error. (gen_ecc): Repalce arg NBITS by CURVE. (read_parameter_file): Add keywords "Key-Curve" and "Subkey-Curve". (ask_curve): New. (generate_keypair, generate_subkeypair): Use ask_curve. (do_generate_keypair): Also pass curve name. * g10/keylist.c (list_keyblock_print, list_keyblock_colon): Print curve name. * g10/parse-packet.c (mpi_read): Remove workaround for Libcgrypt < 1.5. (parse_key): Fix ECC case. Print the curve name. * g10/pkglue.c (mpi_from_sexp): Rename to get_mpi_from_sexp. (pk_verify, pk_check_secret_key): Add special case for Ed25519. * g10/seskey.c (encode_md_value): Ditto. * g10/sign.c (do_sign, hash_for, sign_file): Ditto. -- Be warned that this code is subject to further changes and that the format will very likely change before a release. There are also known bugs and missing code. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
9ae48b173c
commit
402aa0f948
20 changed files with 574 additions and 139 deletions
|
@ -817,6 +817,17 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
|||
nbits_from_pk (pk), pubkey_letter (pk->pubkey_algo),
|
||||
keystr_from_pk (pk), datestr_from_pk (pk));
|
||||
|
||||
if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
|
||||
|| pk->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
{
|
||||
char *curve = openpgp_oid_to_str (pk->pkey[0]);
|
||||
const char *name = openpgp_oid_to_curve (curve);
|
||||
if (!*name || *name == '?')
|
||||
name = curve;
|
||||
es_fprintf (es_stdout, " %s", name);
|
||||
xfree (curve);
|
||||
}
|
||||
|
||||
if (pk->flags.revoked)
|
||||
{
|
||||
es_fprintf (es_stdout, " [");
|
||||
|
@ -940,6 +951,18 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
|||
s2k_char,
|
||||
nbits_from_pk (pk2), pubkey_letter (pk2->pubkey_algo),
|
||||
keystr_from_pk (pk2), datestr_from_pk (pk2));
|
||||
|
||||
if (pk2->pubkey_algo == PUBKEY_ALGO_ECDSA
|
||||
|| pk2->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
{
|
||||
char *curve = openpgp_oid_to_str (pk2->pkey[0]);
|
||||
const char *name = openpgp_oid_to_curve (curve);
|
||||
if (!*name || *name == '?')
|
||||
name = curve;
|
||||
es_fprintf (es_stdout, " %s", name);
|
||||
xfree (curve);
|
||||
}
|
||||
|
||||
if (pk2->flags.revoked)
|
||||
{
|
||||
es_fprintf (es_stdout, " [");
|
||||
|
@ -1172,16 +1195,28 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
|||
es_putc (':', es_stdout);
|
||||
es_putc (':', es_stdout);
|
||||
print_capabilities (pk, keyblock);
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (secret)
|
||||
{
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (stubkey)
|
||||
es_putc ('#', es_stdout);
|
||||
else if (serialno)
|
||||
es_fputs(serialno, es_stdout);
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
es_fputs (serialno, es_stdout);
|
||||
}
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
es_putc (':', es_stdout); /* End of field 16. */
|
||||
if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
|
||||
|| pk->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
{
|
||||
char *curve = openpgp_oid_to_str (pk->pkey[0]);
|
||||
const char *name = openpgp_oid_to_curve (curve);
|
||||
if (!*name || *name == '?')
|
||||
name = curve;
|
||||
es_fputs (name, es_stdout);
|
||||
xfree (curve);
|
||||
}
|
||||
es_putc (':', es_stdout); /* End of field 17. */
|
||||
es_putc ('\n', es_stdout);
|
||||
|
||||
print_revokers (pk);
|
||||
|
@ -1285,16 +1320,28 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
|||
/* fixme: add LID and ownertrust here */
|
||||
);
|
||||
print_capabilities (pk2, NULL);
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (secret)
|
||||
{
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (stubkey)
|
||||
es_putc ('#', es_stdout);
|
||||
else if (serialno)
|
||||
es_fputs (serialno, es_stdout);
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
}
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
es_putc (':', es_stdout); /* End of field 16. */
|
||||
if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
|
||||
|| pk->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
{
|
||||
char *curve = openpgp_oid_to_str (pk->pkey[0]);
|
||||
const char *name = openpgp_oid_to_curve (curve);
|
||||
if (!*name || *name == '?')
|
||||
name = curve;
|
||||
es_fputs (name, es_stdout);
|
||||
xfree (curve);
|
||||
}
|
||||
es_putc (':', es_stdout); /* End of field 17. */
|
||||
es_putc ('\n', es_stdout);
|
||||
if (fpr > 1)
|
||||
print_fingerprint (pk2, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue