GETINFO: prefix filename with / if it owns the lock.
[libpwmd.git] / src / crypto.h
blob397d49f62ad94c320741f8c17c2e3a0c8d986f74
1 /*
2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
3 Ben Kibbey <bjk@luxsci.net>
5 This file is part of pwmd.
7 Pwmd is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
12 Pwmd is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef CRYPTO_H
21 #define CRYPTO_H
23 #include <assuan.h>
24 #include <gpg-error.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <gpgme.h>
28 #include <time.h>
30 #ifdef HAVE_STDINT_H
31 #include <stdint.h>
32 #elif defined (HAVE_INTTYPES_H)
33 #include <inttypes.h>
34 #endif
36 #include "common.h"
38 struct save_s
40 char **pubkey; /* SAVE --keyid */
41 char **sigkey; /* SAVE --sign-keyid */
44 struct crypto_s
46 assuan_context_t client_ctx;
47 gpgme_ctx_t ctx;
48 unsigned char *plaintext;
49 size_t plaintext_size;
50 gpgme_data_t cipher;
51 char **pubkey;
52 char **sigkey;
53 char *filename; /* the currently opened data file */
54 struct save_s save;
55 gpg_error_t progress_rc;
56 time_t status_timeout;
59 gpgme_error_t crypto_init (struct crypto_s **, void *, const char *, int);
60 gpgme_error_t crypto_init_ctx (struct crypto_s *, int);
61 gpgme_error_t crypto_genkey (struct client_s *, struct crypto_s *,
62 const unsigned char *);
63 gpgme_error_t crypto_encrypt (struct client_s *, struct crypto_s *);
64 gpgme_error_t crypto_decrypt (struct client_s *, struct crypto_s *);
65 gpgme_error_t crypto_passwd (struct client_s *, struct crypto_s *);
66 void crypto_cleanup (struct crypto_s *);
67 void crypto_cleanup_save (struct save_s *);
68 void crypto_cleanup_non_keys (struct crypto_s *);
69 gpgme_error_t crypto_data_to_buf (const gpgme_data_t, unsigned char **,
70 size_t *);
71 char *crypto_default_key_params ();
72 gpg_error_t crypto_write_file (struct crypto_s *);
73 gpgme_error_t crypto_list_keys (struct crypto_s *, char **, int secret,
74 gpgme_key_t **);
75 char *crypto_key_info (const gpgme_key_t);
76 void crypto_free_key_list (gpgme_key_t *);
77 gpg_error_t crypto_try_decrypt (struct client_s *, int);
79 #endif