pam_pkcs11  0.6.8
pkcs11_lib.h
Go to the documentation of this file.
00001 /*
00002  * PKCS #11 PAM Login Module
00003  * Copyright (C) 2003 Mario Strasser <mast@gmx.net>,
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * $Id: pkcs11_lib.h 435 2010-06-07 14:53:17Z ludovic.rousseau $
00016  */
00017 #ifndef __PKCS11_LIB_H__
00018 #define __PKCS11_LIB_H__
00019 
00020 #include "cert_st.h"
00021 
00022 typedef struct cert_object_str cert_object_t;
00023 typedef struct pkcs11_handle_str pkcs11_handle_t;
00024 
00025 #ifndef __PKCS11_LIB_C__
00026 #define PKCS11_EXTERN extern
00027 #else
00028 #define PKCS11_EXTERN
00029 #endif
00030 
00031 PKCS11_EXTERN int crypto_init(cert_policy *policy);
00032 PKCS11_EXTERN int load_pkcs11_module(const char *module, pkcs11_handle_t **h);
00033 PKCS11_EXTERN int init_pkcs11_module(pkcs11_handle_t *h,int flag);
00034 PKCS11_EXTERN int find_slot_by_number(pkcs11_handle_t *h,unsigned int slot_num,
00035                                       unsigned int *slot);
00036 PKCS11_EXTERN int find_slot_by_number_and_label(pkcs11_handle_t *h,
00037                                       int slot_num, const char *slot_label,
00038                                       unsigned int *slot);
00039 PKCS11_EXTERN const char *get_slot_tokenlabel(pkcs11_handle_t *h);
00040 PKCS11_EXTERN int wait_for_token(pkcs11_handle_t *h,
00041                                  int wanted_slot_num,
00042                                  const char *wanted_token_label,
00043                                  unsigned int *slot);
00044 PKCS11_EXTERN int find_slot_by_slotlabel(pkcs11_handle_t *h,
00045                                  const char *wanted_slot_label,
00046                                  unsigned int *slot);
00047 PKCS11_EXTERN int find_slot_by_slotlabel_and_tokenlabel(pkcs11_handle_t *h,
00048                                  const char *wanted_slot_label,
00049                                  const char *wanted_token_label,
00050                                  unsigned int *slot);
00051 PKCS11_EXTERN int wait_for_token_by_slotlabel(pkcs11_handle_t *h,
00052                                  const char *wanted_slot_label,
00053                                  const char *wanted_token_label,
00054                                  unsigned int *slot);
00055 PKCS11_EXTERN const X509 *get_X509_certificate(cert_object_t *cert);
00056 PKCS11_EXTERN void release_pkcs11_module(pkcs11_handle_t *h);
00057 PKCS11_EXTERN int open_pkcs11_session(pkcs11_handle_t *h, unsigned int slot);
00058 PKCS11_EXTERN int close_pkcs11_session(pkcs11_handle_t *h);
00059 PKCS11_EXTERN int pkcs11_login(pkcs11_handle_t *h, char *password);
00060 PKCS11_EXTERN int pkcs11_pass_login(pkcs11_handle_t *h, int nullok);
00061 PKCS11_EXTERN int get_slot_login_required(pkcs11_handle_t *h);
00062 PKCS11_EXTERN int get_slot_protected_authentication_path(pkcs11_handle_t *h);
00063 PKCS11_EXTERN cert_object_t **get_certificate_list(pkcs11_handle_t *h,
00064                                                   int *ncert);
00065 PKCS11_EXTERN int get_private_key(pkcs11_handle_t *h, cert_object_t *);
00066 PKCS11_EXTERN int sign_value(pkcs11_handle_t *h, cert_object_t *,
00067                unsigned char *data, unsigned long length,
00068                unsigned char **signature, unsigned long *signature_length);
00069 PKCS11_EXTERN int get_random_value(unsigned char *data, int length);
00070 
00071 #undef PKCS11_EXTERN
00072 
00073 /* end of pkcs11_lib.h */
00074 #endif