Debian Codegraph @

src/util/support.h

raw symbols SCIP
1 /* support.h - PAM authentication via OpenPGP smartcards.
2 Copyright (C) 2004, 2005, 2007, 2008 g10 Code GmbH
3
4 This file is part of Poldi.
5
6 Poldi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Poldi is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21 #ifndef POLDI_SUPPORT_H
22 #define POLDI_SUPPORT_H
23
24 #include <gcrypt.h>
25 #include <dirent.h>
26
27 /* This function generates a challenge; the challenge will be stored
28 in newly allocated memory, which is to be stored in *CHALLENGE;
29 it's length in bytes is to be stored in *CHALLENGE_N. Returns
30 proper error code. */
31 gpg_error_t challenge_generate (unsigned char **challenge, size_t *challenge_n);
32
33 /* Releases the challenge contained in CHALLENGE generated by
34 challenge_generate(). */
35 void challenge_release (unsigned char *challenge);
36
37 /* This functions verifies that the signature contained in RESPONSE of
38 size RESPONSE_N (in bytes) is indeed the result of signing the
39 challenge given in CHALLENGE of size CHALLENGE_N (in bytes) with
40 the secret key belonging to the public key given as PUBLIC_KEY.
41 Returns proper error code. */
42 gpg_error_t challenge_verify (gcry_sexp_t public_key,
43 unsigned char *challenge, size_t challenge_n,
44 unsigned char *response, size_t response_n);
45
46 /* This function converts the given S-Expression SEXP into it's
47 `ADVANCED' string representation, using newly-allocated memory,
48 storing the resulting NUL-terminated string in *SEXP_STRING.
49 Returns a proper error code. */
50 gpg_error_t sexp_to_string (gcry_sexp_t sexp, char **sexp_string);
51
52 /* This function retrieves the content from the file specified by
53 FILENAMED and writes it into a newly allocated chunk of memory,
54 which is then stored in *STRING. Returns proper error code. */
55 gpg_error_t file_to_string (const char *filename, char **string);
56
57 /* This function retrieves the content from the file specified by
58 FILENAMED and writes it into a newly allocated chunk of memory,
59 which is then stored in *DATA and *DATALEN. Returns proper error
60 code. */
61 gpg_error_t file_to_binstring (const char *filename, void **data, size_t *datalen);
62
63 /* This functions converts the given string-representation of an
64 S-Expression into a new S-Expression object, which is to be stored
65 in *SEXP. Returns proper error code. */
66 gpg_error_t string_to_sexp (gcry_sexp_t *sexp, char *string);
67
68 gpg_error_t char_vector_dup (int len, const char **a, char ***b);
69
70 void char_vector_free (char **a);
71
72 int my_strlen (const char *s);
73
74 int pk_algo (gcry_sexp_t sexp_key);
75
76 gpg_error_t challenge_data (gcry_sexp_t *data, int algo,
77 unsigned char *challenge, size_t challenge_n);
78
79 gpg_error_t response_signature (gcry_sexp_t *sig, int algo,
80 unsigned char *response, size_t response_n);
81 #endif
82
83 /* END */