Open ssl1
Open ssl1
Kaouther hamani
Chams Nadine Saadallah
OpenSSL
OpenSSL is an open source software
library useful for encryption and secure
network communication. SSL stands for
Secure Sockets Layer, a cryptographic
communications protocol.
OpenSSL
Protocole SSL Le protocole TLS
Le protocole SSL estpour
est un acronyme entre la couche
Secure Socket TCP/IP
Layer quiet une (Transport Layer Security) est une évolution de
application
est un utilisant
protocoleTCP.(en Lefait principe
un ensemblegénérale
de d’un SSL réalisé par l’IETF et qui sert de base à
protocole de typequi
protocoles) SSL est qu’il
a été se passe
développé par en
la deux temps : HTTPS par exemple.
société
1. Une poignée Communication
Netscape de mains : c’est une étape durant
Corporation laquelle
pour
le client et le serveur
permettre de la s’identifient,
communication se mettent d’accord
sécurisée en sur
le type du système
mode de chiffrement
client/serveur pour des et lesapplication
clefs qui seront
utilisés lors du
réseaux reste de
utilisant la communication. 2. La phase de
TCP/IP.
communication : les données sont alors échangées en
format compressées et chiffrées et signées.
OpenSSL
This tutorial will demonstrate one way to use openssl to exchange a file
between two parties. There are 3 sections on asymmetric encryption,
certificates and RSA
OpenSSL
Asymmetric Encryption:
Let’s say you have two parties (Alice and Bob) communicating over an insecure network, one on which an
attacker (Eve) could intercept all communications. They want to communicate with confidentiality , meaning
Eve shouldn’t be able to understand what they’re talking about, even if she can listen to everything they are
sending each other. They want authenticity – Eve shouldn’t be able to defraud Alice by sending messages to
her claiming to be from Bob, and vice versa.
OpenSSL
Certificates:
Alice and Bob can use certificates to ensure that their public keys are authentic. They first generate a
certificate signing request (CSR) that contains their public keys, some important information about
themselves (name, address, organization, etc..) and is signed with their private keys. These CSR’s are then
signed by a trusted third party - a Certificate Authority (CA) , with a private key of its own, and turned into
certificates.
OpenSSL
RSA:
The setup behind RSA is as follows:
1. Select two large primes p and q
2. Compute n = pq and Ф(n) = (p - 1)(q - 1)
3. Choose an encryption key e that is relatively prime to Ф(n)
4. Calculate a decryption key d such that ed = 1 mod Ф(n)
5. Your private key is all of { e, n, p, q, d }
6. Your public key is { e, n } i.e the public exponent and modulus
Then the encryption and decryption functions are (where M = message, C = ciphertext):
● C = Me mod n
● M = Cd mod n
It’s important to note that in practice M should not be a plaintext
message. Rather a plaintext message should be processed into M
using a padding algorithm.
OpenSSL
1.Download the OpenSSL for Windows installation package.
2.Double-click the installation file.
3.If the following error message appears, you should install Microsoft Visual C++
2008 Redistributables.
4.Double-click the installation file and click on Next
If you want to follow along, you can make 3 folders, 1 for Alice, Bob and the CA respectively. You need to
repeat steps 1.a and 1.b for Bob and CA so they can have their own pair of keys. And you need to generate a
self-signed certificate for the CA (shown below).
OpenSSL
Step 1.a - Alice generates a private key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 –pkeyopt rsa_keygen_pubexp:3 -out privkey-A.pem
● x509 ➝ an x509 certificate utility (displays, converts, edits and signs x509 certificates)
● -req ➝ a certificate request is taken as input (default is a certificate)
● -CA root.crt ➝ specifies the CA certificate to be used as the issuer of Alice’s certificate
● -CAkey rootkey.pem ➝ specifies the private key used in signing (rootkey.pem)
● -CAcreateserial ➝ creates a serial number file which contains a counter for how many
certificates were signed by this CA
● -days 500 ➝ sets Alice’s certificate to expire in 500 days
● -sha256 ➝ specifies the hashing algorithm to be used for the certificate’s signature
OpenSSL
Step 2.a - Alice verifies Bob’s public certificate
openssl verify -CAfile root.crt Bob.crt
Step 3.c - Alice hashes symkey.pem and encrypts it using her private key
● dgst -sha1 ➝ hash the input file using the sha1 algorithm
● -sign privkey-A.pem ➝ sign the hash with the specified private key
● symkey.pem ➝ the input file to be hashed
OpenSSL
Step 4.a - Bob decrypts symkey.enc using his private key
openssl pkeyutl -decrypt - in symkey.enc -inkey privkey-B.pem –out symkey.pem
openssl enc -aes-256-cbc -pass file:symkey.pem -p -md sha256 – in largefile.txt -out ciphertext.bin
openssl enc -aes-256-cbc -d -pass file:symkey.pem -p -md sha256 – in ciphertext.bin -out largefile.txt
● -d ➝ decryption flag