#include // CS 1501 Fall 2002 // Some help and guidance for your Digital Signature assignment #include // needed for atoi and itoa #include #include main() { unsigned char csig[48]; // overall array for signature unsigned char stamp[16] = "JR20021017004435"; // Example initials, date // and time with NO separators index locations // will be used for parsing ZZ modulus, other, zsig; // ZZs for modulus, hash result and overall signature RandomLen(modulus, 128); // example modulus RandomLen(other, 128); // example hash result (you must calculate this // in your program) unsigned char moda[16], othera[16]; BytesFromZZ(moda, modulus, 16L); // Converting ZZs into 16 char strings BytesFromZZ(othera, other, 16L); for (int i = 0; i < 16; i++) // Now the overall signature string is set { // very specifically -- 16 chars for each csig[i] = stamp[i]; // of the 3parts csig[i + 16] = moda[i]; csig[i + 32] = othera[i]; } ZZFromBytes(zsig, csig, 48L); // This is the ZZ overall signature prior // to RSA encoding. Once RSA decrypted, // follow directions as stated in the // assignment // Now we'll see how the ZZ is converted back to its parts. Naturally, the // decrypted ZZ must first be read from the file (using >>) and then // RSA encrypted to reveal the signature ZZ ZZ newmod, newother; unsigned char newcsig[48], newstamp[16], newmoda[16], newothera[16]; int newnum; BytesFromZZ(newcsig, zsig, 48L); // First convert the sig ZZ back into a // sequence of bytes for (int i = 0; i < 16; i++) // break it up into its components { newstamp[i] = newcsig[i]; newmoda[i] = newcsig[i + 16]; newothera[i] = newcsig[i + 32]; } ZZFromBytes(newmod, newmoda, 16L); // ways ZZFromBytes(newother, newothera, 16L); // Check to see that the values match cout << "Original: " << endl; for (int i = 0; i < 16; i++) cout << stamp[i]; cout << endl; cout << modulus << ":" << other << endl; cout << endl; cout << "Copies: " << endl; for (int i = 0; i < 16; i++) cout << newstamp[i]; cout << endl; cout << newmod << ":" << newother << endl; }