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 #ifndef VALIDATE_H_ 22 #define VALIDATE_H_ 1 23 24 typedef struct { 25 const __ops_keydata_t *key; 26 unsigned packet; 27 unsigned offset; 28 } validate_reader_t; 29 30 /** Struct used with the validate_key_cb callback */ 31 typedef struct { 32 __ops_public_key_t pkey; 33 __ops_public_key_t subkey; 34 __ops_secret_key_t skey; 35 enum { 36 ATTRIBUTE = 1, 37 ID 38 } last_seen; 39 __ops_user_id_t user_id; 40 __ops_user_attribute_t user_attribute; 41 unsigned char hash[OPS_MAX_HASH_SIZE]; 42 const __ops_keyring_t *keyring; 43 validate_reader_t *rarg; 44 __ops_validation_t *result; 45 __ops_parse_cb_return_t(*cb_get_passphrase) (const __ops_parser_content_t *, __ops_parse_cb_info_t *); 46 } validate_key_cb_t; 47 48 /** Struct use with the validate_data_cb callback */ 49 typedef struct { 50 enum { 51 LITERAL_DATA, 52 SIGNED_CLEARTEXT 53 } use; /* <! this is set to indicate what 54 * kind of data we have */ 55 union { 56 __ops_literal_data_body_t literal_data_body; /* <! Used to hold 57 * Literal Data */ 58 __ops_signed_cleartext_body_t signed_cleartext_body; /* <! Used to hold 59 * Signed Cleartext */ 60 } data; /* <! the data itself */ 61 unsigned char hash[OPS_MAX_HASH_SIZE]; /* <! the hash */ 62 __ops_memory_t *mem; 63 const __ops_keyring_t *keyring; /* <! keyring to use */ 64 validate_reader_t *rarg; /* <! reader-specific arg */ 65 __ops_validation_t *result; /* <! where to put the result */ 66 } validate_data_cb_t; /* <! used with 67 * validate_data_cb callback */ 68 69 void __ops_keydata_reader_set(__ops_parse_info_t *, const __ops_keydata_t *); 70 71 __ops_parse_cb_return_t __ops_validate_key_cb(const __ops_parser_content_t *, __ops_parse_cb_info_t *); 72 73 bool __ops_validate_file(__ops_validation_t *, const char *, const int, const __ops_keyring_t *); 74 bool __ops_validate_mem(__ops_validation_t *, __ops_memory_t *, const int, const __ops_keyring_t *); 75 76 __ops_parse_cb_return_t validate_data_cb(const __ops_parser_content_t *, __ops_parse_cb_info_t *); 77 78 #endif /* !VALIDATE_H_ */ 79