libdigidocpp
|
#include <Digest.h>
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 | |
DigestPrivate * | d |
digidoc::Digest::Digest | ( | ) | throw (IOException) |
Initializes OpenSSL digest calculator.
IOException | throws 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().
digidoc::Digest::Digest | ( | int | method | ) | throw (IOException) |
Initializes OpenSSL digest calculator.
method | digest method (e.g NID_sha1 for SHA1, see openssl/obj_mac.h). |
IOException | throws 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.
methodUri | digest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1). |
IOException | throws exception if the digest calculator initialization failed. |
Definition at line 87 of file Digest.cpp.
|
virtual |
Destroys OpenSSL digest calculator.
Definition at line 97 of file Digest.cpp.
|
virtual |
Calculate message digest. SHA context will be invalid after this call. For calculating an other digest you must create new SHA1Digest class.
IOException | throws 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().
int digidoc::Digest::getMethod | ( | ) | const |
Definition at line 118 of file Digest.cpp.
std::string digidoc::Digest::getName | ( | ) | const |
Definition at line 126 of file Digest.cpp.
unsigned int digidoc::Digest::getSize | ( | ) | const |
Definition at line 134 of file Digest.cpp.
Referenced by digidoc::SignatureBES::checkKeyInfo(), digidoc::SignatureTM::setOCSPCertificate(), and digidoc::Signature::setSigningCertificate().
std::string digidoc::Digest::getUri | ( | ) | const |
return returns digest method URI.
Definition at line 151 of file Digest.cpp.
References URI_SHA1, URI_SHA224, URI_SHA256, URI_SHA384, and URI_SHA512.
Referenced by digidoc::SignatureTM::notarize(), digidoc::SignatureBES::prepareSignedInfo(), digidoc::SignatureTM::setOCSPCertificate(), and digidoc::Signature::setSigningCertificate().
|
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
methodUri | igest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1). |
Definition at line 218 of file Digest.cpp.
Referenced by digidoc::SignatureBES::checkDocumentRefDigest(), digidoc::SignatureBES::checkKeyInfo(), and digidoc::SignatureBES::checkReferenceToSigProps().
void digidoc::Digest::reset | ( | ) |
Definition at line 167 of file Digest.cpp.
References THROW_IOEXCEPTION.
Referenced by Digest().
|
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
methodUri | digest method URI (e.g. 'http://www.w3.org/2000/09/xmldsig#sha1' for SHA1). |
IOException | throws 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().
void digidoc::Digest::update | ( | const std::vector< unsigned char > & | data | ) | throw (IOException) |
Add data for digest calculation.
data | data to add for digest calculation. |
IOException | throws exception if SHA1 update failed. |
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().
|
virtual |
Add data for digest calculation. After calling getDigest()
SHA context is uninitialized and this method should not be called.
data | data to add for digest calculation. |
length | length of the data. |
IOException | throws exception if update failed. |
Definition at line 240 of file Digest.cpp.
References THROW_IOEXCEPTION.
|
private |