Openssl Cheat Sheet: by Via
Openssl Cheat Sheet: by Via
Checking version Encrypt a file using ARIA 256 in CBC block cipher mode using a specified
openssl version -a encryption key (K:256 bits) and initialization vector (iv:128 bits)
How fast it runs on the system using four CPU cores and openssl enc -aria-256-cbc -in cleartext.file -out ciphertext.file -K
Get basic help Encrypt a file using Camellia 192 algorithm in COUNTER block cipher mode
openssl help with key and iv provided
openssl enc -camellia-192-ctr -in cleartext.file -out ciphertext.file -K
ENCODING / DECODING 6c7a1b3487d28d3bf444186d7c529b48d67dd6206c7a1b34 -iv
470bc29762496046882b61ecee68e07c
Encoding a file using Base64
openssl base64 -in file.data
ASYMMETRIC ENCRYPTION
Encoding some text using Base64
List elliptic curves available
echo -n "some text" | openssl base64
openssl ecparam -list_curves
Base64 decode a file with output to another file
Create 4096 bits RSA public-private key pair
openssl base64 -d -in encoded.data -out decoded.data
openssl genrsa -out pub_priv.key 4096
List all supported symmetric encryption ciphers Encrypt private key using 3DES algorithm
openssl enc -list openssl ec -in ecP384priv.key -des3 -out ecP384priv_enc.key
Generate DSA parameters for the private key. 2048 bits length Display the public key contained in the CSR file
openssl dsaparam -out dsaparam.pem 2048 openssl req -pubkey -noout -in request.csr
Generate DSA public-private key for signing documents and protect Create a self-signed certificate, a new 2048 bits RSA key pair with
it using AES128 algorithm one year of validity
openssl gendsa -out dsaprivatekey.pem -aes-128-cbc openssl req -newkey rsa:2048 -nodes -keyout priv.key -x509 -
dsaparam.pem days 365 -out cert.crt
Copy the public key of the DSA public-private key file to another file Create and sign a new certificate using the CSR file and the private
openssl dsa -in dsaprivatekey.pem -pubout -out key for signing ( you must have a openssl.cnf file prepared )
dsapublickey.pem openssl ca -in request.csr -out certificate.crt -config
To print out the contents of a DSA key pair file ./CA/config/openssl.cnf
openssl dsa -in dsaprivatekey.pem -text -noout Display PEM format certificate information
Signing the sha-256 hash of a file using RSA private key openssl x509 -text -noout -in cert.crt
openssl dgst -sha256 -sign rsakey.key -out signature.data Extract the certificate's public key
document.pdf openssl x509 -pubkey -noout -in cert.crt
Signing the sha3-512 has of a file using DSA private key Extract the public key's modulus in the certificate
openssl pkeyutl -sign -pkeyopt digest:sha3-512 -in openssl x509 -modulus -noout -in cert.crt
document.docx -inkey dsaprivatekey.pem -out signature.data Convert a certificate from PEM to DER format
Verify DSA signature openssl x509 -inform PEM -outform DER -in cert.crt -out
openssl pkeyutl -verify -sigfile dsasignature.data -inkey cert.der
dsakey.pem -in document.docx Checking whether the certificate pubic key matches a private key
Create a private key using P-384 Elliptic Curve and request file. One step per file. Must match in the output hashes.
openssl ecparam -name secp384r1 -genkey -out ecP384priv.key openssl x509 -modulus -in certificate.crt -noout | openssl dgst -
Encrypt private key using 3DES algorithm sha256
openssl ec -in ecP384priv.key -des3 -out ecP384priv_enc.key openssl rsa -modulus -in private.key -noout | openssl dgst -
sha256
Sign a PDF file using Elliptic Curves with the generated key
openssl req -modulus -in request.csr -noout | openssl dgst -
openssl pkeyutl -sign -inkey ecP384priv_enc.key -pkeyopt
sha256
digest:sha3-512 -in document.pdf -out signature.data
Verify the file's signature. If it's ok you must receive "Signature
WORKING WITH TLS PROTOCOL
Verified Successfully"
List all cipher suites supported
openssl pkeyutl -verify -in document.pdf -sigfile signature.data
openssl ciphers -V 'ALL'
-inkey ecP384priv_enc.key
List all cipher suites supported with AES
DIGITAL CERTIFICATES openssl ciphers -V 'AES'
Generating a CSR file and a 4096 bits RSA key pair List all cipher suites supporting CAMELLIA & SHA256 algorithms.
openssl req -newkey rsa:4096 -keyout private.key -out openssl ciphers -V 'CAMELLIA+SHA256'
request.csr TLS connection to a server using port 443 (HTTPS)
Display Certificate Signing Request ( CSR ) content openssl s_client -connect domain.com:443
openssl req -text -noout -in request.csr
WORKING WITH TLS PROTOCOL (cont) SIMPLE CA CONFIGURATION FILE ( openssl.cnf ) (cont)
[ ca ]
default_ca = CA_default
[ CA_default ]
dir = ./personalCA
database = $dir/index.txt
new_certs_dir = $dir/newcerts
certificate = $dir/cacert.pem