Yes, I modified the program with read() instead of getline(). This works
sometimes, I'm going to explain better:
*I save the signature, in "signing method", calculated with RSASS<PSS,SHA1>
as a string object , this way:*
fstream f1; //local variable
f1.open("./Signatures", fstream::out | fstream::binary) // I don't
use fstream::app because I'm testing with only one file
//I use is_open() to check that the file is really open
f1.write(signature.c_str(), signature.size());
// signature size is always 192 bytes, it is a public class member
variable
f1.close();
*I load the signature, in "checking method" this way:*
fstream f2;
int size;
//local variables
f2.open("./Signatures", fstream::in | fstream::binary)
//I use is_open() to check the file is really open
f2.seekg(0, ios::end);
size = tellg();
cout << "size" << size << "bytes\n";
//it checks the size of the file "Signatures": always 192 bytes;
because every time I sign a new file the new signature overwrite the old one
f2.seekg(0, ios::beg); //get
pointer back to the beginning of the file
*char buffer[size];*
//local char array, dimensionated with the size of the signature (always
192 bytes)
int i;
for(i = 0; i< size; i++)
{
buffer[i] = 0;
//buffer initialization
}
*f2.read(buffer, size);*
cout << f2.gcount() << "bytes\n"; //it reads
always:192 bytes
f2.close();
digsignature = "";
//public class member variable
*digsignature = buffer*;
*cout << digsignature << "bytes\n";* //The digital
signature is valid only if digsignature = 192 bytes
try
{
StringSource SS(esadigest + *buffer*, true, new
SignatureVerificationFilter(Verifier, new StirngSink(recovered),
SignatureVerificationFilter::EXCEPTION |
SignatureVerificationFilter::PUT_MESSAGE));
// I use buffer (always 192 bytes) in SS, but It works only if digsignature
= 192 bytes. Sometimes it has a value less or more of 192 bytes (why???)
}
catch(CryptoPP::Exception e)
{
cerr << "ERROR:" << e.what();
}
e.what() returns: digital signature is not valid; esadigest is checked the
same of that calculated; my key pair is checked valid and I don't think its
format could make problems.
So the digital signature is the problem, something in the way I save/read
it goes wrong. I am very close to finish this project, but I can't until I
fix this.
Maybe I should build a function that transforms bytes to char and char to
byte to deal with the signature? And in this case, how should I save the
signature?
Any suggestions?
Michele
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.