libdigidocpp
digidoc::CNGSigner Class Reference

#include <CNGSigner.h>

Inheritance diagram for digidoc::CNGSigner:
Inheritance graph
Collaboration diagram for digidoc::CNGSigner:
Collaboration graph

Public Member Functions

 CNGSigner (const std::string &pin, bool selectFirst) throw (SignException)
virtual ~CNGSigner ()
X509 * getCert () const throw (SignException)
void setPin (const std::string &pin)
void setSelectFirst (bool first)
void sign (const Digest &digest, Signature &signature) throw (SignException)
virtual int type () const
- Public Member Functions inherited from digidoc::Signer
virtual ~Signer ()
void setSignatureProductionPlace (const SignatureProductionPlace &signatureProductionPlace)
SignatureProductionPlace getSignatureProductionPlace () const
void setSignerRole (const SignerRole &signerRole)
SignerRole getSignerRole () const

Private Attributes

CNGSignerPrivated

Detailed Description

Definition at line 27 of file CNGSigner.h.

Constructor & Destructor Documentation

CNGSigner::CNGSigner ( const std::string &  pin,
bool  selectFirst 
) throw (SignException)

Initializes CNG library

Exceptions
SignExceptionexception is thrown if the provided CNG driver loading failed.

Definition at line 125 of file CNGSigner.cpp.

CNGSigner::~CNGSigner ( )
virtual

Uninitializes CNG library and releases acquired memory.

Definition at line 142 of file CNGSigner.cpp.

References d, and digidoc::CNGSignerPrivate::h.

Member Function Documentation

X509 * CNGSigner::getCert ( ) const throw (SignException)
virtual

Finds all slots connected with the computer, if the slots have tokens, lists all certificates found in token. If there are more that 1 certificate lets the user application select (by calling the selectSignCertificate callback function) the certificate used for signing.

Returns
returns certificate used for signing.
Exceptions
throwsexception if failed to select the signing certificate. For example no cards found or card has no certificate.

Implements digidoc::Signer.

Definition at line 159 of file CNGSigner.cpp.

References _CRYPTUI_SELECTCERTIFICATE_STRUCT::cDisplayStores, digidoc::CNGSignerPrivate::cert, digidoc::CNGSignerPrivate::CertFilter(), CryptUIDlgSelectCertificate, d, digidoc::CNGSignerPrivate::f_NCryptFreeObject, digidoc::X509Cert::handle(), digidoc::CNGSignerPrivate::key, _CRYPTUI_SELECTCERTIFICATE_STRUCT::pFilterCallback, _CRYPTUI_SELECTCERTIFICATE_STRUCT::pvCallbackData, _CRYPTUI_SELECTCERTIFICATE_STRUCT::rghDisplayStores, digidoc::CNGSignerPrivate::selectFirst, and THROW_SIGNEXCEPTION.

Referenced by type().

Here is the call graph for this function:

Here is the caller graph for this function:

void CNGSigner::setPin ( const std::string &  pin)

Definition at line 212 of file CNGSigner.cpp.

References d, digidoc::util::File::encodeName(), and digidoc::CNGSignerPrivate::pin.

Here is the call graph for this function:

void CNGSigner::setSelectFirst ( bool  first)

Definition at line 217 of file CNGSigner.cpp.

References d, and digidoc::CNGSignerPrivate::selectFirst.

void CNGSigner::sign ( const Digest digest,
Signature signature 
) throw (SignException)
virtual

Signs the digest provided using the selected certificate. If the certificate needs PIN, the PIN is acquired by calling the callback function getPin.

Parameters
digestdigest, which is being signed.
signaturememory for the signature that is created. Struct parameter length is set to the actual signature length.
Exceptions
SignExceptionthrows exception if the signing operation failed.

Implements digidoc::Signer.

Definition at line 231 of file CNGSigner.cpp.

References d, DEBUG, e, digidoc::CNGSignerPrivate::f_NCryptSetProperty, digidoc::CNGSignerPrivate::f_NCryptSignHash, digidoc::CNGSignerPrivate::key, digidoc::CNGSignerPrivate::pin, digidoc::Exception::PINCanceled, digidoc::Exception::PINFailed, digidoc::Exception::setCode(), and THROW_SIGNEXCEPTION.

Here is the call graph for this function:

int digidoc::CNGSigner::type ( ) const
virtual
Returns
returns signature digest method

Reimplemented from digidoc::Signer.

Definition at line 279 of file CNGSigner.cpp.

References getCert(), digidoc::X509Cert::getCertificatePolicies(), digidoc::Conf::getInstance(), digidoc::X509Cert::getPaddingSize(), i, and digidoc::Digest::toMethod().

Here is the call graph for this function:

Member Data Documentation

CNGSignerPrivate* digidoc::CNGSigner::d
private

Definition at line 40 of file CNGSigner.h.

Referenced by getCert(), setPin(), setSelectFirst(), sign(), and ~CNGSigner().


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