Re: [PATCH 0/8] Implement Curve448 ECDH and Ed448

2019-12-08 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes:

> I don't understand the gnutls failure. I've logged in to gitlab and
> pressed the "Retry"-button. If it keeps failing, I'll need some help
> investigating.

The retry passed. Merged this deletion (ecdsa over curve25519) to master
now.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs


Re: patch: fix check for __builtin_bswap64

2019-12-08 Thread George Koehler
On Thu, 5 Dec 2019 03:20:19 -0500
Jeffrey Walton  wrote:

> On Thu, Dec 5, 2019 at 3:08 AM Niels Möller  wrote:
> > ...
> >
> > Does OpenBSBs runtime linker look in /usr/local/lib by default? The
> > configure script also supports --with-lib-path=/usr/local/lib, which
> > will add a -L flag and in addition attempt to guess the proper
> > -R/-Wl,-rpath flags.
> 
> The runtime linker is configured to use /usr/local/lib. However,
> compile and link requires explicit -I /usr/local/include and -L
> /usr/local/lib to find things.
> 
> (Based on my testing of DragonFly, FreeBSD, OpenBSD and NetBSD. I
> don't recall what Debian's kFreeBSD does).
> 
> Jeff

Each BSD has its own runtime linker.  I believe that OpenBSD ld.so(1)
looks in /usr/local/lib by default, but NetBSD ld.elf_so(1) doesn't
look there.

For OpenBSD, ldconfig(8) sets the runtime path.  It always looks in
/usr/lib, but /etc/rc tells ldconfig to also look in /usr/X11R6/lib
and /usr/local/lib.  I can get the path from ldconfig:

# OpenBSD
$ ldconfig -r | grep directories
search directories: /usr/lib:/usr/X11R6/lib:/usr/local/lib

NetBSD allows /etc/ld.so.conf to add directories to the runtime path,
but my NetBSD install has no ld.so.conf, so the default path has only
/usr/lib.  Some executables have RPATH to look in /usr/X11R7/lib or
/usr/pkg/lib.  (My install has no /usr/local.)

For example, OpenBSD's xterm(1) doesn't need RPATH, but NetBSD's
xterm(1) needs RPATH with /usr/X11R7/lib.

# OpenBSD
$ readelf -d /usr/X11R6/bin/xterm | grep -E 'NEED|PATH'
 0x0001 (NEEDED) Shared library: [libXaw.so.15.0]
 0x0001 (NEEDED) Shared library: [libXpm.so.9.0]
 0x0001 (NEEDED) Shared library: [libXt.so.11.0]
 ...
 0x0001 (NEEDED) Shared library: [libc.so.96.0]

# NetBSD
$ readelf -d /usr/X11R7/bin/xterm | grep -E 'NEED|PATH'
 0x0001 (NEEDED) Shared library: [libXft.so.3]
 0x0001 (NEEDED) Shared library: [libfontconfig.so.2]
 0x0001 (NEEDED) Shared library: [libfreetype.so.18]
 ...
 0x0001 (NEEDED) Shared library: [libc.so.12]
 0x000f (RPATH)  Library rpath: [/usr/X11R7/lib]

If I don't set RPATH, I can't use /usr/X11R7/lib in NetBSD:

# OpenBSD
$ gcc -o code code.c -L/usr/X11R6/lib -lX11
...
$ ./code
It works!

# NetBSD
$ gcc -o code code.c -L/usr/X11R7/lib -lX11
$ ./code
Shared object "libX11.so.7" not found
$ gcc -o code code.c -L/usr/X11R7/lib -lX11 -R/usr/X11R7/lib
$ ./code
It works!

The NEEDED values on OpenBSD have an extra number: [libc.so.96.0]
instead of just [libc.so.96].  This is because OpenBSD has its different
version rule.

Other systems require M == X in
  SONAME libwhat.so.Mfor  NEEDED libwhat.so.X
OpenBSD requires M == X && N >= Y in
  SONAME libwhat.so.M.N  for  NEEDED libwhat.so.X.Y
  https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs

Other systems have symbolic links:

# NetBSD
$ cd /usr/X11R7/lib
$ ls -l libX11.so*
lrwxr-xr-x  1 root  wheel   13 Jul 17  2018 libX11.so -> libX11.so.7.0
lrwxr-xr-x  1 root  wheel   13 Jul 17  2018 libX11.so.7 -> libX11.so.7.0
-r--r--r--  1 root  wheel  1273908 Jul 17  2018 libX11.so.7.0

OpenBSD doesn't have these links.  The compile-time ld(1) and run-time
ld.so(1) look for libraries named [libwhat.so.X.Y].

Nettle doesn't know OpenBSD's version rule.  My git checkout of Nettle,
configured for OpenBSD, wants to install [libnettle.so.7.0] with
symlinks from [libnettle.so] and [libnettle.so.7], where the SONAME is
[libnettle.so.7].  To obey the version rule, it should install
[libnettle.so.7.0] without symlinks, and the SONAME should also be
[libnettle.so.7.0].  I didn't fix my git checkout to obey the version
rule, because I didn't need to.

I know one other quirk: some build tools (but not Nettle's) use
$ORIGIN in the runtime path.  DragonFly and OpenBSD need a compiler
flag "cc -Wl,-z,origin" to enable $ORIGIN, but other systems don't
need this flag.
  https://github.com/mesonbuild/meson/pull/3530/files

This mail is too long; I stop now.  --George
___
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs


Re: [PATCH 0/8] Implement Curve448 ECDH and Ed448

2019-12-08 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes:

> ni...@lysator.liu.se (Niels Möller) writes:
>
>> ni...@lysator.liu.se (Niels Möller) writes:
>>
>>> I'm considering the below patch. I think there's room for further
>>> improvement, maybe splitting the h_to_a method up (it's called with op
>>> == 0, and with op == 2 from the ecdsa, but never with op == 1). Maybe
>>> adding a some ecc_mod_canonical function. But deleting this unneeded
>>> code right away seems like an improvement in itself.
>>
>> Now pushed to master-updates.
>
> Failed the gnutls test "testcompat-openssl",
>
>   ###
>   # Server mode tests (gnutls server-openssl cli#
>   ###
>   Check TLS 1.0 with DHE-RSA ciphersuite
>   %NO_ETM: Check TLS 1.0 with DHE-RSA ciphersuite
>   %DISABLE_SAFE_RENEGOTIATION: Check TLS 1.0 with DHE-RSA ciphersuite
>   %NO_TICKETS: Check TLS 1.0 with DHE-RSA ciphersuite
>   %COMPAT: Check TLS 1.0 with DHE-RSA ciphersuite
>   %SAFE_RENEGOTIATION: Check TLS 1.0 with DHE-RSA ciphersuite
>   HTTP Server listening on IPv4 0.0.0.0 port 18033...done
>   HTTP Server listening on IPv6 :: port 18033...done
>   HTTP Server listening on IPv4 0.0.0.0 port 22536...done
>   HTTP Server listening on IPv6 :: port 22536...done
>   HTTP Server listening on IPv4 0.0.0.0 port 15595...done
>   HTTP Server listening on IPv6 :: port 15595...done
>   HTTP Server listening on IPv4 0.0.0.0 port 22743...done
>   HTTP Server listening on IPv6 :: port 22743...done
>   HTTP Server listening on IPv4 0.0.0.0 port 10935...done
>   HTTP Server listening on IPv6 :: port 10935...done
>   HTTP Server listening on IPv4 0.0.0.0 port 43747...done
>   HTTP Server listening on IPv6 :: port 43747...done
>   Exiting via signal 15
>
> Maybe unrelated to this change?

I don't understand the gnutls failure. I've logged in to gitlab and
pressed the "Retry"-button. If it keeps failing, I'll need some help
investigating.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs


Re: [PATCH 0/8] Implement Curve448 ECDH and Ed448

2019-12-08 Thread Niels Möller
Daiki Ueno  writes:

> From 8bc6e735d4b40cbab5e187a28e01b63a04ecd92b Mon Sep 17 00:00:00 2001
> From: Daiki Ueno 
> Date: Fri, 23 Jun 2017 17:26:18 +0200
> Subject: [PATCH 2/4] Implement Curve448 primitives
>
> This patch adds the necessary primitives for "curve448", defined in
> RFC 7748.  Those primitives are namely: addition, doubling, scalar
> multiplication of the generator or an arbitrary point, inversion, and
> square root.

[...]

> +/* Computes a^{(p-3)/4} = a^{2^446-2^222-1} mod m. Needs 9 * n scratch
> +   space. */
> +static void
> +ecc_mod_pow_446m224m1 (const struct ecc_modulo *p,
> +mp_limb_t *rp, const mp_limb_t *ap,
> +mp_limb_t *scratch)
> +{
> +#define t0 scratch
> +#define t1 (scratch + 3*ECC_LIMB_SIZE)
> +#define t2 (scratch + 6*ECC_LIMB_SIZE)

I think 6*n scratch space should be enough (with no other changes to
this function),

  #define t0 scratch
  #define t1 (scratch + 2*ECC_LIMB_SIZE)
  #define t2 (scratch + 4*ECC_LIMB_SIZE)

(And it could possibly be trimmed down a bit further, by storing the
reused value a^{2^222 - 1} first).

Do you agree? Then storage for a few other things can likely be trimmed
down too, in particular, curve448_mul would get the same scratch need as
curve25519_mul, 12*n rather than 14*n. 

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs