root/openpgpsdk/trunk/include/openpgpsdk/keyring.h

Revision 612 (checked in by rachel, 5 years ago)

This (and previous commit) adds extra doxygen documentation.

Line 
1 /*
2  * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
3  * All rights reserved.
4  * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
5  * their moral rights under the UK Copyright Design and Patents Act 1988 to
6  * be recorded as the authors of this copyright work.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9  * use this file except in compliance with the License.
10  *
11  * You may obtain a copy of the License at
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 /** \file
23  */
24
25 #ifndef OPS_KEYRING_H
26 #define OPS_KEYRING_H
27
28 #include "packet.h"
29 #include "memory.h"
30
31 typedef struct ops_keydata ops_keydata_t;
32
33 /** \struct ops_keyring_t
34  * A keyring
35  */
36
37 typedef struct
38     {
39     int nkeys; // while we are constructing a key, this is the offset
40     int nkeys_allocated;
41     ops_keydata_t *keys;
42     } ops_keyring_t;   
43
44 const ops_keydata_t *
45 ops_keyring_find_key_by_id(const ops_keyring_t *keyring,
46                            const unsigned char keyid[OPS_KEY_ID_SIZE]);
47 const ops_keydata_t *
48 ops_keyring_find_key_by_userid(const ops_keyring_t *keyring,
49                                const char* userid);
50 void ops_keydata_free(ops_keydata_t *key);
51 void ops_keyring_free(ops_keyring_t *keyring);
52 void ops_dump_keyring(const ops_keyring_t *keyring);
53 const ops_public_key_t *
54 ops_get_public_key_from_data(const ops_keydata_t *data);
55 ops_boolean_t ops_is_key_secret(const ops_keydata_t *data);
56 const ops_secret_key_t *
57 ops_get_secret_key_from_data(const ops_keydata_t *data);
58 ops_secret_key_t *
59 ops_get_writable_secret_key_from_data(ops_keydata_t *data);
60 ops_secret_key_t *ops_decrypt_secret_key_from_data(const ops_keydata_t *key,
61                                                    const char *pphrase);
62
63 ops_boolean_t ops_keyring_read_from_file(ops_keyring_t *keyring, const ops_boolean_t armour, const char *filename);
64 ops_boolean_t ops_keyring_read_from_mem(ops_keyring_t *keyring, const ops_boolean_t armour, ops_memory_t *mem);
65
66 char *ops_malloc_passphrase(char *passphrase);
67 char *ops_get_passphrase(void);
68
69 void ops_keyring_list(const ops_keyring_t* keyring);
70
71 void ops_set_secret_key(ops_parser_content_union_t* content,const ops_keydata_t *key);
72
73 const unsigned char* ops_get_key_id(const ops_keydata_t *key);
74 unsigned ops_get_user_id_count(const ops_keydata_t *key);
75 const unsigned char* ops_get_user_id(const ops_keydata_t *key, unsigned index);
76 ops_boolean_t ops_is_key_supported(const ops_keydata_t *key);
77 const ops_keydata_t* ops_keyring_get_key_by_index(const ops_keyring_t *keyring, int index);
78
79 ops_user_id_t* ops_add_userid_to_keydata(ops_keydata_t* keydata, const ops_user_id_t* userid);
80 ops_packet_t* ops_add_packet_to_keydata(ops_keydata_t* keydata, const ops_packet_t* packet);
81 void ops_add_signed_userid_to_keydata(ops_keydata_t* keydata, const ops_user_id_t* userid, const ops_packet_t* packet);
82
83 ops_boolean_t ops_add_selfsigned_userid_to_keydata(ops_keydata_t* keydata, ops_user_id_t* userid);
84
85 ops_keydata_t *ops_keydata_new(void);
86 void ops_keydata_init(ops_keydata_t* keydata, const ops_content_tag_t type);
87
88 #endif
89
Note: See TracBrowser for help on using the browser.