libdigidocpp
digidoc::Digest Class Reference

#include <Digest.h>

Collaboration diagram for digidoc::Digest:
Collaboration graph

Public Member Functions

 Digest () throw (IOException)
 Digest (int method) throw (IOException)
 Digest (const std::string &methodUri) throw (IOException)
virtual ~Digest ()
void reset ()
void update (const std::vector< unsigned char > &data) throw (IOException)
virtual void update (const unsigned char *data, unsigned long length) throw (IOException)
virtual std::vector< unsigned
char > 
getDigest () throw (IOException)
unsigned int getSize () const
int getMethod () const
std::string getName () const
std::string getUri () const

Static Public Member Functions

static int toMethod (const std::string &methodUri) throw (IOException)
static bool isSupported (const std::string &methodUri)

Private Attributes

DigestPrivated

Detailed Description

Definition at line 44 of file Digest.h.

Constructor & Destructor Documentation

digidoc::Digest::Digest ( ) throw (IOException)

Initializes OpenSSL digest calculator.

Exceptions
IOExceptionthrows exception if the digest calculator initialization failed.

Definition at line 50 of file Digest.cpp.

References d, digidoc::Conf::getInstance(), digidoc::DigestPrivate::method, reset(), and toMethod().

Here is the call graph for this function:

digidoc::Digest::Digest ( int  method) throw (IOException)

Initializes OpenSSL digest calculator.

Parameters
methoddigest method (e.g NID_sha1 for SHA1, see openssl/obj_mac.h).
Exceptions
IOExceptionthrows exception if the digest calculator initialization failed.

Definition at line 63 of file Digest.cpp.

References THROW_IOEXCEPTION.

digidoc::Digest::Digest ( const std::string &  methodUri) throw (IOException)

Initializes OpenSSL digest calculator.

Parameters
methodUridigest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1).
Exceptions
IOExceptionthrows exception if the digest calculator initialization failed.

Definition at line 87 of file Digest.cpp.

digidoc::Digest::~Digest ( )
virtual

Destroys OpenSSL digest calculator.

Definition at line 97 of file Digest.cpp.

Member Function Documentation

std::vector< unsigned char > digidoc::Digest::getDigest ( ) throw (IOException)
virtual

Calculate message digest. SHA context will be invalid after this call. For calculating an other digest you must create new SHA1Digest class.

Returns
returns the calculated digest.
Exceptions
IOExceptionthrows exception if update failed.

Definition at line 269 of file Digest.cpp.

References i, and THROW_IOEXCEPTION.

Referenced by digidoc::SignatureBES::checkKeyInfo(), digidoc::SignatureTM::notarize(), digidoc::SignatureTM::setOCSPCertificate(), digidoc::Signature::setSigningCertificate(), digidoc::SignatureTM::validateOffline(), and digidoc::SignatureBES::validateOnline().

Here is the caller graph for this function:

int digidoc::Digest::getMethod ( ) const
Returns
returns digest method OpenSSL NID. See openssl/obj_mac.h for available methods.

Definition at line 118 of file Digest.cpp.

std::string digidoc::Digest::getName ( ) const
Returns
returns digest method name.

Definition at line 126 of file Digest.cpp.

unsigned int digidoc::Digest::getSize ( ) const
Returns
returns size of the digest.

Definition at line 134 of file Digest.cpp.

Referenced by digidoc::SignatureBES::checkKeyInfo(), digidoc::SignatureTM::setOCSPCertificate(), and digidoc::Signature::setSigningCertificate().

Here is the caller graph for this function:

std::string digidoc::Digest::getUri ( ) const
bool digidoc::Digest::isSupported ( const std::string &  methodUri)
static

Check if methodUri is supported by Digest.create(methodUri) method For available method URIs see:

W3C XML Encryption Syntax and Processing (10 December 2005) http://www.w3.org/TR/xmlenc-core/

RFC 4051 http://www.ietf.org/rfc/rfc4051.txt

Parameters
methodUriigest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1).
Returns
if methodUri is supported

Definition at line 218 of file Digest.cpp.

Referenced by digidoc::SignatureBES::checkDocumentRefDigest(), digidoc::SignatureBES::checkKeyInfo(), and digidoc::SignatureBES::checkReferenceToSigProps().

Here is the caller graph for this function:

void digidoc::Digest::reset ( )

Definition at line 167 of file Digest.cpp.

References THROW_IOEXCEPTION.

Referenced by Digest().

Here is the caller graph for this function:

int digidoc::Digest::toMethod ( const std::string &  methodUri) throw (IOException)
static

Converts digest method URI to OpenSSL method id (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' to NID_sha1, see openssl/obj_mac.h) For available method URIs see:

W3C XML Encryption Syntax and Processing (10 December 2005) http://www.w3.org/TR/xmlenc-core/

RFC 4051 http://www.ietf.org/rfc/rfc4051.txt

Parameters
methodUridigest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1).
Returns
returns digest OpenSSL method id.
Exceptions
IOExceptionthrows exception if digest method is not supported.

Definition at line 197 of file Digest.cpp.

References THROW_IOEXCEPTION, URI_RSA_SHA1, URI_RSA_SHA224, URI_RSA_SHA256, URI_RSA_SHA384, URI_RSA_SHA512, URI_SHA1, URI_SHA224, URI_SHA256, URI_SHA384, and URI_SHA512.

Referenced by Digest(), digidoc::CNGSigner::type(), and digidoc::EstEIDSigner::type().

Here is the caller graph for this function:

void digidoc::Digest::update ( const std::vector< unsigned char > &  data) throw (IOException)

Add data for digest calculation.

Parameters
datadata to add for digest calculation.
Exceptions
IOExceptionthrows exception if SHA1 update failed.
See Also
update(const unsigned char* data, unsigned long length)

Definition at line 110 of file Digest.cpp.

Referenced by digidoc::SignatureBES::checkKeyInfo(), digidoc::SignatureTM::notarize(), digidoc::SignatureTM::setOCSPCertificate(), digidoc::Signature::setSigningCertificate(), digidoc::SignatureTM::validateOffline(), and digidoc::SignatureBES::validateOnline().

Here is the caller graph for this function:

void digidoc::Digest::update ( const unsigned char *  data,
unsigned long  length 
) throw (IOException)
virtual

Add data for digest calculation. After calling getDigest() SHA context is uninitialized and this method should not be called.

Parameters
datadata to add for digest calculation.
lengthlength of the data.
Exceptions
IOExceptionthrows exception if update failed.
See Also
getDigest()

Definition at line 240 of file Digest.cpp.

References THROW_IOEXCEPTION.

Member Data Documentation

DigestPrivate* digidoc::Digest::d
private

Definition at line 64 of file Digest.h.

Referenced by Digest().


The documentation for this class was generated from the following files: