1/*- 2 * Copyright (c) 2009 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Alistair Crooks (agc@NetBSD.org) 7 * 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. 16 * 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. 28 */ 29/* 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. 35 * 36 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 37 * use this file except in compliance with the License. 38 * 39 * You may obtain a copy of the License at 40 * http://www.apache.org/licenses/LICENSE-2.0 41 * 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. 45 * 46 * See the License for the specific language governing permissions and 47 * limitations under the License. 48 */ 49 50/** \file 51 */ 52#ifndef CREATE_H_ 53#define CREATE_H_ 54 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" 62 63/** 64 * \ingroup Create 65 * This struct contains the required information about how to write this stream 66 */ 67struct pgp_output_t { 68 pgp_writer_t writer; 69 pgp_error_t *errors; /* error stack */ 70}; 71 72pgp_output_t *pgp_output_new(void); 73void pgp_output_delete(pgp_output_t *); 74 75int pgp_filewrite(const char *, const char *, const size_t, const unsigned); 76 77void pgp_build_pubkey(pgp_memory_t *, const pgp_pubkey_t *, unsigned); 78 79unsigned pgp_calc_sesskey_checksum(pgp_pk_sesskey_t *, uint8_t *); 80unsigned pgp_write_struct_userid(pgp_output_t *, const uint8_t *); 81unsigned pgp_write_ss_header(pgp_output_t *, unsigned, pgp_content_enum); 82unsigned pgp_write_struct_seckey(const pgp_seckey_t *, 83 const uint8_t *, 84 const size_t, 85 pgp_output_t *); 86unsigned pgp_write_one_pass_sig(pgp_output_t *, 87 const pgp_seckey_t *, 88 const pgp_hash_alg_t, 89 const pgp_sig_type_t); 90unsigned pgp_write_litdata(pgp_output_t *, 91 const uint8_t *, 92 const int, 93 const pgp_litdata_enum); 94pgp_pk_sesskey_t *pgp_create_pk_sesskey(const pgp_key_t *, const char *); 95unsigned pgp_write_pk_sesskey(pgp_output_t *, pgp_pk_sesskey_t *); 96unsigned pgp_write_xfer_pubkey(pgp_output_t *, 97 const pgp_key_t *, const unsigned); 98unsigned pgp_write_xfer_seckey(pgp_output_t *, 99 const pgp_key_t *, 100 const uint8_t *, 101 const size_t, 102 const unsigned); 103 104void pgp_fast_create_userid(uint8_t **, uint8_t *); 105unsigned pgp_write_userid(const uint8_t *, pgp_output_t *); 106void pgp_fast_create_rsa_pubkey(pgp_pubkey_t *, time_t, BIGNUM *, BIGNUM *); 107unsigned pgp_write_rsa_pubkey(time_t, const BIGNUM *, const BIGNUM *, 108 pgp_output_t *); 109void pgp_fast_create_rsa_seckey(pgp_seckey_t *, time_t, BIGNUM *, 110 BIGNUM *, BIGNUM *, BIGNUM *, 111 BIGNUM *, BIGNUM *); 112unsigned encode_m_buf(const uint8_t *, size_t, const pgp_pubkey_t *, 113 uint8_t *); 114unsigned pgp_fileread_litdata(const char *, const pgp_litdata_enum, 115 pgp_output_t *); 116unsigned pgp_write_symm_enc_data(const uint8_t *, const int, 117 pgp_output_t *); 118 119#endif /* CREATE_H_ */ 120