Photo by Signature Pro on Unsplash

Digital Trust: The Magic of r and s

--

So, what does a digital signature look like? Well, it often has an r value and an s value: (r,s). So, let’s look at the DSA (Digital Signature Algorithm) signature. For this, Figure 1 shows an outline of the setup of the DSA signature, and where Bob uses his private key (sk) to sign a hash of a message, and Alice proves with his public key (pk,g,p,q). We also use a random nonce value (k) for the signature, and we must take care that we do not reuse the value.

The output of the signature is (r,s). We can create a keypair and signature for a file named test.txt. In this case, we create a 1,024 bit key pair and use the SHA-256 hash. The file contains “This is a test.” [here]:

openssl dsaparam -out dsaparam.pem 1024
openssl gendsa -out 1.pem dsaparam.pem
openssl dgst -sha256 -sign 1.pem -out 1.sig -hex test.txt
type 1.sig
type 1.sig | openssl enc -base64
openssl dsa -in 1.pem - text

and a sample test [here]:

SA-SHA2-256(test.txt)= 303c021c41f04a15af85a5215f181ccd1999931db8051cd6c77c71d9dfa9b079021c17be382511cd4313fb24bec6618390638a1b652600a68d633bf9b23e

RFNBLVNIQTItMjU2KHRlc3QudHh0KT0gMzAzYzAyMWM0MWYwNGExNWFmODVhNTIx…

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.