Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

The Data Encryption Algorithm is designed to encipher and decipher blocks of data consisting of 64 bits under control of a 56-bit key.

If my data is more than 64 bits, (suppose 66 or 67 bits), will it take remaining bits as 0s (zeros)?

How would it encrypt?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Well, the methods we use to take a block cipher (such as DES), and turn it into an actually useful function (say, to encrypt a large message) is called a mode of operation.

Such a mode of operation takes the message (generally of arbitrary length), and processes it (usually block by block), using the block cipher as a primitive.

There are a number of such modes of operation, the most popular of which are CBC mode and counter mode. BTW: the mode where you just send the message in pieces to the block cipher in 64 bit chunks (and the encrypted message is just the output of the block cipher) is referred to as ECB mode – that is rarely appropriate (and certainly never unless you know what you're doing).

As for which mode would be appropriate for you, well, I can't answer that without knowing more about your application (and the security properties you need).

In addition, you say that you are intending to use DES. DES is generally frowned upon nowadays (machines to break it are known to exist); the block cipher AES is usually a better choice (it is about as efficient in software, and it is currently believed to be secure).

share|improve this answer
    
Thanks for the help poncho.i am interested in cryptography and doing a DES alogrithm as small science project.recently i read that DES is being used in E-passport (in Germany). I am using CBC mode for my project. –  Prasanna Kumar Nov 1 '11 at 3:26
    
I would hope that you misread that (or it was misreported), and that the Germans use something secure (AES perhaps, or TDES). –  poncho Nov 1 '11 at 4:08
    
I'm just wondering...Will i encrypt each block using the same key? –  Goot Jan 27 at 12:48
1  
@Goot: yes, in CBC mode, you use the same key for each block. –  poncho Jan 27 at 13:30
1  
@Goot: well, ECB mode should be avoided unless you know what you're doing. However, ECB mode also uses the same key for each block. –  poncho Jan 27 at 19:46

Additionally to a mode of operation, as mentioned by poncho's answer, you will probably (depending of the mode of operation) need a padding mode, i.e. a function which converts bit-strings of arbitrary length (or usually only byte-strings of arbitrary length) to strings with length which are of a multiple of the block size.

Such a padding function is easily invertible and adds normally nothing into the security of the cipher, it just appends some bytes before encrypting, and (its inverse) removes them again after decryption.

A popular padding mode is the one defined in PKCS#7 (RFC 2315, section 10.3, Note 2):

  • Append enough bytes to get to full block size, at least one (i.e. at most a full block).
  • Each appended byte has the same value, the number of bytes added.
  • On unpadding, check the last byte and make sure that there are that many bytes before with the same value.

For your 67-bit value we would need a special padding mode for non-byte-aligned bit sequences. A possible way would be do as is to append a 1 bit, then a series of 0 bits, then the binary encoding of the whole padding size (in the last some bits of the padding). (Something similar as this is done by SHA-1, but there the length of the message, not the padding size is in the last bits.)

Anyway, you would then have to encrypt two full blocks (i.e. $2·64 = 128$ bits) of plaintext, resulting probably in $3·64 = 196$ bit of ciphertext (including the initialization vector needed for most modes of operation).

Some modes, as CTR, OFB and CFB allow encrypting also bit strings shorter than whole blocks. You would still have an initialization vector overhead, i.e. you would have $64 + 67 = 131$ bits of ciphertext.

(Note that you normally also should use authentication to avoid chosen-ciphertext attacks, so you would add the size of some authentication tag to this.)

share|improve this answer
    
thanks for the help Paŭlo Ebermann.. –  Prasanna Kumar Nov 1 '11 at 3:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.