bcrypt 4.2.1__tar.gz → 4.3.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.2
2
2
  Name: bcrypt
3
- Version: 4.2.1
3
+ Version: 4.3.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,14 +11,13 @@ 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
+ Requires-Python: >=3.8
22
21
  Description-Content-Type: text/x-rst
23
22
  License-File: LICENSE
24
23
  Provides-Extra: tests
@@ -79,6 +78,15 @@ While bcrypt remains an acceptable choice for password storage, depending on you
79
78
  Changelog
80
79
  =========
81
80
 
81
+ Unreleased
82
+ ----------
83
+
84
+ * Dropped support for Python 3.7.
85
+ * We now support free-threaded Python 3.13.
86
+ * We now support PyPy 3.11.
87
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
88
+ ``manylinux``, and for ARMv7l on ``manylinux``.
89
+
82
90
  4.2.1
83
91
  -----
84
92
 
@@ -308,7 +316,7 @@ Compatibility
308
316
  -------------
309
317
 
310
318
  This library should be compatible with py-bcrypt and it will run on Python
311
- 3.6+, and PyPy 3.
319
+ 3.8+ (including free-threaded builds), and PyPy 3.
312
320
 
313
321
  Security
314
322
  --------
@@ -51,6 +51,15 @@ While bcrypt remains an acceptable choice for password storage, depending on you
51
51
  Changelog
52
52
  =========
53
53
 
54
+ Unreleased
55
+ ----------
56
+
57
+ * Dropped support for Python 3.7.
58
+ * We now support free-threaded Python 3.13.
59
+ * We now support PyPy 3.11.
60
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
61
+ ``manylinux``, and for ARMv7l on ``manylinux``.
62
+
54
63
  4.2.1
55
64
  -----
56
65
 
@@ -280,7 +289,7 @@ Compatibility
280
289
  -------------
281
290
 
282
291
  This library should be compatible with py-bcrypt and it will run on Python
283
- 3.6+, and PyPy 3.
292
+ 3.8+ (including free-threaded builds), and PyPy 3.
284
293
 
285
294
  Security
286
295
  --------
@@ -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 = "4.3.0"
15
15
  authors = [
16
16
  {name = "The Python Cryptographic Authority developers", email = "cryptography-dev@python.org"}
17
17
  ]
@@ -24,7 +24,6 @@ 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",
@@ -32,7 +31,7 @@ classifiers = [
32
31
  "Programming Language :: Python :: 3.12",
33
32
  "Programming Language :: Python :: 3.13",
34
33
  ]
35
- requires-python = ">= 3.7"
34
+ requires-python = ">= 3.8"
36
35
  dynamic = ["readme"]
37
36
 
38
37
  [project.urls]
@@ -73,3 +72,6 @@ warn_redundant_casts = true
73
72
  warn_unused_ignores = true
74
73
  warn_unused_configs = true
75
74
  strict_equality = true
75
+
76
+ [tool.check-manifest]
77
+ ignore = ["tests/reference/*"]
@@ -16,9 +16,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
16
16
 
17
17
  [[package]]
18
18
  name = "bcrypt"
19
- version = "0.16.0"
19
+ version = "0.17.0"
20
20
  source = "registry+https://github.com/rust-lang/crates.io-index"
21
- checksum = "2b1866ecef4f2d06a0bb77880015fdf2b89e25a1c2e5addacb87e459c86dc67e"
21
+ checksum = "92758ad6077e4c76a6cadbce5005f666df70d4f13b19976b1a8062eef880040f"
22
22
  dependencies = [
23
23
  "base64",
24
24
  "blowfish",
@@ -50,6 +50,12 @@ dependencies = [
50
50
  "subtle",
51
51
  ]
52
52
 
53
+ [[package]]
54
+ name = "bitflags"
55
+ version = "2.8.0"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
58
+
53
59
  [[package]]
54
60
  name = "block-buffer"
55
61
  version = "0.10.4"
@@ -93,9 +99,9 @@ dependencies = [
93
99
 
94
100
  [[package]]
95
101
  name = "cpufeatures"
96
- version = "0.2.15"
102
+ version = "0.2.17"
97
103
  source = "registry+https://github.com/rust-lang/crates.io-index"
98
- checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6"
104
+ checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
99
105
  dependencies = [
100
106
  "libc",
101
107
  ]
@@ -133,13 +139,14 @@ dependencies = [
133
139
 
134
140
  [[package]]
135
141
  name = "getrandom"
136
- version = "0.2.15"
142
+ version = "0.3.1"
137
143
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
144
+ checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
139
145
  dependencies = [
140
146
  "cfg-if",
141
147
  "libc",
142
148
  "wasi",
149
+ "windows-targets",
143
150
  ]
144
151
 
145
152
  [[package]]
@@ -156,18 +163,18 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
156
163
 
157
164
  [[package]]
158
165
  name = "inout"
159
- version = "0.1.3"
166
+ version = "0.1.4"
160
167
  source = "registry+https://github.com/rust-lang/crates.io-index"
161
- checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
168
+ checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
162
169
  dependencies = [
163
170
  "generic-array",
164
171
  ]
165
172
 
166
173
  [[package]]
167
174
  name = "libc"
168
- version = "0.2.164"
175
+ version = "0.2.170"
169
176
  source = "registry+https://github.com/rust-lang/crates.io-index"
170
- checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
177
+ checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
171
178
 
172
179
  [[package]]
173
180
  name = "memoffset"
@@ -180,9 +187,9 @@ dependencies = [
180
187
 
181
188
  [[package]]
182
189
  name = "once_cell"
183
- version = "1.20.2"
190
+ version = "1.20.3"
184
191
  source = "registry+https://github.com/rust-lang/crates.io-index"
185
- checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
192
+ checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
186
193
 
187
194
  [[package]]
188
195
  name = "pbkdf2"
@@ -195,24 +202,24 @@ dependencies = [
195
202
 
196
203
  [[package]]
197
204
  name = "portable-atomic"
198
- version = "1.9.0"
205
+ version = "1.11.0"
199
206
  source = "registry+https://github.com/rust-lang/crates.io-index"
200
- checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
207
+ checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
201
208
 
202
209
  [[package]]
203
210
  name = "proc-macro2"
204
- version = "1.0.89"
211
+ version = "1.0.93"
205
212
  source = "registry+https://github.com/rust-lang/crates.io-index"
206
- checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
213
+ checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
207
214
  dependencies = [
208
215
  "unicode-ident",
209
216
  ]
210
217
 
211
218
  [[package]]
212
219
  name = "pyo3"
213
- version = "0.23.1"
220
+ version = "0.23.5"
214
221
  source = "registry+https://github.com/rust-lang/crates.io-index"
215
- checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40"
222
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
216
223
  dependencies = [
217
224
  "cfg-if",
218
225
  "indoc",
@@ -228,9 +235,9 @@ dependencies = [
228
235
 
229
236
  [[package]]
230
237
  name = "pyo3-build-config"
231
- version = "0.23.1"
238
+ version = "0.23.5"
232
239
  source = "registry+https://github.com/rust-lang/crates.io-index"
233
- checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09"
240
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
234
241
  dependencies = [
235
242
  "once_cell",
236
243
  "target-lexicon",
@@ -238,9 +245,9 @@ dependencies = [
238
245
 
239
246
  [[package]]
240
247
  name = "pyo3-ffi"
241
- version = "0.23.1"
248
+ version = "0.23.5"
242
249
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75"
250
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
244
251
  dependencies = [
245
252
  "libc",
246
253
  "pyo3-build-config",
@@ -248,9 +255,9 @@ dependencies = [
248
255
 
249
256
  [[package]]
250
257
  name = "pyo3-macros"
251
- version = "0.23.1"
258
+ version = "0.23.5"
252
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
253
- checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a"
260
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
254
261
  dependencies = [
255
262
  "proc-macro2",
256
263
  "pyo3-macros-backend",
@@ -260,9 +267,9 @@ dependencies = [
260
267
 
261
268
  [[package]]
262
269
  name = "pyo3-macros-backend"
263
- version = "0.23.1"
270
+ version = "0.23.5"
264
271
  source = "registry+https://github.com/rust-lang/crates.io-index"
265
- checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8"
272
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
266
273
  dependencies = [
267
274
  "heck",
268
275
  "proc-macro2",
@@ -273,9 +280,9 @@ dependencies = [
273
280
 
274
281
  [[package]]
275
282
  name = "quote"
276
- version = "1.0.37"
283
+ version = "1.0.38"
277
284
  source = "registry+https://github.com/rust-lang/crates.io-index"
278
- checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
285
+ checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
279
286
  dependencies = [
280
287
  "proc-macro2",
281
288
  ]
@@ -299,9 +306,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
299
306
 
300
307
  [[package]]
301
308
  name = "syn"
302
- version = "2.0.87"
309
+ version = "2.0.98"
303
310
  source = "registry+https://github.com/rust-lang/crates.io-index"
304
- checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
311
+ checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
305
312
  dependencies = [
306
313
  "proc-macro2",
307
314
  "quote",
@@ -316,15 +323,15 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
316
323
 
317
324
  [[package]]
318
325
  name = "typenum"
319
- version = "1.17.0"
326
+ version = "1.18.0"
320
327
  source = "registry+https://github.com/rust-lang/crates.io-index"
321
- checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
328
+ checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
322
329
 
323
330
  [[package]]
324
331
  name = "unicode-ident"
325
- version = "1.0.13"
332
+ version = "1.0.17"
326
333
  source = "registry+https://github.com/rust-lang/crates.io-index"
327
- checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
334
+ checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
328
335
 
329
336
  [[package]]
330
337
  name = "unindent"
@@ -340,9 +347,85 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
340
347
 
341
348
  [[package]]
342
349
  name = "wasi"
343
- version = "0.11.0+wasi-snapshot-preview1"
350
+ version = "0.13.3+wasi-0.2.2"
351
+ source = "registry+https://github.com/rust-lang/crates.io-index"
352
+ checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
353
+ dependencies = [
354
+ "wit-bindgen-rt",
355
+ ]
356
+
357
+ [[package]]
358
+ name = "windows-targets"
359
+ version = "0.52.6"
360
+ source = "registry+https://github.com/rust-lang/crates.io-index"
361
+ checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
362
+ dependencies = [
363
+ "windows_aarch64_gnullvm",
364
+ "windows_aarch64_msvc",
365
+ "windows_i686_gnu",
366
+ "windows_i686_gnullvm",
367
+ "windows_i686_msvc",
368
+ "windows_x86_64_gnu",
369
+ "windows_x86_64_gnullvm",
370
+ "windows_x86_64_msvc",
371
+ ]
372
+
373
+ [[package]]
374
+ name = "windows_aarch64_gnullvm"
375
+ version = "0.52.6"
376
+ source = "registry+https://github.com/rust-lang/crates.io-index"
377
+ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
378
+
379
+ [[package]]
380
+ name = "windows_aarch64_msvc"
381
+ version = "0.52.6"
344
382
  source = "registry+https://github.com/rust-lang/crates.io-index"
345
- checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
383
+ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
384
+
385
+ [[package]]
386
+ name = "windows_i686_gnu"
387
+ version = "0.52.6"
388
+ source = "registry+https://github.com/rust-lang/crates.io-index"
389
+ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
390
+
391
+ [[package]]
392
+ name = "windows_i686_gnullvm"
393
+ version = "0.52.6"
394
+ source = "registry+https://github.com/rust-lang/crates.io-index"
395
+ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
396
+
397
+ [[package]]
398
+ name = "windows_i686_msvc"
399
+ version = "0.52.6"
400
+ source = "registry+https://github.com/rust-lang/crates.io-index"
401
+ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
402
+
403
+ [[package]]
404
+ name = "windows_x86_64_gnu"
405
+ version = "0.52.6"
406
+ source = "registry+https://github.com/rust-lang/crates.io-index"
407
+ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
408
+
409
+ [[package]]
410
+ name = "windows_x86_64_gnullvm"
411
+ version = "0.52.6"
412
+ source = "registry+https://github.com/rust-lang/crates.io-index"
413
+ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
414
+
415
+ [[package]]
416
+ name = "windows_x86_64_msvc"
417
+ version = "0.52.6"
418
+ source = "registry+https://github.com/rust-lang/crates.io-index"
419
+ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
420
+
421
+ [[package]]
422
+ name = "wit-bindgen-rt"
423
+ version = "0.33.0"
424
+ source = "registry+https://github.com/rust-lang/crates.io-index"
425
+ checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
426
+ dependencies = [
427
+ "bitflags",
428
+ ]
346
429
 
347
430
  [[package]]
348
431
  name = "zeroize"
@@ -6,12 +6,12 @@ edition = "2018"
6
6
  publish = false
7
7
 
8
8
  [dependencies]
9
- pyo3 = { version = "0.23", features = ["abi3"] }
10
- bcrypt = "0.16"
9
+ pyo3 = { version = "0.23.5", features = ["abi3"] }
10
+ bcrypt = "0.17"
11
11
  bcrypt-pbkdf = "0.10.0"
12
12
  base64 = "0.22.1"
13
13
  subtle = "2.6"
14
- getrandom = "0.2"
14
+ getrandom = "0.3"
15
15
 
16
16
  [features]
17
17
  extension-module = ["pyo3/extension-module"]
@@ -46,7 +46,7 @@ fn gensalt<'p>(
46
46
  }
47
47
 
48
48
  let mut salt = [0; 16];
49
- getrandom::getrandom(&mut salt).unwrap();
49
+ getrandom::fill(&mut salt).unwrap();
50
50
 
51
51
  let encoded_salt = BASE64_ENGINE.encode(salt);
52
52
 
@@ -83,14 +83,14 @@ fn hashpw<'p>(
83
83
  // salt here is not just the salt bytes, but rather an encoded value
84
84
  // containing a version number, number of rounds, and the salt.
85
85
  // Should be [prefix, cost, hash]. This logic is copied from `bcrypt`
86
- let raw_parts: Vec<_> = salt
86
+ let [raw_version, raw_cost, remainder]: [&[u8]; 3] = salt
87
87
  .split(|&b| b == b'$')
88
88
  .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] {
89
+ .collect::<Vec<_>>()
90
+ .try_into()
91
+ .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
92
+
93
+ let version = match raw_version {
94
94
  b"2y" => bcrypt::Version::TwoY,
95
95
  b"2b" => bcrypt::Version::TwoB,
96
96
  b"2a" => bcrypt::Version::TwoA,
@@ -99,15 +99,20 @@ fn hashpw<'p>(
99
99
  return Err(pyo3::exceptions::PyValueError::new_err("Invalid salt"));
100
100
  }
101
101
  };
102
- let cost = std::str::from_utf8(raw_parts[1])
102
+ let cost = std::str::from_utf8(raw_cost)
103
103
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?
104
104
  .parse::<u32>()
105
105
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
106
+
107
+ if remainder.len() < 22 {
108
+ return Err(pyo3::exceptions::PyValueError::new_err("Invalid salt"));
109
+ }
110
+
106
111
  // The last component can contain either just the salt, or the salt and
107
112
  // the result hash, depending on if the `salt` value come from `hashpw` or
108
113
  // `gensalt`.
109
114
  let raw_salt = BASE64_ENGINE
110
- .decode(&raw_parts[2][..22])
115
+ .decode(&remainder[..22])
111
116
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?
112
117
  .try_into()
113
118
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
@@ -177,7 +182,7 @@ fn kdf<'p>(
177
182
  })
178
183
  }
179
184
 
180
- #[pyo3::pymodule]
185
+ #[pyo3::pymodule(gil_used = false)]
181
186
  mod _bcrypt {
182
187
  use pyo3::types::PyModuleMethods;
183
188
 
@@ -197,14 +202,14 @@ mod _bcrypt {
197
202
  // When updating this, also update pyproject.toml
198
203
  // This isn't named __version__ because passlib treats the existence of
199
204
  // that attribute as proof that we're a different module
200
- m.add("__version_ex__", "4.2.1")?;
205
+ m.add("__version_ex__", "4.3.0")?;
201
206
 
202
207
  let author = "The Python Cryptographic Authority developers";
203
208
  m.add("__author__", author)?;
204
209
  m.add("__email__", "cryptography-dev@python.org")?;
205
210
 
206
211
  m.add("__license__", "Apache License, Version 2.0")?;
207
- m.add("__copyright__", format!("Copyright 2013-2024 {author}"))?;
212
+ m.add("__copyright__", format!("Copyright 2013-2025 {author}"))?;
208
213
 
209
214
  Ok(())
210
215
  }
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: bcrypt
3
- Version: 4.2.1
3
+ Version: 4.3.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,14 +11,13 @@ 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
+ Requires-Python: >=3.8
22
21
  Description-Content-Type: text/x-rst
23
22
  License-File: LICENSE
24
23
  Provides-Extra: tests
@@ -79,6 +78,15 @@ While bcrypt remains an acceptable choice for password storage, depending on you
79
78
  Changelog
80
79
  =========
81
80
 
81
+ Unreleased
82
+ ----------
83
+
84
+ * Dropped support for Python 3.7.
85
+ * We now support free-threaded Python 3.13.
86
+ * We now support PyPy 3.11.
87
+ * We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
88
+ ``manylinux``, and for ARMv7l on ``manylinux``.
89
+
82
90
  4.2.1
83
91
  -----
84
92
 
@@ -308,7 +316,7 @@ Compatibility
308
316
  -------------
309
317
 
310
318
  This library should be compatible with py-bcrypt and it will run on Python
311
- 3.6+, and PyPy 3.
319
+ 3.8+ (including free-threaded builds), and PyPy 3.
312
320
 
313
321
  Security
314
322
  --------
@@ -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
@@ -171,7 +174,7 @@ _2y_test_vectors = [
171
174
  ]
172
175
 
173
176
 
174
- def test_gensalt_basic(monkeypatch):
177
+ def test_gensalt_basic():
175
178
  salt = bcrypt.gensalt()
176
179
  assert salt.startswith(b"$2b$12$")
177
180
 
@@ -219,7 +222,7 @@ def test_gensalt_bad_prefix():
219
222
  bcrypt.gensalt(prefix=b"bad")
220
223
 
221
224
 
222
- def test_gensalt_2a_prefix(monkeypatch):
225
+ def test_gensalt_2a_prefix():
223
226
  salt = bcrypt.gensalt(prefix=b"2a")
224
227
  assert salt.startswith(b"$2a$12$")
225
228
 
@@ -275,6 +278,8 @@ def test_checkpw_bad_salt():
275
278
  b"password",
276
279
  b"$2b$3$mdEQPMOtfPX.WGZNXgF66OhmBlOGKEd66SQ7DyJPGucYYmvTJYviy",
277
280
  )
281
+ with pytest.raises(ValueError):
282
+ bcrypt.checkpw(b"password", b"$2b$12$incorrect")
278
283
 
279
284
 
280
285
  def test_checkpw_str_password():
@@ -492,3 +497,24 @@ def test_2a_wraparound_bug():
492
497
  )
493
498
  == b"$2a$04$R1lJ2gkNaoPGdafE.H.16.1MKHPvmKwryeulRe225LKProWYwt9Oi"
494
499
  )
500
+
501
+
502
+ def test_multithreading():
503
+ def create_user(pw):
504
+ salt = bcrypt.gensalt(4)
505
+ hash_ = bcrypt.hashpw(pw, salt)
506
+ key = bcrypt.kdf(pw, salt, 32, 50)
507
+ assert bcrypt.checkpw(pw, hash_)
508
+ return (salt, hash_, key)
509
+
510
+ user_creator = ThreadPoolExecutor(max_workers=4)
511
+ pws = [uuid.uuid4().bytes for _ in range(50)]
512
+
513
+ futures = [user_creator.submit(create_user, pw) for pw in pws]
514
+
515
+ users = [future.result() for future in futures]
516
+
517
+ for pw, (salt, hash_, key) in zip(pws, users):
518
+ assert bcrypt.hashpw(pw, salt) == hash_
519
+ assert bcrypt.checkpw(pw, hash_)
520
+ 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