[packages/python3-crypt-r] Use upstream PR variant

arekm arekm at pld-linux.org
Tue Oct 13 16:47:00 CEST 2026


commit 78778da0c7193a859620d5d02c2a832ebfd09372
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 13 16:43:51 2026 +0200

    Use upstream PR variant

 python3-crypt-r.spec |  3 +-
 yescrypt.patch       | 77 ++++++++++++++++++++++++++++++++--------------------
 2 files changed, 50 insertions(+), 30 deletions(-)
---
diff --git a/python3-crypt-r.spec b/python3-crypt-r.spec
index 553971d..2e22682 100644
--- a/python3-crypt-r.spec
+++ b/python3-crypt-r.spec
@@ -5,11 +5,12 @@
 Summary:	A copy of the `crypt` module that was removed in Python 3.13
 Name:		python3-crypt-r
 Version:	3.13.1
-Release:	4
+Release:	5
 License:	PSL
 Group:		Libraries/Python
 Source0:	https://files.pythonhosted.org/packages/source/c/crypt-r/%{module}-%{version}.tar.gz
 # Source0-md5:	8f37eed58cb8ada45721b703432b819f
+# https://github.com/fedora-python/crypt_r/pull/18
 Patch0:		yescrypt.patch
 URL:		https://pypi.org/project/crypt-r/
 BuildRequires:	libxcrypt-devel >= 4.2.0
diff --git a/yescrypt.patch b/yescrypt.patch
index 4bd2673..8451974 100644
--- a/yescrypt.patch
+++ b/yescrypt.patch
@@ -1,10 +1,20 @@
-Add METHOD_YESCRYPT: crypt_gensalt(3) from libxcrypt builds the setting
-string (yescrypt needs 16 bytes in its own base64 encoding, so random
-characters from _saltchars are rejected); rounds maps to the libxcrypt
-cost 1-11. yescrypt becomes the first (default) method, as in libxcrypt.
+From 5adc7840c13e69ae4302c9c7f2b6875bbb613bbc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Arkadiusz=20Mis=CC=81kiewicz?= <arekm at maven.pl>
+Date: Tue, 13 Oct 2026 15:41:01 +0200
+Subject: [PATCH] Add METHOD_YESCRYPT
+
+yescrypt is the default on Fedora, Debian and others, but mksalt()
+can't make a valid salt for it, so let libxcrypt's crypt_gensalt()
+build the setting. The default method stays SHA-512.
+---
+ README.rst            | 16 +++++++++---
+ src/_crypt_r.c        | 60 +++++++++++++++++++++++++++++++++++++++++++
+ src/crypt_r.py        | 15 ++++++++++-
+ tests/test_crypt_r.py | 37 ++++++++++++++++++++++++++
+ 4 files changed, 123 insertions(+), 5 deletions(-)
 
 diff --git a/README.rst b/README.rst
-index 834720b..4c75eda 100644
+index 95dc17d..2720c9d 100644
 --- a/README.rst
 +++ b/README.rst
 @@ -21,8 +21,6 @@ not security/cryptography.
@@ -16,23 +26,19 @@ index 834720b..4c75eda 100644
  No future development is planned.
  
  To use this module, you can either import ``crypt_r`` explicitly
-@@ -54,9 +52,15 @@ New in Python 3.3.
- The ``crypt_r`` module defines the list of hashing methods (not all methods
- are available on all platforms):
+@@ -62,6 +60,12 @@ are available on all platforms):
+    Another Modular Crypt Format method with 16 character salt and 43
+    character hash based on the SHA-256 hash function.
  
 +``METHOD_YESCRYPT``
-+   A Modular Crypt Format method with 22 character salt and 43 character
-+   hash based on the yescrypt key derivation function; the default and
-+   recommended method of libxcrypt.  The salt is generated by
-+   ``crypt_gensalt(3)`` from libxcrypt.  This is the strongest method.
++   Another Modular Crypt Format method with 22 character salt and 43
++   character hash based on the yescrypt key derivation function,
++   recommended by libxcrypt for new hashes.  Available only when built
++   against libxcrypt, whose `crypt_gensalt(3)`_ generates the salt.
 +
- ``METHOD_SHA512``
-    A Modular Crypt Format method with 16 character salt and 86 character
--   hash based on the SHA-512 hash function.  This is the strongest method.
-+   hash based on the SHA-512 hash function.
- 
- ``METHOD_SHA256``
-    Another Modular Crypt Format method with 16 character salt and 43
+ ``METHOD_BLOWFISH``
+    Another Modular Crypt Format method with 22 character salt and 31
+    character hash based on the Blowfish cipher.
 @@ -131,12 +135,15 @@ The ``crypt_r`` module defines the following functions:
     to  ``crypt`` .
  
@@ -51,6 +57,13 @@ index 834720b..4c75eda 100644
  
     New in Python 3.3.
  
+@@ -207,5 +214,6 @@ please refer to the `Python 3.12 Changelog`_.
+ .. _PEP 594: https://peps.python.org/pep-0594/#crypt
+ .. _crypt(3): https://manpages.debian.org/crypt(3)
+ .. _crypt_r(3): https://manpages.debian.org/crypt_r(3)
++.. _crypt_gensalt(3): https://manpages.debian.org/crypt_gensalt(3)
+ .. _hmac.compare_digest(): https://docs.python.org/3/library/hmac.html#hmac.compare_digest
+ .. _Python 3.12 Changelog: https://docs.python.org/3.12/whatsnew/changelog.html
 diff --git a/src/_crypt_r.c b/src/_crypt_r.c
 index 066ed53..0731c44 100644
 --- a/src/_crypt_r.c
@@ -125,7 +138,7 @@ index 066ed53..0731c44 100644
  };
  
 diff --git a/src/crypt_r.py b/src/crypt_r.py
-index afd6d82..948bdd1 100644
+index afd6d82..34d41d9 100644
 --- a/src/crypt_r.py
 +++ b/src/crypt_r.py
 @@ -45,6 +45,15 @@ def mksalt(method=None, *, rounds=None):
@@ -155,20 +168,22 @@ index afd6d82..948bdd1 100644
          result = crypt('', salt)
      except OSError as e:
          # Not all libc libraries support all encryption methods.
-@@ -102,6 +111,8 @@ def _add_method(name, *args, rounds=None):
-         return True
-     return False
- 
-+# libxcrypt's default and recommended method for new hashes.
-+_add_method('YESCRYPT', 'y', 22, 73)
+@@ -105,6 +114,10 @@ def _add_method(name, *args, rounds=None):
  _add_method('SHA512', '6', 16, 106)
  _add_method('SHA256', '5', 16, 63)
  
++# Listed after SHA-2, like Blowfish, so the default method stays the same;
++# the lowest cost keeps the import-time probe as cheap as Blowfish's.
++_add_method('YESCRYPT', 'y', 22, 73, rounds=1)
++
+ # Choose the strongest supported version of Blowfish hashing.
+ # Early versions have flaws.  Version 'a' fixes flaws of
+ # the initial implementation, 'b' fixes flaws of 'a'.
 diff --git a/tests/test_crypt_r.py b/tests/test_crypt_r.py
-index ef8769e..b5e26f5 100644
+index ef8769e..1e91f59 100644
 --- a/tests/test_crypt_r.py
 +++ b/tests/test_crypt_r.py
-@@ -69,7 +69,43 @@ class CryptRTestCase(unittest.TestCase):
+@@ -69,7 +69,44 @@ class CryptRTestCase(unittest.TestCase):
              cr2 = self.crypt.crypt('mypassword', cr)
              self.assertEqual(cr2, cr)
  
@@ -176,7 +191,8 @@ index ef8769e..b5e26f5 100644
 +        crypt_r.METHOD_YESCRYPT in crypt_r.methods, 'requires support of yescrypt'
 +    )
 +    def test_yescrypt(self):
-+        self.assertEqual(self.crypt.methods[0], self.crypt.METHOD_YESCRYPT)
++        # Adding yescrypt must not change the default method.
++        self.assertNotEqual(self.crypt.methods[0], self.crypt.METHOD_YESCRYPT)
 +        # Arbitrary characters from _saltchars are not a valid yescrypt salt,
 +        # so every generated one must be accepted, not just most of them.
 +        salts = {self.crypt.mksalt(self.crypt.METHOD_YESCRYPT) for _ in range(20)}
@@ -212,3 +228,6 @@ index ef8769e..b5e26f5 100644
          for method in (self.crypt.METHOD_SHA256, self.crypt.METHOD_SHA512,
                         self.crypt.METHOD_BLOWFISH):
              with self.assertRaises(TypeError):
+-- 
+2.56.0
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python3-crypt-r.git/commitdiff/78778da0c7193a859620d5d02c2a832ebfd09372



More information about the pld-cvs-commit mailing list