+int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose,
+ bool html)
+{
+ struct tm *created = NULL;
+ time_t created_time = 0;
+ int type = 0;
+ int length = 0;
+ uint64_t keyid = 0;
+
+ while (subkeys != NULL) {
+ if (subkeys->packet->tag == OPENPGP_PACKET_PUBLICSUBKEY) {
+
+ created_time = (subkeys->packet->data[1] << 24) +
+ (subkeys->packet->data[2] << 16) +
+ (subkeys->packet->data[3] << 8) +
+ subkeys->packet->data[4];
+ created = gmtime(&created_time);
+
+ switch (subkeys->packet->data[0]) {
+ case 2:
+ case 3:
+ type = subkeys->packet->data[7];
+ length = (subkeys->packet->data[8] << 8) +
+ subkeys->packet->data[9];
+ break;
+ case 4:
+ type = subkeys->packet->data[5];
+ length = (subkeys->packet->data[6] << 8) +
+ subkeys->packet->data[7];
+ break;
+ default:
+ logthing(LOGTHING_ERROR,
+ "Unknown key type: %d",
+ subkeys->packet->data[0]);
+ }
+
+ if (get_packetid(subkeys->packet,
+ &keyid) != ONAK_E_OK) {
+ logthing(LOGTHING_ERROR, "Couldn't get keyid.");
+ }
+ printf("sub %5d%c/%08X %04d/%02d/%02d\n",
+ length,
+ (type == OPENPGP_PKALGO_RSA) ? 'R' :
+ ((type == OPENPGP_PKALGO_ELGAMAL_ENC) ? 'g' :
+ ((type == OPENPGP_PKALGO_DSA) ? 'D' : '?')),
+ (uint32_t) (keyid & 0xFFFFFFFF),
+ created->tm_year + 1900,
+ created->tm_mon + 1,
+ created->tm_mday);
+
+ }
+ if (verbose) {
+ list_sigs(subkeys->sigs, html);
+ }
+ subkeys = subkeys->next;
+ }
+
+ return 0;
+}
+
+void display_fingerprint(struct openpgp_publickey *key)
+{
+ int i = 0;
+ size_t length = 0;
+ unsigned char fp[20];
+
+ get_fingerprint(key->publickey, fp, &length);
+ printf(" Key fingerprint =");
+ for (i = 0; i < length; i++) {
+ if ((length == 16) ||
+ (i % 2 == 0)) {
+ printf(" ");
+ }
+ if (length == 20 && (i * 2) == length) {
+ /* Extra space in the middle of a SHA1 fingerprint */
+ printf(" ");
+ }
+ printf("%02X", fp[i]);
+ }
+ printf("\n");
+
+ return;
+}
+
+void display_skshash(struct openpgp_publickey *key, bool html)
+{
+ int i = 0;
+ struct skshash hash;
+
+ get_skshash(key, &hash);
+ printf(" Key hash = ");
+ if (html) {
+ printf("<a href=\"lookup?op=hget&search=");
+ for (i = 0; i < sizeof(hash.hash); i++) {
+ printf("%02X", hash.hash[i]);
+ }
+ printf("\">");
+ }
+ for (i = 0; i < sizeof(hash.hash); i++) {
+ printf("%02X", hash.hash[i]);
+ }
+ if (html) {
+ printf("</a>");
+ }
+ printf("\n");
+
+ return;
+}
+