root/openpgpsdk/trunk/include/openpgpsdk/signature.h

Revision 701 (checked in by ben, 4 years ago)

Code contributed by Alasdair Mackintosh <alasdair@google.com> to do
partial length encodings and signatures much more cleanly.

Line 
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 "util.h"
30 #include "create.h"
31
32 typedef struct ops_create_signature ops_create_signature_t;
33
34 ops_create_signature_t *ops_create_signature_new(void);
35 void ops_create_signature_delete(ops_create_signature_t *sig);
36
37 ops_boolean_t
38 ops_check_user_id_certification_signature(const ops_public_key_t *key,
39                                           const ops_user_id_t *id,
40                                           const ops_signature_t *sig,
41                                           const ops_public_key_t *signer,
42                                           const unsigned char *raw_packet);
43 ops_boolean_t
44 ops_check_user_attribute_certification_signature(const ops_public_key_t *key,
45                                                  const ops_user_attribute_t *attribute,
46                                                  const ops_signature_t *sig,
47                                                  const ops_public_key_t *signer,
48                                                  const unsigned char *raw_packet);
49 ops_boolean_t
50 ops_check_subkey_signature(const ops_public_key_t *key,
51                            const ops_public_key_t *subkey,
52                            const ops_signature_t *sig,
53                            const ops_public_key_t *signer,
54                            const unsigned char *raw_packet);
55 ops_boolean_t
56 ops_check_direct_signature(const ops_public_key_t *key,
57                            const ops_signature_t *sig,
58                            const ops_public_key_t *signer,
59                            const unsigned char *raw_packet);
60 ops_boolean_t
61 ops_check_hash_signature(ops_hash_t *hash,
62                          const ops_signature_t *sig,
63                          const ops_public_key_t *signer);
64 void ops_signature_start_key_signature(ops_create_signature_t *sig,
65                                        const ops_public_key_t *key,
66                                        const ops_user_id_t *id,
67                                        ops_sig_type_t type);
68 void ops_signature_start_cleartext_signature(ops_create_signature_t *sig,
69                                              const ops_secret_key_t *key,
70                                              const ops_hash_algorithm_t hash,
71                                              const ops_sig_type_t type);
72 void ops_signature_start_message_signature(ops_create_signature_t *sig,
73                                              const ops_secret_key_t *key,
74                                              const ops_hash_algorithm_t hash,
75                                              const ops_sig_type_t type);
76
77 void ops_signature_add_data(ops_create_signature_t *sig,const void *buf,
78                             size_t length);
79 ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig);
80 ops_boolean_t ops_signature_hashed_subpackets_end(ops_create_signature_t *sig);
81 ops_boolean_t ops_write_signature(ops_create_signature_t *sig,const ops_public_key_t *key,
82                          const ops_secret_key_t *skey, ops_create_info_t *opt);
83 ops_boolean_t ops_signature_add_creation_time(ops_create_signature_t *sig,time_t when);
84 ops_boolean_t ops_signature_add_issuer_key_id(ops_create_signature_t *sig,
85                                      const unsigned char keyid[OPS_KEY_ID_SIZE]);
86 void ops_signature_add_primary_user_id(ops_create_signature_t *sig,
87                                        ops_boolean_t primary);
88
89 // Standard Interface
90 ops_boolean_t ops_sign_file_as_cleartext(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t overwrite);
91 ops_boolean_t ops_sign_buf_as_cleartext(const char* input, const size_t len, ops_memory_t** output, const ops_secret_key_t *skey);
92 ops_boolean_t ops_sign_file(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t use_armour, const ops_boolean_t overwrite);
93 ops_memory_t * ops_sign_buf(const void* input, const size_t input_len, const ops_sig_type_t sig_type,  const ops_secret_key_t *skey, const ops_boolean_t use_armour);
94 ops_boolean_t ops_writer_push_signed(ops_create_info_t *cinfo, const ops_sig_type_t sig_type, const ops_secret_key_t *skey);
95
96 #endif
97
Note: See TracBrowser for help on using the browser.