Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / crypto / external / bsd / netpgp / dist / src / lib / validate.h
blob5efce41c411b4f7eb947a2994fd752cac3a2d51c
1 /*-
2 * Copyright (c) 2009 The NetBSD Foundation, Inc.
3 * All rights reserved.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Alistair Crooks (agc@NetBSD.org)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
31 * All rights reserved.
32 * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
33 * their moral rights under the UK Copyright Design and Patents Act 1988 to
34 * be recorded as the authors of this copyright work.
36 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
37 * use this file except in compliance with the License.
39 * You may obtain a copy of the License at
40 * http://www.apache.org/licenses/LICENSE-2.0
42 * Unless required by applicable law or agreed to in writing, software
43 * distributed under the License is distributed on an "AS IS" BASIS,
44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 * See the License for the specific language governing permissions and
47 * limitations under the License.
49 #ifndef VALIDATE_H_
50 #define VALIDATE_H_ 1
52 typedef struct {
53 const __ops_key_t *key;
54 unsigned packet;
55 unsigned offset;
56 } validate_reader_t;
58 /** Struct used with the validate_key_cb callback */
59 typedef struct {
60 __ops_pubkey_t pubkey;
61 __ops_pubkey_t subkey;
62 __ops_seckey_t seckey;
63 enum {
64 ATTRIBUTE = 1,
66 } last_seen;
67 __ops_userid_t userid;
68 __ops_userattr_t userattr;
69 unsigned char hash[OPS_MAX_HASH_SIZE];
70 const __ops_keyring_t *keyring;
71 validate_reader_t *reader;
72 __ops_validation_t *result;
73 __ops_cb_ret_t(*getpassphrase) (const __ops_packet_t *,
74 __ops_cbdata_t *);
75 } validate_key_cb_t;
77 /** Struct use with the validate_data_cb callback */
78 typedef struct {
79 enum {
80 LITDATA,
81 SIGNED_CLEARTEXT
82 } type;
83 union {
84 __ops_litdata_body_t litdata_body;
85 __ops_cleartext_body_t cleartext_body;
86 } data;
87 unsigned char hash[OPS_MAX_HASH_SIZE];
88 __ops_memory_t *mem;
89 const __ops_keyring_t *keyring;
90 validate_reader_t *reader;/* reader-specific arg */
91 __ops_validation_t *result;
92 char *detachname;
93 } validate_data_cb_t;
95 void __ops_keydata_reader_set(__ops_stream_t *, const __ops_key_t *);
97 __ops_cb_ret_t __ops_validate_key_cb(const __ops_packet_t *, __ops_cbdata_t *);
99 unsigned __ops_validate_file(__ops_io_t *,
100 __ops_validation_t *,
101 const char *,
102 const char *,
103 const int,
104 const __ops_keyring_t *);
106 unsigned __ops_validate_mem(__ops_io_t *,
107 __ops_validation_t *,
108 __ops_memory_t *,
109 __ops_memory_t **,
110 const int,
111 const __ops_keyring_t *);
113 __ops_cb_ret_t validate_data_cb(const __ops_packet_t *, __ops_cbdata_t *);
115 #endif /* !VALIDATE_H_ */