/*
* The Initial Developer of the Original Code is International
* Business Machines Corporation. Portions created by IBM
* Corporation are Copyright(C) 2005 International Business
* Machines Corporation. All Rights Reserved.
*
* it under the terms of the Common Public License as published by
* IBM Corporation; either version 1 of the License, or(at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Common Public License for more details.
*
* You should have received a copy of the Common Public License
* along with this program; if not, a copy can be viewed at
*/
/* (C) COPYRIGHT International Business Machines Corp. 2001, 2002, 2005 */
/*
*/
#ifndef _TPMTOK_INT_H
#define _TPMTOK_INT_H
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <strings.h>
#include <md5.h>
#include <sha1.h>
#include <limits.h>
#include <syslog.h>
#include <errno.h>
#include <sys/byteorder.h>
#include <security/cryptoki.h>
#include <tss/platform.h>
#include <tss/tss_defines.h>
#include <tss/tss_typedef.h>
#include <tss/tss_structs.h>
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
// RSA block formatting types
//
enum {
STATE_INVALID = 0,
};
#ifndef PATH_MAX
#endif
#ifndef PACK_DATA
#define PACK_DATA
#endif
typedef enum {
typedef struct _DL_NODE
{
void *data;
} DL_NODE;
/*
* Filenames used to store migration data.
*/
//
// Both of the strings below have a length of 32 chars and must be
// padded with spaces, and non - null terminated.
//
#define PKW_CRYPTOKI_LIB_VERSION_MINOR 0
/*
* CKA_HIDDEN will be used to filter return results on
* a C_FindObjects call. Used for objects internal to the
* TPM token for management
*/
/* custom attributes for the TPM token */
/*
* CKA_ENC_AUTHDATA will be used to store the encrypted SHA-1
* hashes of auth data passed in for TPM keys. The authdata
* will be encrypted using either the public
* leaf key or the private leaf key
*/
/* custom return codes for the TPM token */
typedef struct {
} ST_SESSION_T;
typedef struct {
void *Previous;
void *Next;
typedef struct {
enum {
};
typedef struct _ENCR_DECR_CONTEXT
{
typedef struct _DIGEST_CONTEXT
{
union {
} context;
typedef struct _SIGN_VERIFY_CONTEXT
{
typedef struct _SESSION
{
} SESSION;
typedef struct _TEMPLATE
{
} TEMPLATE;
typedef struct _OBJECT
{
} OBJECT;
typedef struct _OBJECT_MAP
{
} OBJECT_MAP;
typedef struct _ATTRIBUTE_PARSE_LIST
{
void *ptr;
typedef struct _OP_STATE_DATA
{
typedef struct _TWEAK_VEC
{
int allow_key_mods;
} TWEAK_VEC;
typedef struct _TOKEN_DATA
{
} TOKEN_DATA;
typedef struct _RSA_DIGEST_CONTEXT {
typedef struct _MECH_LIST_ELEMENT
{
struct mech_list_item;
struct mech_list_item {
};
struct mech_list_item *
struct mech_list_item *head);
typedef struct _TOK_OBJ_ENTRY
{
typedef struct _LW_SHM_TYPE
{
} LW_SHM_TYPE;
typedef unsigned int CK_ULONG_32;
typedef struct CK_ATTRIBUTE_32 {
char *get_tpm_keystore_path();
struct messages {
char *msg;
};
struct token_specific_struct {
int (*t_slot2local)();
CK_BYTE *,
CK_BYTE *,
CK_ULONG *,
OBJECT *);
CK_BYTE *,
CK_BYTE *,
OBJECT *);
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_ULONG *);
};
/*
* Global Variables
*/
extern token_spec_t token_specific;
extern CK_BBOOL initialized;
extern char *card_function_names[];
extern char *total_function_names[];
extern MECH_LIST_ELEMENT mech_list[];
extern CK_ULONG mech_list_len;
extern pthread_mutex_t native_mutex;
extern void *xproclock;
extern DL_NODE *sess_obj_list;
extern DL_NODE *publ_token_obj_list;
extern DL_NODE *priv_token_obj_list;
extern DL_NODE *object_map;
extern LW_SHM_TYPE *global_shm;
extern TOKEN_DATA *nv_token_data;
extern CK_ULONG next_object_handle;
extern CK_ULONG next_session_handle;
extern CK_STATE global_login_state;
extern CK_BYTE ber_AlgIdRSAEncryption[];
extern CK_ULONG ber_AlgIdRSAEncryptionLen;
extern CK_BYTE ber_rsaEncryption[];
extern CK_ULONG ber_rsaEncryptionLen;
extern CK_ULONG ber_idDSALen;
extern CK_BYTE ber_md5WithRSAEncryption[];
extern CK_ULONG ber_md5WithRSAEncryptionLen;
extern CK_BYTE ber_sha1WithRSAEncryption[];
extern CK_ULONG ber_sha1WithRSAEncryptionLen;
extern CK_BYTE ber_AlgMd5[];
extern CK_ULONG ber_AlgMd5Len;
extern CK_BYTE ber_AlgSha1[];
extern CK_ULONG ber_AlgSha1Len;
extern CK_C_INITIALIZE_ARGS cinit_args;
/*
* Function Prototypes
*/
void *attach_shared_memory();
void detach_shared_memory(char *);
int API_Initialized();
void Terminate_All_Process_Sessions();
int API_Register();
void API_UnRegister();
void CreateXProcLock(void *);
int XProcLock(void *);
int XProcUnLock(void *);
void _init(void);
void loginit();
void logterm();
void logit(int, char *, ...);
void AddToSessionList(Session_Struct_t *);
void RemoveFromSessionList(Session_Struct_t *);
extern void init_slot_info(TOKEN_DATA *);
unsigned long, unsigned char *);
CK_RV load_public_token_objects(void);
SESSION *,
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG);
void dlist_purge(DL_NODE *);
CK_RV attach_shm(void);
CK_RV detach_shm(void);
// encryption manager routines
//
CK_MECHANISM *,
CK_MECHANISM *,
CK_MECHANISM *);
CK_MECHANISM *,
CK_ATTRIBUTE *, CK_ULONG,
CK_ATTRIBUTE *, CK_ULONG,
CK_OBJECT_HANDLE *);
CK_MECHANISM *,
CK_BYTE *,
CK_ULONG *);
CK_MECHANISM *,
CK_ATTRIBUTE *,
CK_BYTE *,
CK_OBJECT_HANDLE *);
CK_MECHANISM *,
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_ULONG);
CK_MECHANISM *,
CK_BYTE *,
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_BYTE *,
CK_ULONG *);
CK_BYTE *,
CK_ULONG);
CK_BYTE *,
CK_ULONG);
// session manager routines
//
CK_RV session_mgr_logout_all(void);
CK_OBJECT_HANDLE *);
OBJECT *, CK_OBJECT_HANDLE *);
CK_ATTRIBUTE *,
DL_NODE *,
CK_ATTRIBUTE *,
CK_ULONG);
CK_ULONG *);
CK_ATTRIBUTE *,
CK_ULONG);
OBJECT **);
OBJECT *,
OBJECT **);
CK_BYTE **,
CK_ULONG_32 *);
CK_ATTRIBUTE *,
CK_ULONG);
OBJECT **,
CK_ATTRIBUTE *,
CK_ULONG);
CK_ATTRIBUTE *, CK_ULONG);
CK_ULONG);
CK_ULONG);
CK_ULONG);
CK_ATTRIBUTE *, CK_ULONG);
// DATA OBJECT ROUTINES
//
// CERTIFICATE ROUTINES
//
// KEY ROUTINES
//
CK_ULONG);
// rsa routines
//
// Generic secret key routines
CK_ATTRIBUTE *);
CK_ATTRIBUTE **, CK_ATTRIBUTE **);
/* log to stdout */
(int)__LINE__, __VA_ARGS__);
/* Debug logging */
#ifdef DEBUG
/* Error logging */
"ERROR: " data)
/* Warn logging */
"WARNING: " data)
/* Info Logging */
"", __VA_ARGS__)
#else
#define LogDebug(...)
#define LogDebug1(...)
#define LogBlob(...)
#define LogError(...)
#define LogError1(...)
#define LogWarn(...)
#define LogWarn1(...)
#define LogInfo(...)
#define LogInfo1(...)
#define st_err_log(...)
#endif
/*
* CK_FUNCTION_LIST is a structure holding a Cryptoki spec
* version and pointers of appropriate types to all the
* Cryptoki functions
*/
/* CK_FUNCTION_LIST is new for v2.0 */
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
(CK_INFO_PTR pInfo);
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
(CK_SLOT_ID slotID);
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
typedef CK_RV
struct ST_FCN_LIST {
};
#endif /* _TPMTOK_INT_H */