bcrypt 4.2.1__tar.gz → 5.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ include LICENSE README.rst
2
2
 
3
3
  include pyproject.toml
4
4
 
5
- include tox.ini .coveragerc
5
+ include noxfile.py .coveragerc
6
6
 
7
7
  recursive-include src py.typed *.pyi
8
8
  recursive-include src/_bcrypt Cargo.toml Cargo.lock *.rs
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: bcrypt
3
- Version: 4.2.1
3
+ Version: 5.0.0
4
4
  Summary: Modern password hashing for your software and your servers
5
5
  Author-email: The Python Cryptographic Authority developers <cryptography-dev@python.org>
6
6
  License: Apache-2.0
@@ -11,20 +11,22 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
11
11
  Classifier: Programming Language :: Python :: Implementation :: PyPy
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3.7
15
14
  Classifier: Programming Language :: Python :: 3.8
16
15
  Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
20
19
  Classifier: Programming Language :: Python :: 3.13
21
- Requires-Python: >=3.7
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
22
+ Requires-Python: >=3.8
22
23
  Description-Content-Type: text/x-rst
23
24
  License-File: LICENSE
24
25
  Provides-Extra: tests
25
26
  Requires-Dist: pytest!=3.3.0,>=3.2.1; extra == "tests"
26
27
  Provides-Extra: typecheck
27
28
  Requires-Dist: mypy; extra == "typecheck"
29
+ Dynamic: license-file
28
30
 
29
31
  bcrypt
30
32
  ======
@@ -79,6 +81,25 @@ While bcrypt remains an acceptable choice for password storage, depending on you
79
81
  Changelog
80
82
  =========
81
83
 
84
+ 5.0.0
85
+ -----
86
+
87
+ * Bumped MSRV to 1.74.
88
+ * Added support for Python 3.14 and free-threaded Python 3.14.
89
+ * Added support for Windows on ARM.
90
+ * Passing ``hashpw`` a password longer than 72 bytes now raises a
91
+ ``ValueError``. Previously the password was silently truncated, following the
92
+ behavior of the original OpenBSD ``bcrypt`` implementation.
93
+
94
+ 4.3.0
95
+ -----
96
+
97
+ * Dropped support for Python 3.7.
98
+ * We now support free-threaded Python 3.13.
99
+ * We now support PyPy 3.11.
100
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
101
+ ``manylinux``, and for ARMv7l on ``manylinux``.
102
+
82
103
  4.2.1
83
104
  -----
84
105
 
@@ -308,7 +329,7 @@ Compatibility
308
329
  -------------
309
330
 
310
331
  This library should be compatible with py-bcrypt and it will run on Python
311
- 3.6+, and PyPy 3.
332
+ 3.8+ (including free-threaded builds), and PyPy 3.
312
333
 
313
334
  Security
314
335
  --------
@@ -51,6 +51,25 @@ While bcrypt remains an acceptable choice for password storage, depending on you
51
51
  Changelog
52
52
  =========
53
53
 
54
+ 5.0.0
55
+ -----
56
+
57
+ * Bumped MSRV to 1.74.
58
+ * Added support for Python 3.14 and free-threaded Python 3.14.
59
+ * Added support for Windows on ARM.
60
+ * Passing ``hashpw`` a password longer than 72 bytes now raises a
61
+ ``ValueError``. Previously the password was silently truncated, following the
62
+ behavior of the original OpenBSD ``bcrypt`` implementation.
63
+
64
+ 4.3.0
65
+ -----
66
+
67
+ * Dropped support for Python 3.7.
68
+ * We now support free-threaded Python 3.13.
69
+ * We now support PyPy 3.11.
70
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
71
+ ``manylinux``, and for ARMv7l on ``manylinux``.
72
+
54
73
  4.2.1
55
74
  -----
56
75
 
@@ -280,7 +299,7 @@ Compatibility
280
299
  -------------
281
300
 
282
301
  This library should be compatible with py-bcrypt and it will run on Python
283
- 3.6+, and PyPy 3.
302
+ 3.8+ (including free-threaded builds), and PyPy 3.
284
303
 
285
304
  Security
286
305
  --------
@@ -0,0 +1,42 @@
1
+ import nox
2
+
3
+ nox.options.reuse_existing_virtualenvs = True
4
+ nox.options.default_venv_backend = "uv|virtualenv"
5
+
6
+
7
+ @nox.session
8
+ def tests(session: nox.Session) -> None:
9
+ session.install("coverage")
10
+ session.install(".[tests]")
11
+
12
+ session.run(
13
+ "coverage", "run", "-m", "pytest", "--strict-markers", *session.posargs
14
+ )
15
+ session.run("coverage", "combine")
16
+ session.run("coverage", "report", "-m", "--fail-under", "100")
17
+
18
+
19
+ @nox.session
20
+ def pep8(session: nox.Session) -> None:
21
+ session.install("ruff")
22
+
23
+ session.run("ruff", "check", ".")
24
+ session.run("ruff", "format", "--check", ".")
25
+
26
+
27
+ @nox.session
28
+ def mypy(session: nox.Session) -> None:
29
+ session.install("mypy")
30
+ session.install(".[tests]")
31
+
32
+ session.run("mypy", "tests/")
33
+
34
+
35
+ @nox.session
36
+ def packaging(session: nox.Session) -> None:
37
+ session.install("setuptools-rust", "check-manifest", "readme_renderer")
38
+
39
+ session.run("check-manifest")
40
+ session.run(
41
+ "python3", "-m", "readme_renderer", "README.rst", "-o", "/dev/null"
42
+ )
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
  [project]
12
12
  name = "bcrypt"
13
13
  # When updating this, also update lib.rs
14
- version = "4.2.1"
14
+ version = "5.0.0"
15
15
  authors = [
16
16
  {name = "The Python Cryptographic Authority developers", email = "cryptography-dev@python.org"}
17
17
  ]
@@ -24,15 +24,16 @@ classifiers = [
24
24
  "Programming Language :: Python :: Implementation :: PyPy",
25
25
  "Programming Language :: Python :: 3",
26
26
  "Programming Language :: Python :: 3 :: Only",
27
- "Programming Language :: Python :: 3.7",
28
27
  "Programming Language :: Python :: 3.8",
29
28
  "Programming Language :: Python :: 3.9",
30
29
  "Programming Language :: Python :: 3.10",
31
30
  "Programming Language :: Python :: 3.11",
32
31
  "Programming Language :: Python :: 3.12",
33
32
  "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
34
+ "Programming Language :: Python :: Free Threading :: 3 - Stable",
34
35
  ]
35
- requires-python = ">= 3.7"
36
+ requires-python = ">= 3.8"
36
37
  dynamic = ["readme"]
37
38
 
38
39
  [project.urls]
@@ -73,3 +74,6 @@ warn_redundant_casts = true
73
74
  warn_unused_ignores = true
74
75
  warn_unused_configs = true
75
76
  strict_equality = true
77
+
78
+ [tool.check-manifest]
79
+ ignore = ["tests/reference/*"]
@@ -4,9 +4,9 @@ version = 3
4
4
 
5
5
  [[package]]
6
6
  name = "autocfg"
7
- version = "1.4.0"
7
+ version = "1.5.0"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
9
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
10
10
 
11
11
  [[package]]
12
12
  name = "base64"
@@ -16,9 +16,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
16
16
 
17
17
  [[package]]
18
18
  name = "bcrypt"
19
- version = "0.16.0"
19
+ version = "0.17.1"
20
20
  source = "registry+https://github.com/rust-lang/crates.io-index"
21
- checksum = "2b1866ecef4f2d06a0bb77880015fdf2b89e25a1c2e5addacb87e459c86dc67e"
21
+ checksum = "abaf6da45c74385272ddf00e1ac074c7d8a6c1a1dda376902bd6a427522a8b2c"
22
22
  dependencies = [
23
23
  "base64",
24
24
  "blowfish",
@@ -77,9 +77,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
77
77
 
78
78
  [[package]]
79
79
  name = "cfg-if"
80
- version = "1.0.0"
80
+ version = "1.0.3"
81
81
  source = "registry+https://github.com/rust-lang/crates.io-index"
82
- checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
82
+ checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
83
83
 
84
84
  [[package]]
85
85
  name = "cipher"
@@ -93,9 +93,9 @@ dependencies = [
93
93
 
94
94
  [[package]]
95
95
  name = "cpufeatures"
96
- version = "0.2.15"
96
+ version = "0.2.17"
97
97
  source = "registry+https://github.com/rust-lang/crates.io-index"
98
- checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6"
98
+ checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
99
99
  dependencies = [
100
100
  "libc",
101
101
  ]
@@ -133,12 +133,13 @@ dependencies = [
133
133
 
134
134
  [[package]]
135
135
  name = "getrandom"
136
- version = "0.2.15"
136
+ version = "0.3.3"
137
137
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
138
+ checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
139
139
  dependencies = [
140
140
  "cfg-if",
141
141
  "libc",
142
+ "r-efi",
142
143
  "wasi",
143
144
  ]
144
145
 
@@ -150,24 +151,24 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
150
151
 
151
152
  [[package]]
152
153
  name = "indoc"
153
- version = "2.0.5"
154
+ version = "2.0.6"
154
155
  source = "registry+https://github.com/rust-lang/crates.io-index"
155
- checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
156
+ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
156
157
 
157
158
  [[package]]
158
159
  name = "inout"
159
- version = "0.1.3"
160
+ version = "0.1.4"
160
161
  source = "registry+https://github.com/rust-lang/crates.io-index"
161
- checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
162
+ checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
162
163
  dependencies = [
163
164
  "generic-array",
164
165
  ]
165
166
 
166
167
  [[package]]
167
168
  name = "libc"
168
- version = "0.2.164"
169
+ version = "0.2.176"
169
170
  source = "registry+https://github.com/rust-lang/crates.io-index"
170
- checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
171
+ checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
171
172
 
172
173
  [[package]]
173
174
  name = "memoffset"
@@ -180,9 +181,9 @@ dependencies = [
180
181
 
181
182
  [[package]]
182
183
  name = "once_cell"
183
- version = "1.20.2"
184
+ version = "1.21.3"
184
185
  source = "registry+https://github.com/rust-lang/crates.io-index"
185
- checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
186
+ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
186
187
 
187
188
  [[package]]
188
189
  name = "pbkdf2"
@@ -195,26 +196,25 @@ dependencies = [
195
196
 
196
197
  [[package]]
197
198
  name = "portable-atomic"
198
- version = "1.9.0"
199
+ version = "1.11.1"
199
200
  source = "registry+https://github.com/rust-lang/crates.io-index"
200
- checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
201
+ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
201
202
 
202
203
  [[package]]
203
204
  name = "proc-macro2"
204
- version = "1.0.89"
205
+ version = "1.0.101"
205
206
  source = "registry+https://github.com/rust-lang/crates.io-index"
206
- checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
207
+ checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
207
208
  dependencies = [
208
209
  "unicode-ident",
209
210
  ]
210
211
 
211
212
  [[package]]
212
213
  name = "pyo3"
213
- version = "0.23.1"
214
+ version = "0.26.0"
214
215
  source = "registry+https://github.com/rust-lang/crates.io-index"
215
- checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40"
216
+ checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383"
216
217
  dependencies = [
217
- "cfg-if",
218
218
  "indoc",
219
219
  "libc",
220
220
  "memoffset",
@@ -228,19 +228,18 @@ dependencies = [
228
228
 
229
229
  [[package]]
230
230
  name = "pyo3-build-config"
231
- version = "0.23.1"
231
+ version = "0.26.0"
232
232
  source = "registry+https://github.com/rust-lang/crates.io-index"
233
- checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09"
233
+ checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f"
234
234
  dependencies = [
235
- "once_cell",
236
235
  "target-lexicon",
237
236
  ]
238
237
 
239
238
  [[package]]
240
239
  name = "pyo3-ffi"
241
- version = "0.23.1"
240
+ version = "0.26.0"
242
241
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75"
242
+ checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105"
244
243
  dependencies = [
245
244
  "libc",
246
245
  "pyo3-build-config",
@@ -248,9 +247,9 @@ dependencies = [
248
247
 
249
248
  [[package]]
250
249
  name = "pyo3-macros"
251
- version = "0.23.1"
250
+ version = "0.26.0"
252
251
  source = "registry+https://github.com/rust-lang/crates.io-index"
253
- checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a"
252
+ checksum = "2e64eb489f22fe1c95911b77c44cc41e7c19f3082fc81cce90f657cdc42ffded"
254
253
  dependencies = [
255
254
  "proc-macro2",
256
255
  "pyo3-macros-backend",
@@ -260,9 +259,9 @@ dependencies = [
260
259
 
261
260
  [[package]]
262
261
  name = "pyo3-macros-backend"
263
- version = "0.23.1"
262
+ version = "0.26.0"
264
263
  source = "registry+https://github.com/rust-lang/crates.io-index"
265
- checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8"
264
+ checksum = "100246c0ecf400b475341b8455a9213344569af29a3c841d29270e53102e0fcf"
266
265
  dependencies = [
267
266
  "heck",
268
267
  "proc-macro2",
@@ -273,18 +272,24 @@ dependencies = [
273
272
 
274
273
  [[package]]
275
274
  name = "quote"
276
- version = "1.0.37"
275
+ version = "1.0.40"
277
276
  source = "registry+https://github.com/rust-lang/crates.io-index"
278
- checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
277
+ checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
279
278
  dependencies = [
280
279
  "proc-macro2",
281
280
  ]
282
281
 
282
+ [[package]]
283
+ name = "r-efi"
284
+ version = "5.3.0"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
287
+
283
288
  [[package]]
284
289
  name = "sha2"
285
- version = "0.10.8"
290
+ version = "0.10.9"
286
291
  source = "registry+https://github.com/rust-lang/crates.io-index"
287
- checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
292
+ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
288
293
  dependencies = [
289
294
  "cfg-if",
290
295
  "cpufeatures",
@@ -299,9 +304,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
299
304
 
300
305
  [[package]]
301
306
  name = "syn"
302
- version = "2.0.87"
307
+ version = "2.0.106"
303
308
  source = "registry+https://github.com/rust-lang/crates.io-index"
304
- checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
309
+ checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
305
310
  dependencies = [
306
311
  "proc-macro2",
307
312
  "quote",
@@ -310,27 +315,27 @@ dependencies = [
310
315
 
311
316
  [[package]]
312
317
  name = "target-lexicon"
313
- version = "0.12.16"
318
+ version = "0.13.3"
314
319
  source = "registry+https://github.com/rust-lang/crates.io-index"
315
- checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
320
+ checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c"
316
321
 
317
322
  [[package]]
318
323
  name = "typenum"
319
- version = "1.17.0"
324
+ version = "1.18.0"
320
325
  source = "registry+https://github.com/rust-lang/crates.io-index"
321
- checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
326
+ checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
322
327
 
323
328
  [[package]]
324
329
  name = "unicode-ident"
325
- version = "1.0.13"
330
+ version = "1.0.19"
326
331
  source = "registry+https://github.com/rust-lang/crates.io-index"
327
- checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
332
+ checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
328
333
 
329
334
  [[package]]
330
335
  name = "unindent"
331
- version = "0.2.3"
336
+ version = "0.2.4"
332
337
  source = "registry+https://github.com/rust-lang/crates.io-index"
333
- checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
338
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
334
339
 
335
340
  [[package]]
336
341
  name = "version_check"
@@ -340,9 +345,27 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
340
345
 
341
346
  [[package]]
342
347
  name = "wasi"
343
- version = "0.11.0+wasi-snapshot-preview1"
348
+ version = "0.14.7+wasi-0.2.4"
349
+ source = "registry+https://github.com/rust-lang/crates.io-index"
350
+ checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
351
+ dependencies = [
352
+ "wasip2",
353
+ ]
354
+
355
+ [[package]]
356
+ name = "wasip2"
357
+ version = "1.0.1+wasi-0.2.4"
358
+ source = "registry+https://github.com/rust-lang/crates.io-index"
359
+ checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
360
+ dependencies = [
361
+ "wit-bindgen",
362
+ ]
363
+
364
+ [[package]]
365
+ name = "wit-bindgen"
366
+ version = "0.46.0"
344
367
  source = "registry+https://github.com/rust-lang/crates.io-index"
345
- checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
368
+ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
346
369
 
347
370
  [[package]]
348
371
  name = "zeroize"
@@ -3,15 +3,17 @@ name = "bcrypt-rust"
3
3
  version = "0.1.0"
4
4
  authors = ["The bcrypt developers <cryptography-dev@python.org>"]
5
5
  edition = "2018"
6
+ # This specifies the MSRV
7
+ rust-version = "1.74.0"
6
8
  publish = false
7
9
 
8
10
  [dependencies]
9
- pyo3 = { version = "0.23", features = ["abi3"] }
10
- bcrypt = "0.16"
11
+ pyo3 = { version = "0.26", features = ["abi3"] }
12
+ bcrypt = "0.17"
11
13
  bcrypt-pbkdf = "0.10.0"
12
14
  base64 = "0.22.1"
13
15
  subtle = "2.6"
14
- getrandom = "0.2"
16
+ getrandom = "0.3"
15
17
 
16
18
  [features]
17
19
  extension-module = ["pyo3/extension-module"]
@@ -26,13 +26,12 @@ pub const BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::Genera
26
26
  );
27
27
 
28
28
  #[pyo3::pyfunction]
29
- #[pyo3(signature = (rounds=None, prefix=None))]
29
+ #[pyo3(signature = (rounds=12, prefix=None), text_signature = "(rounds=12, prefix=b'2b')")]
30
30
  fn gensalt<'p>(
31
31
  py: pyo3::Python<'p>,
32
- rounds: Option<u16>,
32
+ rounds: u16,
33
33
  prefix: Option<&[u8]>,
34
34
  ) -> pyo3::PyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
35
- let rounds = rounds.unwrap_or(12);
36
35
  let prefix = prefix.unwrap_or(b"2b");
37
36
 
38
37
  if prefix != b"2a" && prefix != b"2b" {
@@ -46,7 +45,7 @@ fn gensalt<'p>(
46
45
  }
47
46
 
48
47
  let mut salt = [0; 16];
49
- getrandom::getrandom(&mut salt).unwrap();
48
+ getrandom::fill(&mut salt).unwrap();
50
49
 
51
50
  let encoded_salt = BASE64_ENGINE.encode(salt);
52
51
 
@@ -78,19 +77,28 @@ fn hashpw<'p>(
78
77
  // bytes on the updated prefix $2b$, but leaving $2a$ unchanged for
79
78
  // compatibility. However, pyca/bcrypt 2.0.0 *did* correctly truncate inputs
80
79
  // on $2a$, so we do it here to preserve compatibility with 2.0.0
81
- let password = &password[..password.len().min(72)];
80
+ // Silent truncation is _probably_ not the best idea, even if the "original"
81
+ // OpenBSD implementation did/does this.
82
+ // We prefer to raise a ValueError in this case - if the user _wants_ to truncate,
83
+ // they can always do so manually by passing s[:72] instead of s into hashpw().
84
+
85
+ if password.len() > 72 {
86
+ return Err(pyo3::exceptions::PyValueError::new_err(
87
+ "password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])",
88
+ ));
89
+ }
82
90
 
83
91
  // salt here is not just the salt bytes, but rather an encoded value
84
92
  // containing a version number, number of rounds, and the salt.
85
93
  // Should be [prefix, cost, hash]. This logic is copied from `bcrypt`
86
- let raw_parts: Vec<_> = salt
94
+ let [raw_version, raw_cost, remainder]: [&[u8]; 3] = salt
87
95
  .split(|&b| b == b'$')
88
96
  .filter(|s| !s.is_empty())
89
- .collect();
90
- if raw_parts.len() != 3 {
91
- return Err(pyo3::exceptions::PyValueError::new_err("Invalid salt"));
92
- }
93
- let version = match raw_parts[0] {
97
+ .collect::<Vec<_>>()
98
+ .try_into()
99
+ .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
100
+
101
+ let version = match raw_version {
94
102
  b"2y" => bcrypt::Version::TwoY,
95
103
  b"2b" => bcrypt::Version::TwoB,
96
104
  b"2a" => bcrypt::Version::TwoA,
@@ -99,21 +107,26 @@ fn hashpw<'p>(
99
107
  return Err(pyo3::exceptions::PyValueError::new_err("Invalid salt"));
100
108
  }
101
109
  };
102
- let cost = std::str::from_utf8(raw_parts[1])
110
+ let cost = std::str::from_utf8(raw_cost)
103
111
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?
104
112
  .parse::<u32>()
105
113
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
114
+
115
+ if remainder.len() < 22 {
116
+ return Err(pyo3::exceptions::PyValueError::new_err("Invalid salt"));
117
+ }
118
+
106
119
  // The last component can contain either just the salt, or the salt and
107
120
  // the result hash, depending on if the `salt` value come from `hashpw` or
108
121
  // `gensalt`.
109
122
  let raw_salt = BASE64_ENGINE
110
- .decode(&raw_parts[2][..22])
123
+ .decode(&remainder[..22])
111
124
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?
112
125
  .try_into()
113
126
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
114
127
 
115
128
  let hashed = py
116
- .allow_threads(|| bcrypt::hash_with_salt(password, cost, raw_salt))
129
+ .detach(|| bcrypt::hash_with_salt(password, cost, raw_salt))
117
130
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
118
131
  Ok(pyo3::types::PyBytes::new(
119
132
  py,
@@ -170,14 +183,14 @@ fn kdf<'p>(
170
183
  }
171
184
 
172
185
  pyo3::types::PyBytes::new_with(py, desired_key_bytes, |output| {
173
- py.allow_threads(|| {
186
+ py.detach(|| {
174
187
  bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, output).unwrap();
175
188
  });
176
189
  Ok(())
177
190
  })
178
191
  }
179
192
 
180
- #[pyo3::pymodule]
193
+ #[pyo3::pymodule(gil_used = false)]
181
194
  mod _bcrypt {
182
195
  use pyo3::types::PyModuleMethods;
183
196
 
@@ -197,14 +210,14 @@ mod _bcrypt {
197
210
  // When updating this, also update pyproject.toml
198
211
  // This isn't named __version__ because passlib treats the existence of
199
212
  // that attribute as proof that we're a different module
200
- m.add("__version_ex__", "4.2.1")?;
213
+ m.add("__version_ex__", "5.0.0")?;
201
214
 
202
215
  let author = "The Python Cryptographic Authority developers";
203
216
  m.add("__author__", author)?;
204
217
  m.add("__email__", "cryptography-dev@python.org")?;
205
218
 
206
219
  m.add("__license__", "Apache License, Version 2.0")?;
207
- m.add("__copyright__", format!("Copyright 2013-2024 {author}"))?;
220
+ m.add("__copyright__", format!("Copyright 2013-2025 {author}"))?;
208
221
 
209
222
  Ok(())
210
223
  }
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: bcrypt
3
- Version: 4.2.1
3
+ Version: 5.0.0
4
4
  Summary: Modern password hashing for your software and your servers
5
5
  Author-email: The Python Cryptographic Authority developers <cryptography-dev@python.org>
6
6
  License: Apache-2.0
@@ -11,20 +11,22 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
11
11
  Classifier: Programming Language :: Python :: Implementation :: PyPy
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3.7
15
14
  Classifier: Programming Language :: Python :: 3.8
16
15
  Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
20
19
  Classifier: Programming Language :: Python :: 3.13
21
- Requires-Python: >=3.7
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
22
+ Requires-Python: >=3.8
22
23
  Description-Content-Type: text/x-rst
23
24
  License-File: LICENSE
24
25
  Provides-Extra: tests
25
26
  Requires-Dist: pytest!=3.3.0,>=3.2.1; extra == "tests"
26
27
  Provides-Extra: typecheck
27
28
  Requires-Dist: mypy; extra == "typecheck"
29
+ Dynamic: license-file
28
30
 
29
31
  bcrypt
30
32
  ======
@@ -79,6 +81,25 @@ While bcrypt remains an acceptable choice for password storage, depending on you
79
81
  Changelog
80
82
  =========
81
83
 
84
+ 5.0.0
85
+ -----
86
+
87
+ * Bumped MSRV to 1.74.
88
+ * Added support for Python 3.14 and free-threaded Python 3.14.
89
+ * Added support for Windows on ARM.
90
+ * Passing ``hashpw`` a password longer than 72 bytes now raises a
91
+ ``ValueError``. Previously the password was silently truncated, following the
92
+ behavior of the original OpenBSD ``bcrypt`` implementation.
93
+
94
+ 4.3.0
95
+ -----
96
+
97
+ * Dropped support for Python 3.7.
98
+ * We now support free-threaded Python 3.13.
99
+ * We now support PyPy 3.11.
100
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
101
+ ``manylinux``, and for ARMv7l on ``manylinux``.
102
+
82
103
  4.2.1
83
104
  -----
84
105
 
@@ -308,7 +329,7 @@ Compatibility
308
329
  -------------
309
330
 
310
331
  This library should be compatible with py-bcrypt and it will run on Python
311
- 3.6+, and PyPy 3.
332
+ 3.8+ (including free-threaded builds), and PyPy 3.
312
333
 
313
334
  Security
314
335
  --------
@@ -2,8 +2,8 @@
2
2
  LICENSE
3
3
  MANIFEST.in
4
4
  README.rst
5
+ noxfile.py
5
6
  pyproject.toml
6
- tox.ini
7
7
  src/_bcrypt/Cargo.lock
8
8
  src/_bcrypt/Cargo.toml
9
9
  src/_bcrypt/src/lib.rs
@@ -1,3 +1,6 @@
1
+ import uuid
2
+ from concurrent.futures import ThreadPoolExecutor
3
+
1
4
  import pytest
2
5
 
3
6
  import bcrypt
@@ -118,24 +121,6 @@ _test_vectors = [
118
121
  b"$2a$05$XXXXXXXXXXXXXXXXXXXXXO",
119
122
  b"$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a",
120
123
  ),
121
- (
122
- b"0123456789abcdefghijklmnopqrstuvwxyz"
123
- b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
124
- b"chars after 72 are ignored",
125
- b"$2a$05$abcdefghijklmnopqrstuu",
126
- b"$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui",
127
- ),
128
- (
129
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
130
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
131
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
132
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
133
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
134
- b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
135
- b"chars after 72 are ignored as usual",
136
- b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.",
137
- b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6",
138
- ),
139
124
  (
140
125
  b"\xa3",
141
126
  b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.",
@@ -171,7 +156,7 @@ _2y_test_vectors = [
171
156
  ]
172
157
 
173
158
 
174
- def test_gensalt_basic(monkeypatch):
159
+ def test_gensalt_basic():
175
160
  salt = bcrypt.gensalt()
176
161
  assert salt.startswith(b"$2b$12$")
177
162
 
@@ -219,7 +204,7 @@ def test_gensalt_bad_prefix():
219
204
  bcrypt.gensalt(prefix=b"bad")
220
205
 
221
206
 
222
- def test_gensalt_2a_prefix(monkeypatch):
207
+ def test_gensalt_2a_prefix():
223
208
  salt = bcrypt.gensalt(prefix=b"2a")
224
209
  assert salt.startswith(b"$2a$12$")
225
210
 
@@ -249,6 +234,25 @@ def test_checkpw_2y_prefix(password, hashed, expected):
249
234
  assert bcrypt.checkpw(password, hashed) is True
250
235
 
251
236
 
237
+ @pytest.mark.parametrize(
238
+ ("pw_length", "should_raise"),
239
+ [
240
+ (71, False),
241
+ (72, False),
242
+ (73, True),
243
+ ],
244
+ )
245
+ def test_hashpw_raises_correctly_for_long_passwords(pw_length, should_raise):
246
+ password = b"\xaa" * pw_length
247
+ salt = b"$2b$04$xnFVhJsTzsFBTeP3PpgbMe"
248
+
249
+ if should_raise:
250
+ with pytest.raises(ValueError):
251
+ bcrypt.hashpw(password, salt)
252
+ else:
253
+ bcrypt.hashpw(password, salt)
254
+
255
+
252
256
  def test_hashpw_invalid():
253
257
  with pytest.raises(ValueError):
254
258
  bcrypt.hashpw(b"password", b"$2z$04$cVWp4XaNU8a4v1uMRum2SO")
@@ -275,6 +279,8 @@ def test_checkpw_bad_salt():
275
279
  b"password",
276
280
  b"$2b$3$mdEQPMOtfPX.WGZNXgF66OhmBlOGKEd66SQ7DyJPGucYYmvTJYviy",
277
281
  )
282
+ with pytest.raises(ValueError):
283
+ bcrypt.checkpw(b"password", b"$2b$12$incorrect")
278
284
 
279
285
 
280
286
  def test_checkpw_str_password():
@@ -485,10 +491,22 @@ def test_invalid_params(password, salt, desired_key_bytes, rounds, error):
485
491
  bcrypt.kdf(password, salt, desired_key_bytes, rounds)
486
492
 
487
493
 
488
- def test_2a_wraparound_bug():
489
- assert (
490
- bcrypt.hashpw(
491
- (b"0123456789" * 26)[:255], b"$2a$04$R1lJ2gkNaoPGdafE.H.16."
492
- )
493
- == b"$2a$04$R1lJ2gkNaoPGdafE.H.16.1MKHPvmKwryeulRe225LKProWYwt9Oi"
494
- )
494
+ def test_multithreading():
495
+ def create_user(pw):
496
+ salt = bcrypt.gensalt(4)
497
+ hash_ = bcrypt.hashpw(pw, salt)
498
+ key = bcrypt.kdf(pw, salt, 32, 50)
499
+ assert bcrypt.checkpw(pw, hash_)
500
+ return (salt, hash_, key)
501
+
502
+ user_creator = ThreadPoolExecutor(max_workers=4)
503
+ pws = [uuid.uuid4().bytes for _ in range(50)]
504
+
505
+ futures = [user_creator.submit(create_user, pw) for pw in pws]
506
+
507
+ users = [future.result() for future in futures]
508
+
509
+ for pw, (salt, hash_, key) in zip(pws, users):
510
+ assert bcrypt.hashpw(pw, salt) == hash_
511
+ assert bcrypt.checkpw(pw, hash_)
512
+ assert bcrypt.kdf(pw, salt, 32, 50) == key
bcrypt-4.2.1/tox.ini DELETED
@@ -1,43 +0,0 @@
1
- [tox]
2
- isolated_build = True
3
-
4
- [testenv]
5
- extras =
6
- tests
7
- deps =
8
- coverage
9
- passenv =
10
- RUSTUP_HOME
11
- commands =
12
- coverage run -m pytest --strict-markers {posargs}
13
- coverage combine
14
- coverage report -m --fail-under 100
15
-
16
- [testenv:pep8]
17
- deps =
18
- ruff
19
- commands =
20
- ruff check .
21
- ruff format --check .
22
-
23
- [testenv:mypy]
24
- extras =
25
- tests
26
- deps =
27
- mypy
28
- commands =
29
- mypy tests/
30
-
31
- [testenv:packaging]
32
- deps =
33
- setuptools-rust
34
- check-manifest
35
- readme_renderer
36
- commands =
37
- check-manifest
38
- python3 -m readme_renderer README.rst -o /dev/null
39
-
40
-
41
- [check-manifest]
42
- ignore =
43
- tests/reference/*
File without changes
File without changes
File without changes
@@ -28,16 +28,16 @@ from ._bcrypt import (
28
28
  )
29
29
 
30
30
  __all__ = [
31
- "gensalt",
32
- "hashpw",
33
- "checkpw",
34
- "kdf",
35
- "__title__",
36
- "__summary__",
37
- "__uri__",
38
- "__version__",
39
31
  "__author__",
32
+ "__copyright__",
40
33
  "__email__",
41
34
  "__license__",
42
- "__copyright__",
35
+ "__summary__",
36
+ "__title__",
37
+ "__uri__",
38
+ "__version__",
39
+ "checkpw",
40
+ "gensalt",
41
+ "hashpw",
42
+ "kdf",
43
43
  ]
File without changes
File without changes