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
s: int
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
hash_algo: Optional[Any]
msg: bytes
inside: bool
class ECDSASignAction(params, hash_algo, msg, privkey)[source]

Bases: ECDSAAction

ECDSA signing.

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

Bases: ECDSAAction

ECDSA verification.

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

Bases: object

EC based signature primitive (ECDSA).

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

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

property can_verify: bool

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

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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

Bases: Signature

ECDSA with SHA1.

property can_sign: bool

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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

Bases: Signature

ECDSA with SHA224.

property can_sign: bool

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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

Bases: Signature

ECDSA with SHA256.

property can_sign: bool

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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

Bases: Signature

ECDSA with SHA384.

property can_sign: bool

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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

Bases: Signature

ECDSA with SHA512.

property can_sign: bool

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

property can_verify: bool

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

sign_data(data, nonce=None)

Sign data.

Return type:

SignatureResult

sign_hash(digest, nonce=None)

Sign already hashed data.

Return type:

SignatureResult

verify_data(signature, data)

Verify data.

Return type:

bool

verify_hash(signature, digest)

Verify already hashed data.

Return type:

bool

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