From 52b7a60cf9f3cd2e5900396b0e3e65cbd335bc23 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 29 Sep 2023 11:34:06 +0200 Subject: common: Add new function b64decode. * common/b64dec.c (b64decode): New. * common/t-b64.c: Change license to LGPL. (oops): New macro. (hex2buffer): New. (test_b64decode): New. (main): Default to run the new test. * common/Makefile.am (module_maint_tests): Move t-b64 to ... (module_tests): here. -- Sometimes we have a short base64 encoded string we need todecode. This function makes it simpler. License change of the test module justified because I am the single author of the code. --- common/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/util.h') diff --git a/common/util.h b/common/util.h index aa24e39e6..83882caf2 100644 --- a/common/util.h +++ b/common/util.h @@ -171,6 +171,8 @@ gpg_error_t b64dec_start (struct b64state *state, const char *title); gpg_error_t b64dec_proc (struct b64state *state, void *buffer, size_t length, size_t *r_nbytes); gpg_error_t b64dec_finish (struct b64state *state); +gpg_error_t b64decode (const char *string, const char *title, + void **r_buffer, size_t *r_buflen); /*-- sexputil.c */ char *canon_sexp_to_string (const unsigned char *canon, size_t canonlen); -- cgit v1.2.3 From 4963f13f8fa914acfc9addd5f4f19ff75d983ef5 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 6 Oct 2023 12:04:00 +0200 Subject: scd:openpgp: Return better error codes for the Reset Code. * scd/app-openpgp.c (do_change_pin): Use GPG_ERR_BAD_RESET_CODE where appropriate. * common/util.h: Add error codes missing in gpgrt 1.46. * agent/call-pinentry.c (unlock_pinentry): Handle GPG_ERR_BAD_RESET_CODE. (agent_askpin): Ditlo. Also simply condition. (agent_get_passphrase): Ditto. * g10/call-agent.c (status_sc_op_failure): Handle GPG_ERR_BAD_RESET_CODE. * g10/card-util.c (write_sc_op_status): Ditto. * tools/card-call-scd.c (status_sc_op_failure): Ditto. --- common/util.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common/util.h') diff --git a/common/util.h b/common/util.h index 83882caf2..875969187 100644 --- a/common/util.h +++ b/common/util.h @@ -39,6 +39,11 @@ * libgpg-error version. Define them here. * Example: (#if GPG_ERROR_VERSION_NUMBER < 0x011500 // 1.21) */ +#if GPG_ERROR_VERSION_NUMBER < 0x012f00 /* 1.47 */ +# define GPG_ERR_BAD_PUK 320 +# define GPG_ERR_NO_RESET_CODE 321 +# define GPG_ERR_BAD_RESET_CODE 322 +#endif #ifndef EXTERN_UNLESS_MAIN_MODULE # if !defined (INCLUDED_BY_MAIN_MODULE) -- cgit v1.2.3