xref: /netbsd-src/crypto/external/bsd/netpgp/dist/include/netpgp.h (revision f92f386dca8e399c33f9cede12c08dcfba055a01)
193bf6008Sagc /*-
293bf6008Sagc  * Copyright (c) 2009 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  */
2993bf6008Sagc #ifndef NETPGP_H_
3093bf6008Sagc #define NETPGP_H_
3193bf6008Sagc 
327e613096Sagc #ifndef __BEGIN_DECLS
337e613096Sagc #  if defined(__cplusplus)
347e613096Sagc #  define __BEGIN_DECLS           extern "C" {
357e613096Sagc #  define __END_DECLS             }
367e613096Sagc #  else
377e613096Sagc #  define __BEGIN_DECLS
387e613096Sagc #  define __END_DECLS
397e613096Sagc #  endif
407e613096Sagc #endif
417e613096Sagc 
427e613096Sagc __BEGIN_DECLS
437e613096Sagc 
44c64158a1Sagc /* structure used to hold (key,value) pair information */
45*f92f386dSchristos typedef struct {
46c64158a1Sagc 	unsigned	  c;		/* # of elements used */
47c64158a1Sagc 	unsigned	  size;		/* size of array */
48c64158a1Sagc 	char		**name;		/* key names */
49c64158a1Sagc 	char		**value;	/* value information */
5093bf6008Sagc 	void		 *pubring;	/* public key ring */
51c64158a1Sagc 	void		 *secring;	/* s3kr1t key ring */
52d21b929eSagc 	void		 *io;		/* the io struct for results/errs */
5341335e2dSagc 	void		 *passfp;	/* file pointer for password input */
5493bf6008Sagc } netpgp_t;
5593bf6008Sagc 
5693bf6008Sagc /* begin and end */
57c64158a1Sagc int netpgp_init(netpgp_t *);
5893bf6008Sagc int netpgp_end(netpgp_t *);
5993bf6008Sagc 
6093bf6008Sagc /* debugging, reflection and information */
6193bf6008Sagc int netpgp_set_debug(const char *);
6293bf6008Sagc int netpgp_get_debug(const char *);
6393bf6008Sagc const char *netpgp_get_info(const char *);
64bcfd8565Sagc int netpgp_list_packets(netpgp_t *, char *, int, char *);
6593bf6008Sagc 
664b3a3e18Sagc /* variables */
674b3a3e18Sagc int netpgp_setvar(netpgp_t *, const char *, const char *);
684b3a3e18Sagc char *netpgp_getvar(netpgp_t *, const char *);
699e63cf3fSagc int netpgp_incvar(netpgp_t *, const char *, const int);
7065386b72Sagc int netpgp_unsetvar(netpgp_t *, const char *);
719e63cf3fSagc 
729e63cf3fSagc /* set home directory information */
739e63cf3fSagc int netpgp_set_homedir(netpgp_t *, char *, const char *, const int);
744b3a3e18Sagc 
7593bf6008Sagc /* key management */
765aae2c74Sagc int netpgp_list_keys(netpgp_t *, const int);
77922661ddSagc int netpgp_list_keys_json(netpgp_t *, char **, const int);
7893bf6008Sagc int netpgp_find_key(netpgp_t *, char *);
79b15ec256Sagc char *netpgp_get_key(netpgp_t *, const char *, const char *);
80b15ec256Sagc char *netpgp_export_key(netpgp_t *, char *);
8193bf6008Sagc int netpgp_import_key(netpgp_t *, char *);
8293bf6008Sagc int netpgp_generate_key(netpgp_t *, char *, int);
8393bf6008Sagc 
8493bf6008Sagc /* file management */
85c64158a1Sagc int netpgp_encrypt_file(netpgp_t *, const char *, const char *, char *, int);
86c64158a1Sagc int netpgp_decrypt_file(netpgp_t *, const char *, char *, int);
87c64158a1Sagc int netpgp_sign_file(netpgp_t *, const char *, const char *, char *, int, int, int);
88c64158a1Sagc int netpgp_verify_file(netpgp_t *, const char *, const char *, int);
8993bf6008Sagc 
90d369874eSagc /* memory signing and encryption */
91ad7bc21dSagc int netpgp_sign_memory(netpgp_t *, const char *, char *, size_t, char *, size_t, const unsigned, const unsigned);
92d369874eSagc int netpgp_verify_memory(netpgp_t *, const void *, const size_t, void *, size_t, const int);
93d369874eSagc int netpgp_encrypt_memory(netpgp_t *, const char *, void *, const size_t, char *, size_t, int);
94d369874eSagc int netpgp_decrypt_memory(netpgp_t *, const void *, const size_t, char *, size_t, const int);
95ad7bc21dSagc 
96600b302bSagc /* match and hkp-related functions */
97922661ddSagc int netpgp_match_keys_json(netpgp_t *, char **, char *, const char *, const int);
985aae2c74Sagc int netpgp_match_keys(netpgp_t *, char *, const char *, void *, const int);
99600b302bSagc int netpgp_match_pubkeys(netpgp_t *, char *, void *);
1000bbf5d48Sagc int netpgp_format_json(void *, const char *, const int);
101600b302bSagc 
102600b302bSagc int netpgp_validate_sigs(netpgp_t *);
103600b302bSagc 
104ba555534Sagc /* save pgp key in ssh format */
105ba555534Sagc int netpgp_write_sshkey(netpgp_t *, char *, const char *, char *, size_t);
106ba555534Sagc 
107ba555534Sagc 
1087e613096Sagc __END_DECLS
1097e613096Sagc 
11093bf6008Sagc #endif /* !NETPGP_H_ */
111