1#ifndef TRF_LOADMANAGER_H 2#define TRF_LOADMANAGER_H 3 4/* -*- c -*- 5 * loadman.h - 6 * 7 * internal definitions for loading of shared libraries required by Trf. 8 * 9 * Copyright (c) 1996-1999 Andreas Kupries (a.kupries@westend.com) 10 * All rights reserved. 11 * 12 * Permission is hereby granted, without written agreement and without 13 * license or royalty fees, to use, copy, modify, and distribute this 14 * software and its documentation for any purpose, provided that the 15 * above copyright notice and the following two paragraphs appear in 16 * all copies of this software. 17 * 18 * IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 19 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS 20 * SOFTWARE AND ITS DOCUMENTATION, EVEN IF I HAVE BEEN ADVISED OF THE 21 * POSSIBILITY OF SUCH DAMAGE. 22 * 23 * I SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND 26 * I HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 27 * ENHANCEMENTS, OR MODIFICATIONS. 28 * 29 * CVS: $Id: loadman.h,v 1.11 2008/12/11 19:04:25 andreas_kupries Exp $ 30 */ 31 32/* 33 * The procedures defined here manage the loading of libraries required 34 * by various glue-code for crytographic algorithms. Dependent on the 35 * functionality requested more than one library will be tried before 36 * giving up entirely. 37 * 38 * All following sections define a structure for each algorithm to fill 39 * with the addresses of the functions required here, plus a procedure 40 * to do the filling. 41 */ 42 43#ifdef __cplusplus 44extern "C" { 45#endif 46 47#include "transformInt.h" 48 49#ifdef HAVE_MD2_H 50# ifdef OPENSSL_SUB 51# include <openssl/md2.h> 52# else 53# include <md2.h> 54# endif 55#else 56# include "../compat/md2.h" 57#endif 58 59#ifdef HAVE_SHA_H 60# ifdef OPENSSL_SUB 61# include <openssl/sha.h> 62# else 63# include <sha.h> 64# endif 65#else 66# include "../compat/sha.h" 67#endif 68 69#if defined(HAVE_MD5_H) && !defined(MD5_STATIC_BUILD) 70# ifdef OPENSSL_SUB 71# include <openssl/md5.h> 72# else 73# include <md5.h> 74# endif 75# ifdef HAVE_UNISTD_H 76# include <unistd.h> 77# endif 78#else 79# include "../md5-crypt/md5.h" 80# include "../md5-crypt/trf_crypt.h" 81# define MD5_CTX struct md5_ctx 82#endif 83 84 85#ifdef TCL_STORAGE_CLASS 86# undef TCL_STORAGE_CLASS 87#endif 88#ifdef BUILD_Trf 89# define TCL_STORAGE_CLASS DLLEXPORT 90#else 91# define TCL_STORAGE_CLASS DLLIMPORT 92#endif 93 94/* Structures, variables and functions to load and access the functionality 95 * required for MD2 and SHA1. Affected command in case of failure: md2, sha1. 96 */ 97 98/* Structures containing the vectors to jump through to the implementation 99 * of the functionality. 100 */ 101 102typedef struct Md2Functions { 103 long loaded; 104 void (* init) _ANSI_ARGS_ ((MD2_CTX* c)); 105 void (* update) _ANSI_ARGS_ ((MD2_CTX* c, unsigned char* data, 106 unsigned long length)); 107 void (* final) _ANSI_ARGS_ ((unsigned char* digest, MD2_CTX* c)); 108} md2Functions; 109 110typedef struct Md5Functions { 111 long loaded; 112 void (* init) __P ((MD5_CTX* c)); 113 void (* update) __P ((MD5_CTX* c, unsigned char* data, 114 unsigned long length)); 115 void* (* final) __P ((unsigned char* digest, MD5_CTX* c)); 116 117 const char* (* crypt) _ANSI_ARGS_ ((const char* key, const char* salt)); 118 119} md5Functions; 120 121typedef struct Sha1Functions { 122 long loaded; 123 void (* init) _ANSI_ARGS_ ((SHA_CTX* c)); 124 void (* update) _ANSI_ARGS_ ((SHA_CTX* c, unsigned char* data, 125 unsigned long length)); 126 void (* final) _ANSI_ARGS_ ((unsigned char* digest, SHA_CTX* c)); 127} sha1Functions; 128 129 130 131 132/* Global variables containing the vectors declared above. 99% of the time they 133 * are read, but during load a write is required, which has to be protected by 134 * a mutex in case of a thread-enabled Tcl. 135 */ 136 137EXTERN md2Functions md2f; /* THREADING: serialize initialization */ 138EXTERN md5Functions md5f; /* THREADING: serialize initialization */ 139EXTERN sha1Functions sha1f; /* THREADING: serialize initialization */ 140 141 142EXTERN int 143TrfLoadMD2 _ANSI_ARGS_ ((Tcl_Interp *interp)); 144 145EXTERN int 146TrfLoadMD5 _ANSI_ARGS_ ((Tcl_Interp *interp)); 147 148EXTERN int 149TrfLoadSHA1 _ANSI_ARGS_ ((Tcl_Interp *interp)); 150 151 152#undef TCL_STORAGE_CLASS 153#define TCL_STORAGE_CLASS DLLIMPORT 154 155#ifdef __cplusplus 156} 157#endif /* C++ */ 158#endif /* TRF_LOADMANAGER_H */ 159