Name Description Size
__init__.py 1219
_compat.py Common functions for providing cross-python version compatibility. 1108
_rwlock.py Read-Write locking primitive Synchronization object used in a solution of so-called second readers-writers problem. In this problem, many readers can simultaneously access a share, and a writer has an exclusive access to this share. Additionally, the following constraints should be met: 1) no reader should be kept waiting if the share is currently opened for reading unless a writer is also waiting for the share, 2) no writer should be kept waiting for the share longer than absolutely necessary. The implementation is based on [1, secs. 4.2.2, 4.2.6, 4.2.7] with a modification -- adding an additional lock (C{self.__readers_queue}) -- in accordance with [2]. Sources: [1] A.B. Downey: "The little book of semaphores", Version 2.1.5, 2008 [2] P.J. Courtois, F. Heymans, D.L. Parnas: "Concurrent Control with 'Readers' and 'Writers'", Communications of the ACM, 1971 (via [3]) [3] http://en.wikipedia.org/wiki/Readers-writers_problem 2848
_version.py { "date": "2020-01-02T17:05:04+0100", "dirty": false, "error": null, "full-revisionid": "93b04ba3ddb7c2716e07761393a179c061718c34", "version": "0.15" } 496
curves.py 4278
der.py Encode a binary string as a BIT STRING using :term:`DER` encoding. Note, because there is no native Python object that can encode an actual bit string, this function only accepts byte strings as the `s` argument. The byte string is the actual bit string that will be encoded, padded on the right (least significant bits, looking from big endian perspective) to the first full byte. If the bit string has a bit length that is multiple of 8, then the padding should not be included. For correct DER encoding the padding bits MUST be set to 0. Number of bits of padding need to be provided as the `unused` parameter. In case they are specified as None, it means the number of unused bits is already encoded in the string as the first byte. The deprecated call convention specifies just the `s` parameters and encodes the number of unused bits as first parameter (same convention as with None). Empty string must be encoded with `unused` specified as 0. Future version of python-ecdsa will make specifying the `unused` argument mandatory. :param s: bytes to encode :type s: bytes like object :param unused: number of bits at the end of `s` that are unused, must be between 0 and 7 (inclusive) :type unused: int or None :raises ValueError: when `unused` is too large or too small :return: `s` encoded using DER :rtype: bytes 13864
ecdh.py Class for performing Elliptic-curve Diffie-Hellman (ECDH) operations. 10459
ecdsa.py Implementation of Elliptic-Curve Digital Signatures. Classes and methods for elliptic-curve signatures: private keys, public keys, signatures, NIST prime-modulus curves with modulus lengths of 192, 224, 256, 384, and 521 bits. Example: # (In real-life applications, you would probably want to # protect against defects in SystemRandom.) from random import SystemRandom randrange = SystemRandom().randrange # Generate a public/private key pair using the NIST Curve P-192: g = generator_192 n = g.order() secret = randrange( 1, n ) pubkey = Public_key( g, g * secret ) privkey = Private_key( pubkey, secret ) # Signing a hash value: hash = randrange( 1, n ) signature = privkey.sign( hash, randrange( 1, n ) ) # Verifying a signature for a hash value: if pubkey.verifies( hash, signature ): print_("Demo verification succeeded.") else: print_("*** Demo verification failed.") # Verification fails if the hash value is modified: if pubkey.verifies( hash-1, signature ): print_("**** Demo verification failed to reject tampered hash.") else: print_("Demo verification correctly rejected tampered hash.") Version of 2009.05.16. Revision history: 2005.12.31 - Initial version. 2008.11.25 - Substantial revisions introducing new classes. 2009.05.16 - Warn against using random.randrange in real applications. 2009.05.17 - Use random.SystemRandom by default. Written in 2005 by Peter Pearson and placed in the public domain. 17546
ellipticcurve.py Elliptic Curve over the field of integers modulo a prime. 24278
keys.py Primary classes for performing signing and verification operations. .. glossary:: raw encoding Conversion of public, private keys and signatures (which in mathematical sense are integers or pairs of integers) to strings of bytes that does not use any special tags or encoding rules. For any given curve, all keys of the same type or signatures will be encoded to byte strings of the same length. In more formal sense, the integers are encoded as big-endian, constant length byte strings, where the string length is determined by the curve order (e.g. for NIST256p the order is 256 bits long, so the private key will be 32 bytes long while public key will be 64 bytes long). The encoding of a single integer is zero-padded on the left if the numerical value is low. In case of public keys and signatures, which are comprised of two integers, the integers are simply concatenated. uncompressed The most common formatting specified in PKIX standards. Specified in X9.62 and SEC1 standards. The only difference between it and :term:`raw encoding` is the prepending of a 0x04 byte. Thus an uncompressed NIST256p public key encoding will be 65 bytes long. compressed The public point representation that uses half of bytes of the :term:`uncompressed` encoding (rounded up). It uses the first byte of the encoding to specify the sign of the y coordinate and encodes the x coordinate as-is. The first byte of the encoding is equal to 0x02 or 0x03. Compressed encoding of NIST256p public key will be 33 bytes long. hybrid A combination of :term:`uncompressed` and :term:`compressed` encodings. Both x and y coordinates are stored just as in :term:`compressed` encoding, but the first byte reflects the sign of the y coordinate. The first byte of the encoding will be equal to 0x06 or 0x7. Hybrid encoding of NIST256p public key will be 65 bytes long. PEM The acronym stands for Privacy Enhanced Email, but currently it is used primarily as the way to encode :term:`DER` objects into text that can be either easily copy-pasted or transferred over email. It uses headers like ``-----BEGIN <type of contents>-----`` and footers like ``-----END <type of contents>-----`` to separate multiple types of objects in the same file or the object from the surrounding comments. The actual object stored is base64 encoded. DER Distinguished Encoding Rules, the way to encode :term:`ASN.1` objects deterministically and uniquely into byte strings. ASN.1 Abstract Syntax Notation 1 is a standard description language for specifying serialisation and deserialisation of data structures in a portable and cross-platform way. bytes-like object All the types that implement the buffer protocol. That includes ``str`` (only on python2), ``bytes``, ``bytesarray``, ``array.array` and ``memoryview`` of those objects. Please note that ``array.array` serialisation (converting it to byte string) is endianess dependant! Signature computed over ``array.array`` of integers on a big-endian system will not be verified on a little-endian system and vice-versa. 52990
numbertheory.py Base class for exceptions in this module. 15427
rfc6979.py RFC 6979: Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA) http://tools.ietf.org/html/rfc6979 Many thanks to Coda Hale for his implementation in Go language: https://github.com/codahale/rfc6979 2701
test_der.py This is the old way to use the function. 12609
test_ecdh.py 13472
test_ecdsa.py Check test vectors from X9.62 18334
test_ellipticcurve.py 6160
test_jacobi.py 10778
test_keys.py Verify that ecdsa.keys.VerifyingKey.from_string() can be used with bytes-like objects 12701
test_malformed_sigs.py Since the data is hashed for processing, really any string will do. 10170
test_numbertheory.py Strategy that returns lists of numbers, all having a common factor. 9004
test_pyecdsa.py 64737
test_rw_lock.py @param buffer_: common buffer_ shared by the readers and writers @type buffer_: list @type rw_lock: L{RWLock} @param init_sleep_time: sleep time before doing any action @type init_sleep_time: C{float} @param sleep_time: sleep time while in critical section @type sleep_time: C{float} @param to_write: data that will be appended to the buffer 6899
util.py Convert a bytestring to string of 0's and 1's 14007