| 1 | /* scd.h - Interface to Scdaemon |
| 2 | Copyright (C) 2007, 2008, 2009 g10code 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 3 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 General Public License |
| 17 | along with this program; if not, see |
| 18 | <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef POLDI_SCD_H |
| 21 | #define POLDI_SCD_Hcxx . . $ `src/scd/scd.h:21:9`! |
| 22 | |
| 23 | #include <poldi.h>cxx . . $ `<file>/src/poldi.h`/ |
| 24 | |
| 25 | #include "util/simplelog.h"cxx . . $ `<file>/src/util/simplelog.h`/ |
| 26 | |
| 27 | struct scd_contextcxx . . $ scd_context#; |
| 28 | |
| 29 | typedef struct scd_contextcxx . . $ scd_context# *scd_context_tcxx . . $ scd_context_t#; |
| 30 | |
| 31 | struct scd_cardinfocxx . . $ scd_cardinfo# |
| 32 | { |
| 33 | char *serialnocxx . . $ scd_cardinfo#serialno.; /* malloced hex string. */ |
| 34 | char *disp_namecxx . . $ scd_cardinfo#disp_name.; /* malloced. */ |
| 35 | char *pubkey_urlcxx . . $ scd_cardinfo#pubkey_url.; /* malloced. */ |
| 36 | char *login_datacxx . . $ scd_cardinfo#login_data.; /* malloced. */ |
| 37 | char *disp_langcxx . . $ scd_cardinfo#disp_lang.; /* malloced. */ |
| 38 | char fpr1validcxx . . $ scd_cardinfo#fpr1valid.; |
| 39 | char fpr2validcxx . . $ scd_cardinfo#fpr2valid.; |
| 40 | char fpr3validcxx . . $ scd_cardinfo#fpr3valid.; |
| 41 | char fpr1cxx . . $ scd_cardinfo#fpr1.[20]; |
| 42 | char fpr2cxx . . $ scd_cardinfo#fpr2.[20]; |
| 43 | char fpr3cxx . . $ scd_cardinfo#fpr3.[20]; |
| 44 | }; |
| 45 | |
| 46 | typedef struct scd_cardinfocxx . . $ scd_cardinfo# scd_cardinfo_tcxx . . $ scd_cardinfo_t#; |
| 47 | |
| 48 | #define SCD_FLAG_VERBOSEcxx . . $ `src/scd/scd.h:48:9`! (1 << 0) |
| 49 | |
| 50 | /* Fork it off and work by pipes. Returns proper error code or zero |
| 51 | on success. */ |
| 52 | gpg_error_tcxx . . $ gpg_error_t# scd_connectcxx . . $ scd_connect(b5c77484bce79416). (scd_context_tcxx . . $ scd_context_t# *scd_ctx, int use_agent, |
| 53 | const char *scd_path, const char *scd_options, |
| 54 | log_handle_tcxx . . $ log_handle_t# loghandle); |
| 55 | |
| 56 | /* Disconnect from SCDaemon; destroy the context SCD_CTX. */ |
| 57 | void scd_disconnectcxx . . $ scd_disconnect(96f585546e882556). (scd_context_tcxx . . $ scd_context_t# scd_ctx); |
| 58 | |
| 59 | typedef int (*scd_pincb_tcxx . . $ scd_pincb_t#) (void *data, const char *, char *, size_t); |
| 60 | |
| 61 | void scd_set_pincbcxx . . $ scd_set_pincb(bb86724bcfc9ee60). (scd_context_tcxx . . $ scd_context_t# scd_ctx, |
| 62 | scd_pincb_tcxx . . $ scd_pincb_t# pincb, void *cookie); |
| 63 | |
| 64 | /* Return the serial number of the card or an appropriate error. The |
| 65 | serial number is returned as a hexstring. */ |
| 66 | gpg_error_tcxx . . $ gpg_error_t# scd_serialnocxx . . $ scd_serialno(8fbe1a4b844610be). (scd_context_tcxx . . $ scd_context_t# ctx, char **r_serialno); |
| 67 | |
| 68 | /* Read information from card and fill the cardinfo structure |
| 69 | CARDINFO. Returns proper error code, zero on success. */ |
| 70 | int scd_learncxx . . $ scd_learn(f694227e099c0ef7). (scd_context_tcxx . . $ scd_context_t# ctx, |
| 71 | struct scd_cardinfocxx . . $ scd_cardinfo# *cardinfo); |
| 72 | |
| 73 | /* Simply release the cardinfo structure INFO. INFO being NULL is |
| 74 | okay. */ |
| 75 | void scd_release_cardinfocxx . . $ scd_release_cardinfo(4bb01e237e9372f6). (struct scd_cardinfocxx . . $ scd_cardinfo# cardinfo); |
| 76 | |
| 77 | /* Create a signature using the current card. CTX is the handle for |
| 78 | the scd subsystem. KEYID identifies the key on the card to use for |
| 79 | signing. INDATA/INDATALEN is the input for the signature function. |
| 80 | The signature created is written into newly allocated memory in |
| 81 | *R_BUF, *R_BUFLEN will hold the length of the signature. */ |
| 82 | gpg_error_tcxx . . $ gpg_error_t# scd_pksigncxx . . $ scd_pksign(def977db0e0fd549). (scd_context_tcxx . . $ scd_context_t# ctx, |
| 83 | const char *keyid, |
| 84 | const unsigned char *indata, size_t indatalen, |
| 85 | unsigned char **r_buf, size_t *r_buflen); |
| 86 | |
| 87 | /* Read a key with ID and return it in an allocate buffer pointed to |
| 88 | by r_BUF as a valid S-expression. */ |
| 89 | int scd_readkeycxx . . $ scd_readkey(bbef350ea803bf16). (scd_context_tcxx . . $ scd_context_t# ctx, |
| 90 | const char *id, gcry_sexp_tcxx . . $ gcry_sexp_t# *key); |
| 91 | |
| 92 | /* Sends a GETINFO command for WHAT to the scdaemon through CTX. The |
| 93 | newly allocated result is stored in *RESULT. Returns proper error |
| 94 | code, zero on success. */ |
| 95 | int scd_getinfocxx . . $ scd_getinfo(b8459bee76b2d33b). (scd_context_tcxx . . $ scd_context_t# ctx, const char *what, char **result); |
| 96 | |
| 97 | /* Initializer objet for struct scd_cardinfo instances. */ |
| 98 | extern struct scd_cardinfocxx . . $ scd_cardinfo# scd_cardinfo_nullcxx . . $ scd_cardinfo_null.; |
| 99 | |
| 100 | #endif |