Re: Removing extra padding.




<anurag.choudhary2@xxxxxxxxx> wrote in message
news:1174285848.101047.96420@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,

While Encrypting a file the original data gets padded as per the
block size.

Lets say I am using default block size of 16 for the following
example.

For example , If I am encrypting a text say "Hello World" (length :
11) then at the time of encryption it gets padded with 5 extra bytes
[16 (default block size) - 11 (string length)] = 5 bytes
and hence making a difference in original and cyphered block. How can
I remove this extra padding (of 5 bytes here ) in the output, which is
actually the encrypted block ???

Tell me if some how i can establish this kind of schema while using
AES .
(key)
(key)
Original Block ---------------> ENCRYPTED BLOCK ------------>
Deciphered Block (i.e. original block)
(x bytes) (x
bytes) (x bytes)


THANKS
Anurag

I have no idea how to achieve your goal with a block cipher, but since I
work with streams I can tell you how I do it. Create a variable which holds
the length of the plaintext and then pad, cipher the padded plaintext and
then starting from the first byte count left through the ciphertext until
you reach the original size (the function is ciphertext =
left(ciphertext,originalfilesize)), this removes the padding. Alternately,
because I use MSVB for most of my development pad the plaintext with spaces
chr(32) and the padding doesn't have to be removed before writing the
ciphertext to the file, because after it is decrypted you just run a
trim$(plaintext) function which removes all leading and training spaces and
you are left with the original file size.


.



Relevant Pages

  • Re: RSA padding questions
    ... padding, ... still produces the same ciphertext 'c'? ... problem is that with stego there is a basic assumption that they don't know ... m1 is meaningful plaintext ...
    (sci.crypt)
  • Re: AES encryption with Java
    ... bytes long you should receive ciphertext that is 16 bytes long. ... I'm encrypting 16 byte plaintext and ending up with 32 byte ... It is the point at which anthropogenic warming triggers ...
    (comp.lang.java.security)
  • Re: Encryption using System.Security.Cryptography
    ... Yes, it does not affect the size of ciphertext, but it should be ... > encrypting. ... Since the first plaintext block doesn't have a preceeding ...
    (microsoft.public.dotnet.security)
  • Re: AES encryption with Java
    ... There is at least one padding byte. ... I'm pretty sure that if you encrypt plaintext that is 16 ... bytes long you should receive ciphertext that is 16 bytes long. ... I'm encrypting 16 byte plaintext and ending up with 32 byte ...
    (comp.lang.java.security)
  • Re: Encryption using System.Security.Cryptography
    ... Since the first plaintext block doesn't have a preceeding encrypted block, ... Where ct1...3 are the resulting ciphertext blocks. ... >Subject: Re: Encryption using System.Security.Cryptography ... >the Padding property of the Rijndael class). ...
    (microsoft.public.dotnet.security)