Home   Index   About
Ultimate Pack


Custom Search
Key Derivation Sample

This data was generated using the Microsoft RSA Base Provider. Your session key length and salt length may be different, but the basic process should be the same.

Let's assume that an application has a password ("1134-kelp") that it wants to derive a session key from. It would first hash the password with the CryptHashData function, in this case specifying the MD5 hash algorithm. The following hash value is generated and held internal to the CSP.

0x00000000 73 40 e6 e2 74 b8 ea 39 s@..t..9

0x00000008 93 95 aa 29 d6 38 b5 2a ...).8.*

The application would then call the CryptDeriveKey function in order to create a session key, in this case an RC4 stream cipher key. The CSP uses the first five bytes of the above hash value as the key itself:

0x00000000 73 40 e6 e2 74 s@..t

Because the CRYPT_CREATE_HASH flag was not specified, the key is given a salt value of zero.

If the session key is used to encrypt the following plaintext buffer:

0x00000000 00 01 02 03 04 05 06 07 ........

0x00000008 08 09 0a 0b 0c 0d 0e 0f ........

0x00000010 10 11 12 13 14 15 16 17 ........

0x00000018 18 19 1a 1b 1c 1d 1e 1f ........

The following ciphertext data is generated:

0x00000000 26 59 de 24 44 fa 36 9c &Y.$D.6.

0x00000008 11 0c bb 9d b6 a2 bd 24 .......$

0x00000010 04 2e e3 ba 72 76 f3 27 ....rv.'

0x00000018 8d d5 b4 2f 56 cf f8 c9 .../V...

If the application does specify the CRYPT_CREATE_HASH flag during the CryptDeriveKey function call, then the key is given the following 11 byte salt value:

0x00000000 b8 ea 39 93 95 aa 29 d6 ..9...).

0x00000008 38 b5 2a 8.*

In this case, the following ciphertext data is generated when the above plaintext buffer is encrypted:

0x00000000 47 f4 5d e2 cc 3b 87 1b G.]..;..

0x00000008 95 bc fc 39 fb 86 d3 05 ...9....

0x00000010 da a2 91 fb 80 f1 2a 22 ......*"

0x00000018 c3 b9 ec 91 dd 9f af 50 .......P


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun