From 6cec64c202b0e810cee13f54e042a46eb7b1eb0e Mon Sep 17 00:00:00 2001 From: TiynGER Date: Mon, 18 Jan 2021 19:14:55 +0100 Subject: [PATCH] openssl: added a guide on how to en-/decrypt a file and create keys --- wiki/cryptography.md | 9 +++++++++ wiki/linux/openssl.md | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 wiki/cryptography.md create mode 100644 wiki/linux/openssl.md diff --git a/wiki/cryptography.md b/wiki/cryptography.md new file mode 100644 index 0000000..336dbd8 --- /dev/null +++ b/wiki/cryptography.md @@ -0,0 +1,9 @@ +# Cryptography + +The practice of encryption and decryption is named cryptography. +There are various ways to permit the readability of a message. + +## Linux + +- [openssl](linux/openssl.md) is a big software library for secure communication +over computer networks. It can be used to encrypt and decrypt files using RSA. diff --git a/wiki/linux/openssl.md b/wiki/linux/openssl.md new file mode 100644 index 0000000..4cf3971 --- /dev/null +++ b/wiki/linux/openssl.md @@ -0,0 +1,25 @@ +# OpenSSL + +[OpenSSL](https://www.openssl.org) is a software library for secure +communication over computer networks. + +## Creating a key pair + +As described by [dreikanter](https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b) +you can create and save a pretty secure private key to `private.key` with +`openssl genrsa -aes256 -out private.key 8912`. +After that run `openssl rsa -in private.key -pubout -out public.key` to save the +according public key to `public.key`. + +## Encrypting and decrypting files + +[Dreikanter](https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b) +describes to encrypt larger files with symmetric encryption and encrypt the key +of that using asymmetric encryption. +If however the file is small enough to be encrypted with the public key +`public.key` directly run +`openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out encrypted.txt` +where `plaintext.txt` is the message to encrypt and `encrypted.txt` is the +encrypted message. +You can decrypt the message using the private key `private.key` as follows +`openssl rsautl -decrypt -inkey private.key -in encrypted.txt -out plaintext.txt`.