Skip to content

Commit

Permalink
rpmkeys --verbose --list
Browse files Browse the repository at this point in the history
Give more detailed information about the public keys.

No 100% sure of using --verbose is the right call here. May be we should
add --info to the cli.

Does not list sub keys yet.
  • Loading branch information
ffesti committed Oct 8, 2024
1 parent 3774572 commit 40d9a19
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
16 changes: 16 additions & 0 deletions tests/rpmdb.at
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ runroot rpmkeys --list 4344591e1964c5fc
],
[])

RPMTEST_CHECK([
runroot rpmkeys -v --list 4344591e1964c5fc
],
[0],
[Public key
Issuer: rpm.org RSA testkey <[email protected]>
Fingerprint: 771b18d3d7baa28734333c424344591e1964c5fc
Key ID: 4344591e1964c5fc
Creation Time: Thu Apr 6 12:48:24 2017
Version: V4
Key algorithm: RSA
Hash algorithm: SHA256

],
[])


RPMTEST_CHECK([
runroot rpmkeys --list XXX
Expand Down
27 changes: 26 additions & 1 deletion tools/rpmkeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ static int printKey(rpmPubkey key, void * data)
return 0;
}

static int printKeyLong(rpmPubkey key, void * data)
{
char * fp = rpmPubkeyFingerprintAsHex(key);
char * keyid = rpmPubkeyKeyIDAsHex(key);
pgpDigParams params = rpmPubkeyPgpDigParams(key);
const time_t unixtime = pgpDigParamsCreationTime(params);
rpmlog(RPMLOG_NOTICE, "Public key\n");
rpmlog(RPMLOG_NOTICE, "Issuer: %s\n", pgpDigParamsUserID(params));
rpmlog(RPMLOG_NOTICE, "Fingerprint: %s\n", fp);
rpmlog(RPMLOG_NOTICE, "Key ID: %s\n", keyid);
rpmlog(RPMLOG_NOTICE, "Creation Time: %s", asctime(gmtime(&unixtime)));
rpmlog(RPMLOG_NOTICE, "Version: V%i\n", pgpDigParamsVersion(params));
rpmlog(RPMLOG_NOTICE, "Key algorithm: %s\n", pgpValString(PGPVAL_PUBKEYALGO, pgpDigParamsAlgo(params, PGPVAL_PUBKEYALGO)));

rpmlog(RPMLOG_NOTICE, "Hash algorithm: %s\n", pgpValString(PGPVAL_HASHALGO, pgpDigParamsAlgo(params, PGPVAL_HASHALGO)));
rpmlog(RPMLOG_NOTICE, "\n");
free(fp);
free(keyid);
return 0;

}

int main(int argc, char *argv[])
{
int ec = EXIT_FAILURE;
Expand Down Expand Up @@ -156,7 +178,10 @@ int main(int argc, char *argv[])
}
case MODE_LISTKEY:
{
ec = matchingKeys(keyring, args, NULL, printKey);
if (rpmIsVerbose())
ec = matchingKeys(keyring, args, NULL, printKeyLong);
else
ec = matchingKeys(keyring, args, NULL, printKey);
break;
}
default:
Expand Down

0 comments on commit 40d9a19

Please sign in to comment.