When computing DSA signatures, the first eight bytes of the signature
appear to follow a rather predictable pattern, which I am concerned about.
I've tested this to be so using two slightly different input texts:
1. "Mary had a little lamb"
2. "Mary had a little lama"
For each of these two texts, I computed 10 signatures (all from the same
signing key). The signatures (if expressed in hexadecimal format) all
start with an 8 byte sequence that matches the regular expression:
302[cde]021[45]
Because DSA signatures are computed from SHA1 hashes, I also computed
these SHA! hashes for each of the two inputs. I was relieved to see that
the hashes were very different.
Therefore, the observed pattern must come from whatever DSA_sign() does
after the hash has been computed.
(The test script and its output for one run over
the two texts are appended to this message)
Is the observed pattern normal?
Thanks in advance for any advice,
Erik Leunissen.
=== test script ===
#! /bin/sh
openssl dsaparam -out dsaparam.pem 1024
openssl gendsa -out dsaprivatekey.pem dsaparam.pem
rm ./result
for file in ./text_1 ./text_2 ; do
cat $file >> result
echo "" >> result
openssl dgst -sha1 $file >> result
let i=1
while [ $i -le 10 ]; do
openssl dgst -dss1 -sign dsaprivatekey.pem -out dsasign.bin $file
bin2hex dsasign.bin dsasign.hex
cat dsasign.hex >> result
echo "" >> result
let i=i+1
done
echo "" >> result
done
=== end test script ===
=== result ===
Mary had a little lamb
SHA1(./text_1)= bac9388d0498fb378e528d35abd05792291af182
302c02144635bdb6c9972659cef2303983bc37d40c0a102802147fb258a72737889b87878e54c2302145a536d4d9d9
302c0214338655309994987b1c4f14f8c5e028f126e82403021441084ef8bf5b8051c913132267c19ee31dce7cfafa
302c02142f4c458fdc9110bb3d25b6ce1d012c3b24cf167302141319feb7f56aaa0bc1bd1bcb4a4d8bf3175897cccc
302c02140ba7d14d40aed0d5751f65b726fe9ce81a4c82a002146eb574a5f280c51de934356f6635615856619b8b8b
302c02141b52ed0c1c73ef407b4215c74eba937881efab630214213af6b49dd2beae9ba9cdbf8beece2916e4431818
302c02141e3ff126360c2905e68ef5655cb2798cc1b98ecc021402d85adb43775a747ea22571f7bcba55ec8d30bbbb
302c021461450883621e20253496ac41050e8423d4bb0def021400a4fab9683015769d18799d2a23728a994354e8e8
302d02140514fbce62d6d4ad4e91519d9dc2463ec321bad302150082ec5c73cdfaa430a0d85789f080c111e76d699191
302c02144acbcf4e929a2d925dd8084881f637a9b73b0b3702141363018c428ce557e3cc41345f92568c347f260404
302c021415ff796c3c272c827a67b75b5fb964724d9b0fea02146955111aad60aaa965396e2dbafcf363837f521a1a
Mary had a little lama
SHA1(./text_2)= bd3163f5588e1ec93da72abd40e2205adaa895bb
302c02145f25c207bb79c982debb4ee5275e3afc5f20198f02145de083c0300f9eea3cc8759791776f99d412703e3e
302d02150080d52801ab74352a8b2184413f78a8461da1cc04021412624d9bac4760f747d2fb48dbf830cf3725b8e5e5
302c021455140b79589266a64f3864c9e5893da9a14b2392021433445adbc359f5da59da6e2e5ffa246f150efc8787
302c02146c2ab143c642f5779cd34163f03878e6d29e72d3021429265e01e5a56514d6936fd67c122a0ccbb5204444
302c02142a221409c3860fde2fda6c51c8f0035346be437402140dfb92f6b06c5b32abc505fc312278ca106ea52c2c
302c021418e01463f73571ab47f43488054835fcee9672bb02142443f586b244a778224cdd0eec8bd2e5a63f30bdbd
302c0214490466ec6077a5243165afbc8229ae5e3dc76139021454ecb1d4031106656aecba3db011dd6e15b7513f3f
302c021439e4c1424d0717d9a02461a2e0de4e783af3adb7021461db4b1a25923f636706b0bc35b1383332f4df0707
302c02147bcfbdb888fab46e7ecf89fe4691841d4b665ccd02147bc6e0e0446a65e7c99f7c815c64f77d7122149d9d
302e021500866b521eef5eec6d437a97e0c69e2594b07fa0d1021500843dac9025ffdf5a7ab777f473045ca2b3df071f1f
=== end result ===
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]