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_SIGNATURE_H 26 #define OPS_SIGNATURE_H 27 28 #include "packet.h" 29 #include "create.h" 30 31 typedef struct __ops_create_signature __ops_create_signature_t; 32 33 __ops_create_signature_t *__ops_create_signature_new(void); 34 void __ops_create_signature_delete(__ops_create_signature_t *); 35 36 bool 37 __ops_check_user_id_certification_signature(const __ops_public_key_t *, 38 const __ops_user_id_t *, 39 const __ops_signature_t *, 40 const __ops_public_key_t *, 41 const unsigned char *); 42 bool 43 __ops_check_user_attribute_certification_signature(const __ops_public_key_t *, 44 const __ops_user_attribute_t *, 45 const __ops_signature_t *, 46 const __ops_public_key_t *, 47 const unsigned char *); 48 bool 49 __ops_check_subkey_signature(const __ops_public_key_t *, 50 const __ops_public_key_t *, 51 const __ops_signature_t *, 52 const __ops_public_key_t *, 53 const unsigned char *); 54 bool 55 __ops_check_direct_signature(const __ops_public_key_t *, 56 const __ops_signature_t *, 57 const __ops_public_key_t *, 58 const unsigned char *); 59 bool 60 __ops_check_hash_signature(__ops_hash_t *, 61 const __ops_signature_t *, 62 const __ops_public_key_t *); 63 void 64 __ops_signature_start_key_signature(__ops_create_signature_t *, 65 const __ops_public_key_t *, 66 const __ops_user_id_t *, 67 __ops_sig_type_t); 68 void 69 __ops_signature_start_cleartext_signature(__ops_create_signature_t *, 70 const __ops_secret_key_t *, 71 const __ops_hash_algorithm_t, 72 const __ops_sig_type_t); 73 void 74 __ops_signature_start_message_signature(__ops_create_signature_t *, 75 const __ops_secret_key_t *, 76 const __ops_hash_algorithm_t, 77 const __ops_sig_type_t); 78 79 void 80 __ops_signature_add_data(__ops_create_signature_t *, const void *, size_t); 81 __ops_hash_t *__ops_signature_get_hash(__ops_create_signature_t *); 82 bool __ops_signature_hashed_subpackets_end(__ops_create_signature_t *); 83 bool 84 __ops_write_signature(__ops_create_signature_t *, const __ops_public_key_t *, 85 const __ops_secret_key_t *, __ops_create_info_t *); 86 bool __ops_signature_add_creation_time(__ops_create_signature_t *, time_t); 87 bool __ops_signature_add_issuer_key_id(__ops_create_signature_t *, const unsigned char *); 88 void __ops_signature_add_primary_user_id(__ops_create_signature_t *, bool); 89 90 /* Standard Interface */ 91 bool __ops_sign_file_as_cleartext(const char *, const char *, const __ops_secret_key_t *, const bool); 92 bool __ops_sign_file(const char *, const char *, const __ops_secret_key_t *, const bool, const bool); 93 94 /* armoured stuff */ 95 unsigned __ops_crc24(unsigned, unsigned char); 96 97 void __ops_reader_push_dearmour(__ops_parse_info_t *); 98 99 void __ops_reader_pop_dearmour(__ops_parse_info_t *); 100 bool __ops_writer_push_clearsigned(__ops_create_info_t *, __ops_create_signature_t *); 101 void __ops_writer_push_armoured_message(__ops_create_info_t *); 102 bool __ops_writer_switch_to_armoured_signature(__ops_create_info_t *); 103 104 typedef enum { 105 OPS_PGP_MESSAGE = 1, 106 OPS_PGP_PUBLIC_KEY_BLOCK, 107 OPS_PGP_PRIVATE_KEY_BLOCK, 108 OPS_PGP_MULTIPART_MESSAGE_PART_X_OF_Y, 109 OPS_PGP_MULTIPART_MESSAGE_PART_X, 110 OPS_PGP_SIGNATURE 111 } __ops_armor_type_t; 112 113 #define CRC24_INIT 0xb704ceL 114 115 bool 116 __ops_writer_push_clearsigned(__ops_create_info_t *, __ops_create_signature_t *); 117 void __ops_writer_push_armoured_message(__ops_create_info_t *); 118 bool __ops_writer_switch_to_armoured_signature(__ops_create_info_t *); 119 120 void __ops_writer_push_armoured(__ops_create_info_t *, __ops_armor_type_t); 121 122 #endif 123