# Poco::Crypto

# class ECDSADigestEngine

Library: Crypto
Package: ECDSA
Header: Poco/Crypto/ECDSADigestEngine.h

## Description

This class implements a Poco::DigestEngine that can be used to compute a secure digital signature.

First another Poco::Crypto::DigestEngine is created and used to compute a cryptographic hash of the data to be signed. Then, the hash value is encrypted, using the ECDSA private key.

To verify a signature, pass it to the verify() member function. It will decrypt the signature using the ECDSA public key and compare the resulting hash with the actual hash of the data.

## Inheritance

Direct Base Classes: Poco::DigestEngine

All Base Classes: Poco::DigestEngine

## Member Summary

Member Functions: digest, digestLength, reset, signature, updateImpl, verify

Inherited Functions: constantTimeEquals, digest, digestFromHex, digestLength, digestToHex, reset, update, updateImpl

## Constructors

### ECDSADigestEngine

ECDSADigestEngine(
const ECKey & key,
const std::string & name
);

Creates the ECDSADigestEngine with the given ECDSA key, using the hash algorithm with the given name (e.g., "SHA1", "SHA256", "SHA512", etc.). See the OpenSSL documentation for a list of supported digest algorithms.

Throws a Poco::NotFoundException if no algorithm with the given name exists.

## Destructor

### ~ECDSADigestEngine

~ECDSADigestEngine();

Destroys the ECDSADigestEngine.

## Member Functions

### digest

const DigestEngine::Digest & digest();

Finishes the computation of the digest (the first time it's called) and returns the message digest.

Can be called multiple times.

### digestLength

std::size_t digestLength() const;

Returns the length of the digest in bytes.

See also: Poco::DigestEngine::digestLength()

### reset

void reset();

Resets the engine so that a new digest can be computed.

See also: Poco::DigestEngine::reset()

### signature

const DigestEngine::Digest & signature();

Signs the digest using the ECDSADSA algorithm and the private key (the first time it's called) and returns the result.

Can be called multiple times.

### verify

bool verify(
const DigestEngine::Digest & signature
);

Verifies the data against the signature.

Returns true if the signature can be verified, false otherwise.

### updateImpl

void updateImpl(
const void * data,
std::size_t length
);

See also: Poco::DigestEngine::updateImpl()