bcrypt 4.1.2__tar.gz → 4.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcrypt
3
- Version: 4.1.2
3
+ Version: 4.2.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
@@ -78,6 +78,17 @@ While bcrypt remains an acceptable choice for password storage, depending on you
78
78
  Changelog
79
79
  =========
80
80
 
81
+ 4.2.0
82
+ -----
83
+
84
+ * Bump Rust dependency versions
85
+ * Removed the ``BCRYPT_ALLOW_RUST_163`` environment variable.
86
+
87
+ 4.1.3
88
+ -----
89
+
90
+ * Bump Rust dependency versions
91
+
81
92
  4.1.2
82
93
  -----
83
94
 
@@ -291,11 +302,6 @@ Compatibility
291
302
  This library should be compatible with py-bcrypt and it will run on Python
292
303
  3.6+, and PyPy 3.
293
304
 
294
- C Code
295
- ------
296
-
297
- This library uses code from OpenBSD.
298
-
299
305
  Security
300
306
  --------
301
307
 
@@ -51,6 +51,17 @@ While bcrypt remains an acceptable choice for password storage, depending on you
51
51
  Changelog
52
52
  =========
53
53
 
54
+ 4.2.0
55
+ -----
56
+
57
+ * Bump Rust dependency versions
58
+ * Removed the ``BCRYPT_ALLOW_RUST_163`` environment variable.
59
+
60
+ 4.1.3
61
+ -----
62
+
63
+ * Bump Rust dependency versions
64
+
54
65
  4.1.2
55
66
  -----
56
67
 
@@ -264,11 +275,6 @@ Compatibility
264
275
  This library should be compatible with py-bcrypt and it will run on Python
265
276
  3.6+, and PyPy 3.
266
277
 
267
- C Code
268
- ------
269
-
270
- This library uses code from OpenBSD.
271
-
272
278
  Security
273
279
  --------
274
280
 
@@ -1,9 +1,8 @@
1
1
  [build-system]
2
- # Must be kept in sync with `setup_requirements` in `setup.py`
3
2
  requires = [
4
3
  "setuptools>=42.0.0",
5
4
  "wheel",
6
- "setuptools-rust",
5
+ "setuptools-rust>=1.7.0",
7
6
  ]
8
7
  # Point to the setuptools' PEP517 build backend explicitly to
9
8
  # disable Pip's fallback guessing
@@ -12,7 +11,7 @@ build-backend = "setuptools.build_meta"
12
11
  [project]
13
12
  name = "bcrypt"
14
13
  # When updating this, also update lib.rs
15
- version = "4.1.2"
14
+ version = "4.2.0"
16
15
  authors = [
17
16
  {name = "The Python Cryptographic Authority developers", email = "cryptography-dev@python.org"}
18
17
  ]
@@ -50,13 +49,19 @@ readme = {file = "README.rst", content-type = "text/x-rst"}
50
49
  tests = ["pytest>=3.2.1,!=3.3.0"]
51
50
  typecheck = ["mypy"]
52
51
 
52
+ [[tool.setuptools-rust.ext-modules]]
53
+ target = "bcrypt._bcrypt"
54
+ path = "src/_bcrypt/Cargo.toml"
55
+ py-limited-api = "auto"
56
+ rust-version = ">=1.64.0"
53
57
 
54
58
  [tool.ruff]
55
- ignore = ['N818']
56
- select = ['E', 'F', 'I', 'N', 'W', 'UP', 'RUF']
57
59
  line-length = 79
58
60
 
59
- [tool.ruff.isort]
61
+ lint.ignore = ['N818']
62
+ lint.select = ['E', 'F', 'I', 'N', 'W', 'UP', 'RUF']
63
+
64
+ [tool.ruff.lint.isort]
60
65
  known-first-party = ["bcrypt", "tests"]
61
66
 
62
67
  [tool.mypy]
@@ -4,21 +4,21 @@ version = 3
4
4
 
5
5
  [[package]]
6
6
  name = "autocfg"
7
- version = "1.1.0"
7
+ version = "1.3.0"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
9
+ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
10
10
 
11
11
  [[package]]
12
12
  name = "base64"
13
- version = "0.21.5"
13
+ version = "0.22.1"
14
14
  source = "registry+https://github.com/rust-lang/crates.io-index"
15
- checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
15
+ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
16
16
 
17
17
  [[package]]
18
18
  name = "bcrypt"
19
- version = "0.15.0"
19
+ version = "0.15.1"
20
20
  source = "registry+https://github.com/rust-lang/crates.io-index"
21
- checksum = "28d1c9c15093eb224f0baa400f38fcd713fc1391a6f1c389d886beef146d60a3"
21
+ checksum = "e65938ed058ef47d92cf8b346cc76ef48984572ade631927e9937b5ffc7662c7"
22
22
  dependencies = [
23
23
  "base64",
24
24
  "blowfish",
@@ -50,12 +50,6 @@ dependencies = [
50
50
  "subtle",
51
51
  ]
52
52
 
53
- [[package]]
54
- name = "bitflags"
55
- version = "1.3.2"
56
- source = "registry+https://github.com/rust-lang/crates.io-index"
57
- checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
58
-
59
53
  [[package]]
60
54
  name = "block-buffer"
61
55
  version = "0.10.4"
@@ -99,9 +93,9 @@ dependencies = [
99
93
 
100
94
  [[package]]
101
95
  name = "cpufeatures"
102
- version = "0.2.11"
96
+ version = "0.2.12"
103
97
  source = "registry+https://github.com/rust-lang/crates.io-index"
104
- checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0"
98
+ checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
105
99
  dependencies = [
106
100
  "libc",
107
101
  ]
@@ -139,9 +133,9 @@ dependencies = [
139
133
 
140
134
  [[package]]
141
135
  name = "getrandom"
142
- version = "0.2.11"
136
+ version = "0.2.15"
143
137
  source = "registry+https://github.com/rust-lang/crates.io-index"
144
- checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
138
+ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
145
139
  dependencies = [
146
140
  "cfg-if",
147
141
  "libc",
@@ -150,15 +144,15 @@ dependencies = [
150
144
 
151
145
  [[package]]
152
146
  name = "heck"
153
- version = "0.4.1"
147
+ version = "0.5.0"
154
148
  source = "registry+https://github.com/rust-lang/crates.io-index"
155
- checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
149
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
156
150
 
157
151
  [[package]]
158
152
  name = "indoc"
159
- version = "2.0.4"
153
+ version = "2.0.5"
160
154
  source = "registry+https://github.com/rust-lang/crates.io-index"
161
- checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
155
+ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
162
156
 
163
157
  [[package]]
164
158
  name = "inout"
@@ -171,25 +165,15 @@ dependencies = [
171
165
 
172
166
  [[package]]
173
167
  name = "libc"
174
- version = "0.2.151"
168
+ version = "0.2.155"
175
169
  source = "registry+https://github.com/rust-lang/crates.io-index"
176
- checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
177
-
178
- [[package]]
179
- name = "lock_api"
180
- version = "0.4.11"
181
- source = "registry+https://github.com/rust-lang/crates.io-index"
182
- checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
183
- dependencies = [
184
- "autocfg",
185
- "scopeguard",
186
- ]
170
+ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
187
171
 
188
172
  [[package]]
189
173
  name = "memoffset"
190
- version = "0.9.0"
174
+ version = "0.9.1"
191
175
  source = "registry+https://github.com/rust-lang/crates.io-index"
192
- checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
176
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
193
177
  dependencies = [
194
178
  "autocfg",
195
179
  ]
@@ -200,29 +184,6 @@ version = "1.19.0"
200
184
  source = "registry+https://github.com/rust-lang/crates.io-index"
201
185
  checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
202
186
 
203
- [[package]]
204
- name = "parking_lot"
205
- version = "0.12.1"
206
- source = "registry+https://github.com/rust-lang/crates.io-index"
207
- checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
208
- dependencies = [
209
- "lock_api",
210
- "parking_lot_core",
211
- ]
212
-
213
- [[package]]
214
- name = "parking_lot_core"
215
- version = "0.9.9"
216
- source = "registry+https://github.com/rust-lang/crates.io-index"
217
- checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
218
- dependencies = [
219
- "cfg-if",
220
- "libc",
221
- "redox_syscall",
222
- "smallvec",
223
- "windows-targets",
224
- ]
225
-
226
187
  [[package]]
227
188
  name = "pbkdf2"
228
189
  version = "0.12.2"
@@ -232,26 +193,33 @@ dependencies = [
232
193
  "digest",
233
194
  ]
234
195
 
196
+ [[package]]
197
+ name = "portable-atomic"
198
+ version = "1.7.0"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265"
201
+
235
202
  [[package]]
236
203
  name = "proc-macro2"
237
- version = "1.0.70"
204
+ version = "1.0.86"
238
205
  source = "registry+https://github.com/rust-lang/crates.io-index"
239
- checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
206
+ checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
240
207
  dependencies = [
241
208
  "unicode-ident",
242
209
  ]
243
210
 
244
211
  [[package]]
245
212
  name = "pyo3"
246
- version = "0.20.0"
213
+ version = "0.22.2"
247
214
  source = "registry+https://github.com/rust-lang/crates.io-index"
248
- checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b"
215
+ checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433"
249
216
  dependencies = [
250
217
  "cfg-if",
251
218
  "indoc",
252
219
  "libc",
253
220
  "memoffset",
254
- "parking_lot",
221
+ "once_cell",
222
+ "portable-atomic",
255
223
  "pyo3-build-config",
256
224
  "pyo3-ffi",
257
225
  "pyo3-macros",
@@ -260,9 +228,9 @@ dependencies = [
260
228
 
261
229
  [[package]]
262
230
  name = "pyo3-build-config"
263
- version = "0.20.0"
231
+ version = "0.22.2"
264
232
  source = "registry+https://github.com/rust-lang/crates.io-index"
265
- checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5"
233
+ checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8"
266
234
  dependencies = [
267
235
  "once_cell",
268
236
  "target-lexicon",
@@ -270,9 +238,9 @@ dependencies = [
270
238
 
271
239
  [[package]]
272
240
  name = "pyo3-ffi"
273
- version = "0.20.0"
241
+ version = "0.22.2"
274
242
  source = "registry+https://github.com/rust-lang/crates.io-index"
275
- checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b"
243
+ checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6"
276
244
  dependencies = [
277
245
  "libc",
278
246
  "pyo3-build-config",
@@ -280,9 +248,9 @@ dependencies = [
280
248
 
281
249
  [[package]]
282
250
  name = "pyo3-macros"
283
- version = "0.20.0"
251
+ version = "0.22.2"
284
252
  source = "registry+https://github.com/rust-lang/crates.io-index"
285
- checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b"
253
+ checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206"
286
254
  dependencies = [
287
255
  "proc-macro2",
288
256
  "pyo3-macros-backend",
@@ -292,40 +260,26 @@ dependencies = [
292
260
 
293
261
  [[package]]
294
262
  name = "pyo3-macros-backend"
295
- version = "0.20.0"
263
+ version = "0.22.2"
296
264
  source = "registry+https://github.com/rust-lang/crates.io-index"
297
- checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424"
265
+ checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372"
298
266
  dependencies = [
299
267
  "heck",
300
268
  "proc-macro2",
269
+ "pyo3-build-config",
301
270
  "quote",
302
271
  "syn",
303
272
  ]
304
273
 
305
274
  [[package]]
306
275
  name = "quote"
307
- version = "1.0.33"
276
+ version = "1.0.36"
308
277
  source = "registry+https://github.com/rust-lang/crates.io-index"
309
- checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
278
+ checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
310
279
  dependencies = [
311
280
  "proc-macro2",
312
281
  ]
313
282
 
314
- [[package]]
315
- name = "redox_syscall"
316
- version = "0.4.1"
317
- source = "registry+https://github.com/rust-lang/crates.io-index"
318
- checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
319
- dependencies = [
320
- "bitflags",
321
- ]
322
-
323
- [[package]]
324
- name = "scopeguard"
325
- version = "1.2.0"
326
- source = "registry+https://github.com/rust-lang/crates.io-index"
327
- checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
328
-
329
283
  [[package]]
330
284
  name = "sha2"
331
285
  version = "0.10.8"
@@ -337,23 +291,17 @@ dependencies = [
337
291
  "digest",
338
292
  ]
339
293
 
340
- [[package]]
341
- name = "smallvec"
342
- version = "1.11.2"
343
- source = "registry+https://github.com/rust-lang/crates.io-index"
344
- checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
345
-
346
294
  [[package]]
347
295
  name = "subtle"
348
- version = "2.5.0"
296
+ version = "2.6.1"
349
297
  source = "registry+https://github.com/rust-lang/crates.io-index"
350
- checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
298
+ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
351
299
 
352
300
  [[package]]
353
301
  name = "syn"
354
- version = "2.0.41"
302
+ version = "2.0.72"
355
303
  source = "registry+https://github.com/rust-lang/crates.io-index"
356
- checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269"
304
+ checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
357
305
  dependencies = [
358
306
  "proc-macro2",
359
307
  "quote",
@@ -362,9 +310,9 @@ dependencies = [
362
310
 
363
311
  [[package]]
364
312
  name = "target-lexicon"
365
- version = "0.12.12"
313
+ version = "0.12.15"
366
314
  source = "registry+https://github.com/rust-lang/crates.io-index"
367
- checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
315
+ checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
368
316
 
369
317
  [[package]]
370
318
  name = "typenum"
@@ -396,65 +344,8 @@ version = "0.11.0+wasi-snapshot-preview1"
396
344
  source = "registry+https://github.com/rust-lang/crates.io-index"
397
345
  checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
398
346
 
399
- [[package]]
400
- name = "windows-targets"
401
- version = "0.48.5"
402
- source = "registry+https://github.com/rust-lang/crates.io-index"
403
- checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
404
- dependencies = [
405
- "windows_aarch64_gnullvm",
406
- "windows_aarch64_msvc",
407
- "windows_i686_gnu",
408
- "windows_i686_msvc",
409
- "windows_x86_64_gnu",
410
- "windows_x86_64_gnullvm",
411
- "windows_x86_64_msvc",
412
- ]
413
-
414
- [[package]]
415
- name = "windows_aarch64_gnullvm"
416
- version = "0.48.5"
417
- source = "registry+https://github.com/rust-lang/crates.io-index"
418
- checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
419
-
420
- [[package]]
421
- name = "windows_aarch64_msvc"
422
- version = "0.48.5"
423
- source = "registry+https://github.com/rust-lang/crates.io-index"
424
- checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
425
-
426
- [[package]]
427
- name = "windows_i686_gnu"
428
- version = "0.48.5"
429
- source = "registry+https://github.com/rust-lang/crates.io-index"
430
- checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
431
-
432
- [[package]]
433
- name = "windows_i686_msvc"
434
- version = "0.48.5"
435
- source = "registry+https://github.com/rust-lang/crates.io-index"
436
- checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
437
-
438
- [[package]]
439
- name = "windows_x86_64_gnu"
440
- version = "0.48.5"
441
- source = "registry+https://github.com/rust-lang/crates.io-index"
442
- checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
443
-
444
- [[package]]
445
- name = "windows_x86_64_gnullvm"
446
- version = "0.48.5"
447
- source = "registry+https://github.com/rust-lang/crates.io-index"
448
- checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
449
-
450
- [[package]]
451
- name = "windows_x86_64_msvc"
452
- version = "0.48.5"
453
- source = "registry+https://github.com/rust-lang/crates.io-index"
454
- checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
455
-
456
347
  [[package]]
457
348
  name = "zeroize"
458
- version = "1.7.0"
349
+ version = "1.8.1"
459
350
  source = "registry+https://github.com/rust-lang/crates.io-index"
460
- checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
351
+ checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
@@ -6,11 +6,11 @@ edition = "2018"
6
6
  publish = false
7
7
 
8
8
  [dependencies]
9
- pyo3 = { version = "0.20.0", features = ["abi3"] }
9
+ pyo3 = { version = "0.22", features = ["abi3"] }
10
10
  bcrypt = "0.15"
11
11
  bcrypt-pbkdf = "0.10.0"
12
- base64 = "0.21.5"
13
- subtle = "2.5"
12
+ base64 = "0.22.1"
13
+ subtle = "2.6"
14
14
  getrandom = "0.2"
15
15
 
16
16
  [features]
@@ -1,10 +1,19 @@
1
- // This file is dual licensed under the terms of the Apache License, Version
2
- // 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
- // for complete details.
1
+ // Licensed under the Apache License, Version 2.0 (the "License");
2
+ // you may not use this file except in compliance with the License.
3
+ // You may obtain a copy of the License at
4
+ //
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+ //
7
+ // Unless required by applicable law or agreed to in writing, software
8
+ // distributed under the License is distributed on an "AS IS" BASIS,
9
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ // See the License for the specific language governing permissions and
11
+ // limitations under the License.
4
12
 
5
13
  #![deny(rust_2018_idioms)]
6
14
 
7
15
  use base64::Engine;
16
+ use pyo3::types::PyBytesMethods;
8
17
  use pyo3::PyTypeInfo;
9
18
  use std::convert::TryInto;
10
19
  use std::io::Write;
@@ -15,12 +24,13 @@ pub const BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::Genera
15
24
  base64::engine::general_purpose::NO_PAD,
16
25
  );
17
26
 
18
- #[pyo3::prelude::pyfunction]
27
+ #[pyo3::pyfunction]
28
+ #[pyo3(signature = (rounds=None, prefix=None))]
19
29
  fn gensalt<'p>(
20
30
  py: pyo3::Python<'p>,
21
31
  rounds: Option<u16>,
22
32
  prefix: Option<&[u8]>,
23
- ) -> pyo3::PyResult<&'p pyo3::types::PyBytes> {
33
+ ) -> pyo3::PyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
24
34
  let rounds = rounds.unwrap_or(12);
25
35
  let prefix = prefix.unwrap_or(b"2b");
26
36
 
@@ -39,7 +49,7 @@ fn gensalt<'p>(
39
49
 
40
50
  let encoded_salt = BASE64_ENGINE.encode(salt);
41
51
 
42
- pyo3::types::PyBytes::new_with(
52
+ pyo3::types::PyBytes::new_bound_with(
43
53
  py,
44
54
  1 + prefix.len() + 1 + 2 + 1 + encoded_salt.len(),
45
55
  |mut b| {
@@ -55,12 +65,12 @@ fn gensalt<'p>(
55
65
  )
56
66
  }
57
67
 
58
- #[pyo3::prelude::pyfunction]
68
+ #[pyo3::pyfunction]
59
69
  fn hashpw<'p>(
60
70
  py: pyo3::Python<'p>,
61
71
  password: &[u8],
62
72
  salt: &[u8],
63
- ) -> pyo3::PyResult<&'p pyo3::types::PyBytes> {
73
+ ) -> pyo3::PyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
64
74
  // bcrypt originally suffered from a wraparound bug:
65
75
  // http://www.openwall.com/lists/oss-security/2012/01/02/4
66
76
  // This bug was corrected in the OpenBSD source by truncating inputs to 72
@@ -104,35 +114,30 @@ fn hashpw<'p>(
104
114
  let hashed = py
105
115
  .allow_threads(|| bcrypt::hash_with_salt(password, cost, raw_salt))
106
116
  .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
107
- Ok(pyo3::types::PyBytes::new(
117
+ Ok(pyo3::types::PyBytes::new_bound(
108
118
  py,
109
119
  hashed.format_for_version(version).as_bytes(),
110
120
  ))
111
121
  }
112
122
 
113
- #[pyo3::prelude::pyfunction]
114
- fn checkpw(
115
- py: pyo3::Python<'_>,
116
- password: &[u8],
117
- hashed_password: &[u8],
118
- ) -> pyo3::PyResult<bool> {
123
+ #[pyo3::pyfunction]
124
+ fn checkpw(py: pyo3::Python<'_>, password: &[u8], hashed_password: &[u8]) -> pyo3::PyResult<bool> {
119
125
  Ok(hashpw(py, password, hashed_password)?
120
126
  .as_bytes()
121
127
  .ct_eq(hashed_password)
122
128
  .into())
123
129
  }
124
130
 
125
- #[pyo3::prelude::pyfunction]
131
+ #[pyo3::pyfunction]
132
+ #[pyo3(signature = (password, salt, desired_key_bytes, rounds, ignore_few_rounds=false))]
126
133
  fn kdf<'p>(
127
134
  py: pyo3::Python<'p>,
128
135
  password: &[u8],
129
136
  salt: &[u8],
130
137
  desired_key_bytes: usize,
131
138
  rounds: u32,
132
- ignore_few_rounds: Option<bool>,
133
- ) -> pyo3::PyResult<&'p pyo3::types::PyBytes> {
134
- let ignore_few_rounds = ignore_few_rounds.unwrap_or(false);
135
-
139
+ ignore_few_rounds: bool,
140
+ ) -> pyo3::PyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
136
141
  if password.is_empty() || salt.is_empty() {
137
142
  return Err(pyo3::exceptions::PyValueError::new_err(
138
143
  "password and salt must not be empty",
@@ -155,15 +160,15 @@ fn kdf<'p>(
155
160
  // They probably think bcrypt.kdf()'s rounds parameter is logarithmic,
156
161
  // expecting this value to be slow enough (it probably would be if this
157
162
  // were bcrypt). Emit a warning.
158
- pyo3::PyErr::warn(
163
+ pyo3::PyErr::warn_bound(
159
164
  py,
160
- pyo3::exceptions::PyUserWarning::type_object(py),
165
+ &pyo3::exceptions::PyUserWarning::type_object_bound(py),
161
166
  &format!("Warning: bcrypt.kdf() called with only {rounds} round(s). This few is not secure: the parameter is linear, like PBKDF2."),
162
167
  3
163
168
  )?;
164
169
  }
165
170
 
166
- pyo3::types::PyBytes::new_with(py, desired_key_bytes, |output| {
171
+ pyo3::types::PyBytes::new_bound_with(py, desired_key_bytes, |output| {
167
172
  py.allow_threads(|| {
168
173
  bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, output).unwrap();
169
174
  });
@@ -171,28 +176,35 @@ fn kdf<'p>(
171
176
  })
172
177
  }
173
178
 
174
- #[pyo3::prelude::pymodule]
175
- fn _bcrypt(_py: pyo3::Python<'_>, m: &pyo3::types::PyModule) -> pyo3::PyResult<()> {
176
- m.add_function(pyo3::wrap_pyfunction!(gensalt, m)?)?;
177
- m.add_function(pyo3::wrap_pyfunction!(hashpw, m)?)?;
178
- m.add_function(pyo3::wrap_pyfunction!(checkpw, m)?)?;
179
- m.add_function(pyo3::wrap_pyfunction!(kdf, m)?)?;
179
+ #[pyo3::pymodule]
180
+ mod _bcrypt {
181
+ use pyo3::types::PyModuleMethods;
182
+
183
+ #[pymodule_export]
184
+ use super::{checkpw, gensalt, hashpw, kdf};
180
185
 
181
- m.add("__title__", "bcrypt")?;
182
- m.add("__summary__", "Modern(-ish) password hashing for your software and your servers")?;
183
- m.add("__uri__", "https://github.com/pyca/bcrypt/")?;
186
+ // Not yet possible to add constants declaratively.
187
+ #[pymodule_init]
188
+ fn init(m: &pyo3::Bound<'_, pyo3::types::PyModule>) -> pyo3::PyResult<()> {
189
+ m.add("__title__", "bcrypt")?;
190
+ m.add(
191
+ "__summary__",
192
+ "Modern(-ish) password hashing for your software and your servers",
193
+ )?;
194
+ m.add("__uri__", "https://github.com/pyca/bcrypt/")?;
184
195
 
185
- // When updating this, also update pyproject.toml
186
- // This isn't named __version__ because passlib treats the existence of
187
- // that attribute as proof that we're a different module
188
- m.add("__version_ex__", "4.1.2")?;
196
+ // When updating this, also update pyproject.toml
197
+ // This isn't named __version__ because passlib treats the existence of
198
+ // that attribute as proof that we're a different module
199
+ m.add("__version_ex__", "4.2.0")?;
189
200
 
190
- let author = "The Python Cryptographic Authority developers";
191
- m.add("__author__", author)?;
192
- m.add("__email__", "cryptography-dev@python.org")?;
201
+ let author = "The Python Cryptographic Authority developers";
202
+ m.add("__author__", author)?;
203
+ m.add("__email__", "cryptography-dev@python.org")?;
193
204
 
194
- m.add("__license__", "Apache License, Version 2.0")?;
195
- m.add("__copyright__", format!("Copyright 2013-2023 {author}"))?;
205
+ m.add("__license__", "Apache License, Version 2.0")?;
206
+ m.add("__copyright__", format!("Copyright 2013-2024 {author}"))?;
196
207
 
197
- Ok(())
208
+ Ok(())
209
+ }
198
210
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcrypt
3
- Version: 4.1.2
3
+ Version: 4.2.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
@@ -78,6 +78,17 @@ While bcrypt remains an acceptable choice for password storage, depending on you
78
78
  Changelog
79
79
  =========
80
80
 
81
+ 4.2.0
82
+ -----
83
+
84
+ * Bump Rust dependency versions
85
+ * Removed the ``BCRYPT_ALLOW_RUST_163`` environment variable.
86
+
87
+ 4.1.3
88
+ -----
89
+
90
+ * Bump Rust dependency versions
91
+
81
92
  4.1.2
82
93
  -----
83
94
 
@@ -291,11 +302,6 @@ Compatibility
291
302
  This library should be compatible with py-bcrypt and it will run on Python
292
303
  3.6+, and PyPy 3.
293
304
 
294
- C Code
295
- ------
296
-
297
- This library uses code from OpenBSD.
298
-
299
305
  Security
300
306
  --------
301
307
 
@@ -3,7 +3,6 @@ LICENSE
3
3
  MANIFEST.in
4
4
  README.rst
5
5
  pyproject.toml
6
- setup.py
7
6
  tox.ini
8
7
  src/_bcrypt/Cargo.lock
9
8
  src/_bcrypt/Cargo.toml
@@ -17,7 +17,7 @@ commands =
17
17
  deps =
18
18
  ruff
19
19
  commands =
20
- ruff .
20
+ ruff check .
21
21
  ruff format --check .
22
22
 
23
23
  [testenv:mypy]
@@ -35,7 +35,7 @@ deps =
35
35
  readme_renderer
36
36
  commands =
37
37
  check-manifest
38
- python setup.py check --metadata --restructuredtext --strict
38
+ python3 -m readme_renderer README.rst -o /dev/null
39
39
 
40
40
 
41
41
  [check-manifest]
bcrypt-4.1.2/setup.py DELETED
@@ -1,101 +0,0 @@
1
- import os
2
- import platform
3
- import re
4
- import shutil
5
- import subprocess
6
- import sys
7
-
8
- from setuptools import setup
9
-
10
- try:
11
- from setuptools_rust import RustExtension
12
- except ImportError:
13
- print(
14
- """
15
- =============================DEBUG ASSISTANCE==========================
16
- If you are seeing an error here please try the following to
17
- successfully install bcrypt:
18
-
19
- Upgrade to the latest pip and try again. This will fix errors for most
20
- users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
21
- =============================DEBUG ASSISTANCE==========================
22
- """
23
- )
24
- raise
25
-
26
- if platform.python_implementation() == "PyPy":
27
- if sys.pypy_version_info < (2, 6):
28
- raise RuntimeError(
29
- "bcrypt is not compatible with PyPy < 2.6. Please upgrade PyPy to "
30
- "use this library."
31
- )
32
-
33
-
34
- try:
35
- setup(
36
- rust_extensions=[
37
- RustExtension(
38
- "bcrypt._bcrypt",
39
- "src/_bcrypt/Cargo.toml",
40
- py_limited_api="auto",
41
- rust_version=(
42
- ">=1.64.0"
43
- if os.environ.get("BCRYPT_ALLOW_RUST_163", "0") != "0"
44
- else ">=1.63.0"
45
- ),
46
- ),
47
- ],
48
- )
49
- except:
50
- # Note: This is a bare exception that re-raises so that we don't interfere
51
- # with anything the installation machinery might want to do. Because we
52
- # print this for any exception this msg can appear (e.g. in verbose logs)
53
- # even if there's no failure. For example, SetupRequirementsError is raised
54
- # during PEP517 building and prints this text. setuptools raises SystemExit
55
- # when compilation fails right now, but it's possible this isn't stable
56
- # or a public API commitment so we'll remain ultra conservative.
57
-
58
- import pkg_resources
59
-
60
- print(
61
- """
62
- =============================DEBUG ASSISTANCE=============================
63
- If you are seeing a compilation error please try the following steps to
64
- successfully install bcrypt:
65
- 1) Upgrade to the latest pip and try again. This will fix errors for most
66
- users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
67
- 2) Ensure you have a recent Rust toolchain installed. bcrypt requires
68
- rustc >= 1.64.0. (1.63 may be used by setting the BCRYPT_ALLOW_RUST_163
69
- environment variable)
70
- """
71
- )
72
- print(f" Python: {'.'.join(str(v) for v in sys.version_info[:3])}")
73
- print(f" platform: {platform.platform()}")
74
- for dist in ["pip", "setuptools", "setuptools_rust"]:
75
- try:
76
- version = pkg_resources.get_distribution(dist).version
77
- except pkg_resources.DistributionNotFound:
78
- version = "n/a"
79
- print(f" {dist}: {version}")
80
- version = "n/a"
81
- if shutil.which("rustc") is not None:
82
- try:
83
- # If for any reason `rustc --version` fails, silently ignore it
84
- rustc_output = subprocess.run(
85
- ["rustc", "--version"],
86
- capture_output=True,
87
- timeout=0.5,
88
- encoding="utf8",
89
- check=True,
90
- ).stdout
91
- version = re.sub("^rustc ", "", rustc_output.strip())
92
- except subprocess.SubprocessError:
93
- pass
94
- print(f" rustc: {version}")
95
-
96
- print(
97
- """\
98
- =============================DEBUG ASSISTANCE=============================
99
- """
100
- )
101
- raise
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes