signature.h revision 1.5.2.2
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_signature __ops_create_signature_t;
32
33__ops_create_signature_t *__ops_create_signature_new(void);
34void            __ops_create_signature_delete(__ops_create_signature_t *);
35
36bool
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 *);
42bool
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 *);
48bool
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 *);
54bool
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 *);
59bool
60__ops_check_hash_signature(__ops_hash_t *,
61			 const __ops_signature_t *,
62			 const __ops_public_key_t *);
63void
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);
68void
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);
73void
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
79void
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 *);
82bool   __ops_signature_hashed_subpackets_end(__ops_create_signature_t *);
83bool
84__ops_write_signature(__ops_create_signature_t *, const __ops_public_key_t *,
85		    const __ops_secret_key_t *, __ops_create_info_t *);
86bool   __ops_signature_add_creation_time(__ops_create_signature_t *, time_t);
87bool __ops_signature_add_issuer_key_id(__ops_create_signature_t *, const unsigned char *);
88void            __ops_signature_add_primary_user_id(__ops_create_signature_t *, bool);
89
90/* Standard Interface */
91bool   __ops_sign_file_as_cleartext(const char *, const char *, const __ops_secret_key_t *, const bool);
92bool   __ops_sign_file(const char *, const char *, const __ops_secret_key_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_signature_t *);
101void            __ops_writer_push_armoured_message(__ops_create_info_t *);
102bool   __ops_writer_switch_to_armoured_signature(__ops_create_info_t *);
103
104typedef 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
115bool
116__ops_writer_push_clearsigned(__ops_create_info_t *, __ops_create_signature_t *);
117void            __ops_writer_push_armoured_message(__ops_create_info_t *);
118bool   __ops_writer_switch_to_armoured_signature(__ops_create_info_t *);
119
120void            __ops_writer_push_armoured(__ops_create_info_t *, __ops_armor_type_t);
121
122#endif
123