1
/* idea-stub.c - Dummy module for the deprecated IDEA cipher.
2
* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
4
* This file is part of GnuPG.
6
* GnuPG is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* GnuPG is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
/* IDEA is a patented algorithm and therefore the use of IDEA in
22
countries where this patent is valid can not be allowed due to the
23
terms of the GNU General Public License. Those restrictions are
24
there to help protecting the freedom of software. For more
25
information on the nonsense of software patents and the general
26
problem with this, please see http://www.noepatents.org.
28
However for research purposes and in certain situations it might be
29
useful to use this algorithm anyway.
31
We provide this stub which will dynload a idea module and is only
32
used if the configure run did't found statically linked file.
33
See http://www.gnupg.org/why-not-dea.html for details.
48
#include "algorithms.h"
55
#define HAVE_DL_DLOPEN
56
#define USE_DYNAMIC_LINKING
58
static int last_error = 0;
61
dlopen (const char *pathname, int mode)
63
void *h = LoadLibrary (pathname);
66
log_error ("LoadLibrary failed: %s\n", w32_strerror (errno));
74
dlclose ( void *handle )
77
return FreeLibrary (handle);
85
return w32_strerror (0);
90
dlsym (void *handle, const char *name)
92
void *h = GetProcAddress (handle, name);
95
log_error ("GetProcAddress failed: %s\n", w32_strerror (errno));
102
/* We do only support dlopen and the Windows emulation of it. */
103
#ifndef HAVE_DL_DLOPEN
104
#undef USE_DYNAMIC_LINKING
108
const char *(*INFO_FNC)(int, size_t*, size_t*, size_t*,
109
int (**)( void *, const byte *, unsigned),
110
void (**)( void *, byte *, const byte *),
111
void (**)( void *, byte *, const byte *));
114
load_module (const char *name)
116
#ifdef USE_DYNAMIC_LINKING
122
/* Make sure we are not setuid. */
123
if (getuid() != geteuid())
124
log_bug("trying to load an extension while still setuid\n");
127
handle = dlopen (name, RTLD_NOW);
134
sym = dlsym (handle, "idea_get_info");
136
sym = dlsym (handle, "_idea_get_info");
143
log_info ("invalid module `%s': %s\n", name?name:"???", err?err:"???");
146
#endif /*USE_DYNAMIC_LINKING*/
151
idea_get_info( int algo, size_t *keylen,
152
size_t *blocksize, size_t *contextsize,
153
int (**r_setkey)( void *c, const byte *key, unsigned keylen ),
154
void (**r_encrypt)( void *c, byte *outbuf, const byte *inbuf ),
155
void (**r_decrypt)( void *c, byte *outbuf, const byte *inbuf )
158
static int initialized;
159
static INFO_FNC info_fnc;
166
for (i=0; (rstr = dynload_enum_module_names (i)); i++)
168
info_fnc = load_module (rstr);
174
return NULL; /* dynloadable module not found. */
175
rstr = info_fnc (algo, keylen, blocksize, contextsize,
176
r_setkey, r_encrypt, r_decrypt);
177
if (rstr && *keylen == 128 && *blocksize == 8
178
&& *r_setkey && *r_encrypt && r_decrypt)