1ebfedea0SLionel Sambuc /*- 2ebfedea0SLionel Sambuc * Copyright (c) 2009,2010 The NetBSD Foundation, Inc. 3ebfedea0SLionel Sambuc * All rights reserved. 4ebfedea0SLionel Sambuc * 5ebfedea0SLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation 6ebfedea0SLionel Sambuc * by Alistair Crooks (agc@NetBSD.org) 7ebfedea0SLionel Sambuc * 8ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without 9ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions 10ebfedea0SLionel Sambuc * are met: 11ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright 12ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer. 13ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 14ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 15ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution. 16ebfedea0SLionel Sambuc * 17ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18ebfedea0SLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19ebfedea0SLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20ebfedea0SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21ebfedea0SLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22ebfedea0SLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23ebfedea0SLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24ebfedea0SLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25ebfedea0SLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26ebfedea0SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ebfedea0SLionel Sambuc * POSSIBILITY OF SUCH DAMAGE. 28ebfedea0SLionel Sambuc */ 29ebfedea0SLionel Sambuc #ifndef NETPGPSDK_H_ 30ebfedea0SLionel Sambuc #define NETPGPSDK_H_ 31ebfedea0SLionel Sambuc 32ebfedea0SLionel Sambuc #include "keyring.h" 33ebfedea0SLionel Sambuc #include "crypto.h" 34ebfedea0SLionel Sambuc #include "signature.h" 35ebfedea0SLionel Sambuc #include "packet-show.h" 36ebfedea0SLionel Sambuc 37*0a6a1f1dSLionel Sambuc #ifndef __printflike 38*0a6a1f1dSLionel Sambuc #define __printflike(n, m) __attribute__((format(printf,n,m))) 39*0a6a1f1dSLionel Sambuc #endif 40*0a6a1f1dSLionel Sambuc 41ebfedea0SLionel Sambuc typedef struct pgp_validation_t { 42ebfedea0SLionel Sambuc unsigned validc; 43ebfedea0SLionel Sambuc pgp_sig_info_t *valid_sigs; 44ebfedea0SLionel Sambuc unsigned invalidc; 45ebfedea0SLionel Sambuc pgp_sig_info_t *invalid_sigs; 46ebfedea0SLionel Sambuc unsigned unknownc; 47ebfedea0SLionel Sambuc pgp_sig_info_t *unknown_sigs; 48ebfedea0SLionel Sambuc time_t birthtime; 49ebfedea0SLionel Sambuc time_t duration; 50ebfedea0SLionel Sambuc } pgp_validation_t; 51ebfedea0SLionel Sambuc 52ebfedea0SLionel Sambuc void pgp_validate_result_free(pgp_validation_t *); 53ebfedea0SLionel Sambuc 54ebfedea0SLionel Sambuc unsigned 55ebfedea0SLionel Sambuc pgp_validate_key_sigs(pgp_validation_t *, 56ebfedea0SLionel Sambuc const pgp_key_t *, 57ebfedea0SLionel Sambuc const pgp_keyring_t *, 58ebfedea0SLionel Sambuc pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *)); 59ebfedea0SLionel Sambuc 60ebfedea0SLionel Sambuc unsigned 61ebfedea0SLionel Sambuc pgp_validate_all_sigs(pgp_validation_t *, 62ebfedea0SLionel Sambuc const pgp_keyring_t *, 63ebfedea0SLionel Sambuc pgp_cb_ret_t cb(const pgp_packet_t *, pgp_cbdata_t *)); 64ebfedea0SLionel Sambuc 65ebfedea0SLionel Sambuc unsigned pgp_check_sig(const uint8_t *, 66ebfedea0SLionel Sambuc unsigned, const pgp_sig_t *, const pgp_pubkey_t *); 67ebfedea0SLionel Sambuc 68ebfedea0SLionel Sambuc const char *pgp_get_info(const char *type); 69ebfedea0SLionel Sambuc 70*0a6a1f1dSLionel Sambuc int pgp_asprintf(char **, const char *, ...) __printflike(2, 3); 71ebfedea0SLionel Sambuc 72*0a6a1f1dSLionel Sambuc void netpgp_log(const char *, ...) __printflike(1, 2); 73ebfedea0SLionel Sambuc 74ebfedea0SLionel Sambuc int netpgp_strcasecmp(const char *, const char *); 75ebfedea0SLionel Sambuc char *netpgp_strdup(const char *); 76ebfedea0SLionel Sambuc 77ebfedea0SLionel Sambuc 78ebfedea0SLionel Sambuc #endif 79