193bf6008Sagc /*- 2b15ec256Sagc * Copyright (c) 2009,2010 The NetBSD Foundation, Inc. 393bf6008Sagc * All rights reserved. 493bf6008Sagc * 593bf6008Sagc * This code is derived from software contributed to The NetBSD Foundation 693bf6008Sagc * by Alistair Crooks (agc@NetBSD.org) 793bf6008Sagc * 893bf6008Sagc * Redistribution and use in source and binary forms, with or without 993bf6008Sagc * modification, are permitted provided that the following conditions 1093bf6008Sagc * are met: 1193bf6008Sagc * 1. Redistributions of source code must retain the above copyright 1293bf6008Sagc * notice, this list of conditions and the following disclaimer. 1393bf6008Sagc * 2. Redistributions in binary form must reproduce the above copyright 1493bf6008Sagc * notice, this list of conditions and the following disclaimer in the 1593bf6008Sagc * documentation and/or other materials provided with the distribution. 1693bf6008Sagc * 1793bf6008Sagc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1893bf6008Sagc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1993bf6008Sagc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2093bf6008Sagc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2193bf6008Sagc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2293bf6008Sagc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2393bf6008Sagc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2493bf6008Sagc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2593bf6008Sagc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2693bf6008Sagc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2793bf6008Sagc * POSSIBILITY OF SUCH DAMAGE. 2893bf6008Sagc */ 294b3a3e18Sagc #ifndef NETPGPSDK_H_ 304b3a3e18Sagc #define NETPGPSDK_H_ 3193bf6008Sagc 3293bf6008Sagc #include "keyring.h" 3393bf6008Sagc #include "crypto.h" 3493bf6008Sagc #include "signature.h" 3593bf6008Sagc #include "packet-show.h" 3693bf6008Sagc 3708dd6cefSagc #ifndef __printflike 3808dd6cefSagc #define __printflike(n, m) __attribute__((format(printf,n,m))) 3908dd6cefSagc #endif 4008dd6cefSagc 41fc1f8641Sagc typedef struct pgp_validation_t { 42b15ec256Sagc unsigned validc; 43fc1f8641Sagc pgp_sig_info_t *valid_sigs; 44b15ec256Sagc unsigned invalidc; 45fc1f8641Sagc pgp_sig_info_t *invalid_sigs; 46b15ec256Sagc unsigned unknownc; 47fc1f8641Sagc pgp_sig_info_t *unknown_sigs; 48600b302bSagc time_t birthtime; 49600b302bSagc time_t duration; 50fc1f8641Sagc } pgp_validation_t; 5193bf6008Sagc 52fc1f8641Sagc void pgp_validate_result_free(pgp_validation_t *); 5393bf6008Sagc 544b3a3e18Sagc unsigned 55fc1f8641Sagc pgp_validate_key_sigs(pgp_validation_t *, 56fc1f8641Sagc const pgp_key_t *, 57fc1f8641Sagc const pgp_keyring_t *, 58fc1f8641Sagc pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *)); 5993bf6008Sagc 604b3a3e18Sagc unsigned 61fc1f8641Sagc pgp_validate_all_sigs(pgp_validation_t *, 62fc1f8641Sagc const pgp_keyring_t *, 63fc1f8641Sagc pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *)); 6493bf6008Sagc 65fc1f8641Sagc unsigned pgp_check_sig(const uint8_t *, 66fc1f8641Sagc unsigned, const pgp_sig_t *, const pgp_pubkey_t *); 6793bf6008Sagc 68fc1f8641Sagc const char *pgp_get_info(const char *type); 6993bf6008Sagc 70e371cb1bSjoerg int pgp_asprintf(char **, const char *, ...) __printflike(2, 3); 719e63cf3fSagc 72e371cb1bSjoerg void netpgp_log(const char *, ...) __printflike(1, 2); 73d21b929eSagc 74b15ec256Sagc int netpgp_strcasecmp(const char *, const char *); 75b15ec256Sagc char *netpgp_strdup(const char *); 76b15ec256Sagc 77*0294a66bSjhigh int ecdsa_numbits(const pgp_ecdsa_pubkey_t *); 78*0294a66bSjhigh int ecdsa_nid(const pgp_ecdsa_pubkey_t *); 79*0294a66bSjhigh pgp_hash_alg_t ecdsa_hashalg(const pgp_ecdsa_pubkey_t *); 80*0294a66bSjhigh int ecdsa_hashsize(const pgp_ecdsa_pubkey_t *); 81d21b929eSagc 8293bf6008Sagc #endif 83