2022-03-23 06:45:36 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
2018-02-03 11:36:14 +01:00
|
|
|
buildPythonPackage,
|
2023-08-22 10:46:53 +02:00
|
|
|
callPackage,
|
2023-05-12 14:17:16 +00:00
|
|
|
cargo,
|
2024-02-02 18:31:33 +01:00
|
|
|
certifi,
|
2018-02-03 11:36:14 +01:00
|
|
|
cffi,
|
2024-01-19 12:56:44 +00:00
|
|
|
cryptography-vectors ? (callPackage ./vectors.nix { }),
|
2023-08-22 10:46:53 +02:00
|
|
|
fetchPypi,
|
2024-02-08 16:20:42 +01:00
|
|
|
fetchpatch2,
|
2023-06-21 14:13:56 +02:00
|
|
|
isPyPy,
|
|
|
|
libiconv,
|
|
|
|
libxcrypt,
|
|
|
|
openssl,
|
2023-04-06 00:16:22 +02:00
|
|
|
pkg-config,
|
2023-06-21 14:13:56 +02:00
|
|
|
pretend,
|
2024-02-02 18:31:33 +01:00
|
|
|
pytest-xdist,
|
2023-08-22 10:46:53 +02:00
|
|
|
pytestCheckHook,
|
2022-06-01 20:21:07 +02:00
|
|
|
pythonOlder,
|
2023-06-21 14:13:56 +02:00
|
|
|
rustc,
|
|
|
|
rustPlatform,
|
|
|
|
Security,
|
|
|
|
setuptoolsRustBuildHook,
|
2018-02-03 11:36:14 +01:00
|
|
|
}:
|
|
|
|
|
2018-08-21 02:47:41 +02:00
|
|
|
buildPythonPackage rec {
|
2018-02-03 11:36:14 +01:00
|
|
|
pname = "cryptography";
|
2024-03-07 02:33:52 +01:00
|
|
|
version = "42.0.5"; # Also update the hash in vectors.nix
|
2023-11-27 18:18:11 +01:00
|
|
|
pyproject = true;
|
|
|
|
|
2023-06-21 14:13:56 +02:00
|
|
|
disabled = pythonOlder "3.7";
|
2018-02-03 11:36:14 +01:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-03-07 02:33:52 +01:00
|
|
|
hash = "sha256-b+B+7JXf1HfrlTCu9b6tNP7IGbOq9sW9bSBWXaYHv+E=";
|
2018-02-03 11:36:14 +01:00
|
|
|
};
|
|
|
|
|
2021-02-08 14:07:11 +01:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
sourceRoot = "${pname}-${version}/${cargoRoot}";
|
|
|
|
name = "${pname}-${version}";
|
2024-03-07 02:33:52 +01:00
|
|
|
hash = "sha256-Pw3ftpcDMfZr/w6US5fnnyPVsFSB9+BuIKazDocYjTU=";
|
2021-02-08 14:07:11 +01:00
|
|
|
};
|
|
|
|
|
2024-02-08 16:20:42 +01:00
|
|
|
patches = [
|
|
|
|
(fetchpatch2 {
|
|
|
|
# skip overflowing tests on 32 bit; https://github.com/pyca/cryptography/pull/10366
|
|
|
|
url = "https://github.com/pyca/cryptography/commit/d741901dddd731895346636c0d3556c6fa51fbe6.patch";
|
|
|
|
hash = "sha256-eC+MZg5O8Ia5CbjRE4y+JhaFs3Q5c62QtPHr3x9T+zw=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-04-26 19:02:49 -07:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pyproject.toml \
|
2024-02-02 18:31:33 +01:00
|
|
|
--replace-fail "--benchmark-disable" ""
|
2023-04-26 19:02:49 -07:00
|
|
|
'';
|
|
|
|
|
2021-02-08 14:07:11 +01:00
|
|
|
cargoRoot = "src/rust";
|
|
|
|
|
2023-06-26 23:17:57 +02:00
|
|
|
nativeBuildInputs = [
|
2021-02-08 14:07:11 +01:00
|
|
|
rustPlatform.cargoSetupHook
|
2023-01-27 15:42:53 +01:00
|
|
|
setuptoolsRustBuildHook
|
2023-05-12 14:17:16 +00:00
|
|
|
cargo
|
|
|
|
rustc
|
2023-06-26 23:17:57 +02:00
|
|
|
pkg-config
|
|
|
|
] ++ lib.optionals (!isPyPy) [ cffi ];
|
2020-11-19 20:57:37 +01:00
|
|
|
|
2023-08-22 10:46:53 +02:00
|
|
|
buildInputs =
|
|
|
|
[ openssl ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
Security
|
|
|
|
libiconv
|
|
|
|
]
|
|
|
|
++ lib.optionals (pythonOlder "3.9") [ libxcrypt ];
|
2022-03-23 06:31:52 +01:00
|
|
|
|
2022-03-23 06:44:54 +01:00
|
|
|
propagatedBuildInputs = lib.optionals (!isPyPy) [ cffi ];
|
2018-02-03 11:36:14 +01:00
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [
|
2024-02-02 18:31:33 +01:00
|
|
|
certifi
|
2022-03-23 06:14:53 +01:00
|
|
|
cryptography-vectors
|
2019-03-30 12:13:09 -04:00
|
|
|
pretend
|
2022-03-23 06:32:19 +01:00
|
|
|
pytestCheckHook
|
2024-02-02 18:31:33 +01:00
|
|
|
pytest-xdist
|
2018-02-03 11:36:14 +01:00
|
|
|
];
|
|
|
|
|
2021-02-07 13:35:53 -08:00
|
|
|
pytestFlagsArray = [ "--disable-pytest-warnings" ];
|
|
|
|
|
2023-04-26 19:02:49 -07:00
|
|
|
disabledTestPaths = [
|
|
|
|
# save compute time by not running benchmarks
|
|
|
|
"tests/bench"
|
2022-03-23 06:32:19 +01:00
|
|
|
];
|
2018-11-11 08:55:35 +01:00
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-01-23 23:58:29 +01:00
|
|
|
description = "Package which provides cryptographic recipes and primitives";
|
|
|
|
longDescription = ''
|
|
|
|
Cryptography includes both high level recipes and low level interfaces to
|
|
|
|
common cryptographic algorithms such as symmetric ciphers, message
|
|
|
|
digests, and key derivation functions.
|
|
|
|
'';
|
2020-04-03 15:36:19 +02:00
|
|
|
homepage = "https://github.com/pyca/cryptography";
|
|
|
|
changelog =
|
|
|
|
"https://cryptography.io/en/latest/changelog/#v" + replaceStrings [ "." ] [ "-" ] version;
|
2019-01-23 23:58:29 +01:00
|
|
|
license = with licenses; [
|
|
|
|
asl20
|
|
|
|
bsd3
|
|
|
|
psfl
|
|
|
|
];
|
2022-03-26 14:55:58 +01:00
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2019-01-23 23:58:29 +01:00
|
|
|
};
|
2018-08-21 02:47:41 +02:00
|
|
|
}
|