none
SHA256, SHA384, SHA512 Support in Windows Embedded CE 6.0 RRS feed

  • Question

  • I need to be able to support SHA256, SHA384 and SHA512 in Windows Embedded CE 6.0 and have come across a few problems.

    Whenever I try to create the hash I get an error response of 0x80090008 (Bad Algorithm.)

    My understanding is that SHA2 support was added to Windows Embedded CE 6.0 as part of the April 2010 QFE as KB979675 link: http://support.microsoft.com/kb/979675.

    Looking at the KB article again it sounds like the SHA2 support might only work via SSL and that I might not be able to generate a SHA2 hash on its own like you can for SHA1, MD4, MD5, etc...

    Can anyone confirm if you can use SHA256/SHA384/SHA512 for a hash or if the update only added the necessary support for SSL?

    My platform:

    • ARM
    • Windows Embedded CE 6.0
    • QFEs updated to Feb 2014

    Here is the test code, please note that I have removed a lot of error checking, resource cleanup, logging etc to keep the code short.

    static int Hash_( const BYTE* const inputData, const UINT32* const inputDataLen, BYTE** hashedData, UINT32* const hashedDataSize, ALG_ID algorithm) { HCRYPTPROV provider = NULL; HCRYPTKEY cryptKey = NULL; HCRYPTHASH hash = NULL; if (!CryptAcquireContext( &provider, NULL, NULL, PROV_RSA_FULL, 0)) { goto cleanup; } if (!CryptCreateHash( provider, algorithm, cryptKey, 0, &hash)) {

                    // **** Bad Algorithm Occurs Here ****     goto cleanup; } if (!CryptHashData( hash, inputData, inputDataLen, 0)) { goto cleanup; } DWORD size = sizeof(DWORD); if (!CryptGetHashParam( hash, HP_HASHSIZE, (BYTE*)hashedDataSize, &size, 0)) { goto cleanup; } *hashedData = new BYTE[*hashedDataSize]; if (!CryptGetHashParam( hash, HP_HASHVAL, *hashedData, (DWORD*)hashedDataSize, 0)) { goto cleanup; } cleanup: return error; } // Hash_

    EDIT: The above code works for SHA1, MD2, MD4 and MD5 but fails on SHA256, SHA384 and SHA512

    Thanks,

    Brad.


    • Edited by Bradley Remedios Tuesday, April 29, 2014 11:06 PM Forgot to mention working hash algorithms
    Tuesday, April 29, 2014 11:05 PM

Answers

All replies