[31588] in Kerberos

home help back first fref pref prev next nref lref last post

Re: RFC 3962 and DK(tkey, "kerberos") function

daemon@ATHENA.MIT.EDU (kerberos@noopy.org)
Thu Oct 15 10:54:41 2009

MIME-Version: 1.0
In-Reply-To: <1255615432.23997.58.camel@ray>
Date: Thu, 15 Oct 2009 10:53:59 -0400
Message-ID: <cba4e37e0910150753m655c4d87u2641bff3880c7cd@mail.gmail.com>
From: kerberos@noopy.org
To: Greg Hudson <ghudson@mit.edu>
Cc: "kerberos@mit.edu" <kerberos@mit.edu>
Content-Type: text/plain; charset="iso-8859-1"
Errors-To: kerberos-bounces@mit.edu
Content-Transfer-Encoding: 8bit

On Thu, Oct 15, 2009 at 10:03 AM, Greg Hudson <ghudson@mit.edu> wrote:
> On Tue, 2009-10-13 at 15:42 -0400, kerberos@noopy.org wrote:
>> Basically what I'm trying to do in
>> my DK function is: "encrypt my 'kerberos' block with the temporary key
>> I got from my derive bytes function."
>>
>> Am I understanding how I create the final key correctly here?
>
> You have the right idea to the best of my understanding, with the
> proviso that you should be using the cipher's default input vector
> (which I believe is all-bits-zero) and not an IV left over from any
> previous encryption.  So, I'm not immediately sure why you're not
> getting the right result.

*blushing* I figured out the error of my ways this morning.
Apparently some code I'd added for debugging was reading the result
Rfc2898DeriveBytes(...) *twice*, like so:

  Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(passPhrase,
saltValueBytes, passwordIterations);
  Console.WriteLine("debug me: " +
BitConverter.ToString(k1.GetBytes(keySize / 8))); // correct result
  byte[] keyBytes = k1.GetBytes(keySize / 8);
  Console.WriteLine(BitConverter.ToString(keyBytes)); // wrong result

The end result of calling GetBytes(...) twice was that my
intermediate/temporary key was flat *wrong* (as it was generated by
having read twice as many bits as it should've been) and this caused
my DK(...) function to fail.

I modified my code like so:

  Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(passPhrase,
saltValueBytes, passwordIterations);
  byte[] keyBytes = k1.GetBytes(keySize / 8);
  Console.WriteLine(BitConverter.ToString(keyBytes)); // correct result

Then I went back to each of the test vectors in RFC 3962 and
everything matched up.  Then I went back and compared to output of
ktpass.exe and everything matched up.  Sweet.  :-)

Thanks everyone for your clarification.  Very helpful!

-- 
K

________________________________________________
Kerberos mailing list           Kerberos@mit.edu
https://mailman.mit.edu/mailman/listinfo/kerberos


home help back first fref pref prev next nref lref last post