Question: Part II: Generate and verify digital signatures using a SHA-256 hash. * Sign a given file o Generate a SHA-256 hash of the content of
Part II: Generate and verify digital signatures using a SHA-256 hash.
* Sign a given file o Generate a SHA-256 hash of the content of the file to be signed (e.g., "file.txt", "file.exe", "mydoc.txt", ...);
*Sign/"decrypt" this hash value using the private key stored in d_n.txt; o Save the signature to a file named file_name.signature (for example, mydoc.txt.signature); (in practice, the original content and the signature are saved in one document);
* Verify the signed file o Generate a SHA-256 hash of the content of the file to be signed;
*Obtain the signature from the signature file; o "encrypt" saved hash value (signature) using the public key stored in e_n.txt;
* Compare the SHA-256 hash value and the "encrypted" signature;
*Report whether the document is authentic or modified. Output to the console "authentic" if authentic, "modified" if not authentic. SHA-256 algorithm generates an almost-unique, fixed size 256-bit (32-byte) hash. See https://en.wikipedia.org/wiki/SHA-2 for more description of SHA.
For a c++ implementation, you can download the messageDigest written by Olivier or access the code directly at: https://www.zedwood.com/article/cpp-sha256-function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
