validate.h

00001 /*
00002  * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
00003  * All rights reserved.
00004  * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
00005  * their moral rights under the UK Copyright Design and Patents Act 1988 to
00006  * be recorded as the authors of this copyright work.
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00009  * use this file except in compliance with the License. 
00010  * 
00011  * You may obtain a copy of the License at 
00012  *     http://www.apache.org/licenses/LICENSE-2.0 
00013  * 
00014  * Unless required by applicable law or agreed to in writing, software 
00015  * distributed under the License is distributed on an "AS IS" BASIS, 
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
00017  * 
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 
00023 typedef struct
00024     {
00025     unsigned int valid_count;
00026     ops_signature_info_t * valid_sigs;
00027     unsigned int invalid_count;
00028     ops_signature_info_t * invalid_sigs;
00029     unsigned int unknown_signer_count;
00030     ops_signature_info_t * unknown_sigs;
00031     } ops_validate_result_t;
00032 
00033 void ops_validate_result_free(ops_validate_result_t *result);
00034 
00035 ops_boolean_t ops_validate_key_signatures(ops_validate_result_t *result,
00036                                  const ops_keydata_t* keydata,
00037                                  const ops_keyring_t *ring,
00038                                  ops_parse_cb_return_t cb (const ops_parser_content_t *, ops_parse_cb_info_t *));
00039 ops_boolean_t ops_validate_all_signatures(ops_validate_result_t *result,
00040                                  const ops_keyring_t *ring,
00041                                  ops_parse_cb_return_t (const ops_parser_content_t *, ops_parse_cb_info_t *));
00042 
00043 void ops_keydata_reader_set(ops_parse_info_t *pinfo,
00044                              const ops_keydata_t *key);
00045 
00046 typedef struct
00047     {
00048     const ops_keydata_t *key;
00049     unsigned packet;
00050     unsigned offset;
00051     } validate_reader_arg_t;
00052 
00054 typedef struct
00055     {
00056     ops_public_key_t pkey;
00057     ops_public_key_t subkey;
00058     ops_secret_key_t skey;
00059     enum
00060         {
00061         ATTRIBUTE=1,
00062         ID,
00063         } last_seen;
00064     ops_user_id_t user_id;
00065     ops_user_attribute_t user_attribute;
00066     unsigned char hash[OPS_MAX_HASH_SIZE];
00067     const ops_keyring_t *keyring;
00068     validate_reader_arg_t *rarg;
00069     ops_validate_result_t *result;
00070     ops_parse_cb_return_t (*cb_get_passphrase) (const ops_parser_content_t *, ops_parse_cb_info_t *);
00071     } validate_key_cb_arg_t;
00072 
00074 typedef struct validate_data_cb_arg
00075     {
00076     enum
00077         {
00078         LITERAL_DATA,
00079         SIGNED_CLEARTEXT
00080         } use; /*<! this is set to indicate what kind of data we have */
00081 
00082     union
00083         {
00084         ops_literal_data_body_t literal_data_body; /*<! Used to hold Literal Data */
00085         ops_signed_cleartext_body_t signed_cleartext_body; /*<! Used to hold Signed Cleartext */
00086         } data;
00087 
00088     unsigned char hash[OPS_MAX_HASH_SIZE]; /*<! the hash */
00089     const ops_keyring_t *keyring; /*<! keyring to use */
00090     validate_reader_arg_t *rarg; /*<! reader-specific arg */
00091     ops_validate_result_t *result; /*<! where to put the result */
00092     } validate_data_cb_arg_t; /*<! used with validate_data_cb callback */
00093 
00094 ops_boolean_t ops_check_signature(const unsigned char *hash,
00095                                   unsigned length,
00096                                   const ops_signature_t *sig,
00097                                   const ops_public_key_t *signer);
00098 ops_parse_cb_return_t
00099 ops_validate_key_cb(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo);
00100 
00101 ops_boolean_t ops_validate_file(ops_validate_result_t* result, const char* filename, const int armoured, const ops_keyring_t* keyring);
00102 ops_boolean_t ops_validate_mem(ops_validate_result_t *result, ops_memory_t* mem, const int armoured, const ops_keyring_t* keyring);
00103 ops_boolean_t ops_validate_detached_signature(const void *literal_data, unsigned int literal_data_length, const unsigned char *signature_packet, unsigned int signature_packet_length,const ops_keydata_t *signers_key) ;

Generated on Thu May 23 00:00:02 2013 for OpenPGP:SDK by  doxygen 1.4.6