SlideShare a Scribd company logo
DES & RSA Algorithms Overview
                Tutorial




03/01/2013       NOUNI El Bachir     1
Comparison And Uses



DES : It's a symmetric algorithm designed for
 encrypting data. Its advantage is that it's fast for
 large data size, but it present one inconvenient
 is that of changing keys between the tow tiers.




03/01/2013             NOUNI El Bachir                  2
Comparison And Uses



RSA : it's an asymmetric algorithm designed for
 encrypting data also. Its inconvenience is that
 it's too slow for large data size. It use tow keys
 instead of DES which uses one shared key. One
 of these keys is secret and the other is public.
 The Data that is encrypted by one is decrypted
 by the other but not by the same key.

03/01/2013           NOUNI El Bachir              3
Tools

 
     Through this tutorial we will use the Openssl
     tool. This tool is by default integrated in Linux.
     For Windows users they should download this
     tool by following this link :
     http://slproweb.com/products/Win32OpenSSL.html
 
     After the installation of openssl; whether you
     add the path of openssl.exe to your system
     path, our each time at the command prompt
     you use the full path of openssl.exe.

03/01/2013                    NOUNI El Bachir             4
Parameters Of These Algorithms

 
     DES :
             −   Secret key (64 bits)
             −   Initialization vector (64 bits)
 
     RSA :
             −   Secret key
             −   Secret key length
             −   Public key
             −   The modulus
03/01/2013                      NOUNI El Bachir    5
TP : Test Each Algorithm (DES)

 
     The instructions thereafter were tested under
     Linux system.
 
     DES :
 To use this algorithm we have to generate first
   its parameters (secret key,initialization vector).
   To do so we will use /dev/urandom file and
   head command.
 The synopsis of each one is :

03/01/2013              NOUNI El Bachir                 6
TP : Test Each Algorithm (DES)

 
     |> cat /dev/urandom | head -1 > random.bin

 
     the result after using |> xxd            random.bin   to show file
     content in Hex format :
 0000000: 95c3 e2d9 62c9 8d24 fa03 69e7 59aa aa11      ....b..$..i.Y...

 
     So we choose 95C3E2D962C98D24 as secret Key
     and FA0369E759AAAA11 as initialization vector.
 
     After that we can encrypt and decrypt a file.
 |> Openssl enc -e -des-cbc -in inputfile -out outputfile -nosalt -K
    95C3E2D962C98D24 -iv FA0369E759AAAA11 -a



03/01/2013                       NOUNI El Bachir                          7
TP : Test Each Algorithm (DES)

 
     -des-cbc : DES algorithm using CBC mode
 
     -e : for encryption
 
     -in [inputfile] : to specify input file
 
     -out [outputfile] : to specify output file
 
     -K XX..XX : to specify secret key 64 bits
 
     -iv XX..XX : to specify initialization vector 64 bits
 
     -a : encoding output file in base64 format
 
     -nosalt : no salt will be used
03/01/2013                    NOUNI El Bachir                8
TP : Test Each Algorithm (DES)

 
     For decryption we use the same command line,
     we have to just change -e option by -d for
     decryption.




03/01/2013            NOUNI El Bachir           9
TP : Test Each Algorithm (RSA)

The implementation of RSA follow three steps :
    Generate a encrypted secret key of 1024 or
    2048 length.
     Generate the public key from the secret one.
To do so, we will use genrsa and rsa commands.
    Synopsis of these commands is :


03/01/2013             NOUNI El Bachir              10
TP : Test Each Algorithm (RSA)

 
         openssl genrsa [-out filename] [-passout arg] [-des] [-des3] [-idea]
         [-f4] [-3] [-rand file(s)] [-engine id] [numbits]
 
         openssl rsa [-inform PEM|NET|DER] [-outform PEM|NET|DER] [-in
         filename] [-passin arg] [-out filename] [-passout arg] [-sgckey] [-
         des] [-des3] [-idea] [-text] [-noout] [-modulus] [-check] [-pubin]
         [-pubout] [-engine id]

 For encryption we will use rsautl command of
    following synopsis :
 
         openssl rsautl [-in file] [-out file] [-inkey file] [-pubin] [-
         certin] [-sign] [-verify] [-encrypt] [-decrypt] [-pkcs] [d-ssl] [-
         raw] [-hexdump] [-asn1parse]

 Lets now try this algorithm :

03/01/2013                        NOUNI El Bachir                          11
TP : Test Each Algorithm (RSA)

To generate the secret key :
|> openssl genrsa -des -out sckey.pem 2048

-des : DES which will be used to encrypt the
  secret key.
-out : to specify the output file.
2048 : key length.
After Enter Key press the prompt will demand to
  you to enter a phrase password.
03/01/2013                     NOUNI El Bachir    12
TP : Test Each Algorithm (RSA)

To generate the public key :
|> openssl rsa -pubout < sckey.pem > pkey.pem

-pubout : to specify that wie want to generate a
  public key from the secret one sckey.pem.
< : input flow redirection
> : output flow redirection



03/01/2013                     NOUNI El Bachir     13
TP : Test Each Algorithm (RSA)

To encrypt data with public key :
|> openssl rsautl -encrypt -in inputfile -out outputfile -inkey pkey.pem
   -pubin -a

-encrypt : for encryption.
-in : to specify input file path.
-out : to specify output file.
-inkey : key file to use.
-pubin : specify that the key specified with -inkey
    is a public key. Without this options secret key
    is used.
03/01/2013              NOUNI El Bachir              14
Best practice

RSA : to exchange shared secret key
DES : to encrypt data using exchanged shared
 secret key.
Scenario :
Alice (sA,PA) and Bobe (sB,PB).
Alice want send data to Bobe, but it is the first
  time. So they should define a shared key.

03/01/2013             NOUNI El Bachir              15
Best practice

So Alice had to generate a random 64 bits key
 (DES) and an initialization vector (64 bits) and
 encrypt it using the public key of Bobe P B. Then
 send it to Bobe.
Bobe will receive encrypted key and will decrypt it.
 At this moment its ok but he should send an
 acknowledgment to Alice to tell him that he
 receive the key successfully. So he should
 encrypt the received key using public key of
 Alice and send it to him.
03/01/2013            NOUNI El Bachir                16
Best practice

After this handshaking it is ok to exchange
  encrypted that using shared secret key (64 bits).
It is recommended to use Tripe DES instead of
   DES because it is more secure. To use this
   algorithm in what we have seen, you can just
   change -des by -des3 in RSA section and for
   DES section you choose -des-ede-cbc instead
   of -des-cbc.


03/01/2013           NOUNI El Bachir              17
Bibliography

http://www.openssl.org/docs/apps/enc.html
http://www.openssl.org/docs/apps/genrsa.html
http://www.openssl.org/docs/apps/rsautl.html
http://www.openssl.org/docs/apps/rsa.html




03/01/2013             NOUNI El Bachir         18
Thanks
             nouni.ebachir@gmail.com




03/01/2013        NOUNI El Bachir      19

More Related Content

PPTX
Addressing modes of 8086
PPT
Gsm radio-interface
PPTX
Automata Theory - Turing machine
PPTX
8257 DMA Controller
PPTX
Encapsulating security payload in Cryptography and Network Security
PPTX
HDLC(High level Data Link Control)
PPTX
LINEAR BOUNDED AUTOMATA (LBA).pptx
PDF
PAI Unit 3 Paging in 80386 Microporcessor
Addressing modes of 8086
Gsm radio-interface
Automata Theory - Turing machine
8257 DMA Controller
Encapsulating security payload in Cryptography and Network Security
HDLC(High level Data Link Control)
LINEAR BOUNDED AUTOMATA (LBA).pptx
PAI Unit 3 Paging in 80386 Microporcessor

What's hot (20)

PPTX
Rice Theorem.pptx
PDF
Block cipher modes of operations
PPTX
IEEE 802.11 Architecture and Services
PPTX
Cyclic redundancy check
PPTX
Leaky bucket A
PPT
Traditional symmetric-key cipher
PPTX
IP Security
PPTX
IEEE STANDARDS 802.3,802.4,802.5
PPTX
Code generation
PPT
Mac layer
PPTX
Asynchronous transfer mode
PPTX
Evolution of microprocessors and 80486 Microprocessor.
PPTX
Ascii adjust & decimal adjust
PPTX
Hdlc ppt..
PPTX
Ethernet Computer network
PPT
Congestion control and quality of service
PDF
Amba bus
PPTX
Leaky Bucket & Tocken Bucket - Traffic shaping
PPTX
Ssl and tls
Rice Theorem.pptx
Block cipher modes of operations
IEEE 802.11 Architecture and Services
Cyclic redundancy check
Leaky bucket A
Traditional symmetric-key cipher
IP Security
IEEE STANDARDS 802.3,802.4,802.5
Code generation
Mac layer
Asynchronous transfer mode
Evolution of microprocessors and 80486 Microprocessor.
Ascii adjust & decimal adjust
Hdlc ppt..
Ethernet Computer network
Congestion control and quality of service
Amba bus
Leaky Bucket & Tocken Bucket - Traffic shaping
Ssl and tls
Ad

Viewers also liked (20)

PDF
RSA ALGORITHM
PDF
The 3-D Secure Protocol
DOC
Rsa Algorithm
PPT
Data encryption, Description, DES
PPTX
All About Snort
PDF
PDF
Patterns for Secure Boot and Secure Storage in Computer Systems
PPT
Mathematics Towards Elliptic Curve Cryptography-by Dr. R.Srinivasan
PPTX
RSA ALGORITHM
PDF
ECC vs RSA: Battle of the Crypto-Ninjas
PDF
JTAG Interface (Intro)
PPT
13 asymmetric key cryptography
PPT
PKI and Applications
PDF
Elliptic Curve Cryptography for those who are afraid of maths
PPTX
Hazards & protection
PDF
SSL Secure socket layer
PPT
Secure Socket Layer (SSL)
DOCX
Steganography using visual cryptography: Report
PDF
Elliptic Curve Cryptography and Zero Knowledge Proof
RSA ALGORITHM
The 3-D Secure Protocol
Rsa Algorithm
Data encryption, Description, DES
All About Snort
Patterns for Secure Boot and Secure Storage in Computer Systems
Mathematics Towards Elliptic Curve Cryptography-by Dr. R.Srinivasan
RSA ALGORITHM
ECC vs RSA: Battle of the Crypto-Ninjas
JTAG Interface (Intro)
13 asymmetric key cryptography
PKI and Applications
Elliptic Curve Cryptography for those who are afraid of maths
Hazards & protection
SSL Secure socket layer
Secure Socket Layer (SSL)
Steganography using visual cryptography: Report
Elliptic Curve Cryptography and Zero Knowledge Proof
Ad

Similar to (Crypto) DES And RSA Algorithms Overview (20)

PDF
Computer Security Laboratory Manual .pdf
PPSX
comp security lab.ppsx
PPTX
PROTECTED CONTENT: END-TO-END PGP ENCRYPTION FOR DRUPAL
ODP
Applying Security Algorithms Using openSSL crypto library
PPTX
encryption and decryption ,and its types
PPTX
RSA Algorithm and its implementation in C++.pptx
PDF
A Study of RSA Algorithm in Cryptography
PDF
Analysis of rsa algorithm using gpu
PDF
ANALYSIS OF RSA ALGORITHM USING GPU PROGRAMMING
PDF
CNIT 123 12: Cryptography
PPTX
Rass presentation
PPT
PPT
Introduction to cryptography and Network Security
DOCX
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
PDF
Ch34508510
PPT
Nwc rsa
PPT
OpenPGP/GnuPG Encryption
PPTX
RSA Algorithem and information about rsa
PDF
Chapter 8 cryptography lanjutan
PDF
A Modified Technique For Performing Data Encryption & Data Decryption
Computer Security Laboratory Manual .pdf
comp security lab.ppsx
PROTECTED CONTENT: END-TO-END PGP ENCRYPTION FOR DRUPAL
Applying Security Algorithms Using openSSL crypto library
encryption and decryption ,and its types
RSA Algorithm and its implementation in C++.pptx
A Study of RSA Algorithm in Cryptography
Analysis of rsa algorithm using gpu
ANALYSIS OF RSA ALGORITHM USING GPU PROGRAMMING
CNIT 123 12: Cryptography
Rass presentation
Introduction to cryptography and Network Security
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
Ch34508510
Nwc rsa
OpenPGP/GnuPG Encryption
RSA Algorithem and information about rsa
Chapter 8 cryptography lanjutan
A Modified Technique For Performing Data Encryption & Data Decryption

(Crypto) DES And RSA Algorithms Overview

  • 1. DES & RSA Algorithms Overview Tutorial 03/01/2013 NOUNI El Bachir 1
  • 2. Comparison And Uses DES : It's a symmetric algorithm designed for encrypting data. Its advantage is that it's fast for large data size, but it present one inconvenient is that of changing keys between the tow tiers. 03/01/2013 NOUNI El Bachir 2
  • 3. Comparison And Uses RSA : it's an asymmetric algorithm designed for encrypting data also. Its inconvenience is that it's too slow for large data size. It use tow keys instead of DES which uses one shared key. One of these keys is secret and the other is public. The Data that is encrypted by one is decrypted by the other but not by the same key. 03/01/2013 NOUNI El Bachir 3
  • 4. Tools  Through this tutorial we will use the Openssl tool. This tool is by default integrated in Linux. For Windows users they should download this tool by following this link : http://slproweb.com/products/Win32OpenSSL.html  After the installation of openssl; whether you add the path of openssl.exe to your system path, our each time at the command prompt you use the full path of openssl.exe. 03/01/2013 NOUNI El Bachir 4
  • 5. Parameters Of These Algorithms  DES : − Secret key (64 bits) − Initialization vector (64 bits)  RSA : − Secret key − Secret key length − Public key − The modulus 03/01/2013 NOUNI El Bachir 5
  • 6. TP : Test Each Algorithm (DES)  The instructions thereafter were tested under Linux system.  DES : To use this algorithm we have to generate first its parameters (secret key,initialization vector). To do so we will use /dev/urandom file and head command. The synopsis of each one is : 03/01/2013 NOUNI El Bachir 6
  • 7. TP : Test Each Algorithm (DES)  |> cat /dev/urandom | head -1 > random.bin  the result after using |> xxd random.bin to show file content in Hex format : 0000000: 95c3 e2d9 62c9 8d24 fa03 69e7 59aa aa11 ....b..$..i.Y...  So we choose 95C3E2D962C98D24 as secret Key and FA0369E759AAAA11 as initialization vector.  After that we can encrypt and decrypt a file. |> Openssl enc -e -des-cbc -in inputfile -out outputfile -nosalt -K 95C3E2D962C98D24 -iv FA0369E759AAAA11 -a 03/01/2013 NOUNI El Bachir 7
  • 8. TP : Test Each Algorithm (DES)  -des-cbc : DES algorithm using CBC mode  -e : for encryption  -in [inputfile] : to specify input file  -out [outputfile] : to specify output file  -K XX..XX : to specify secret key 64 bits  -iv XX..XX : to specify initialization vector 64 bits  -a : encoding output file in base64 format  -nosalt : no salt will be used 03/01/2013 NOUNI El Bachir 8
  • 9. TP : Test Each Algorithm (DES)  For decryption we use the same command line, we have to just change -e option by -d for decryption. 03/01/2013 NOUNI El Bachir 9
  • 10. TP : Test Each Algorithm (RSA) The implementation of RSA follow three steps : Generate a encrypted secret key of 1024 or 2048 length. Generate the public key from the secret one. To do so, we will use genrsa and rsa commands. Synopsis of these commands is : 03/01/2013 NOUNI El Bachir 10
  • 11. TP : Test Each Algorithm (RSA)  openssl genrsa [-out filename] [-passout arg] [-des] [-des3] [-idea] [-f4] [-3] [-rand file(s)] [-engine id] [numbits]  openssl rsa [-inform PEM|NET|DER] [-outform PEM|NET|DER] [-in filename] [-passin arg] [-out filename] [-passout arg] [-sgckey] [- des] [-des3] [-idea] [-text] [-noout] [-modulus] [-check] [-pubin] [-pubout] [-engine id] For encryption we will use rsautl command of following synopsis :  openssl rsautl [-in file] [-out file] [-inkey file] [-pubin] [- certin] [-sign] [-verify] [-encrypt] [-decrypt] [-pkcs] [d-ssl] [- raw] [-hexdump] [-asn1parse] Lets now try this algorithm : 03/01/2013 NOUNI El Bachir 11
  • 12. TP : Test Each Algorithm (RSA) To generate the secret key : |> openssl genrsa -des -out sckey.pem 2048 -des : DES which will be used to encrypt the secret key. -out : to specify the output file. 2048 : key length. After Enter Key press the prompt will demand to you to enter a phrase password. 03/01/2013 NOUNI El Bachir 12
  • 13. TP : Test Each Algorithm (RSA) To generate the public key : |> openssl rsa -pubout < sckey.pem > pkey.pem -pubout : to specify that wie want to generate a public key from the secret one sckey.pem. < : input flow redirection > : output flow redirection 03/01/2013 NOUNI El Bachir 13
  • 14. TP : Test Each Algorithm (RSA) To encrypt data with public key : |> openssl rsautl -encrypt -in inputfile -out outputfile -inkey pkey.pem -pubin -a -encrypt : for encryption. -in : to specify input file path. -out : to specify output file. -inkey : key file to use. -pubin : specify that the key specified with -inkey is a public key. Without this options secret key is used. 03/01/2013 NOUNI El Bachir 14
  • 15. Best practice RSA : to exchange shared secret key DES : to encrypt data using exchanged shared secret key. Scenario : Alice (sA,PA) and Bobe (sB,PB). Alice want send data to Bobe, but it is the first time. So they should define a shared key. 03/01/2013 NOUNI El Bachir 15
  • 16. Best practice So Alice had to generate a random 64 bits key (DES) and an initialization vector (64 bits) and encrypt it using the public key of Bobe P B. Then send it to Bobe. Bobe will receive encrypted key and will decrypt it. At this moment its ok but he should send an acknowledgment to Alice to tell him that he receive the key successfully. So he should encrypt the received key using public key of Alice and send it to him. 03/01/2013 NOUNI El Bachir 16
  • 17. Best practice After this handshaking it is ok to exchange encrypted that using shared secret key (64 bits). It is recommended to use Tripe DES instead of DES because it is more secure. To use this algorithm in what we have seen, you can just change -des by -des3 in RSA section and for DES section you choose -des-ede-cbc instead of -des-cbc. 03/01/2013 NOUNI El Bachir 17
  • 19. Thanks nouni.ebachir@gmail.com 03/01/2013 NOUNI El Bachir 19