pyecsca.ec.signature module

Provides an implementation of ECDSA (Elliptic Curve Digital Signature Algorithm).

class SignatureResult(r, s)[source]

Bases: object

ECDSA signature result (r, s).

r: int[source]
s: int[source]
static from_DER(data)[source]

Load an ECDSA signature from ASN.1 DER data.

Return type:

SignatureResult

to_DER()[source]

Output this signature into ASN.1 DER.

Return type:

bytes

class ECDSAAction(params, hash_algo, msg)[source]

Bases: Action

An ECDSA action base class.

params: DomainParameters[source]
hash_algo: Optional[Any][source]
msg: bytes[source]
inside: bool[source]
class ECDSASignAction(params, hash_algo, msg, privkey)[source]

Bases: ECDSAAction

ECDSA signing.

privkey: Mod[source]
params: DomainParameters[source]
hash_algo: Optional[Any][source]
msg: bytes[source]
inside: bool[source]
class ECDSAVerifyAction(params, hash_algo, msg, signature, pubkey)[source]

Bases: ECDSAAction

ECDSA verification.

signature: SignatureResult[source]
pubkey: Point[source]
params: DomainParameters[source]
hash_algo: Optional[Any][source]
msg: bytes[source]
inside: bool[source]
class Signature(mult, params, add=None, pubkey=None, privkey=None, hash_algo=None)[source]

Bases: object

EC based signature primitive (ECDSA).

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

verify_data(signature, data)[source]

Verify data.

Return type:

bool

class ECDSA_NONE(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with raw message input.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
class ECDSA_SHA1(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with SHA1.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
class ECDSA_SHA224(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with SHA224.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
class ECDSA_SHA256(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with SHA256.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
class ECDSA_SHA384(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with SHA384.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]
class ECDSA_SHA512(mult, params, add=None, pubkey=None, privkey=None)[source]

Bases: Signature

ECDSA with SHA512.

property can_sign: bool[source]

Whether this instance can sign (has a private key).

property can_verify: bool[source]

Whether this instance can verify (has a public key and add formula).

sign_data(data, nonce=None)[source]

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)[source]

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)[source]

Verify data.

Return type:

bool

verify_hash(signature, digest)[source]

Verify already hashed data.

Return type:

bool

mult: ScalarMultiplier[source]
params: DomainParameters[source]
add: Optional[AdditionFormula][source]
pubkey: Optional[Point][source]
privkey: Optional[Mod][source]
hash_algo: Optional[Any][source]