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 "packet-parse.h" 30 31 typedef struct __ops_keydata __ops_keydata_t; 32 33 /** \struct __ops_keyring_t 34 * A keyring 35 */ 36 37 typedef struct __ops_keyring_t { 38 int nkeys; 39 /*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 *__ops_keyring_find_key_by_id(const __ops_keyring_t *, const unsigned char *); 45 const __ops_keydata_t *__ops_keyring_find_key_by_userid(const __ops_keyring_t *, const char *); 46 void __ops_keydata_free(__ops_keydata_t *); 47 void __ops_keyring_free(__ops_keyring_t *); 48 void __ops_dump_keyring(const __ops_keyring_t *); 49 const __ops_public_key_t *__ops_get_public_key_from_data(const __ops_keydata_t *); 50 bool __ops_is_key_secret(const __ops_keydata_t *); 51 const __ops_secret_key_t *__ops_get_secret_key_from_data(const __ops_keydata_t *); 52 __ops_secret_key_t *__ops_get_writable_secret_key_from_data(__ops_keydata_t *); 53 __ops_secret_key_t *__ops_decrypt_secret_key_from_data(const __ops_keydata_t *, const char *); 54 55 bool __ops_keyring_read_from_file(__ops_keyring_t *, const bool, const char *); 56 57 char *__ops_malloc_passphrase(char *); 58 59 void __ops_keyring_list(const __ops_keyring_t *); 60 61 void __ops_set_secret_key(__ops_parser_content_union_t *, const __ops_keydata_t *); 62 63 const unsigned char *__ops_get_key_id(const __ops_keydata_t *); 64 unsigned __ops_get_user_id_count(const __ops_keydata_t *); 65 const unsigned char *__ops_get_user_id(const __ops_keydata_t *, unsigned); 66 bool __ops_is_key_supported(const __ops_keydata_t *); 67 const __ops_keydata_t *__ops_keyring_get_key_by_index(const __ops_keyring_t *, int); 68 69 __ops_user_id_t *__ops_add_userid_to_keydata(__ops_keydata_t *, const __ops_user_id_t *); 70 __ops_packet_t *__ops_add_packet_to_keydata(__ops_keydata_t *, const __ops_packet_t *); 71 void __ops_add_signed_userid_to_keydata(__ops_keydata_t *, const __ops_user_id_t *, const __ops_packet_t *); 72 73 bool __ops_add_selfsigned_userid_to_keydata(__ops_keydata_t *, __ops_user_id_t *); 74 75 __ops_keydata_t *__ops_keydata_new(void); 76 void __ops_keydata_init(__ops_keydata_t *, const __ops_content_tag_t); 77 78 void __ops_copy_userid(__ops_user_id_t *, const __ops_user_id_t *); 79 void __ops_copy_packet(__ops_packet_t *, const __ops_packet_t *); 80 unsigned __ops_get_keydata_content_type(const __ops_keydata_t *); 81 82 int __ops_parse_and_accumulate(__ops_keyring_t *, __ops_parse_info_t *); 83 84 void __ops_print_public_keydata(const __ops_keydata_t *); 85 void __ops_print_public_key(const __ops_public_key_t *); 86 87 void __ops_print_secret_keydata(const __ops_keydata_t *); 88 void __ops_list_packets(char *, bool, __ops_keyring_t *, __ops_parse_cb_t *); 89 90 int __ops_export_key(const __ops_keydata_t *, unsigned char *); 91 92 #endif /* OPS_KEYRING_H */ 93