Mailing List Archive

gnupg on OpenBSD
hello!

i'm trying to use gnupg on OpenBSD. here are some
problems with gnupg-0.4.1:

- /dev/random does not work on OpenBSD, i use /dev/srandom instead
(random(4) says: /dev/random reserved for nuclear noise generators.)
- dynamic loading with dlopen works on OpenBSD, but:
* dlopen() is not defined in libdl, but in crt0.o and friends
* OpenBSD binaries are a.out, so every symbol begins with "_"

the rsa extension module works with:
gcc -shared -rdynamic -fpic rsa.c -Wl,-Bshareable -Wl,-x -o rsa
i'm not sure if this is the only way.

-markus


the following patches are quick hacks,
they test against the OS instead of features.

--- cipher/rand-unix.c-dist Tue Oct 6 19:35:49 1998
+++ cipher/rand-unix.c Tue Oct 6 19:37:41 1998
@@ -126,7 +126,11 @@

if( level >= 2 ) {
if( fd_random == -1 )
+ #if defined(__OpenBSD__)
+ fd_random = open_device( "/dev/srandom", 8 );
+ #else
fd_random = open_device( "/dev/random", 8 );
+ #endif
fd = fd_random;
}
else {
--- cipher/dynload.c.dist Tue Oct 13 10:37:25 1998
+++ cipher/dynload.c Tue Oct 13 10:47:56 1998
@@ -125,7 +125,11 @@
log_error("%s: error loading extension: %s\n", el->name, dlerror() );
goto failure;
}
+#ifdef __OpenBSD__
+ name = (char**)dlsym(el->handle, "_gnupgext_version");
+#else
name = (char**)dlsym(el->handle, "gnupgext_version");
+#endif
if( (err=dlerror()) ) {
log_error("%s: not a gnupg extension: %s\n", el->name, err );
goto failure;
@@ -137,7 +141,11 @@
el->hintstr? el->hintstr:"",
el->hintstr? ")":"");

+#ifdef __OpenBSD__
+ sym = dlsym(el->handle, "_gnupgext_enum_func");
+#else
sym = dlsym(el->handle, "gnupgext_enum_func");
+#endif
if( (err=dlerror()) ) {
log_error("%s: invalid gnupg extension: %s\n", el->name, err );
goto failure;
Re: gnupg on OpenBSD [ In reply to ]
Markus Friedl <Markus.Friedl@informatik.uni-erlangen.de> writes:

> - /dev/random does not work on OpenBSD, i use /dev/srandom instead
> (random(4) says: /dev/random reserved for nuclear noise generators.)

[.Wim, I remember we talked about this - what was your solution?]

> - dynamic loading with dlopen works on OpenBSD, but:
> * dlopen() is not defined in libdl, but in crt0.o and friends
> * OpenBSD binaries are a.out, so every symbol begins with "_"

AFAIK, dlopen() does only work with ELF. The correct solution is to
use th dld. Need this for FreeBSD anyway.


Werner
Re: gnupg on OpenBSD [ In reply to ]
> > - dynamic loading with dlopen works on OpenBSD, but:
> > * dlopen() is not defined in libdl, but in crt0.o and friends
> > * OpenBSD binaries are a.out, so every symbol begins with "_"
>
> AFAIK, dlopen() does only work with ELF. The correct solution is to
> use th dld. Need this for FreeBSD anyway.

hm, dlopen() did exist in SunOS4 and SunOS4 has no ELF binaries.
(perhaps you're talking about linux?). nevertheless, there is no
libdl or libdld on OpenBSD and OpenBSD uses a.out _and_ dlopen()
workes on OpenBSD, at least i was able to verify pgp-rsa signatures
using the rsa-module.

-markus