root/openpgpsdk/trunk/include/openpgpsdk/create.h

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

Implemented writing of armoured transferable public and private keys.
Refactored armoured code to remove duplication.

Line 
1 /** \file
2  */
3
4 #ifndef OPS_CREATE_H
5 #define OPS_CREATE_H
6
7 #include "types.h"
8 #include "packet.h"
9 #include "crypto.h"
10 #include "memory.h"
11 #include "errors.h"
12 #include "keyring.h"
13
14 typedef struct ops_writer_info ops_writer_info_t;
15 /**
16  * \ingroup Create
17  * the writer function prototype
18  */
19 typedef ops_boolean_t ops_writer_t(const unsigned char *src,
20                                       unsigned length,
21                                       ops_error_t **errors,
22                                       ops_writer_info_t *winfo);
23 typedef ops_boolean_t ops_writer_finaliser_t(ops_error_t **errors,
24                                              ops_writer_info_t *winfo);
25 typedef void ops_writer_destroyer_t(ops_writer_info_t *winfo);
26
27 ops_create_info_t *ops_create_info_new(void);
28 void ops_create_info_delete(ops_create_info_t *info);
29 void *ops_writer_get_arg(ops_writer_info_t *winfo);
30 ops_boolean_t ops_stacked_write(const void *src,unsigned length,
31                                 ops_error_t **errors,
32                                 ops_writer_info_t *winfo);
33
34 void ops_writer_set(ops_create_info_t *info,
35                     ops_writer_t *writer,
36                     ops_writer_finaliser_t *finaliser,
37                     ops_writer_destroyer_t *destroyer,
38                     void *arg);
39 void ops_writer_push(ops_create_info_t *info,
40                      ops_writer_t *writer,
41                      ops_writer_finaliser_t *finaliser,
42                      ops_writer_destroyer_t *destroyer,
43                      void *arg);
44 void ops_writer_pop(ops_create_info_t *info);
45 void ops_writer_generic_destroyer(ops_writer_info_t *winfo);
46 ops_boolean_t ops_writer_passthrough(const unsigned char *src,
47                                      unsigned length,
48                                      ops_error_t **errors,
49                                      ops_writer_info_t *winfo);
50
51 void ops_writer_set_fd(ops_create_info_t *info,int fd);
52 ops_boolean_t ops_writer_close(ops_create_info_t *info);
53
54 ops_boolean_t ops_write(const void *src,unsigned length,
55                         ops_create_info_t *opt);
56 ops_boolean_t ops_write_length(unsigned length,ops_create_info_t *opt);
57 ops_boolean_t ops_write_ptag(ops_content_tag_t tag,ops_create_info_t *opt);
58 ops_boolean_t ops_write_scalar(unsigned n,unsigned length,
59                                ops_create_info_t *opt);
60 ops_boolean_t ops_write_mpi(const BIGNUM *bn,ops_create_info_t *opt);
61 ops_boolean_t ops_write_encrypted_mpi(const BIGNUM *bn, ops_crypt_t* crypt, ops_create_info_t *info);
62 ops_boolean_t ops_write_ss_header(unsigned length,ops_content_tag_t type,
63                                   ops_create_info_t *opt);
64
65 void ops_fast_create_rsa_public_key(ops_public_key_t *key,time_t time,
66                                     BIGNUM *n,BIGNUM *e);
67 void ops_create_rsa_public_key(ops_public_key_t *key,time_t time,
68                                const BIGNUM *n,const BIGNUM *e);
69 void ops_build_public_key(ops_memory_t *out,const ops_public_key_t *key,
70                           ops_boolean_t make_packet);
71 ops_boolean_t ops_write_struct_public_key(const ops_public_key_t *key,
72                                           ops_create_info_t *opt);
73 ops_boolean_t ops_write_rsa_public_key(time_t time,const BIGNUM *n,
74                                        const BIGNUM *e,
75                                        ops_create_info_t *opt);
76
77 void ops_fast_create_user_id(ops_user_id_t *id,unsigned char *user_id);
78 ops_boolean_t ops_write_struct_user_id(ops_user_id_t *id,
79                                        ops_create_info_t *opt);
80 ops_boolean_t ops_write_user_id(const unsigned char *user_id,ops_create_info_t *opt);
81
82 void ops_create_rsa_secret_key(ops_secret_key_t *key,const BIGNUM *p,
83                                const BIGNUM *q,const BIGNUM *d,
84                                const BIGNUM *u,const BIGNUM *n,
85                                const BIGNUM *e);
86 void ops_fast_create_rsa_secret_key(ops_secret_key_t *key,time_t time,
87                                     BIGNUM *p,BIGNUM *q,BIGNUM *d,BIGNUM *u,
88                                     BIGNUM *n,BIGNUM *e);
89 ops_boolean_t ops_write_struct_secret_key(const ops_secret_key_t *key,
90                                           const unsigned char* passphrase,
91                                           const size_t pplen,
92                                           ops_create_info_t *info);
93
94 ops_pk_session_key_t *ops_create_pk_session_key(const ops_keydata_t *key);
95
96 void ops_create_m_buf(ops_pk_session_key_t *session_key, unsigned char *buf);
97
98 // RENAMED from ops_boolean_t ops_write_literal_data(const unsigned char *data,
99 ops_boolean_t ops_write_literal_data_from_buf(const unsigned char *data,
100                                      const int maxlen,
101                                      const ops_literal_data_type_t type,
102                                      ops_create_info_t *info);
103 ops_boolean_t ops_write_literal_data_from_file(const char *filename,
104                                                const ops_literal_data_type_t type,
105                                                ops_create_info_t *info);
106
107 ops_memory_t* ops_write_buf_from_file(const char *filename);
108 int ops_write_file_from_buf(const char* filename, const char* buf, const size_t len);
109
110 ops_boolean_t ops_write_symmetrically_encrypted_data(const unsigned char *data,
111                                                      const int len,
112                                                      ops_create_info_t *info);
113
114 ops_boolean_t ops_write_se_ip_data(const unsigned char *data,
115                                    const unsigned int len,
116                                    ops_crypt_t *crypt,
117                                    ops_create_info_t *info);
118 ops_boolean_t ops_write_pk_session_key(ops_create_info_t *info,
119                                        ops_pk_session_key_t *pksk);
120 ops_boolean_t ops_calc_session_key_checksum(ops_pk_session_key_t *session_key, unsigned char *cs);
121 void ops_calc_mdc_hash(const unsigned char* preamble, const size_t sz_preamble, const unsigned char* data, const unsigned int len, unsigned char *hashed);
122
123 ops_boolean_t ops_write_one_pass_sig(const ops_secret_key_t* skey, const ops_hash_algorithm_t hash_alg, const ops_sig_type_t sig_type, ops_create_info_t* info);
124
125 ops_boolean_t ops_write_transferable_public_key(const ops_keydata_t *key, ops_boolean_t armoured, ops_create_info_t *info);
126 ops_boolean_t ops_write_transferable_secret_key(const ops_keydata_t *key, const unsigned char* passphrase, size_t pplen, ops_boolean_t armoured, ops_create_info_t *info);
127
128 #endif
129
Note: See TracBrowser for help on using the browser.