using the key as the IV in RijndaelManaged, any problem?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default using the key as the IV in RijndaelManaged, any problem?

    I have two questions hoping someone could give me some insights.

    I'm implementing an encryption solution using the RijndaelManaged class.
    What I found very strange is that if I use a different IV on the decrypte
    end, a binary file (such as a zip file) decrypts without any problem, but if
    it's a text file, it adds some scrumbled characters at the beginning even
    though the rest of the file is decrypted without problem. Why does this
    happen?

    Because of this issue, I need to have the same IV on both ends. I'd like to
    avoid managing another piece of cryptic data (in addition to the key), I'm
    thinking of using the key as the IV. I use a 256-bit key so I increased the
    blocksize on my RijndaelManaged object to 256 and this actually speed up the
    encryption process by about 10% when I tested with a file of 3 MB in size.
    This is good. However, I just don't know if using the same byte array as
    the key and the IV is a security concern, that is, whether it's easier to
    figure out the IV from the encrypted data. Because if so, then my key is
    also exposed.

    Thanks a lot for any suggestions.
    Bob


    Bob Guest

  2. Similar Questions and Discussions

    1. contribute problem - access denied file may not existpermission problem
      Recieving the following error message - "access denied file may not exist , or there could be a permission problem" this happened this morning ,...
    2. Problem playing Quicktime thru .DCR embedded in HTML - pathreferencing problem?
      Greetings earthlings and Director heads. Here's the problem: created an HTML file containing shockwave (dcr) movie that calls quicktime movies in...
    3. Uploading problem = weird warning (was: access denied problem.....)
      Hi, I had a problem where my upload form was not working on our production server but was working on two other servers, after checking the...
    4. #21611 [Opn]: Problem with version_compare() (Was: Problem with pear cli and release numbers)
      ID: 21611 Updated by: et@php.net -Summary: Problem with pear cli and release numbers Reported By: jan at horde...
    5. Problem with Apache Web Server config file and PHP (please give advice on what problem may be me)
      HI: Can anyone refer me to someone that can help with the problem below. I installed Apache Web Server on my laptop which has Windows XP. I...
  3. #2

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Bob,
    I am looking at using the Rijndael algorithm, as well. Have you understood
    the need of using the IV? Reading the AES specs - Advance Encryption
    Standard - based on the Rijndael algorithm, I could not find any IV
    references. May be I need to do more reading....

    Thanks,
    Eugen

    " Bob" <bobatkpmg@yahoo.com> wrote in message
    news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > I have two questions hoping someone could give me some insights.
    >
    > I'm implementing an encryption solution using the RijndaelManaged class.
    > What I found very strange is that if I use a different IV on the decrypte
    > end, a binary file (such as a zip file) decrypts without any problem, but
    if
    > it's a text file, it adds some scrumbled characters at the beginning even
    > though the rest of the file is decrypted without problem. Why does this
    > happen?
    >
    > Because of this issue, I need to have the same IV on both ends. I'd like
    to
    > avoid managing another piece of cryptic data (in addition to the key), I'm
    > thinking of using the key as the IV. I use a 256-bit key so I increased
    the
    > blocksize on my RijndaelManaged object to 256 and this actually speed up
    the
    > encryption process by about 10% when I tested with a file of 3 MB in size.
    > This is good. However, I just don't know if using the same byte array as
    > the key and the IV is a security concern, that is, whether it's easier to
    > figure out the IV from the encrypted data. Because if so, then my key is
    > also exposed.
    >
    > Thanks a lot for any suggestions.
    > Bob
    >
    >

    Eugen Feraru Guest

  4. #3

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Hi Bob,
    you don't need to encrypt IV - just send it in plain text prepended to
    cipher text.
    The point is that you can use different IV with the same encryption session
    key for encrypting multiple packages, thus producing different cipher text
    even if plain text was the same.
    IV is used differently depending on modes of operations. ECB - no effect,
    CBC XORes every previous cipher block with next plain text block before
    encrypting it, IV is used as the block 0. CFB and OFB uses IV as starting
    block when generating cipher stream and use previous cipher block for
    generating next keystream block.

    -Valery.
    [url]http://www.harper.no/valery[/url]

    " Bob" <bobatkpmg@yahoo.com> wrote in message
    news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    >I have two questions hoping someone could give me some insights.
    >
    > I'm implementing an encryption solution using the RijndaelManaged class.
    > What I found very strange is that if I use a different IV on the decrypte
    > end, a binary file (such as a zip file) decrypts without any problem, but
    > if
    > it's a text file, it adds some scrumbled characters at the beginning even
    > though the rest of the file is decrypted without problem. Why does this
    > happen?
    >
    > Because of this issue, I need to have the same IV on both ends. I'd like
    > to
    > avoid managing another piece of cryptic data (in addition to the key), I'm
    > thinking of using the key as the IV. I use a 256-bit key so I increased
    > the
    > blocksize on my RijndaelManaged object to 256 and this actually speed up
    > the
    > encryption process by about 10% when I tested with a file of 3 MB in size.
    > This is good. However, I just don't know if using the same byte array as
    > the key and the IV is a security concern, that is, whether it's easier to
    > figure out the IV from the encrypted data. Because if so, then my key is
    > also exposed.
    >
    > Thanks a lot for any suggestions.
    > Bob
    >
    >

    Valery Pryamikov Guest

  5. #4

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Eugen,

    IV is not Rijndael-specific. It is used by encryption algorithms which
    support cipher-block chaining (CBC). When an encryption algorithm, such as
    Rijndael, uses CBC, every block of plain text data is XORed with the
    previous (encrypted) block before it is encrypted. (This is considered a
    good encryption mode - i.e. better than CFB, EBC, etc., which do not need
    IV - because using different IV values the same plain text can be encrypted
    with the same key producing different cipher text.) Anyway, as you might
    have guessed, when the first block of plain text is being encrypted, there
    is no previous block to XOR it with, so this is the purpose that IV serves.
    IV is XORed with the first plain text block, then the result is encrypted.
    The encrypted block is then XORed with the second plain text block and the
    result is encrypted, and so on. Obviously, IV will be needed during
    decryption, but unlike the encryption key (or pass phrase from which the key
    is derived), IV is not considered a sensitive value, so it is normally
    stored as plain text. I hope I made a bit it more clear for you.

    Alek

    "Eugen Feraru" <NoSpam@Spam.com> wrote in message
    news:OsiJFPGOEHA.3096@TK2MSFTNGP09.phx.gbl...
    > Bob,
    > I am looking at using the Rijndael algorithm, as well. Have you understood
    > the need of using the IV? Reading the AES specs - Advance Encryption
    > Standard - based on the Rijndael algorithm, I could not find any IV
    > references. May be I need to do more reading....
    >
    > Thanks,
    > Eugen
    >
    > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > I have two questions hoping someone could give me some insights.
    > >
    > > I'm implementing an encryption solution using the RijndaelManaged class.
    > > What I found very strange is that if I use a different IV on the
    decrypte
    > > end, a binary file (such as a zip file) decrypts without any problem,
    but
    > if
    > > it's a text file, it adds some scrumbled characters at the beginning
    even
    > > though the rest of the file is decrypted without problem. Why does this
    > > happen?
    > >
    > > Because of this issue, I need to have the same IV on both ends. I'd
    like
    > to
    > > avoid managing another piece of cryptic data (in addition to the key),
    I'm
    > > thinking of using the key as the IV. I use a 256-bit key so I increased
    > the
    > > blocksize on my RijndaelManaged object to 256 and this actually speed up
    > the
    > > encryption process by about 10% when I tested with a file of 3 MB in
    size.
    > > This is good. However, I just don't know if using the same byte array
    as
    > > the key and the IV is a security concern, that is, whether it's easier
    to
    > > figure out the IV from the encrypted data. Because if so, then my key
    is
    > > also exposed.
    > >
    > > Thanks a lot for any suggestions.
    > > Bob
    > >
    > >
    >
    >

    Alek Davis Guest

  6. #5

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Valery:

    Thanks for the reply. I understand IV can be plain text and what it does.
    My question is, if I use the key as the IV (so I don't have to send the IV
    as an added baggage or store it on both ends), whether this would add
    security risks.

    I need to keep the key on both ends anyway, so it's convenient to use it as
    the IV. but if the convenience brings risks, then I probably shouldn't do
    it.

    Bob

    "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    > Hi Bob,
    > you don't need to encrypt IV - just send it in plain text prepended to
    > cipher text.
    > The point is that you can use different IV with the same encryption
    session
    > key for encrypting multiple packages, thus producing different cipher text
    > even if plain text was the same.
    > IV is used differently depending on modes of operations. ECB - no effect,
    > CBC XORes every previous cipher block with next plain text block before
    > encrypting it, IV is used as the block 0. CFB and OFB uses IV as starting
    > block when generating cipher stream and use previous cipher block for
    > generating next keystream block.
    >
    > -Valery.
    > [url]http://www.harper.no/valery[/url]
    >
    > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > >I have two questions hoping someone could give me some insights.
    > >
    > > I'm implementing an encryption solution using the RijndaelManaged class.
    > > What I found very strange is that if I use a different IV on the
    decrypte
    > > end, a binary file (such as a zip file) decrypts without any problem,
    but
    > > if
    > > it's a text file, it adds some scrumbled characters at the beginning
    even
    > > though the rest of the file is decrypted without problem. Why does this
    > > happen?
    > >
    > > Because of this issue, I need to have the same IV on both ends. I'd
    like
    > > to
    > > avoid managing another piece of cryptic data (in addition to the key),
    I'm
    > > thinking of using the key as the IV. I use a 256-bit key so I increased
    > > the
    > > blocksize on my RijndaelManaged object to 256 and this actually speed up
    > > the
    > > encryption process by about 10% when I tested with a file of 3 MB in
    size.
    > > This is good. However, I just don't know if using the same byte array
    as
    > > the key and the IV is a security concern, that is, whether it's easier
    to
    > > figure out the IV from the encrypted data. Because if so, then my key
    is
    > > also exposed.
    > >
    > > Thanks a lot for any suggestions.
    > > Bob
    > >
    > >
    >
    >

    Bob Guest

  7. #6

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    IV is needed when the encryption mode is Cipher Block Chaining, which is the
    default in the RijndaelManaged class. You can read the thread "Encryption
    using System.Security.Cryptography" on this group for more details. It's
    basically a "seed" for the encryption process to get started.

    Bob

    "Eugen Feraru" <NoSpam@Spam.com> wrote in message
    news:OsiJFPGOEHA.3096@TK2MSFTNGP09.phx.gbl...
    > Bob,
    > I am looking at using the Rijndael algorithm, as well. Have you understood
    > the need of using the IV? Reading the AES specs - Advance Encryption
    > Standard - based on the Rijndael algorithm, I could not find any IV
    > references. May be I need to do more reading....
    >
    > Thanks,
    > Eugen
    >
    > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > I have two questions hoping someone could give me some insights.
    > >
    > > I'm implementing an encryption solution using the RijndaelManaged class.
    > > What I found very strange is that if I use a different IV on the
    decrypte
    > > end, a binary file (such as a zip file) decrypts without any problem,
    but
    > if
    > > it's a text file, it adds some scrumbled characters at the beginning
    even
    > > though the rest of the file is decrypted without problem. Why does this
    > > happen?
    > >
    > > Because of this issue, I need to have the same IV on both ends. I'd
    like
    > to
    > > avoid managing another piece of cryptic data (in addition to the key),
    I'm
    > > thinking of using the key as the IV. I use a 256-bit key so I increased
    > the
    > > blocksize on my RijndaelManaged object to 256 and this actually speed up
    > the
    > > encryption process by about 10% when I tested with a file of 3 MB in
    size.
    > > This is good. However, I just don't know if using the same byte array
    as
    > > the key and the IV is a security concern, that is, whether it's easier
    to
    > > figure out the IV from the encrypted data. Because if so, then my key
    is
    > > also exposed.
    > >
    > > Thanks a lot for any suggestions.
    > > Bob
    > >
    > >
    >
    >

    Bob Guest

  8. #7

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Bob,
    AFAIK, using key as IV doesn't increase risk of key being compromised, but
    it demeans use of chaining and feedback modes (which is to generate
    different cipher from the same text by using different IV). If using fixed
    IV-KEY pair is your intention - then you can also consider switchig to ECB
    for better performace. Chaining and Feedback modes with fixed IV-KEY pair
    will just use more processor cycles, but only insignificantly (if at all)
    increase cipher strength.

    -Valery.

    [url]http://www.harper.no/valery[/url]


    " Bob" <bobatkpmg@yahoo.com> wrote in message
    news:ufSu8lGOEHA.1104@TK2MSFTNGP10.phx.gbl...
    > Valery:
    >
    > Thanks for the reply. I understand IV can be plain text and what it does.
    > My question is, if I use the key as the IV (so I don't have to send the IV
    > as an added baggage or store it on both ends), whether this would add
    > security risks.
    >
    > I need to keep the key on both ends anyway, so it's convenient to use it
    > as
    > the IV. but if the convenience brings risks, then I probably shouldn't do
    > it.
    >
    > Bob
    >
    > "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    > news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    >> Hi Bob,
    >> you don't need to encrypt IV - just send it in plain text prepended to
    >> cipher text.
    >> The point is that you can use different IV with the same encryption
    > session
    >> key for encrypting multiple packages, thus producing different cipher
    >> text
    >> even if plain text was the same.
    >> IV is used differently depending on modes of operations. ECB - no effect,
    >> CBC XORes every previous cipher block with next plain text block before
    >> encrypting it, IV is used as the block 0. CFB and OFB uses IV as starting
    >> block when generating cipher stream and use previous cipher block for
    >> generating next keystream block.
    >>
    >> -Valery.
    >> [url]http://www.harper.no/valery[/url]
    >>
    >> " Bob" <bobatkpmg@yahoo.com> wrote in message
    >> news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    >> >I have two questions hoping someone could give me some insights.
    >> >
    >> > I'm implementing an encryption solution using the RijndaelManaged
    >> > class.
    >> > What I found very strange is that if I use a different IV on the
    > decrypte
    >> > end, a binary file (such as a zip file) decrypts without any problem,
    > but
    >> > if
    >> > it's a text file, it adds some scrumbled characters at the beginning
    > even
    >> > though the rest of the file is decrypted without problem. Why does
    >> > this
    >> > happen?
    >> >
    >> > Because of this issue, I need to have the same IV on both ends. I'd
    > like
    >> > to
    >> > avoid managing another piece of cryptic data (in addition to the key),
    > I'm
    >> > thinking of using the key as the IV. I use a 256-bit key so I
    >> > increased
    >> > the
    >> > blocksize on my RijndaelManaged object to 256 and this actually speed
    >> > up
    >> > the
    >> > encryption process by about 10% when I tested with a file of 3 MB in
    > size.
    >> > This is good. However, I just don't know if using the same byte array
    > as
    >> > the key and the IV is a security concern, that is, whether it's easier
    > to
    >> > figure out the IV from the encrypted data. Because if so, then my key
    > is
    >> > also exposed.
    >> >
    >> > Thanks a lot for any suggestions.
    >> > Bob
    >> >
    >> >
    >>
    >>
    >
    >

    Valery Pryamikov Guest

  9. #8

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Thanks Alek for the detailed response!
    Eugen

    "Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
    news:emIl$kGOEHA.3596@tk2msftngp13.phx.gbl...
    > Eugen,
    >
    > IV is not Rijndael-specific. It is used by encryption algorithms which
    > support cipher-block chaining (CBC). When an encryption algorithm, such as
    > Rijndael, uses CBC, every block of plain text data is XORed with the
    > previous (encrypted) block before it is encrypted. (This is considered a
    > good encryption mode - i.e. better than CFB, EBC, etc., which do not need
    > IV - because using different IV values the same plain text can be
    encrypted
    > with the same key producing different cipher text.) Anyway, as you might
    > have guessed, when the first block of plain text is being encrypted, there
    > is no previous block to XOR it with, so this is the purpose that IV
    serves.
    > IV is XORed with the first plain text block, then the result is encrypted.
    > The encrypted block is then XORed with the second plain text block and the
    > result is encrypted, and so on. Obviously, IV will be needed during
    > decryption, but unlike the encryption key (or pass phrase from which the
    key
    > is derived), IV is not considered a sensitive value, so it is normally
    > stored as plain text. I hope I made a bit it more clear for you.
    >
    > Alek
    >
    > "Eugen Feraru" <NoSpam@Spam.com> wrote in message
    > news:OsiJFPGOEHA.3096@TK2MSFTNGP09.phx.gbl...
    > > Bob,
    > > I am looking at using the Rijndael algorithm, as well. Have you
    understood
    > > the need of using the IV? Reading the AES specs - Advance Encryption
    > > Standard - based on the Rijndael algorithm, I could not find any IV
    > > references. May be I need to do more reading....
    > >
    > > Thanks,
    > > Eugen
    > >
    > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > > I have two questions hoping someone could give me some insights.
    > > >
    > > > I'm implementing an encryption solution using the RijndaelManaged
    class.
    > > > What I found very strange is that if I use a different IV on the
    > decrypte
    > > > end, a binary file (such as a zip file) decrypts without any problem,
    > but
    > > if
    > > > it's a text file, it adds some scrumbled characters at the beginning
    > even
    > > > though the rest of the file is decrypted without problem. Why does
    this
    > > > happen?
    > > >
    > > > Because of this issue, I need to have the same IV on both ends. I'd
    > like
    > > to
    > > > avoid managing another piece of cryptic data (in addition to the key),
    > I'm
    > > > thinking of using the key as the IV. I use a 256-bit key so I
    increased
    > > the
    > > > blocksize on my RijndaelManaged object to 256 and this actually speed
    up
    > > the
    > > > encryption process by about 10% when I tested with a file of 3 MB in
    > size.
    > > > This is good. However, I just don't know if using the same byte array
    > as
    > > > the key and the IV is a security concern, that is, whether it's easier
    > to
    > > > figure out the IV from the encrypted data. Because if so, then my key
    > is
    > > > also exposed.
    > > >
    > > > Thanks a lot for any suggestions.
    > > > Bob
    > > >
    > > >
    > >
    > >
    >
    >

    Eugen Feraru Guest

  10. #9

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Bob,

    It's not a good idea tu resuse the same key / IV combo. An instresting
    approach might be to derive a password with the "PasswordDeriveBytes" class
    and generate a random salt. If you want some further details about password
    generation check out this article:
    [url]http://blogs.msdn.com/shawnfa/archive/2004/04/14/113514.aspx[/url].

    --
    Hernan de Lahitte
    Lagash Systems S.A.
    [url]http://weblogs.asp.net/hernandl[/url]


    This posting is provided "AS IS" with no warranties, and confers no rights.

    " Bob" <bobatkpmg@yahoo.com> wrote in message
    news:ufSu8lGOEHA.1104@TK2MSFTNGP10.phx.gbl...
    > Valery:
    >
    > Thanks for the reply. I understand IV can be plain text and what it does.
    > My question is, if I use the key as the IV (so I don't have to send the IV
    > as an added baggage or store it on both ends), whether this would add
    > security risks.
    >
    > I need to keep the key on both ends anyway, so it's convenient to use it
    as
    > the IV. but if the convenience brings risks, then I probably shouldn't do
    > it.
    >
    > Bob
    >
    > "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    > news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    > > Hi Bob,
    > > you don't need to encrypt IV - just send it in plain text prepended to
    > > cipher text.
    > > The point is that you can use different IV with the same encryption
    > session
    > > key for encrypting multiple packages, thus producing different cipher
    text
    > > even if plain text was the same.
    > > IV is used differently depending on modes of operations. ECB - no
    effect,
    > > CBC XORes every previous cipher block with next plain text block before
    > > encrypting it, IV is used as the block 0. CFB and OFB uses IV as
    starting
    > > block when generating cipher stream and use previous cipher block for
    > > generating next keystream block.
    > >
    > > -Valery.
    > > [url]http://www.harper.no/valery[/url]
    > >
    > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > >I have two questions hoping someone could give me some insights.
    > > >
    > > > I'm implementing an encryption solution using the RijndaelManaged
    class.
    > > > What I found very strange is that if I use a different IV on the
    > decrypte
    > > > end, a binary file (such as a zip file) decrypts without any problem,
    > but
    > > > if
    > > > it's a text file, it adds some scrumbled characters at the beginning
    > even
    > > > though the rest of the file is decrypted without problem. Why does
    this
    > > > happen?
    > > >
    > > > Because of this issue, I need to have the same IV on both ends. I'd
    > like
    > > > to
    > > > avoid managing another piece of cryptic data (in addition to the key),
    > I'm
    > > > thinking of using the key as the IV. I use a 256-bit key so I
    increased
    > > > the
    > > > blocksize on my RijndaelManaged object to 256 and this actually speed
    up
    > > > the
    > > > encryption process by about 10% when I tested with a file of 3 MB in
    > size.
    > > > This is good. However, I just don't know if using the same byte array
    > as
    > > > the key and the IV is a security concern, that is, whether it's easier
    > to
    > > > figure out the IV from the encrypted data. Because if so, then my key
    > is
    > > > also exposed.
    > > >
    > > > Thanks a lot for any suggestions.
    > > > Bob
    > > >
    > > >
    > >
    > >
    >
    >

    Hernan de Lahitte Guest

  11. #10

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Or you can use an approach like this:
    [url]http://www.obviex.com/samples/EncryptionWithSalt.aspx[/url].

    Alek

    "Hernan de Lahitte" <hernan@lagash.com> wrote in message
    news:ubpjqtdOEHA.3348@TK2MSFTNGP09.phx.gbl...
    > Bob,
    >
    > It's not a good idea tu resuse the same key / IV combo. An instresting
    > approach might be to derive a password with the "PasswordDeriveBytes"
    class
    > and generate a random salt. If you want some further details about
    password
    > generation check out this article:
    > [url]http://blogs.msdn.com/shawnfa/archive/2004/04/14/113514.aspx[/url].
    >
    > --
    > Hernan de Lahitte
    > Lagash Systems S.A.
    > [url]http://weblogs.asp.net/hernandl[/url]
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >
    > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > news:ufSu8lGOEHA.1104@TK2MSFTNGP10.phx.gbl...
    > > Valery:
    > >
    > > Thanks for the reply. I understand IV can be plain text and what it
    does.
    > > My question is, if I use the key as the IV (so I don't have to send the
    IV
    > > as an added baggage or store it on both ends), whether this would add
    > > security risks.
    > >
    > > I need to keep the key on both ends anyway, so it's convenient to use it
    > as
    > > the IV. but if the convenience brings risks, then I probably shouldn't
    do
    > > it.
    > >
    > > Bob
    > >
    > > "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    > > news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    > > > Hi Bob,
    > > > you don't need to encrypt IV - just send it in plain text prepended to
    > > > cipher text.
    > > > The point is that you can use different IV with the same encryption
    > > session
    > > > key for encrypting multiple packages, thus producing different cipher
    > text
    > > > even if plain text was the same.
    > > > IV is used differently depending on modes of operations. ECB - no
    > effect,
    > > > CBC XORes every previous cipher block with next plain text block
    before
    > > > encrypting it, IV is used as the block 0. CFB and OFB uses IV as
    > starting
    > > > block when generating cipher stream and use previous cipher block for
    > > > generating next keystream block.
    > > >
    > > > -Valery.
    > > > [url]http://www.harper.no/valery[/url]
    > > >
    > > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > > >I have two questions hoping someone could give me some insights.
    > > > >
    > > > > I'm implementing an encryption solution using the RijndaelManaged
    > class.
    > > > > What I found very strange is that if I use a different IV on the
    > > decrypte
    > > > > end, a binary file (such as a zip file) decrypts without any
    problem,
    > > but
    > > > > if
    > > > > it's a text file, it adds some scrumbled characters at the beginning
    > > even
    > > > > though the rest of the file is decrypted without problem. Why does
    > this
    > > > > happen?
    > > > >
    > > > > Because of this issue, I need to have the same IV on both ends. I'd
    > > like
    > > > > to
    > > > > avoid managing another piece of cryptic data (in addition to the
    key),
    > > I'm
    > > > > thinking of using the key as the IV. I use a 256-bit key so I
    > increased
    > > > > the
    > > > > blocksize on my RijndaelManaged object to 256 and this actually
    speed
    > up
    > > > > the
    > > > > encryption process by about 10% when I tested with a file of 3 MB in
    > > size.
    > > > > This is good. However, I just don't know if using the same byte
    array
    > > as
    > > > > the key and the IV is a security concern, that is, whether it's
    easier
    > > to
    > > > > figure out the IV from the encrypted data. Because if so, then my
    key
    > > is
    > > > > also exposed.
    > > > >
    > > > > Thanks a lot for any suggestions.
    > > > > Bob
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Alek Davis Guest

  12. #11

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    Thanks a lot Hernan.

    "Hernan de Lahitte" <hernan@lagash.com> wrote in message
    news:ubpjqtdOEHA.3348@TK2MSFTNGP09.phx.gbl...
    > Bob,
    >
    > It's not a good idea tu resuse the same key / IV combo. An instresting
    > approach might be to derive a password with the "PasswordDeriveBytes"
    class
    > and generate a random salt. If you want some further details about
    password
    > generation check out this article:
    > [url]http://blogs.msdn.com/shawnfa/archive/2004/04/14/113514.aspx[/url].
    >
    > --
    > Hernan de Lahitte
    > Lagash Systems S.A.
    > [url]http://weblogs.asp.net/hernandl[/url]
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >
    > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > news:ufSu8lGOEHA.1104@TK2MSFTNGP10.phx.gbl...
    > > Valery:
    > >
    > > Thanks for the reply. I understand IV can be plain text and what it
    does.
    > > My question is, if I use the key as the IV (so I don't have to send the
    IV
    > > as an added baggage or store it on both ends), whether this would add
    > > security risks.
    > >
    > > I need to keep the key on both ends anyway, so it's convenient to use it
    > as
    > > the IV. but if the convenience brings risks, then I probably shouldn't
    do
    > > it.
    > >
    > > Bob
    > >
    > > "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    > > news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    > > > Hi Bob,
    > > > you don't need to encrypt IV - just send it in plain text prepended to
    > > > cipher text.
    > > > The point is that you can use different IV with the same encryption
    > > session
    > > > key for encrypting multiple packages, thus producing different cipher
    > text
    > > > even if plain text was the same.
    > > > IV is used differently depending on modes of operations. ECB - no
    > effect,
    > > > CBC XORes every previous cipher block with next plain text block
    before
    > > > encrypting it, IV is used as the block 0. CFB and OFB uses IV as
    > starting
    > > > block when generating cipher stream and use previous cipher block for
    > > > generating next keystream block.
    > > >
    > > > -Valery.
    > > > [url]http://www.harper.no/valery[/url]
    > > >
    > > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > > >I have two questions hoping someone could give me some insights.
    > > > >
    > > > > I'm implementing an encryption solution using the RijndaelManaged
    > class.
    > > > > What I found very strange is that if I use a different IV on the
    > > decrypte
    > > > > end, a binary file (such as a zip file) decrypts without any
    problem,
    > > but
    > > > > if
    > > > > it's a text file, it adds some scrumbled characters at the beginning
    > > even
    > > > > though the rest of the file is decrypted without problem. Why does
    > this
    > > > > happen?
    > > > >
    > > > > Because of this issue, I need to have the same IV on both ends. I'd
    > > like
    > > > > to
    > > > > avoid managing another piece of cryptic data (in addition to the
    key),
    > > I'm
    > > > > thinking of using the key as the IV. I use a 256-bit key so I
    > increased
    > > > > the
    > > > > blocksize on my RijndaelManaged object to 256 and this actually
    speed
    > up
    > > > > the
    > > > > encryption process by about 10% when I tested with a file of 3 MB in
    > > size.
    > > > > This is good. However, I just don't know if using the same byte
    array
    > > as
    > > > > the key and the IV is a security concern, that is, whether it's
    easier
    > > to
    > > > > figure out the IV from the encrypted data. Because if so, then my
    key
    > > is
    > > > > also exposed.
    > > > >
    > > > > Thanks a lot for any suggestions.
    > > > > Bob
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Bob Guest

  13. #12

    Default Re: using the key as the IV in RijndaelManaged, any problem?

    See also sample code here, showing contatenation of items into AES_encrypted file,
    as well as how to manage this with cascaded streams b64 included:
    [url]http://www.jensign.com/JavaScience/dotnet/SimCryptNET[/url]

    - Mitch Gallant
    [url]www.jensign.com[/url]

    "Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
    news:eXiB8EeOEHA.3124@TK2MSFTNGP12.phx.gbl...
    > Or you can use an approach like this:
    > [url]http://www.obviex.com/samples/EncryptionWithSalt.aspx[/url].
    >
    > Alek
    >
    > "Hernan de Lahitte" <hernan@lagash.com> wrote in message
    > news:ubpjqtdOEHA.3348@TK2MSFTNGP09.phx.gbl...
    > > Bob,
    > >
    > > It's not a good idea tu resuse the same key / IV combo. An instresting
    > > approach might be to derive a password with the "PasswordDeriveBytes"
    > class
    > > and generate a random salt. If you want some further details about
    > password
    > > generation check out this article:
    > > [url]http://blogs.msdn.com/shawnfa/archive/2004/04/14/113514.aspx[/url].
    > >
    > > --
    > > Hernan de Lahitte
    > > Lagash Systems S.A.
    > > [url]http://weblogs.asp.net/hernandl[/url]
    > >
    > >
    > > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > >
    > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > news:ufSu8lGOEHA.1104@TK2MSFTNGP10.phx.gbl...
    > > > Valery:
    > > >
    > > > Thanks for the reply. I understand IV can be plain text and what it
    > does.
    > > > My question is, if I use the key as the IV (so I don't have to send the
    > IV
    > > > as an added baggage or store it on both ends), whether this would add
    > > > security risks.
    > > >
    > > > I need to keep the key on both ends anyway, so it's convenient to use it
    > > as
    > > > the IV. but if the convenience brings risks, then I probably shouldn't
    > do
    > > > it.
    > > >
    > > > Bob
    > > >
    > > > "Valery Pryamikov" <Valery@nospam.harper.no> wrote in message
    > > > news:e$pFNVGOEHA.3596@tk2msftngp13.phx.gbl...
    > > > > Hi Bob,
    > > > > you don't need to encrypt IV - just send it in plain text prepended to
    > > > > cipher text.
    > > > > The point is that you can use different IV with the same encryption
    > > > session
    > > > > key for encrypting multiple packages, thus producing different cipher
    > > text
    > > > > even if plain text was the same.
    > > > > IV is used differently depending on modes of operations. ECB - no
    > > effect,
    > > > > CBC XORes every previous cipher block with next plain text block
    > before
    > > > > encrypting it, IV is used as the block 0. CFB and OFB uses IV as
    > > starting
    > > > > block when generating cipher stream and use previous cipher block for
    > > > > generating next keystream block.
    > > > >
    > > > > -Valery.
    > > > > [url]http://www.harper.no/valery[/url]
    > > > >
    > > > > " Bob" <bobatkpmg@yahoo.com> wrote in message
    > > > > news:u6tcT%23EOEHA.3884@TK2MSFTNGP12.phx.gbl...
    > > > > >I have two questions hoping someone could give me some insights.
    > > > > >
    > > > > > I'm implementing an encryption solution using the RijndaelManaged
    > > class.
    > > > > > What I found very strange is that if I use a different IV on the
    > > > decrypte
    > > > > > end, a binary file (such as a zip file) decrypts without any
    > problem,
    > > > but
    > > > > > if
    > > > > > it's a text file, it adds some scrumbled characters at the beginning
    > > > even
    > > > > > though the rest of the file is decrypted without problem. Why does
    > > this
    > > > > > happen?
    > > > > >
    > > > > > Because of this issue, I need to have the same IV on both ends. I'd
    > > > like
    > > > > > to
    > > > > > avoid managing another piece of cryptic data (in addition to the
    > key),
    > > > I'm
    > > > > > thinking of using the key as the IV. I use a 256-bit key so I
    > > increased
    > > > > > the
    > > > > > blocksize on my RijndaelManaged object to 256 and this actually
    > speed
    > > up
    > > > > > the
    > > > > > encryption process by about 10% when I tested with a file of 3 MB in
    > > > size.
    > > > > > This is good. However, I just don't know if using the same byte
    > array
    > > > as
    > > > > > the key and the IV is a security concern, that is, whether it's
    > easier
    > > > to
    > > > > > figure out the IV from the encrypted data. Because if so, then my
    > key
    > > > is
    > > > > > also exposed.
    > > > > >
    > > > > > Thanks a lot for any suggestions.
    > > > > > Bob
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Michel Gallant Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139