14 #include "keystructs.h"
18 #include "onak-conf.h"
21 #include "decodekey.h"
23 int main(int argc, char** argv) {
24 struct openpgp_packet_list *packets = NULL;
25 struct openpgp_packet_list *list_end = NULL;
26 struct openpgp_publickey *keys = NULL;
27 struct openpgp_publickey *key = NULL;
28 struct openpgp_signedpacket_list *uid = NULL;
29 struct openpgp_packet_list *sig = NULL;
30 struct openpgp_packet_list *prevsig = NULL;
35 my_key = strtoull( argv[1], NULL, 16 );
37 /* expect a stream of openpgp packets on stdin comprising some keys */
38 /* strip each key of everything but its pubkey component, uids and
39 * selfsigs and revsigs on those selfsigs */
41 result = read_openpgp_stream( stdin_getchar, NULL, &packets, 0 );
42 result = parse_keys( packets, &keys );
43 free_packet_list(packets);
45 result = cleankeys( keys );
46 /* Iterate over the keys... */
47 for( key = keys; key; key = key->next ) {
48 uint64_t keyid = get_keyid( key );
49 for( uid = key->uids; uid; uid = uid->next ) {
51 for( sig = uid->sigs, prevsig = NULL;
53 prevsig = sig, sig = sig->next ) {
54 uint64_t thissig = sig_keyid( sig->packet );
55 if( thissig != keyid && thissig != my_key ) {
56 /* Don't care about this packet... */
58 prevsig->next = sig->next;
60 uid->sigs = sig->next;
63 free_packet_list( sig );
68 flatten_publickey( key, &packets, &list_end );
70 write_openpgp_stream( stdout_putchar, NULL, packets );