xref: /netbsd-src/crypto/external/bsd/netpgp/dist/src/lib/create.h (revision 9ee9e0d7de4c59c936a17df52be682915dc66f43)
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_CREATE_H
26 #define OPS_CREATE_H
27 
28 #include "types.h"
29 #include "packet.h"
30 #include "crypto.h"
31 #include "errors.h"
32 #include "keyring.h"
33 #include "writer.h"
34 
35 /**
36  * \ingroup Create
37  * This struct contains the required information about how to write this stream
38  */
39 struct __ops_create_info {
40 	__ops_writer_info_t winfo;
41 	__ops_error_t    *errors;	/* !< an error stack */
42 };
43 
44 __ops_create_info_t *__ops_create_info_new(void);
45 void            __ops_create_info_delete(__ops_create_info_t *);
46 
47 int             __ops_write_file_from_buf(const char *, const char *, const size_t, const bool);
48 
49 bool   __ops_calc_session_key_checksum(__ops_pk_session_key_t *, unsigned char *);
50 bool __ops_write_struct_user_id(__ops_user_id_t *, __ops_create_info_t *);
51 bool __ops_write_struct_public_key(const __ops_public_key_t *, __ops_create_info_t *);
52 
53 bool __ops_write_ss_header(unsigned, __ops_content_tag_t, __ops_create_info_t *);
54 bool __ops_write_struct_secret_key(const __ops_secret_key_t *,
55 			    const unsigned char *,
56 			    const size_t,
57 			    __ops_create_info_t *);
58 bool
59 __ops_write_one_pass_sig(const __ops_secret_key_t *,
60 		       const __ops_hash_algorithm_t,
61 		       const __ops_sig_type_t,
62 		       __ops_create_info_t *);
63 bool
64 __ops_write_literal_data_from_buf(const unsigned char *,
65 				const int,
66 				const __ops_literal_data_type_t,
67 				__ops_create_info_t *);
68 __ops_pk_session_key_t *__ops_create_pk_session_key(const __ops_keydata_t *);
69 bool __ops_write_pk_session_key(__ops_create_info_t *, __ops_pk_session_key_t *);
70 bool   __ops_write_transferable_public_key(const __ops_keydata_t *, bool, __ops_create_info_t *);
71 bool   __ops_write_transferable_secret_key(const __ops_keydata_t *, const unsigned char *, const size_t, bool, __ops_create_info_t *);
72 
73 void            __ops_fast_create_user_id(__ops_user_id_t *, unsigned char *);
74 bool   __ops_write_user_id(const unsigned char *, __ops_create_info_t *);
75 void            __ops_fast_create_rsa_public_key(__ops_public_key_t *, time_t, BIGNUM *, BIGNUM *);
76 bool   __ops_write_rsa_public_key(time_t, const BIGNUM *, const BIGNUM *, __ops_create_info_t *);
77 void            __ops_fast_create_rsa_secret_key(__ops_secret_key_t *, time_t, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *);
78 bool   encode_m_buf(const unsigned char *, size_t, const __ops_public_key_t *, unsigned char *);
79 bool   __ops_write_literal_data_from_file(const char *, const __ops_literal_data_type_t, __ops_create_info_t *);
80 bool   __ops_write_symmetrically_encrypted_data(const unsigned char *, const int, __ops_create_info_t *);
81 
82 #endif				/* OPS_CREATE_H */
83