signature.h revision 1.3
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
31typedef struct __ops_create_sig __ops_create_sig_t;
32
33__ops_create_sig_t *__ops_create_sig_new(void);
34void            __ops_create_sig_delete(__ops_create_sig_t *);
35
36bool
37__ops_check_useridcert_sig(const __ops_pubkey_t *,
38					  const __ops_user_id_t *,
39					  const __ops_sig_t *,
40					  const __ops_pubkey_t *,
41					  const unsigned char *);
42bool
43__ops_check_userattrcert_sig(const __ops_pubkey_t *,
44				     const __ops_user_attribute_t *,
45						 const __ops_sig_t *,
46					    const __ops_pubkey_t *,
47					   const unsigned char *);
48bool
49__ops_check_subkey_sig(const __ops_pubkey_t *,
50			   const __ops_pubkey_t *,
51			   const __ops_sig_t *,
52			   const __ops_pubkey_t *,
53			   const unsigned char *);
54bool
55__ops_check_direct_sig(const __ops_pubkey_t *,
56			   const __ops_sig_t *,
57			   const __ops_pubkey_t *,
58			   const unsigned char *);
59bool
60__ops_check_hash_sig(__ops_hash_t *,
61			 const __ops_sig_t *,
62			 const __ops_pubkey_t *);
63void
64__ops_sig_start_key_sig(__ops_create_sig_t *,
65				  const __ops_pubkey_t *,
66				  const __ops_user_id_t *,
67				  __ops_sig_type_t);
68void
69__ops_start_cleartext_sig(__ops_create_sig_t *,
70			const __ops_seckey_t *,
71			const __ops_hash_algorithm_t,
72			const __ops_sig_type_t);
73void
74__ops_start_msg_sig(__ops_create_sig_t *,
75		      const __ops_seckey_t *,
76		      const __ops_hash_algorithm_t,
77		      const __ops_sig_type_t);
78
79void
80__ops_sig_add_data(__ops_create_sig_t *, const void *, size_t);
81__ops_hash_t     *__ops_sig_get_hash(__ops_create_sig_t *);
82bool   __ops_sig_hashed_subpackets_end(__ops_create_sig_t *);
83bool
84__ops_write_sig(__ops_create_sig_t *, const __ops_pubkey_t *,
85		    const __ops_seckey_t *, __ops_create_info_t *);
86bool   __ops_sig_add_birthtime(__ops_create_sig_t *, time_t);
87bool __ops_sig_add_issuer_key_id(__ops_create_sig_t *, const unsigned char *);
88void            __ops_sig_add_primary_user_id(__ops_create_sig_t *, bool);
89
90/* Standard Interface */
91bool   __ops_sign_file_as_cleartext(const char *, const char *, const __ops_seckey_t *, const bool);
92bool   __ops_sign_file(const char *, const char *, const __ops_seckey_t *, const bool, const bool);
93
94/* armoured stuff */
95unsigned        __ops_crc24(unsigned, unsigned char);
96
97void            __ops_reader_push_dearmour(__ops_parse_info_t *);
98
99void            __ops_reader_pop_dearmour(__ops_parse_info_t *);
100bool __ops_writer_push_clearsigned(__ops_create_info_t *, __ops_create_sig_t *);
101void            __ops_writer_push_armoured_message(__ops_create_info_t *);
102
103typedef enum {
104	OPS_PGP_MESSAGE = 1,
105	OPS_PGP_PUBLIC_KEY_BLOCK,
106	OPS_PGP_PRIVATE_KEY_BLOCK,
107	OPS_PGP_MULTIPART_MESSAGE_PART_X_OF_Y,
108	OPS_PGP_MULTIPART_MESSAGE_PART_X,
109	OPS_PGP_SIGNATURE
110} __ops_armor_type_t;
111
112#define CRC24_INIT 0xb704ceL
113
114bool
115__ops_writer_push_clearsigned(__ops_create_info_t *, __ops_create_sig_t *);
116void            __ops_writer_push_armoured_message(__ops_create_info_t *);
117bool   __ops_writer_use_armored_sig(__ops_create_info_t *);
118
119void            __ops_writer_push_armoured(__ops_create_info_t *, __ops_armor_type_t);
120
121#endif
122