tlslite.utils.ecdsakey module
Abstract class for ECDSA.
- class tlslite.utils.ecdsakey.ECDSAKey(public_key, private_key)[source]
Bases:
object
This is an abstract base class for ECDSA keys.
Particular implementations of ECDSA keys, such as
Python_ECDSAKey
… more coming inherit from this.To create or parse an ECDSA key, don’t use one of these classes directly. Instead, use the factory functions in
keyfactory
.- __init__(public_key, private_key)[source]
Create a new ECDSA key.
If public_key or private_key are passed in, the new key will be initialized.
- Parameters:
public_key – ECDSA public key.
private_key – ECDSA private key.
- acceptsPassword()[source]
Return True if the write() method accepts a password for use in encrypting the private key.
- Return type:
- hashAndSign(bytes, rsaScheme=None, hAlg='sha1', sLen=None)[source]
Hash and sign the passed-in bytes.
This requires the key to have a private component. It performs a signature on the passed-in data with selected hash algorithm.
- Parameters:
- Return type:
- Returns:
An ECDSA signature on the passed-in data.
- hashAndVerify(sigBytes, bytes, rsaScheme=None, hAlg='sha1', sLen=None)[source]
Hash and verify the passed-in bytes with the signature.
This verifies an ECDSA signature on the passed-in data with selected hash algorithm.
- Parameters:
sigBytes (bytearray) – An ECDSA signature, DER encoded.
bytes (str or bytearray) – The value which will be hashed and verified.
rsaScheme (str) – Ignored, present for API compatibility with RSA
hAlg (str) – The hash algorithm that will be used
sLen (int) – Ignored, present for API compatibility with RSA
- Return type:
- Returns:
Whether the signature matches the passed-in data.
- sign(bytes, padding=None, hashAlg='sha1', saltLen=None)[source]
Sign the passed-in bytes.
This requires the key to have a private component. It performs an ECDSA signature on the passed-in data.
- Parameters:
- Return type:
- Returns:
An ECDSA signature on the passed-in data.