keyring.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
00003  * All rights reserved.
00004  * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
00005  * their moral rights under the UK Copyright Design and Patents Act 1988 to
00006  * be recorded as the authors of this copyright work.
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00009  * use this file except in compliance with the License. 
00010  * 
00011  * You may obtain a copy of the License at 
00012  *     http://www.apache.org/licenses/LICENSE-2.0 
00013  * 
00014  * Unless required by applicable law or agreed to in writing, software 
00015  * distributed under the License is distributed on an "AS IS" BASIS, 
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
00017  * 
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00025 #ifndef OPS_KEYRING_H
00026 #define OPS_KEYRING_H
00027 
00028 #include "packet.h"
00029 #include "memory.h"
00030 
00031 typedef struct ops_keydata ops_keydata_t;
00032 
00037 typedef struct
00038     {
00039     int nkeys; // while we are constructing a key, this is the offset
00040     int nkeys_allocated;
00041     ops_keydata_t *keys;
00042     } ops_keyring_t;    
00043 
00044 const ops_keydata_t *
00045 ops_keyring_find_key_by_id(const ops_keyring_t *keyring,
00046                            const unsigned char keyid[OPS_KEY_ID_SIZE]);
00047 const ops_keydata_t *
00048 ops_keyring_find_key_by_userid(const ops_keyring_t *keyring,
00049                                const char* userid);
00050 void ops_keydata_free(ops_keydata_t *key);
00051 void ops_keydata_copy(ops_keydata_t *dst, const ops_keydata_t *src);
00052 void ops_keyring_free(ops_keyring_t *keyring);
00053 void ops_dump_keyring(const ops_keyring_t *keyring);
00054 const ops_public_key_t *
00055 ops_get_public_key_from_data(const ops_keydata_t *data);
00056 ops_boolean_t ops_is_key_secret(const ops_keydata_t *data);
00057 const ops_secret_key_t *
00058 ops_get_secret_key_from_data(const ops_keydata_t *data);
00059 ops_secret_key_t *
00060 ops_get_writable_secret_key_from_data(ops_keydata_t *data);
00061 ops_secret_key_t *ops_decrypt_secret_key_from_data(const ops_keydata_t *key,
00062                                                    const char *pphrase);
00063 
00064 ops_boolean_t ops_keyring_read_from_file(ops_keyring_t *keyring,
00065                                          const ops_boolean_t armour,
00066                                          const char *filename);
00067 ops_boolean_t ops_keyring_read_from_mem(ops_keyring_t *keyring,
00068                                         const ops_boolean_t armour,
00069                                         ops_memory_t *mem);
00070 ops_boolean_t ops_write_keyring_to_file(const ops_keyring_t *keyring,
00071                                         ops_boolean_t armoured,
00072                                         const char *filename);
00073 
00074 char *ops_malloc_passphrase(char *passphrase);
00075 char *ops_get_passphrase(void);
00076 
00077 void ops_keyring_list(const ops_keyring_t* keyring);
00078 
00079 void ops_set_secret_key(ops_parser_content_union_t* content,
00080                         const ops_keydata_t *key);
00081 
00082 const unsigned char* ops_get_key_id(const ops_keydata_t *key);
00083 unsigned ops_get_user_id_count(const ops_keydata_t *key);
00084 const unsigned char* ops_get_user_id(const ops_keydata_t *key, unsigned index);
00085 ops_boolean_t ops_is_key_supported(const ops_keydata_t *key);
00086 const ops_keydata_t* ops_keyring_get_key_by_index(const ops_keyring_t *keyring,
00087                                                   int index);
00088 
00089 ops_user_id_t* ops_add_userid_to_keydata(ops_keydata_t *keydata,
00090                                          const ops_user_id_t *userid);
00091 ops_packet_t* ops_add_packet_to_keydata(ops_keydata_t* keydata,
00092                                         const ops_packet_t *packet);
00093 void ops_add_signed_userid_to_keydata(ops_keydata_t *keydata,
00094                                       const ops_user_id_t *userid,
00095                                       const ops_packet_t* packet);
00096 
00097 ops_boolean_t ops_add_selfsigned_userid_to_keydata(ops_keydata_t *keydata,
00098                                                    ops_user_id_t *userid);
00099 
00100 ops_keydata_t *ops_keydata_new(void);
00101 void ops_keydata_init(ops_keydata_t *keydata, const ops_content_tag_t type);
00102 
00103 #endif

Generated on Fri May 24 00:00:03 2013 for OpenPGP:SDK by  doxygen 1.4.6