Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
OpenSSL DES API

OpenSSL DES API

Ratings: (0)|Views: 1,262|Likes:
Published by Finnbarr P. Murphy

More info:

Published by: Finnbarr P. Murphy on Mar 03, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/19/2013

pdf

text

original

 
OpenSSL DES APIs
Finnbarr P. Murphy 
(fpm@fpmurphy.com)
 Now thatOpenSSLhas finally reached version 1.0.0, I decided to take another look how thevariousData Encryption Standard(DES) application programming interfaces (routines) includedin OpenSSL can be used to encrypt and decrypt data. Since there is also a lack of simple examplesavailable on the Internet of how to actually use the OpenSSL DES routines, I have included anumber of examples in this post to encourage readers to experiment with these routines.The original author of the DES routines in OpenSSL’s
libcrypto
was Eric Young. Young and TimHudson posted the first version of of a free cryptographic library called
SSLeay 
(
eay 
stands forEric A, Young) to the Internet in 1995. Amazingly Young managed to single-handedly implementthe full suite of cryptosystems used in SSLeay. Since then the SSLeay library has become part of OpenSSL. However you will still frequently come across references to SSLeay in both man pagesand the source code. Young is still involved in cryptography and currently works for RSA, thesecurity division of EMC.Some background information on DES is probably in order for those who have forgotten theircollege course on cryptography. DES has been around for quite a long time. It was developed byIBM as enhancement to an existing key generator algorithm calledLuciferthat was primarilydeveloped byHorst Feistel. It became a standard in 1977 when the National Bureau of Standards(now called NIST) issued Federal Information Processing Standards Publication 46 (FIPS 46). Thatstandard specified that DES be used within the Federal Government for the cryptographicprotection of sensitive, but unclassified, computer data.DES is a member of the class of ciphers (British English: cyphers) called ablock cipher. In a block cipher, a block of N bits from the plaintext is replaced with a block of N bits from the ciphertext.Ideally the relationship between the input block and the output block is completely random butinvertible. This implies a one-to- one relationship with each input block being mapped to a uniqueoutput block. Mathematically, DES maps the set of all possible 64-bit vectors onto itself. Selectinga DES cryptographic key allows a user to select one of the possible mappingsTechnically speaking, DES is an iterative, block, product cipher system (encryption algorithm). A product cipher system mixes transposition and substitution operations in an alternating manner.Iterations refers to the use of the output of an operation as the input for another iteration of thesame procedure. This is known as a
Feistel structure
or
Feistel network
. A cryptographic systembased on a Feistel structure uses the same basic algorithm for both encryption and decryption. A large proportion of block ciphers, including DES, use a Festel structure.
03-03-2011 Copyright 2004-2011 Finnbarr P. Murphy. All rights reserved. 1/12
 
OpenSSL DES APIs
The algorithmic implementation of DES is known as Data Encryption Algorithm (DEA). DEA usessixteen iterations of a pair of transposition and substitution operations to encrypt or decrypt aninput block. All computations are linear except for theSubstitution-boxes(S-boxes) which providethe non-linear substitution component of the algorithm. Linear algorithms can be easily brokenusing a known plaintext attack. The S-boxes in DEA effectively hinder this form of attack (ClaudeShannon‘s diffusion property.) The number of rounds (16) is important also. An 8-round DEA canbe broken in a few minutes on a PC using a chosen plaintext attack, i.e.
differential cryptoanalysis
.When DEA was proposed, there was considerable criticism with most of it directed at the S-boxes.It was even suggested the the S-boxes might contain a trapdoor. One useful property of DEA isthat it can be implemented very efficiently in software (or in hardware for that matter) using tablelook-up. DES uses a 56-bit encryption key and a 64-bit block. The key itself is specified with 8bytes (64-bits), but the last bit of each byte is used as a parity check of the other 7 bits. Roundkeys are 48-bits and are generated from the 56-bit encryption key by a sequence of permutations.Several methods of incorporating DES into a cryptographic system are possible. Generallyspeaking, these can be classified into either
block
or
stream
methods. In addition a number of modes of operation are specified by theFIPS 81(DES Modes of Operation) standard. The modesspecify how data will be encrypted and decrypted. These are summarized below.
Electronic Codebook Mode (ECB)
64 bits (i.e. a block) are enciphered at a time.
q
The order of the blocks can be rearranged without detection.
q
A plaintext block always produces the same ciphertext block for the same key.
q
An error only affects one ciphertext block.
q
03-03-2011 Copyright 2004-2011 Finnbarr P. Murphy. All rights reserved. 2/12
 
OpenSSL DES APIs
Use discouraged as vulnerable to a directory attack 
q
Cipher Block Chaining Mode (CBC)
Multiples of 64 bits are enciphered at a time.
q
Blocks cannot be rearranged. Each ciphertext block depends on the current and all preceding
q
plaintext blocks.A plaintext block always produces the same ciphertext block for the same key and starting
q
variable.Different starting variables prevent the same plaintext enciphering to the same ciphertext.
q
An error affects the current and following ciphertext blocks.
q
Cipher Feedback Mode (CFB)
Only blocks of j <= 64 bits are enciphered at a time.
q
A small j requires more cycles through the encipherment algorithm per unit of plaintext and thus
q
greater processing overhead.A plaintext block always produces the same ciphertext block for the same key and starting
q
variable.Blocks cannot be rearranged. Each ciphertext block depends on the current and all preceding
q
plaintext blocks.Different starting variables are used to prevent the same plaintext enciphering to the same
q
ciphertext.The strength of this mode depends on the size of the key k (best if j == k).
q
An error will affect the current and the following ciphertext blocks.
q
Output Feedback Mode (OFB)
Only blocks of j <= 64 bits are enciphered at a time.
q
A small j requires more cycles through the encipherment algorithm per unit of plaintext and thus
q
greater processing overhead.A plaintext block always produces the same ciphertext block for the same key and starting
q
variable.Different starting variables are used to prevent the same plaintext enciphering to the same
q
ciphertext.Absence of chaining makes this mode vulnerable to specific attacks.
q
Different start variable values prevent the same plaintext enciphering to the same ciphertext, by
q
producing different key streams.An error bit in the ciphertext causes only one bit to be in error in the deciphered plaintext.
q
It is not self-synchronizing.
q
Triple-DES ECB Mode
Encrypt with key1, decrypt with key2 and encrypt with key3 again.
q
As for ECB encryption but increases the key length to 168 bits.
q
If all keys are the same it is equivalent to encrypting once with just one key.
q
If the first and last key are the same, the key length is 112 bits.
q
If all 3 keys are the same, this is effectively the same as normal ECB mode.
q
Triple-DES CBC Mode
Encrypt with key1, decrypt with key2 and then encrypt with key3.
q
As for CBC encryption but increases the key length to 168 bits with the same restrictions as the
q
Triple-DES ESB modeOur first example shows how to use the basic DES encryption routine,
DES_ecb_encrypt()
, to
03-03-2011 Copyright 2004-2011 Finnbarr P. Murphy. All rights reserved. 3/12

Activity (2)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->