Re: AES (Rijndael) Encryption with CryptoAPI

From: Ryan Menezes [MSFT] (ryanmen_at_online.microsoft.com)
Date: 06/25/04


Date: Thu, 24 Jun 2004 17:42:48 -0700

Trying passing FALSE for the Final flag to CryptEncrypt() if you don't want
a whole extra block added to data which is already a multiple of block size.

-- 
Thanks,
Ryan Menezes [MS]
This posting is provided "AS IS" with no warranties, and confers no rights.
"Pieter Philippaerts" <Pieter.nospam@mentalis.org> wrote in message
news:eBpIqkkWEHA.2576@TK2MSFTNGP10.phx.gbl...
> "Abe Simpson" <abe@simpson.com> wrote in message
> > When I encrypt plaintext that is 1 to 15 bytes long, the resultant
> > ciphertext is always 16 bytes, and a 16-byte plaintext results in a
> 32-byte
> > cipher text.
>
> This is normal behavior. The AES is a block cipher, which means it always
> operates on 16 byte blocks.
> If the input data is not an exact multiple of 16, the data will be padded
> until it has a length that is a multiple of 16.
> If the input data is an exact multiple of 16, the CryptoAPI will add a
full
> 16-byte padding block at the end of the data.
>
> > Rijndael specs provide sample results where 16-byte plaintext becomes
> > 16-byte ciphertext. How do I achieve the same result?
>
> You can simply ignore the last 16 bytes, since they are the encrypted
> padding.
>
> Regards,
> Pieter Philippaerts
>
> P.S.: in case the results of your code are not the same as the results
> you're trying to verify it with, a common mistake is that the CryptoAPI is
> little endian and virtually every other platform is big endian (Java,
.NET,
> and probably the AES reference too). So you may need to reverse the key
and
> IV.
>
>


Relevant Pages

  • Re: Should be in crypto for John E. Hadstate Re: just stupid?
    ... >> The end result of a multiple encryption of cipher A, B, and C is the ... When we create the single cipher ABC from the cipher A, B, C we have ... if A is broken, I win with Multiple ...
    (sci.crypt)
  • Re: Should be in crypto for John E. Hadstate Re: just stupid?
    ... >> It's better to heed the cryptanalytic advice of real cryptologists ... once by different encryptions, here called multiple encryption, to enhance ... I've never said that cascading algorithms only weakens the cipher. ...
    (sci.crypt)
  • Re: some questions about permutation
    ... There is no guarantee that two one-way trapdoor permutations ... the cipher is closed under composition. ... a multiple of phi, you can factor N in polynomial time. ...
    (sci.crypt)
  • Re: Rijndael/Blowfish Cipher Question
    ... >block since the algorithm expects the block length to be a ... >multiple of 8. ... Using a cipher with a 64 bit block length, ... or allow the encryptions to overlap... ...
    (sci.crypt)