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?