harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yuri Dolgov" <dolgov.g.y...@gmail.com>
Subject Re: [classlib][security]How to discard padding data after decryption.
Date Thu, 15 Nov 2007 04:41:04 GMT
>   Now I know if "no padding" mode is adopted, how to manage the padding is
>the job of the caller.
That is exactly the idea of "no padding" mode.

Thanks,
Yuri

On 11/15/07, Leo Li <liyilei1979@gmail.com> wrote:
>
> On 11/14/07, Yuri Dolgov <dolgov.g.yuri@gmail.com> wrote:
> >
> > Hello Leo,
> >
> > For "no padding" modes there is no padding added to the data encrypted.
> > Though
> > you have to encrypt only data aligned to cipher block size.
>
>
>
>    Thank you, Yuri.
>    Now I know if "no padding" mode is adopted, how to manage the padding
> is
> the job of the caller.
>
> Thanks,
> > Yuri
> >
> > On 11/14/07, Leo Li <liyilei1979@gmail.com> wrote:
> > >
> > > Here is an exmple:
> > >
> > >     byte[] data = ...; // data encrypted with DES-CBC-CRC
> > >     byte[] keyBytes = ...;  // the DES key used to encrypt data.
> > >     final byte[] iv = new byte[]
> > >         { ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
> (
> > > byte
> > > ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
> > >             ( byte ) 0x00 };
> > >     Cipher cipher = Cipher.getInstance( "DES/CBC/NoPadding" );
> > >     SecretKey key = new SecretKeySpec( keyBytes, "DES" );
> > >     AlgorithmParameterSpec paramSpec = new IvParameterSpec( iv );
> > >     cipher.init( Cipher.DECRYPT_MODE, key, paramSpec );
> > >     byte[] decryptedData = cipher.doFinal( data );
> > >
> > >     Has the decryptedData got here already discarded the padding
> bytes?
> > If
> > > not, how to discard these data?
> > >
> > >    Is there somebody familar with this?
> > >    Thanks in advance.
> > >
> > > --
> > > Leo Li
> > > China Software Development Lab, IBM
> > >
> >
>
>
>
> --
> Leo Li
> China Software Development Lab, IBM
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message