From 3a1fa13eedb969b561bae18cd3d7c2fb0b63d6ab Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sun, 9 Feb 2020 21:20:48 +0100 Subject: common: New function get_keyalgo_string. * common/openpgp-oid.c (struct keyalgo_string_s): New. (keyalgo_strings): New. (keyalgo_strings_size, keyalgo_strings_used): New. (get_keyalgo_string): New. -- This function is intended as a more general version of gpg's pubkey_string function. It has the advantage to avoid mallocs and uses static table of algorithm strings instead. There should be only a few dozen of such strings (if at all) and thus all those allocations we do internally in gpg's pubkey_string and the static buffers all over the place are not too nice. Signed-off-by: Werner Koch --- g10/keyid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'g10/keyid.c') diff --git a/g10/keyid.c b/g10/keyid.c index a7a54e07b..e6298e5da 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -88,7 +88,10 @@ pubkey_letter( int algo ) "256E" - ECDSA using a curve with 256 bit The macro PUBKEY_STRING_SIZE may be used to allocate a buffer with - a suitable size.*/ + a suitable size. Note that a more general version of this function + exists as get_keyalgo_string. However, that has no special + treatment for the old and unsupported Elgamal which we here print as + xxxNNNN. */ char * pubkey_string (PKT_public_key *pk, char *buffer, size_t bufsize) { -- cgit v1.2.3