My way to answer this question:
Load the public key
@
QCA::ConvertResult conv_res;
QCA::PublicKey pub_key = QCA::PublicKey::fromPEMFile("public.pem", &conv_res);
if(conv_res != QCA::ConvertGood){
qDebug() << "Public key could not be loaded";
return;
}
@
Loading the signature file:
@
QFile sig_file("signature");
sig_file.open(QFile::ReadOnly);
QByteArray sig_text = sig_file.readAll();
sig_file.close();
@
Finally verifying the signature
@
// sec_data is a plain data QCA::SecureArray object that was previosly decrypted using the private key counterpart of the public key being used here
if(!pub_key.canVerify()){
qDebug() << "Bad public key";
return;
}else{
pub_key.startVerify(QCA::EMSA3_SHA1);
pub_key.update(sec_data.data());
if(pub_key.validSignature(sig_text)){
qDebug() << "Signature verification suceedded";
}else{
qDebug() << "Signature verification failed";
}
// To make the verification in one step:
if(pub_key.verifyMessage( sec_data.data(), sig_text, QCA::EMSA3_SHA1)){
Log::write(Log::Levels::Success, "One step signature validation succeeded");
}
}
@
BTW, I used the following command to generate the signed digest of my data.txt file(using Ubuntu Linux):
openssl dgst -verify public.pem -signature signature data.txt