Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / crypto / external / bsd / netpgp / dist / src / lib / create.h
blobbf0256084b69503b9f2d2820bbc0cec5c39ece11
1 /*-
2 * Copyright (c) 2009 The NetBSD Foundation, Inc.
3 * All rights reserved.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Alistair Crooks (agc@NetBSD.org)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
31 * All rights reserved.
32 * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
33 * their moral rights under the UK Copyright Design and Patents Act 1988 to
34 * be recorded as the authors of this copyright work.
36 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
37 * use this file except in compliance with the License.
39 * You may obtain a copy of the License at
40 * http://www.apache.org/licenses/LICENSE-2.0
42 * Unless required by applicable law or agreed to in writing, software
43 * distributed under the License is distributed on an "AS IS" BASIS,
44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 * See the License for the specific language governing permissions and
47 * limitations under the License.
50 /** \file
52 #ifndef CREATE_H_
53 #define CREATE_H_
55 #include "types.h"
56 #include "packet.h"
57 #include "crypto.h"
58 #include "errors.h"
59 #include "keyring.h"
60 #include "writer.h"
61 #include "memory.h"
63 /**
64 * \ingroup Create
65 * This struct contains the required information about how to write this stream
67 struct __ops_output_t {
68 __ops_writer_t writer;
69 __ops_error_t *errors; /* error stack */
72 __ops_output_t *__ops_output_new(void);
73 void __ops_output_delete(__ops_output_t *);
75 int __ops_filewrite(const char *, const char *, const size_t, const unsigned);
77 void __ops_build_pubkey(__ops_memory_t *, const __ops_pubkey_t *, unsigned);
79 unsigned __ops_calc_sesskey_checksum(__ops_pk_sesskey_t *, unsigned char *);
80 unsigned __ops_write_struct_userid(__ops_output_t *, __ops_userid_t *);
81 unsigned __ops_write_ss_header(__ops_output_t *, unsigned, __ops_content_tag_t);
82 unsigned __ops_write_struct_seckey(const __ops_seckey_t *,
83 const unsigned char *,
84 const size_t,
85 __ops_output_t *);
86 unsigned __ops_write_one_pass_sig(__ops_output_t *,
87 const __ops_seckey_t *,
88 const __ops_hash_alg_t,
89 const __ops_sig_type_t);
90 unsigned __ops_write_litdata(__ops_output_t *,
91 const unsigned char *,
92 const int,
93 const __ops_litdata_type_t);
94 __ops_pk_sesskey_t *__ops_create_pk_sesskey(const __ops_key_t *);
95 unsigned __ops_write_pk_sesskey(__ops_output_t *, __ops_pk_sesskey_t *);
96 unsigned __ops_write_xfer_pubkey(__ops_output_t *,
97 const __ops_key_t *, const unsigned);
98 unsigned __ops_write_xfer_seckey(__ops_output_t *,
99 const __ops_key_t *,
100 const unsigned char *,
101 const size_t,
102 const unsigned);
104 void __ops_fast_create_userid(__ops_userid_t *, unsigned char *);
105 unsigned __ops_write_userid(const unsigned char *, __ops_output_t *);
106 void __ops_fast_create_rsa_pubkey(__ops_pubkey_t *, time_t, BIGNUM *, BIGNUM *);
107 unsigned __ops_write_rsa_pubkey(time_t, const BIGNUM *, const BIGNUM *,
108 __ops_output_t *);
109 void __ops_fast_create_rsa_seckey(__ops_seckey_t *, time_t, BIGNUM *,
110 BIGNUM *, BIGNUM *, BIGNUM *,
111 BIGNUM *, BIGNUM *);
112 unsigned encode_m_buf(const unsigned char *, size_t, const __ops_pubkey_t *,
113 unsigned char *);
114 unsigned __ops_fileread_litdata(const char *, const __ops_litdata_type_t,
115 __ops_output_t *);
116 unsigned __ops_write_symm_enc_data(const unsigned char *, const int,
117 __ops_output_t *);
119 #endif /* CREATE_H_ */