Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Encryption Keys (Understand Code)

Hello Experts,
Here is the partial code of my Encryption program which encrypts the data in 256 bits.  Here I am trying to understand the code to take it to next level.

1. What is the meaning of Encryption.m_Key = new byte[0x20] ?  Why it is [0x20], not [0x22] ?
2. What is the meaning of Encryption.m_IV = new byte[0x10] ? Why it is [0x10], not [0x11] ?
3. How line 1 and 2 are related?  I mean to say byte[0x20] and byte[0x10]. Does the 2nd one needs to be 10 byte long because 1st one is 20 bytes?
4. Why do we use m_IV?  Does the name matter here?

Please answer the above questions if possible.  FYI, I am not allowed to post the code.  I modified it as little as possible for explaining things.

Thank you very much in advance.

            public void GenerateKey()
            {
                  Encryption.m_Key = new byte[0x20];
                  Encryption.m_IV = new byte[0x10];
                  
                  RegistryKey key2 = Registry.LocalMachine.OpenSubKey("XXXXXXX").OpenSubKey("SubKey2");
                  if (key2 != null)
                  {
                        RegistryKey key3 = key2.OpenSubKey("SubKey3");
                        if (key3 != null)
                        {
                                      .
                                      .
                                      .
                        }
                  }
            }
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Thank you Andy and Sara for your help.  This clarified many of my doubts.  Can we declare the variables like this?

Encryption.m_Key = new byte[0x10]
Encryption.m_IV = new byte[0x10]
Encryption.m_Key = new byte[0x10]    No, it should be 32 bytes so use 0x20

Encryption.m_IV = new byte[0x10]   Yes
Thank you Andy and Sara.  You guys are great!  Thank you again!!