From: Michael Schroeder Date: Fri, 23 Aug 2013 09:50:28 +0000 (+0200) Subject: refactor a bit X-Git-Tag: BASE-SuSE-Code-13_1-Branch~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9130578587082cc0dbfb249735b15b5c8212c99;p=thirdparty%2Flibsolv.git refactor a bit --- diff --git a/ext/repo_pubkey.c b/ext/repo_pubkey.c index 077f5241..ae8f7271 100644 --- a/ext/repo_pubkey.c +++ b/ext/repo_pubkey.c @@ -197,6 +197,18 @@ struct gpgsig { int sigdatal; }; +static Id +pgphashalgo2type(int algo) +{ + if (algo == 1) + return REPOKEY_TYPE_MD5; + if (algo == 2) + return REPOKEY_TYPE_SHA1; + if (algo == 8) + return REPOKEY_TYPE_SHA256; + return 0; +} + static void parsesigpacket(struct gpgsig *sig, unsigned char *p, int l, unsigned char *pubkey, int pubkeyl, unsigned char *userid, int useridl) { @@ -213,12 +225,7 @@ parsesigpacket(struct gpgsig *sig, unsigned char *p, int l, unsigned char *pubke sig->haveissuer = 1; memcpy(sig->issuer, p + 7, 8); sig->created = p[3] << 24 | p[4] << 16 | p[5] << 8 | p[6]; - if (p[16] == 1) - htype = REPOKEY_TYPE_MD5; - else if (p[16] == 2) - htype = REPOKEY_TYPE_SHA1; - else if (p[16] == 8) - htype = REPOKEY_TYPE_SHA256; + htype = pgphashalgo2type(p[16]); if (htype && pubkey) { void *h = solv_chksum_create(htype); @@ -329,12 +336,7 @@ parsesigpacket(struct gpgsig *sig, unsigned char *p, int l, unsigned char *pubke ql -= sl; } } - if (p[3] == 1) - htype = REPOKEY_TYPE_MD5; - else if (p[3] == 2) - htype = REPOKEY_TYPE_SHA1; - else if (p[3] == 8) - htype = REPOKEY_TYPE_SHA256; + htype = pgphashalgo2type(p[3]); if (sig->haveissuer && htype && pubkey && q && q - p + 2 < l) { void *h = solv_chksum_create(htype);