@@ -636,7 +636,7 @@ def verify(
636
636
:type signature: sigdecode method dependent
637
637
:param data: data signed by the `signature`, will be hashed using
638
638
`hashfunc`, if specified, or default hash function
639
- :type data: bytes like object
639
+ :type data: :term:` bytes- like object`
640
640
:param hashfunc: The default hash function that will be used for
641
641
verification, needs to implement the same interface as hashlib.sha1
642
642
:type hashfunc: callable
@@ -690,7 +690,7 @@ def verify_digest(
690
690
:param signature: encoding of the signature
691
691
:type signature: sigdecode method dependent
692
692
:param digest: raw hash value that the signature authenticates.
693
- :type digest: bytes like object
693
+ :type digest: :term:` bytes- like object`
694
694
:param sigdecode: Callable to define the way the signature needs to
695
695
be decoded to an object, needs to handle `signature` as the
696
696
first parameter, the curve order (an int) as the second and return
@@ -879,7 +879,7 @@ def from_string(cls, string, curve=NIST192p, hashfunc=sha1):
879
879
In Python 3, the expected type is `bytes`.
880
880
881
881
:param string: the raw encoding of the private key
882
- :type string: bytes like object
882
+ :type string: :term:` bytes- like object`
883
883
:param curve: The curve on which the point needs to reside
884
884
:type curve: ~ecdsa.curves.Curve
885
885
:param hashfunc: The default hash function that will be used for
@@ -1012,7 +1012,7 @@ def from_der(cls, string, hashfunc=sha1, valid_curve_encodings=None):
1012
1012
in them will not be detected.
1013
1013
1014
1014
:param string: binary string with DER-encoded private ECDSA key
1015
- :type string: bytes like object
1015
+ :type string: :term:` bytes- like object`
1016
1016
:param valid_curve_encodings: list of allowed encoding formats
1017
1017
for curve parameters. By default (``None``) all are supported:
1018
1018
``named_curve`` and ``explicit``.
@@ -1315,7 +1315,7 @@ def sign_deterministic(
1315
1315
of data is necessary.
1316
1316
1317
1317
:param data: data to be hashed and computed signature over
1318
- :type data: bytes like object
1318
+ :type data: :term:` bytes- like object`
1319
1319
:param hashfunc: hash function to use for computing the signature,
1320
1320
if unspecified, the default hash function selected during
1321
1321
object initialisation will be used (see
@@ -1334,7 +1334,7 @@ def sign_deterministic(
1334
1334
:param extra_entropy: additional data that will be fed into the random
1335
1335
number generator used in the RFC6979 process. Entirely optional.
1336
1336
Ignored with EdDSA.
1337
- :type extra_entropy: bytes like object
1337
+ :type extra_entropy: :term:` bytes- like object`
1338
1338
1339
1339
:return: encoded signature over `data`
1340
1340
:rtype: bytes or sigencode function dependent type
@@ -1374,24 +1374,26 @@ def sign_digest_deterministic(
1374
1374
hashing of data is necessary.
1375
1375
1376
1376
:param digest: hash of data that will be signed
1377
- :type digest: bytes like object
1377
+ :type digest: :term:` bytes- like object`
1378
1378
:param hashfunc: hash function to use for computing the random "k"
1379
1379
value from RFC6979 process,
1380
1380
if unspecified, the default hash function selected during
1381
1381
object initialisation will be used (see
1382
- `VerifyingKey.default_hashfunc`). The object needs to implement
1383
- the same interface as hashlib.sha1.
1382
+ :attr:`.VerifyingKey.default_hashfunc`). The object needs to
1383
+ implement
1384
+ the same interface as :func:`~hashlib.sha1` from :py:mod:`hashlib`.
1384
1385
:type hashfunc: callable
1385
1386
:param sigencode: function used to encode the signature.
1386
1387
The function needs to accept three parameters: the two integers
1387
1388
that are the signature and the order of the curve over which the
1388
1389
signature was computed. It needs to return an encoded signature.
1389
- See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
1390
+ See :func:`~ecdsa.util.sigencode_string` and
1391
+ :func:`~ecdsa.util.sigencode_der`
1390
1392
as examples of such functions.
1391
1393
:type sigencode: callable
1392
1394
:param extra_entropy: additional data that will be fed into the random
1393
1395
number generator used in the RFC6979 process. Entirely optional.
1394
- :type extra_entropy: bytes like object
1396
+ :type extra_entropy: :term:` bytes- like object`
1395
1397
:param bool allow_truncate: if True, the provided digest can have
1396
1398
bigger bit-size than the order of the curve, the extra bits (at
1397
1399
the end of the digest) will be truncated. Use it when signing
@@ -1456,46 +1458,53 @@ def sign(
1456
1458
method instead of this one.
1457
1459
1458
1460
:param data: data that will be hashed for signing
1459
- :type data: bytes like object
1460
- :param callable entropy: randomness source, os.urandom by default.
1461
- Ignored with EdDSA.
1462
- :param hashfunc: hash function to use for hashing the provided `data`.
1461
+ :type data: :term:`bytes-like object`
1462
+ :param callable entropy: randomness source, :func:`os.urandom` by
1463
+ default. Ignored with EdDSA.
1464
+ :param hashfunc: hash function to use for hashing the provided
1465
+ ``data``.
1463
1466
If unspecified the default hash function selected during
1464
1467
object initialisation will be used (see
1465
- `VerifyingKey.default_hashfunc`).
1466
- Should behave like hashlib.sha1. The output length of the
1468
+ :attr:`.VerifyingKey.default_hashfunc`).
1469
+ Should behave like :func:`~hashlib.sha1` from :py:mod:`hashlib`.
1470
+ The output length of the
1467
1471
hash (in bytes) must not be longer than the length of the curve
1468
1472
order (rounded up to the nearest byte), so using SHA256 with
1469
1473
NIST256p is ok, but SHA256 with NIST192p is not. (In the 2**-96ish
1470
1474
unlikely event of a hash output larger than the curve order, the
1471
1475
hash will effectively be wrapped mod n).
1472
- Use hashfunc=hashlib.sha1 to match openssl's -ecdsa-with-SHA1 mode,
1473
- or hashfunc=hashlib.sha256 for openssl-1.0.0's -ecdsa-with-SHA256.
1476
+ If you want to explicitly allow use of large hashes with small
1477
+ curves set the ``allow_truncate`` to ``True``.
1478
+ Use ``hashfunc=hashlib.sha1`` to match openssl's
1479
+ ``-ecdsa-with-SHA1`` mode,
1480
+ or ``hashfunc=hashlib.sha256`` for openssl-1.0.0's
1481
+ ``-ecdsa-with-SHA256``.
1474
1482
Ignored for EdDSA
1475
1483
:type hashfunc: callable
1476
1484
:param sigencode: function used to encode the signature.
1477
1485
The function needs to accept three parameters: the two integers
1478
1486
that are the signature and the order of the curve over which the
1479
1487
signature was computed. It needs to return an encoded signature.
1480
- See `ecdsa.util.sigencode_string` and `ecdsa.util.sigencode_der`
1488
+ See :func:`~ecdsa.util.sigencode_string` and
1489
+ :func:`~ecdsa.util.sigencode_der`
1481
1490
as examples of such functions.
1482
1491
Ignored for EdDSA
1483
1492
:type sigencode: callable
1484
1493
:param int k: a pre-selected nonce for calculating the signature.
1485
1494
In typical use cases, it should be set to None (the default) to
1486
1495
allow its generation from an entropy source.
1487
1496
Ignored for EdDSA.
1488
- :param bool allow_truncate: if True, the provided digest can have
1497
+ :param bool allow_truncate: if `` True`` , the provided digest can have
1489
1498
bigger bit-size than the order of the curve, the extra bits (at
1490
1499
the end of the digest) will be truncated. Use it when signing
1491
1500
SHA-384 output using NIST256p or in similar situations. True by
1492
1501
default.
1493
1502
Ignored for EdDSA.
1494
1503
1495
- :raises RSZeroError: in the unlikely event when "r" parameter or
1496
- "s" parameter of the created signature is equal 0, as that would
1504
+ :raises RSZeroError: in the unlikely event when *r* parameter or
1505
+ *s* parameter of the created signature is equal 0, as that would
1497
1506
leak the key. Caller should try a better entropy source, retry with
1498
- different 'k' , or use the
1507
+ different ``k`` , or use the
1499
1508
:func:`~SigningKey.sign_deterministic` in such case.
1500
1509
1501
1510
:return: encoded signature of the hash of `data`
@@ -1529,7 +1538,7 @@ def sign_digest(
1529
1538
instead of this one.
1530
1539
1531
1540
:param digest: hash value that will be signed
1532
- :type digest: bytes like object
1541
+ :type digest: :term:` bytes- like object`
1533
1542
:param callable entropy: randomness source, os.urandom by default
1534
1543
:param sigencode: function used to encode the signature.
1535
1544
The function needs to accept three parameters: the two integers
0 commit comments