示例#1
0
void bdoc::Signature::validateOffline(bdoc::X509CertStore *store)
{
    DECLARE_STACK_EXCEPTION("Signature is invalid");

    try {
        checkQualifyingProperties();
    }
    catch (StackExceptionBase& e) {
        exc.add(e);
    }

    try {
        checkSignatureMethod();
        checkReferences();
        checkKeyInfo();
        checkSignatureValue();
    }
    catch (StackExceptionBase& e) {
        exc.add(e);
    }

    try {
        checkSigningCertificate(store);
    }
    catch (StackExceptionBase& e) {
        exc.add(e);
    }

    if (exc.hasCauses()) {
        throw exc;
    }
}
示例#2
0
/**
 * Check if signature is valid according to BDoc-BES format. Performs
 * any off-line checks that prove mathematical correctness.
 * However, there is no warranty against if the signature has expired. On-line
 * validation should be performed to check for signature expiration.
 *
 * @throws SignatureException containing details on what's wrong in this signature.
*/
void digidoc::SignatureBES::validateOffline() const throw(SignatureException)
{
    // A "master" exception containing all problems (causes) with this signature.
    // It'll be only thrown in case we have a reason (cause).
    SignatureException resultException(__FILE__, __LINE__, "Signature is invalid");


    try
    {
        checkQualifyingProperties();
    }
    catch (digidoc::Exception& e)
    {
        resultException.addCause(e); // remember and proceed
    }

    try
    {
        checkSignature();
    }
    catch (digidoc::Exception& e)
    {
        resultException.addCause(e); // remember and proceed
    }

    try
    {
        checkSigningCertificate();
    }
    catch (digidoc::Exception& e)
    {
        resultException.addCause(e); // remember and proceed
    }

    // now check if we've gathered some problems with this signature
    if ( resultException.hasCause() )
    {
        throw resultException;
    }
    // else: this signature is fine
}