]> the.earth.li Git - onak.git/blob - decodekey.h
Remove dead store in generic_fetch_key
[onak.git] / decodekey.h
1 /*
2  * keyindex.h - Routines to list an OpenPGP key.
3  *
4  * Copyright 2002-2008 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __DECODEKEY_H__
20 #define __DECODEKEY_H__
21
22 #include <inttypes.h>
23 #include <time.h>
24 #include "keystructs.h"
25 #include "ll.h"
26 #include "onak.h"
27
28 /**
29  *      keysigs - Return the sigs on a given OpenPGP signature packet list.
30  *      @curll: The current linked list. Can be NULL to create a new list.
31  *      @sigs: The signature list we want the sigs on.
32  *
33  *      Returns a linked list of stats_key elements containing the sigs for the
34  *      supplied OpenPGP signature packet list.
35  */
36 struct ll *keysigs(struct ll *curll,
37                 struct openpgp_packet_list *sigs);
38
39 /**
40  *      sig_info - Get info on a given OpenPGP signature packet
41  *      @packet: The signature packet
42  *      @keyid: A pointer for where to return the signature keyid
43  *      @creation: A pointer for where to return the signature creation time
44  *
45  *      Gets any info about a signature packet; parses the subpackets for a v4
46  *      key or pulls the data directly from v2/3. NULL can be passed for any
47  *      values which aren't cared about.
48  */
49 onak_status_t sig_info(struct openpgp_packet *packet, uint64_t *keyid,
50                 time_t *creation);
51
52 /**
53  *      sig_keyid - Return the keyid for a given OpenPGP signature packet.
54  *      @packet: The signature packet.
55  *
56  *      Returns the keyid for the supplied signature packet.
57  */
58 uint64_t sig_keyid(struct openpgp_packet *packet);
59
60 /**
61  *      keyuids - Takes a key and returns an array of its UIDs
62  *      @key: The key to get the uids of.
63  *      @primary: A pointer to store the primary UID in.
64  *
65  *      keyuids takes a public key structure and builds an array of the UIDs 
66  *      on the key. It also attempts to work out the primary UID and returns a
67  *      separate pointer to that particular element of the array.
68  */
69 char **keyuids(struct openpgp_publickey *key, char **primary);
70
71 /**
72  *      keysubkeys - Takes a key & returns an array of its subkey fingerprints
73  *      @key: The key to get the subkeys of.
74  *
75  *      keysubkeys takes a public key structure and returns an array of the
76  *      subkey fingerprints for that key.
77  */
78 struct openpgp_fingerprint *keysubkeys(struct openpgp_publickey *key);
79
80 /**
81  *      parse_subpackets - Parse the subpackets of a Type 4 signature.
82  *      @data: The subpacket data.
83  *      @len: The amount of data available to read.
84  *      @parselen: The amount of data that was actually parsed.
85  *      @keyid: A pointer to where we should return the keyid.
86  *      @creationtime: A pointer to where we should return the creation time.
87  *
88  *      This function parses the subkey data of a Type 4 signature and fills
89  *      in the supplied variables. It also returns the length of the data
90  *      processed. If the value of any piece of data is not desired a NULL
91  *      can be passed instead of a pointer to a storage area for that value.
92  */
93 onak_status_t parse_subpackets(unsigned char *data, size_t len,
94                 size_t *parselen, uint64_t *keyid, time_t *creation);
95
96 enum onak_oid {
97         ONAK_OID_UNKNOWN = 0,
98         ONAK_OID_INVALID,
99         ONAK_OID_CURVE25519,
100         ONAK_OID_ED25519,
101         ONAK_OID_NISTP256,
102         ONAK_OID_NISTP384,
103         ONAK_OID_NISTP521,
104         ONAK_OID_BRAINPOOLP256R1,
105         ONAK_OID_BRAINPOOLP384R1,
106         ONAK_OID_BRAINPOOLP512R1,
107         ONAK_OID_SECP256K1,
108 };
109
110 enum onak_oid onak_parse_oid(uint8_t *buf, size_t len);
111
112 #endif