2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
4 Ben Kibbey <bjk@luxsci.net>
6 This file is part of pwmd.
8 Pwmd is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 Pwmd is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
25 #include <gpg-error.h>
26 #include <sys/types.h>
33 #elif defined (HAVE_INTTYPES_H)
39 #define DEFAULT_EXPIRE (unsigned long)(60*60*24*365*3) // 3 years
41 #define CRYPTO_FLAG_NEWFILE 0x0001
42 #define CRYPTO_FLAG_KEYFILE 0x0002 // --passphrase-file with --import
43 #define CRYPTO_FLAG_SYMMETRIC 0x0004
44 #define CRYPTO_FLAG_PASSWD 0x0008
45 #define CRYPTO_FLAG_PASSWD_NEW 0x0010
46 #define CRYPTO_FLAG_PASSWD_SIGN 0x0020
50 char **pubkey
; /* SAVE --keyid */
51 char *sigkey
; /* SAVE --sign-keyid */
52 char *userid
; /* SAVE genkey parameters */
53 gpgme_key_t
*mainkey
; /* GENKEY --subkey-of */
61 assuan_context_t client_ctx
;
63 unsigned char *plaintext
;
64 size_t plaintext_size
;
68 char *filename
; /* the currently opened data file */
70 gpg_error_t progress_rc
;
71 time_t status_timeout
;
76 gpgme_error_t
crypto_init (struct crypto_s
**, void *, const char *, int,
77 char *passphrase_file
);
78 gpgme_error_t
crypto_init_ctx (struct crypto_s
*, int, char *passphrase_file
);
79 gpgme_error_t
crypto_genkey (struct client_s
*, struct crypto_s
*);
80 gpgme_error_t
crypto_encrypt (struct client_s
*, struct crypto_s
*);
81 gpgme_error_t
crypto_decrypt (struct client_s
*, struct crypto_s
*);
82 gpgme_error_t
crypto_passwd (struct client_s
*, struct crypto_s
*);
83 void crypto_free (struct crypto_s
*);
84 void crypto_free_save (struct save_s
*);
85 void crypto_free_non_keys (struct crypto_s
*);
86 gpgme_error_t
crypto_data_to_buf (const gpgme_data_t
, unsigned char **,
88 gpg_error_t
crypto_write_file (struct crypto_s
*, unsigned char **crc
,
90 gpgme_error_t
crypto_list_keys (struct crypto_s
*, char **, int secret
,
92 char *crypto_key_info (const gpgme_key_t
);
93 void crypto_free_key_list (gpgme_key_t
*);
94 gpg_error_t
crypto_try_decrypt (struct client_s
*, int);
95 void crypto_set_keepalive ();
96 gpg_error_t
crypto_is_symmetric (const char *filename
);
97 gpg_error_t
crypto_keyid_to_16b (char **keys
);
98 gpg_error_t
crypto_keyid_to_16b_once (char *key
);
99 gpg_error_t
crypto_delete_key (struct client_s
*client
, struct crypto_s
*,
100 const gpgme_key_t
, int secret
);