Main Page | Data Structures | Directories | File List | Data Fields | Globals

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$
00016  */
00017 #ifndef __PKCS11_LIB_H__
00018 #define __PKCS11_LIB_H__
00019 
00020 #include <openssl/x509.h>
00021 #include "rsaref/pkcs11.h"
00022 
00023 typedef struct {
00024   CK_KEY_TYPE type;
00025   CK_BYTE *id;
00026   CK_ULONG id_length;
00027   CK_OBJECT_HANDLE private_key;
00028   X509 *x509;
00029 } key_object_t;
00030 
00031 typedef struct {
00032   CK_KEY_TYPE type;
00033   CK_BYTE *id;
00034   CK_ULONG id_length;
00035   X509 *x509;
00036 } cert_object_t;
00037 
00038 typedef struct {
00039   CK_SLOT_ID id;
00040   CK_BBOOL token_present;
00041   CK_UTF8CHAR label[33];
00042 } slot_t;
00043 
00044 typedef struct {
00045   void *module_handle;
00046   CK_FUNCTION_LIST_PTR fl;
00047   slot_t *slots;
00048   CK_ULONG slot_count;
00049   CK_SESSION_HANDLE session;
00050   cert_object_t *certs;
00051   int cert_count;
00052   cert_object_t *choosen_cert;
00053   key_object_t *choosen_key;
00054 } pkcs11_handle_t;
00055 
00056 #ifndef __PKCS11_LIB_C__
00057 #define PKCS11_EXTERN extern
00058 #else 
00059 #define PKCS11_EXTERN
00060 #endif
00061 
00062 PKCS11_EXTERN int load_pkcs11_module(char *module, pkcs11_handle_t *h);
00063 PKCS11_EXTERN int init_pkcs11_module(pkcs11_handle_t *h,int flag);
00064 PKCS11_EXTERN void release_pkcs11_module(pkcs11_handle_t *h);
00065 PKCS11_EXTERN int open_pkcs11_session(pkcs11_handle_t *h, unsigned int slot);
00066 PKCS11_EXTERN int close_pkcs11_session(pkcs11_handle_t *h);
00067 PKCS11_EXTERN int pkcs11_login(pkcs11_handle_t *h, char *password);
00068 PKCS11_EXTERN int pkcs11_pass_login(pkcs11_handle_t *h, int nullok);
00069 PKCS11_EXTERN int get_certificates(pkcs11_handle_t *h);
00070 PKCS11_EXTERN int get_private_key(pkcs11_handle_t *h);
00071 PKCS11_EXTERN int sign_value(pkcs11_handle_t *h, CK_BYTE *data, CK_ULONG length,
00072                CK_BYTE **signature, CK_ULONG *signature_length);
00073 PKCS11_EXTERN int get_random_value(unsigned char *data, int length);
00074 
00075 #undef PKCS11_EXTERN
00076 
00077 /* end of pkcs11_lib.h */
00078 #endif

Generated on Thu Mar 16 22:52:55 2006 for pam_pkcs11 by  doxygen 1.4.2