[pacman-dev] [PATCH 3/8] Add function to extract key id from signatures

Dan McGee dpmcgee at gmail.com
Wed Nov 7 09:21:44 EST 2012


On Fri, Nov 2, 2012 at 10:28 AM, Allan McRae <allan at archlinux.org> wrote:
> This does not support all possibilities of RFC4880, but it does
> cover every key currently used in Arch Linux.
>
> Signed-off-by: Allan McRae <allan at archlinux.org>
> ---
>  lib/libalpm/signing.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/libalpm/signing.h |   2 +
>  2 files changed, 102 insertions(+)
>
> diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
> index 9d56aba..6b13522 100644
> --- a/lib/libalpm/signing.c
> +++ b/lib/libalpm/signing.c
> @@ -948,4 +948,104 @@ int SYMEXPORT alpm_siglist_cleanup(alpm_siglist_t *siglist)
>         return 0;
>  }
>
> +/**
> + * Extract the Issuer Key ID from a signature
> + * @param sig PGP signature
> + * @param len length of signature
> + * @param keys a pointer to storage for key IDs
> + * @return 0 on success, -1 on error
> + */
> +int _alpm_extract_keyid(const unsigned char *sig, size_t len, alpm_list_t **keys)
> +{
> +       size_t pos, spos, blen, hlen, ulen, slen;
> +       pos = 0;
> +
> +       while(pos < len) {
> +               if(!(sig[pos] & 0x80)) {
> +                       return -1;
> +               }
> +
> +               if(sig[pos] & 0x40) {
> +                       // "new" packet format is not supported
Respect the preferred coding style for comments, please. :)

-Dan


More information about the pacman-dev mailing list