Commit graph

103 commits

Author SHA1 Message Date
Dan Ristea
4fd3013fd2 Update native get_bit implementation to return bool
The native implementation of `get_bit` returned 0/1 as int while the GMP implementation and the type hint say `get_bit` returns a bool. Wrapped the result to align the three.
2025-05-25 12:57:08 +02:00
Helder Eijs
3b20e96ffa Add PYCRYPTODOME_DISABLE_GMP flag and simplify to_bytes() for GMP 2024-01-13 18:41:36 +01:00
Helder Eijs
afb5e27a15 Fix side-channel leakage in RSA decryption 2023-12-25 01:30:40 +01:00
Helder Eijs
a31d1634b0 Always use native method bit_length() for integers 2022-12-12 20:36:36 +01:00
Helder Eijs
766730480e Use Python's own gcd() when available 2022-12-12 20:29:13 +01:00
Helder Eijs
fc70572ec1 GH#598: fix missing error handling for Util.number.inverse 2022-12-12 15:05:04 +01:00
Helder Eijs
4f3d3e5b96 Fix GH#526: correct type checking when list for RSA.construct includes a mix of ints and Integers 2022-12-11 00:42:44 +01:00
oittaa
99b297f731 n must be positive odd for the Jacobi symbol 2022-06-05 20:48:20 +02:00
oittaa
c75a5fd557 n must be odd for the Jacobi symbol 2022-06-05 20:48:20 +02:00
Helder Eijs
764c1e81b9 Add Ed25519 keys and EdDSA signatures 2022-05-08 22:35:37 +02:00
Helder Eijs
4a913aa9e8 Removed unused cparser definition 2022-02-05 11:28:42 +01:00
Helder Eijs
122c90bc69 Fix#595: Memory leak for GMP ints 2022-02-04 10:03:51 +01:00
Helder Eijs
615e9c937c Fix int/long on Python2 2021-09-22 00:56:39 +02:00
Helder Eijs
2e7dad9a9f Fix GH#505 and GH#509: Fix segmentation faults with GMP on Aarch64
Do not use GMP sscanf and snprintf. Instead, convert integers into
and from GMP using pure arithmetic operations.
2021-09-22 00:46:56 +02:00
Helder Eijs
cb3f5dd639 Fix GH#466: miller_rabin_test() was not using the provided random source 2021-01-04 23:25:49 +01:00
Helder Eijs
f499fd3756 Better message when avoiding GMP on Windows 2020-06-14 23:35:31 +02:00
Helder Eijs
85718ab980 Add support for left multiplication of an EC point by a scalar 2019-08-26 23:02:40 +02:00
Helder Eijs
4c4241ab52 Use __index__() with Python 3 2019-02-11 13:33:58 +01:00
Helder Eijs
9583c3b8d8 Allow hex() on custom integers 2019-02-11 12:12:41 +01:00
Helder Eijs
e777249231 New monty_pow() requires base smaller than modulus 2019-02-05 09:36:47 +01:00
Helder Eijs
5ddd27932c Move monty_pow() output parameter to 1st position 2019-02-05 09:36:47 +01:00
Helder Eijs
dee55465ac Rename _montgomery module to _modexp 2019-02-05 09:36:47 +01:00
Helder Eijs
d13e46b02d Fix mypy error 2018-11-23 23:19:40 +01:00
Helder Eijs
a9a4ee2da1 More updates to type stubs 2018-11-23 23:07:14 +01:00
Helder Eijs
fa933ab29e Make mypy test pass
In the process, refactor Crypto.Math to make use of inheritance.
2018-11-23 23:07:14 +01:00
Michael Nix
7bae7c1cad adds more type stubs for Math, Protocol, Signature and Util 2018-11-23 23:07:14 +01:00
Helder Eijs
39626a5b01 Move functions to get buffer information into Util._raw_api 2018-11-04 22:05:09 +01:00
Helder Eijs
cd7f0128b6 Make code base suitable for Python 2 and 3 - stop using 2to3 2018-11-04 15:04:23 +01:00
Helder Eijs
c1c1da5471 Lazy creation of GMP methods 2018-10-16 22:09:53 +02:00
Helder Eijs
066b8969ee More cleanup 2018-10-16 22:09:53 +02:00
Helder Eijs
8c4824982b General cleanup, remove old constructs 2018-10-13 21:34:44 +02:00
Helder Eijs
9990033025 Jacobi symbol not defined for negative n, add more test vectors 2018-08-10 12:58:41 +02:00
Helder Eijs
66fdb1fdd4 Increase testing for primality 2018-08-09 22:53:57 +02:00
Helder Eijs
c1b899ba79 Remove max limit for searching for D in Lucas test 2018-08-09 22:53:57 +02:00
Helder Eijs
0df621106b Increase accuracy of the Lucas primality test #189 2018-07-13 22:29:37 +02:00
Helder Eijs
c4956f6adb Disable GMP binding on Windows (with MPIR) 2018-06-18 22:22:46 +02:00
Helder Eijs
cf1b0387b1 Detect GMP libraries with mismatching symbols 2018-02-17 00:25:35 +01:00
Helder Eijs
7bb257dfc9 Force n value to be Integer 2018-02-16 23:43:06 +01:00
Helder Eijs
dc97db81df Add tests for exporting compressed ECC keys 2018-02-16 22:44:43 +01:00
Helder Eijs
3f2be587f3 Add square root modulo prime 2018-02-14 23:50:54 +01:00
Helder Eijs
c502060ee7 Use c_ulonglong for seed 2018-01-22 00:41:09 +01:00
Helder Eijs
381a32ce71 Drop MPIR on Windows 2018-01-22 00:41:09 +01:00
Helder Eijs
d40e878f13 Randomize custom modexp 2018-01-22 00:41:09 +01:00
Helder Eijs
e7806de739 Add benchmark routine to montgomery.c 2018-01-22 00:41:09 +01:00
Helder Eijs
7b1249e718 Add custom implementation for modexp 2018-01-22 00:41:09 +01:00
Helder Eijs
7442bc1edd Simplify Integer logic 2018-01-22 00:39:09 +01:00
Helder Eijs
88595c6fa3 Remove OverflowError from right shift 2018-01-08 12:01:49 +01:00
Helder Eijs
7d03599c65 Fix Integer.get_bit for negative values and overflows
It is not possible anymore to get a specific bit from a negative
integer (representation cannot be intuitive).

OverFlowError is not raised anymore (in line with
https://bugs.python.org/issue29816)
2018-01-08 11:49:10 +01:00
Helder Eijs
0015a57e41 Further fix for C types warning 2017-01-27 10:07:18 -05:00
Helder Eijs
57548f05ee Fixed various warnings 2017-01-26 22:47:38 +01:00