locked
generate secure random from seed RRS feed

  • Question

  • Hi

    I want to create a symmetric key using a secure random generator (in java) using a seed (that has been created by signing some data). In java you can use the secure random generator together with the seed to create the same key over and over again. Is there a class in c# that can do this?
    I know you can do this with the regular Random class but is this safe enough? Why do they distinguish these 2 classes in java but not in c#?
    (I want to use AES encryption.)

    Ok I have found the following class: PasswordDeriveBytes
    I believe that this class can make me a symmetric key, correct? Now 'Rijndael' doesn't seem to be supported by this class.

    Can anyone tell me how I can create a 128 bit key for AES encryption out of a byte array (signed message). So every time I use this byte array to create a key, it will make the same symmetric key.

    (I'm wondering why this is so hard to find. Sorry if I seem a little frustrated.)

    thanks
    Sunday, August 16, 2009 1:07 PM

Answers

  • You can't give in a seed into RNGCryptoServiceProvider. At least I haven't found a way how to do it.

    I solved my problem with PasswordDeriveBytes.getBytes(128). I hope this is secure.
    • Marked as answer by Kurt Stevens Tuesday, October 13, 2009 11:00 AM
    Wednesday, August 26, 2009 6:42 PM

All replies

  • Hi,

    As suggested by the MSDN documentation of the class Random (http://msdn.microsoft.com/en-us/library/system.random%28VS.71%29.aspx ), you have to use the class System.Security.Cryptography.RNGCryptoServiceProvider if you need to generate cryptographically secure key material.

    Cheers,
    --
    Mounir IDRASSI
    IDRIX
    http://www.idrix.fr
    • Proposed as answer by Mounir IDRASSI Wednesday, August 26, 2009 6:37 PM
    Wednesday, August 19, 2009 2:18 AM
  • You can't give in a seed into RNGCryptoServiceProvider. At least I haven't found a way how to do it.

    I solved my problem with PasswordDeriveBytes.getBytes(128). I hope this is secure.
    • Marked as answer by Kurt Stevens Tuesday, October 13, 2009 11:00 AM
    Wednesday, August 26, 2009 6:42 PM
  • Hi Kurt:

    Great is this thread now solved?
    Please tell me if this thread is SOLVED!

    As you used, PasswordDeriveBytes Class and you called one of its
    methods, PasswordDeriveBytes.GetBytes Method. Also, just as you know,
    the "stength" is limited by the number of bytes in the
    hash output.

    Security note: Do NOT hadcode a password in your code.

    Have a nice day...

    Best regards,
    Fisnik


    Coder24.com
    Tuesday, October 13, 2009 6:25 AM