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_WRITER_H 26 #define OPS_WRITER_H 27 28 #include "types.h" 29 #include "packet.h" 30 #include "crypto.h" 31 #include "errors.h" 32 #include "keyring.h" 33 34 /** 35 * \ingroup Create 36 * This struct contains the required information about one writer 37 */ 38 /** 39 * \ingroup Writer 40 * the writer function prototype 41 */ 42 43 typedef struct __ops_writer_info __ops_writer_info_t; 44 typedef bool 45 __ops_writer_t(const unsigned char *, 46 unsigned, 47 __ops_error_t **, 48 __ops_writer_info_t *); 49 typedef bool 50 __ops_writer_finaliser_t(__ops_error_t **, __ops_writer_info_t *); 51 typedef void __ops_writer_destroyer_t(__ops_writer_info_t *); 52 53 /** Writer settings */ 54 struct __ops_writer_info { 55 __ops_writer_t *writer; /* !< the writer itself */ 56 __ops_writer_finaliser_t *finaliser; /* !< the writer's finaliser */ 57 __ops_writer_destroyer_t *destroyer; /* !< the writer's destroyer */ 58 void *arg; /* writer-specific argument */ 59 __ops_writer_info_t *next;/* !< next writer in the stack */ 60 }; 61 62 63 void *__ops_writer_get_arg(__ops_writer_info_t *); 64 bool 65 __ops_stacked_write(const void *, unsigned, 66 __ops_error_t **, 67 __ops_writer_info_t *); 68 69 void 70 __ops_writer_set(__ops_create_info_t *, 71 __ops_writer_t *, 72 __ops_writer_finaliser_t *, 73 __ops_writer_destroyer_t *, 74 void *); 75 void 76 __ops_writer_push(__ops_create_info_t *, 77 __ops_writer_t *, 78 __ops_writer_finaliser_t *, 79 __ops_writer_destroyer_t *, 80 void *); 81 void __ops_writer_pop(__ops_create_info_t *); 82 void __ops_writer_generic_destroyer(__ops_writer_info_t *); 83 bool 84 __ops_writer_passthrough(const unsigned char *, 85 unsigned, 86 __ops_error_t **, 87 __ops_writer_info_t *); 88 89 void __ops_writer_set_fd(__ops_create_info_t *, int); 90 bool __ops_writer_close(__ops_create_info_t *); 91 92 bool 93 __ops_write(const void *, unsigned, __ops_create_info_t *); 94 bool __ops_write_length(unsigned, __ops_create_info_t *); 95 bool __ops_write_ptag(__ops_content_tag_t, __ops_create_info_t *); 96 bool __ops_write_scalar(unsigned, unsigned, __ops_create_info_t *); 97 bool __ops_write_mpi(const BIGNUM *, __ops_create_info_t *); 98 bool __ops_write_encrypted_mpi(const BIGNUM *, __ops_crypt_t *, __ops_create_info_t *); 99 100 void writer_info_delete(__ops_writer_info_t *); 101 bool writer_info_finalise(__ops_error_t **, __ops_writer_info_t *); 102 103 void __ops_writer_push_stream_encrypt_se_ip(__ops_create_info_t *, const __ops_keydata_t *); 104 105 #endif 106