Virgil Security Crypto library  2.6.3
Public Member Functions | Protected Member Functions | List of all members
virgil::crypto::VirgilSignerBase Class Reference

This class provides common functionality to sign and verify data using Virgil Security keys. More...

#include <VirgilSignerBase.h>

Inheritance diagram for virgil::crypto::VirgilSignerBase:
virgil::crypto::VirgilSeqSigner virgil::crypto::VirgilSigner virgil::crypto::VirgilStreamSigner

Public Member Functions

 VirgilSignerBase (foundation::VirgilHash::Algorithm hashAlgorithm=foundation::VirgilHash::Algorithm::SHA384)
 Create signer with predefined hash function. More...
 
foundation::VirgilHash::Algorithm getHashAlgorithm () const
 Return hash algorithm that SHOULD be used to calculate digest of the data to be signed. More...
 
VirgilByteArray signHash (const VirgilByteArray &digest, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
 Create signature over pre-calculated hash. More...
 
bool verifyHash (const VirgilByteArray &digest, const VirgilByteArray &signature, const VirgilByteArray &publicKey)
 Verify signature over pre-calculated hash. More...
 

Protected Member Functions

VirgilByteArray packSignature (const VirgilByteArray &signature) const
 Pack given signature to the ASN.1 structure. More...
 
VirgilByteArray unpackSignature (const VirgilByteArray &packedSignature)
 Unpack signature and correspond hash algorithm from the ASN.1 structure. More...
 

Detailed Description

This class provides common functionality to sign and verify data using Virgil Security keys.

Constructor & Destructor Documentation

virgil::crypto::VirgilSignerBase::VirgilSignerBase ( foundation::VirgilHash::Algorithm  hashAlgorithm = foundation::VirgilHash::Algorithm::SHA384)
explicit

Create signer with predefined hash function.

Note
Specified hash function algorithm is used only during signing.

Member Function Documentation

foundation::VirgilHash::Algorithm virgil::crypto::VirgilSignerBase::getHashAlgorithm ( ) const

Return hash algorithm that SHOULD be used to calculate digest of the data to be signed.

Returns
Hash Algorithm.
VirgilByteArray virgil::crypto::VirgilSignerBase::packSignature ( const VirgilByteArray signature) const
protected

Pack given signature to the ASN.1 structure.

VirgilSignature ::= SEQUENCE {
digestAlgorithm ::= AlgorithmIdentifier,
signature ::= OCTET STRING
}
Parameters
signature- signature to be wrapped
Returns
Packed signature.
Note
This function use value returned by function getHashAlgorithm().
VirgilByteArray virgil::crypto::VirgilSignerBase::signHash ( const VirgilByteArray digest,
const VirgilByteArray privateKey,
const VirgilByteArray privateKeyPassword = VirgilByteArray() 
)

Create signature over pre-calculated hash.

Parameters
digest- hash digest of the data.
privateKey- private key to be used for signature operation.
privateKeyPassword- private key password.
Returns
Signature.
VirgilByteArray virgil::crypto::VirgilSignerBase::unpackSignature ( const VirgilByteArray packedSignature)
protected

Unpack signature and correspond hash algorithm from the ASN.1 structure.

VirgilSignature ::= SEQUENCE {
digestAlgorithm ::= AlgorithmIdentifier,
signature ::= OCTET STRING
}
Parameters
packedSignature- signature packed within ASN.1 structure.
Returns
Signature.
Note
This function has side-effect it changes object field VirgilSignerBase::hashAlgorithm_, that can be accessed via function getHashAlgorithm().
bool virgil::crypto::VirgilSignerBase::verifyHash ( const VirgilByteArray digest,
const VirgilByteArray signature,
const VirgilByteArray publicKey 
)

Verify signature over pre-calculated hash.

Parameters
digest- hash digest of the data.
signature- signature.
publicKey- public key to be used for signature verification.
Returns
true if signature verification was successful, false - otherwise.

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