0
$\begingroup$

From http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf Nist document what i understood is while implementing SHA512 and SHA512/224 the two differences are the Initial hash value and the final result truncation.When i changed the initial hash value of SHA512 to that one of SHA512/224 as specified in the fips 180-4 document and built the CAVS and started testing with the test vector https://pastebin.com/wivUc5eH.

Lets consider the first case:

  Len = 0
  Msg = 00
  MD = d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f

But the result i am obtaining for the above input is:

  SHA512/224 digest
       6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4

Lets consider the second case:

  Len = 8
  Msg = 84
  MD = 3cd36921df5d6963e73739cf4d20211e2d8877c19cff087ade9d0e3a

But the result i am obtaining for the above input is:

  SHA512/224 digest
       8f8fdcb3f617a2d809b3132860b02fee00bdd927d541d42073dd12e7

What am i doing wrong?.Can anyone let me know if the concept i have understood correct.

$\endgroup$
2
$\begingroup$

Your implementation of the algorithms seems to correct, but in the test cases the vectors are those of SHA224. Here are my results:

C:\TMP\0
    SHA224: d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f
    SHA512: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
SHA512/224: 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4

C:\TMP\8
    SHA224: 3cd36921df5d6963e73739cf4d20211e2d8877c19cff087ade9d0e3a
    SHA512: f180d4243a77ba2b31456286cb55ac765117bdac22b8c3d4f7cdc9dd5b7ba49222fc91da2cddcd81c6ad97d18d562a5727bc7660dc8b7ce05a06976e7ad10bbb
SHA512/224: 8f8fdcb3f617a2d809b3132860b02fee00bdd927d541d42073dd12e7
$\endgroup$
  • $\begingroup$ I am new to these cryptographic algorithms so in NIST Site they have not specified any specific test cases for SHA512/224 and SHA512/256. So i thought it might take the test vectors of SHA224. Can you please let me know whether any other site provide test vector to verify my algorithm(SHA512/224)? $\endgroup$ – user3405360 Jun 6 '17 at 10:30
  • $\begingroup$ As a start, use the link from FIPS 180.4 A2 (csrc.nist.gov/groups/ST/toolkit/examples.html). There are a lot of test cases for all hash algorithms, especially csrc.nist.gov/groups/ST/toolkit/documents/Examples/… (with intermediate results) $\endgroup$ – gammatester Jun 6 '17 at 10:46
2
$\begingroup$

As stated by FIPS 186-4 (6.6) The only two differences between SHA-512 and SHA-512/224 are the eight 64-bit words used for initialization, given by FIPS 186-4 (5.3.6.1); and result truncation to the first 224 bits of the 512-bit result: $H_0^{(N)}$, $H_1^{(N)}$, $H_2^{(N)}$ each 64-bit, and the high-order 32 bits of $H_3^{(N)}$.

I suggest to start by checking the SHA-512 implementation pass test vectors; then implement the truncation, and test; then change the initialization value, and test.

[epilogue: that was the test vectors, see this]

$\endgroup$
  • $\begingroup$ I followed the same procedure.But its not working for 512/224 or 512/256 $\endgroup$ – user3405360 Jun 6 '17 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.