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