| 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_Hcxx . . $ `src/util/support.h:22:9`! |
| 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_tcxx . . $ gpg_error_t# challenge_generatecxx . . $ challenge_generate(fee6e208587138e9). (unsigned char **challenge, size_t *challenge_n); |
| 32 | |
| 33 | /* Releases the challenge contained in CHALLENGE generated by |
| 34 | challenge_generate(). */ |
| 35 | void challenge_releasecxx . . $ challenge_release(f25546b61a629de7). (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_tcxx . . $ gpg_error_t# challenge_verifycxx . . $ challenge_verify(ffed3e639787afb3). (gcry_sexp_tcxx . . $ 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_tcxx . . $ gpg_error_t# sexp_to_stringcxx . . $ sexp_to_string(dfc1b8d2b6a0e0f). (gcry_sexp_tcxx . . $ 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_tcxx . . $ gpg_error_t# file_to_stringcxx . . $ file_to_string(a9c69b9d9ab9e4b8). (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_tcxx . . $ gpg_error_t# file_to_binstringcxx . . $ file_to_binstring(e0db3a0091505537). (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_tcxx . . $ gpg_error_t# string_to_sexpcxx . . $ string_to_sexp(4a5ea71d31321a6c). (gcry_sexp_tcxx . . $ gcry_sexp_t# *sexp, char *string); |
| 67 | |
| 68 | gpg_error_tcxx . . $ gpg_error_t# char_vector_dupcxx . . $ char_vector_dup(9354c60f7c8ad8bb). (int len, const char **a, char ***b); |
| 69 | |
| 70 | void char_vector_freecxx . . $ char_vector_free(3ed91490e421178f). (char **a); |
| 71 | |
| 72 | int my_strlencxx . . $ my_strlen(5c4306d8553b3696). (const char *s); |
| 73 | |
| 74 | int pk_algocxx . . $ pk_algo(809ac41603e1f3b8). (gcry_sexp_tcxx . . $ gcry_sexp_t# sexp_key); |
| 75 | |
| 76 | gpg_error_tcxx . . $ gpg_error_t# challenge_datacxx . . $ challenge_data(9f0327bd59ab19da). (gcry_sexp_tcxx . . $ gcry_sexp_t# *data, int algo, |
| 77 | unsigned char *challenge, size_t challenge_n); |
| 78 | |
| 79 | gpg_error_tcxx . . $ gpg_error_t# response_signaturecxx . . $ response_signature(9f0327bd59ab19da). (gcry_sexp_tcxx . . $ gcry_sexp_t# *sig, int algo, |
| 80 | unsigned char *response, size_t response_n); |
| 81 | #endif |
| 82 | |
| 83 | /* END */ |