RSA Encryption and Digital Signature

Generate Private Key

openssl genrsa --out private.key

Generate Public Key

openssl pkey -in private.key -out public.key

RSA Encryption

echo 'Hello Alice!' | tee plain.text

openssl rsautl -encrypt -inkey private.key -in plain.text -out encrypt.data

openssl rsautl -decrypt -inkey public.key  -in encrypt.data -out decrypt.data

cat decrypt.data

RSA Digital Signature

echo 'Hello Bob' | tee plain.text

openssl rsautl -sign -inkey private.key -in plain.text -out sign.data

openssl rsautl -verify -inkey public.key -in sign.data -out verify.data

cat verify.data

参考:

https://en.wikipedia.org/wiki/Public-key_cryptography
https://www.cgi.com/files/white-papers/cgi_whpr_35_pki_e.pdf

 922 total views,  1 views today