1 1.1 agc /*- 2 1.1 agc * Copyright (c) 2009 The NetBSD Foundation, Inc. 3 1.1 agc * All rights reserved. 4 1.1 agc * 5 1.1 agc * This code is derived from software contributed to The NetBSD Foundation 6 1.1 agc * by Alistair Crooks (agc (at) netbsd.org) 7 1.1 agc * 8 1.1 agc * Redistribution and use in source and binary forms, with or without 9 1.1 agc * modification, are permitted provided that the following conditions 10 1.1 agc * are met: 11 1.1 agc * 1. Redistributions of source code must retain the above copyright 12 1.1 agc * notice, this list of conditions and the following disclaimer. 13 1.1 agc * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 agc * notice, this list of conditions and the following disclaimer in the 15 1.1 agc * documentation and/or other materials provided with the distribution. 16 1.1 agc * 17 1.1 agc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 1.1 agc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 1.1 agc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 1.1 agc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 1.1 agc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 1.1 agc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 1.1 agc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 1.1 agc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 1.1 agc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 1.1 agc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 1.1 agc * POSSIBILITY OF SUCH DAMAGE. 28 1.1 agc */ 29 1.1 agc #ifndef NETPGP_H_ 30 1.1 agc #define NETPGP_H_ 31 1.1 agc 32 1.1 agc #ifndef __BEGIN_DECLS 33 1.1 agc # if defined(__cplusplus) 34 1.1 agc # define __BEGIN_DECLS extern "C" { 35 1.1 agc # define __END_DECLS } 36 1.1 agc # else 37 1.1 agc # define __BEGIN_DECLS 38 1.1 agc # define __END_DECLS 39 1.1 agc # endif 40 1.1 agc #endif 41 1.1 agc 42 1.1 agc __BEGIN_DECLS 43 1.1 agc 44 1.1 agc /* structure used to hold (key,value) pair information */ 45 1.1 agc typedef struct netpgp_t { 46 1.1 agc unsigned c; /* # of elements used */ 47 1.1 agc unsigned size; /* size of array */ 48 1.1 agc char **name; /* key names */ 49 1.1 agc char **value; /* value information */ 50 1.1 agc void *pubring; /* public key ring */ 51 1.1 agc void *secring; /* s3kr1t key ring */ 52 1.1 agc void *io; /* the io struct for results/errs */ 53 1.1 agc void *passfp; /* file pointer for password input */ 54 1.1 agc } netpgp_t; 55 1.1 agc 56 1.1 agc /* begin and end */ 57 1.1 agc int netpgp_init(netpgp_t *); 58 1.1 agc int netpgp_end(netpgp_t *); 59 1.1 agc 60 1.1 agc /* debugging, reflection and information */ 61 1.1 agc int netpgp_set_debug(const char *); 62 1.1 agc int netpgp_get_debug(const char *); 63 1.1 agc const char *netpgp_get_info(const char *); 64 1.1 agc int netpgp_list_packets(netpgp_t *, char *, int, char *); 65 1.1 agc 66 1.1 agc /* variables */ 67 1.1 agc int netpgp_setvar(netpgp_t *, const char *, const char *); 68 1.1 agc char *netpgp_getvar(netpgp_t *, const char *); 69 1.2 agc int netpgp_incvar(netpgp_t *, const char *, const int); 70 1.2 agc int netpgp_unsetvar(netpgp_t *, const char *); 71 1.2 agc 72 1.2 agc /* set home directory information */ 73 1.2 agc int netpgp_set_homedir(netpgp_t *, char *, const char *, const int); 74 1.1 agc 75 1.1 agc /* key management */ 76 1.2 agc int netpgp_list_keys(netpgp_t *, const int); 77 1.1 agc int netpgp_find_key(netpgp_t *, char *); 78 1.2 agc char *netpgp_get_key(netpgp_t *, const char *, const char *); 79 1.2 agc char *netpgp_export_key(netpgp_t *, char *); 80 1.1 agc int netpgp_import_key(netpgp_t *, char *); 81 1.1 agc int netpgp_generate_key(netpgp_t *, char *, int); 82 1.1 agc 83 1.1 agc /* file management */ 84 1.1 agc int netpgp_encrypt_file(netpgp_t *, const char *, const char *, char *, int); 85 1.1 agc int netpgp_decrypt_file(netpgp_t *, const char *, char *, int); 86 1.1 agc int netpgp_sign_file(netpgp_t *, const char *, const char *, char *, int, int, int); 87 1.1 agc int netpgp_verify_file(netpgp_t *, const char *, const char *, int); 88 1.1 agc 89 1.2 agc /* memory signing and encryption */ 90 1.1 agc int netpgp_sign_memory(netpgp_t *, const char *, char *, size_t, char *, size_t, const unsigned, const unsigned); 91 1.2 agc int netpgp_verify_memory(netpgp_t *, const void *, const size_t, void *, size_t, const int); 92 1.2 agc int netpgp_encrypt_memory(netpgp_t *, const char *, void *, const size_t, char *, size_t, int); 93 1.2 agc int netpgp_decrypt_memory(netpgp_t *, const void *, const size_t, char *, size_t, const int); 94 1.2 agc 95 1.2 agc /* match and hkp-related functions */ 96 1.2 agc int netpgp_match_keys(netpgp_t *, char *, const char *, void *, const int); 97 1.2 agc int netpgp_match_pubkeys(netpgp_t *, char *, void *); 98 1.2 agc 99 1.2 agc int netpgp_validate_sigs(netpgp_t *); 100 1.1 agc 101 1.1 agc __END_DECLS 102 1.1 agc 103 1.1 agc #endif /* !NETPGP_H_ */ 104