GNU bug report logs - #31985
[PATCH 0/2] Improve python-libscrypt speed

Previous Next

Package: guix-patches;

Reported by: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>

Date: Tue, 26 Jun 2018 22:25:01 UTC

Severity: normal

Tags: patch

Done: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31985 in the body.
You can then email your comments to 31985 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Tue, 26 Jun 2018 22:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Goaziou <mail <at> nicolasgoaziou.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 26 Jun 2018 22:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: guix-patches <at> gnu.org
Cc: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Subject: [PATCH 0/2] Improve python-libscrypt speed
Date: Wed, 27 Jun 2018 00:24:09 +0200
The following patches fix a bug in python-libscrypt, which fallbacks to a slow
implementation.

Feedback welcome.

Nicolas Goaziou (2):
  gnu: Add libscrypt.
  gnu: python-pylibscrypt: Improve speed.

 gnu/packages/crypto.scm        | 28 ++++++++++++++++++++++++++++
 gnu/packages/python-crypto.scm | 21 ++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)

-- 
2.18.0





Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Tue, 26 Jun 2018 22:32:01 GMT) Full text and rfc822 format available.

Message #8 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: 31985 <at> debbugs.gnu.org
Cc: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Subject: [PATCH 1/2] gnu: Add libscrypt.
Date: Wed, 27 Jun 2018 00:31:15 +0200
* gnu/packages/crypto.scm (libscrypt): New variable.
---
 gnu/packages/crypto.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index 338db04f5..38befb838 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2017 Pierre Langlois <pierre.langlois <at> gmx.com>
 ;;; Copyright © 2018 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2018 Arun Isaac <arunisaac <at> systemreboot.net>
+;;; Copyright © 2018 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -478,6 +479,33 @@ utility as a demonstration of the @code{scrypt} key derivation function.
 attacks than alternative functions such as @code{PBKDF2} or @code{bcrypt}.")
     (license license:bsd-2)))
 
+(define-public libscrypt
+  (package
+    (name "libscrypt")
+    (version "1.21")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/technion/libscrypt.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "1d76ys6cp7fi4ng1w3mz2l0p9dbr7ljbk33dcywyimzjz8bahdng"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list (string-append "PREFIX=" %output)
+                          "CC=gcc")
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure))))
+    (home-page "https://lolware.net/libscrypt.html")
+    (synopsis "Scrypt shared library")
+    (description "@code{libscrypt} implements @code{scrypt}
+functionality, a replacement for @code{bcrypt}.")
+    (license license:bsd-3)))
+
 (define-public perl-math-random-isaac-xs
   (package
     (name "perl-math-random-isaac-xs")
-- 
2.18.0





Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Tue, 26 Jun 2018 22:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: 31985 <at> debbugs.gnu.org
Cc: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Subject: [PATCH 2/2] gnu: python-pylibscrypt: Improve speed.
Date: Wed, 27 Jun 2018 00:31:16 +0200
* gnu/packages/python-crypto.scm (python-pylibscrypt): Use "libscrypt"
  implementation instead of "openssl".

"hashlib.scrypt" requires Python 3.6+ and OpenSSL 1.1+.  Since Python is built
with OpenSSL 1.0, the library is unavailable. "pylibscrypt" defaults to a slow
pure Python implementation.  Instead, rely on the much faster "libscrypt".
---
 gnu/packages/python-crypto.scm | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm
index 6162fc835..779b86222 100644
--- a/gnu/packages/python-crypto.scm
+++ b/gnu/packages/python-crypto.scm
@@ -884,14 +884,29 @@ through the Engine interface.")
          "1b3rgzl6dbzs08vhv41b6y4n5189wv7lr27acxn104hs45745abs"))))
     (build-system python-build-system)
     (arguments
-     `(#:tests? #f))                    ;FIXME: unable to find libraries
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'hard-code-path-to-libscrypt
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((libscrypt (assoc-ref inputs "libscrypt")))
+               (substitute* "pylibscrypt/pylibscrypt.py"
+                 (("find_library\\('scrypt'\\)")
+                  (string-append "'" libscrypt "/lib/libscrypt.so'")))
+               #t))))
+       ;; The library can use various scrypt implementations and tests all of
+       ;; them.  Since we only provide a single implementation, most tests
+       ;; fail.  Simply skip them.
+       #:tests? #f))
+    ;; FIXME: Using "libscrypt" is the second best choice.  The best one
+    ;; requires "hashlib.scrypt", provided by Python 3.6+ built with OpenSSL
+    ;; 1.1+.  Use that as soon as Guix provides it.
     (inputs
-     `(("openssl" ,openssl)))
+     `(("libscrypt" ,libscrypt)))
     (home-page "https://github.com/jvarho/pylibscrypt")
     (synopsis "Scrypt for Python")
     (description "There are a lot of different scrypt modules for Python, but
 none of them have everything that I'd like, so here's one more.  It uses
-hashlib.scrypt on Python 3.6 and OpenSSL 1.1.")
+@code{libscrypt}.")
     (license license:isc)))
 
 (define-public python-libnacl
-- 
2.18.0





Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Mon, 02 Jul 2018 15:33:02 GMT) Full text and rfc822 format available.

Message #14 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: 31985 <at> debbugs.gnu.org
Subject: Re: [bug#31985] [PATCH 1/2] gnu: Add libscrypt.
Date: Mon, 02 Jul 2018 17:32:13 +0200
Nicolas Goaziou <mail <at> nicolasgoaziou.fr> skribis:

> * gnu/packages/crypto.scm (libscrypt): New variable.

[...]

> +    (home-page "https://lolware.net/libscrypt.html")
> +    (synopsis "Scrypt shared library")

What about “Password hashing library”?

> +    (description "@code{libscrypt} implements @code{scrypt}
> +functionality, a replacement for @code{bcrypt}.")

Could you expound just a little bit?

OK with these changes, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Mon, 02 Jul 2018 15:34:02 GMT) Full text and rfc822 format available.

Message #17 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: 31985 <at> debbugs.gnu.org
Subject: Re: [bug#31985] [PATCH 2/2] gnu: python-pylibscrypt: Improve speed.
Date: Mon, 02 Jul 2018 17:33:04 +0200
Nicolas Goaziou <mail <at> nicolasgoaziou.fr> skribis:

> * gnu/packages/python-crypto.scm (python-pylibscrypt): Use "libscrypt"
>   implementation instead of "openssl".
>
> "hashlib.scrypt" requires Python 3.6+ and OpenSSL 1.1+.  Since Python is built
> with OpenSSL 1.0, the library is unavailable. "pylibscrypt" defaults to a slow
> pure Python implementation.  Instead, rely on the much faster "libscrypt".

LGTM.  Thanks!

Ludo'.




Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Mon, 02 Jul 2018 21:20:01 GMT) Full text and rfc822 format available.

Message #20 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 31985 <at> debbugs.gnu.org
Subject: Re: [bug#31985] [PATCH 1/2] gnu: Add libscrypt.
Date: Mon, 02 Jul 2018 23:19:00 +0200
Hello,

ludo <at> gnu.org (Ludovic Courtès) writes:

> Nicolas Goaziou <mail <at> nicolasgoaziou.fr> skribis:
>
>> * gnu/packages/crypto.scm (libscrypt): New variable.
>
> [...]
>
>> +    (home-page "https://lolware.net/libscrypt.html")
>> +    (synopsis "Scrypt shared library")
>
> What about “Password hashing library”?

OK.

>> +    (description "@code{libscrypt} implements @code{scrypt}
>> +functionality, a replacement for @code{bcrypt}.")
>
> Could you expound just a little bit?

OK. I used:

    @code{libscrypt} implements @code{scrypt} key derivation function.
    It is designed to be far more secure against hardware brute-force
    attacks than alternative functions such as @code{PBKDF2} or
    @code{bcrypt}.

Let me know if that isn't enough (though I wouldn't know what to say in
addition to the above).

> OK with these changes, thanks!

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738




Reply sent to Nicolas Goaziou <mail <at> nicolasgoaziou.fr>:
You have taken responsibility. (Mon, 02 Jul 2018 21:20:02 GMT) Full text and rfc822 format available.

Notification sent to Nicolas Goaziou <mail <at> nicolasgoaziou.fr>:
bug acknowledged by developer. (Mon, 02 Jul 2018 21:20:02 GMT) Full text and rfc822 format available.

Message #25 received at 31985-done <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 31985-done <at> debbugs.gnu.org
Subject: Re: [bug#31985] [PATCH 2/2] gnu: python-pylibscrypt: Improve speed.
Date: Mon, 02 Jul 2018 23:19:24 +0200
Hello,

ludo <at> gnu.org (Ludovic Courtès) writes:

> Nicolas Goaziou <mail <at> nicolasgoaziou.fr> skribis:
>
>> * gnu/packages/python-crypto.scm (python-pylibscrypt): Use "libscrypt"
>>   implementation instead of "openssl".
>>
>> "hashlib.scrypt" requires Python 3.6+ and OpenSSL 1.1+.  Since Python is built
>> with OpenSSL 1.0, the library is unavailable. "pylibscrypt" defaults to a slow
>> pure Python implementation.  Instead, rely on the much faster "libscrypt".
>
> LGTM.  Thanks!

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738




Information forwarded to guix-patches <at> gnu.org:
bug#31985; Package guix-patches. (Tue, 03 Jul 2018 08:10:02 GMT) Full text and rfc822 format available.

Message #28 received at 31985 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: 31985 <at> debbugs.gnu.org
Subject: Re: [bug#31985] [PATCH 1/2] gnu: Add libscrypt.
Date: Tue, 03 Jul 2018 10:09:30 +0200
Hello Nicolas,

Nicolas Goaziou <mail <at> nicolasgoaziou.fr> skribis:

> OK. I used:
>
>     @code{libscrypt} implements @code{scrypt} key derivation function.
>     It is designed to be far more secure against hardware brute-force
>     attacks than alternative functions such as @code{PBKDF2} or
>     @code{bcrypt}.
>
> Let me know if that isn't enough (though I wouldn't know what to say in
> addition to the above).

LGTM!  The guiding principle should be to give enough context to someone
who doesn’t know the package at all to get an idea of what this is
about (info "(guix) Synopses and Descriptions").

Thank you,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 31 Jul 2018 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 324 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.