1

I am running into a problem with verifying a SHA256 hash signature generated using OpenSSL.

When I invoke

openssl dgst -sha256 -binary -out hash.sha256 in_file 

and I (xxd -g 1 hash.sha256), it looks like this -

00000000: d7 e6 1b 81 5c 32 28 30 7b 7b 45 e1 ef 40 6b 93  
00000010: 34 67 d0 a4 ee c0 64 d1 20 e7 c1 c3 a9 f2 a9 a9  

Similarly, when I invoke

openssl dgst -sha256 -out hash.sha256 -sign private.pem in_file 

to hash and sign all at once, and subsequently verify using

openssl rsautl -in hash.sha256 -out hash.verified -inkey private.pem -verify

and (xxd -g 1 hash.verified), (which should be the same as hash.sha256 from above, I believe) I see

00000000: 30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05  
00000010: 00 04 20 d7 e6 1b 81 5c 32 28 30 7b 7b 45 e1 ef  
00000020: 40 6b 93 34 67 d0 a4 ee c0 64 d1 20 e7 c1 c3 a9  
00000030: f2 a9 a9 

If you look closely, it appears that hash.verified has 19 bytes of data prepended to it, followed by the correct hash (or at least the same as hash.sha256 from above).

What is it putting in my hash?

jww
  • 97,681
  • 90
  • 411
  • 885
zkabitz
  • 41
  • 8
  • 1
    Is it possible this is a salt that openssl derived from my .pem file? I just signed and verified a different file using the same .pem and I saw the same first 19 bytes – zkabitz Feb 15 '18 at 23:11
  • 2
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Feb 16 '18 at 00:33
  • 1
    Here is your duplicate: [OpenSSL ECDSA signatures longer than expected](https://stackoverflow.com/q/44807170/608639). Also see questions like [ECDSA sign with OpenSSL, verify with Crypto++](https://stackoverflow.com/q/17316178/608639), where signature formats must be converted. – jww Feb 16 '18 at 06:36
  • 1
    Thank you - I appreciate the help – zkabitz Feb 16 '18 at 15:13

0 Answers0