cryptography - Length of data to hash for PGP -


i have managed verify simple pgp signed message blocks. however, discovered reason, implementation limits me verifying data 9-16 bytes long. no less. no more.

is there instruction somewhere (rfc4880 or elsewhere) specifies how deal plaintext data of length? maybe there sort of padding missed? pkcs1?

i pretty sure formatted data hash properly, since instructions in rfc 4880 sec 5.2.4 text documents, replace \n \r\n , add trailer. since test values single lines of data, nothing had replaced

all of these values in base 10 unless otherwise noted:

// dsa public key values p = 175466718616740411615640156350265486163809613514213656685227237159351776260193236923030228927905671867677337184318134702903960237546408302010360724274436019639502405323187799029742776686067449287558904042137172927936686590837020160292525250748155580652384740664931255981772117478967314777932252547256795892071 q = 809260232002608708872165272150356204306578772713 g = 127751900783328740354741342100721884490035793278553520238434722215554870393020469115393573782393994875216405838455564598493958342322790638050051759023658096740912555025710033120777570527002197424160086000659457154926758682221072408093235236853997248304424303705425567765059722098677806247252106481642577996274 y = 172935968966072909036304664996424500241381878537444332146572958203083745609400290814117451480512268901233962890933482206538294509037615827035398352528065134903071886710296983781453184598843331365336270501467458073523376152406987560592548479865116940266729198119357206749848310472131186772143408998928864559411 

not working:

-----begin pgp signed message----- hash: sha1  abcd -----begin pgp signature----- version: bcpg v1.39  ifsearecabsfak/tb28uhgfiyya8bwfry21aywfhlmnvbt4acgkqmfilrc933ya2 rwcfdmyi08iz0rdxvhoplga3s5y9j/8an2he7+hhjwfgjnoojt7gaxqjaolo =i2rt -----end pgp signature-----  data hashed (in hex): 6162636404011102001b05024fed076f141c616263203c6d616b636d406161612e636f6d3e04ff00000021  r = 666804200764671083282351405489424949903645052927 s = 558743769080942454889260816818443017172325925608  w =  702955297882281869313155599553522395227576660460 // s^-1 mod q u1 = 190417717173929082607343542521304347388874234334 u2 = 306786785479358548892951170619047936651163362761 v = g^u1 * y^u2 % p % q = 737052148656331043521702886300418501784667890334  v != r 

working:

-----begin pgp signed message----- hash: sha1  0123456789abcdef -----begin pgp signature----- version: bcpg v1.39  ifsearecabsfak/tce0uhgfiyya8bwfry21aywfhlmnvbt4acgkqmfilrc933yyg iqcfercgpsxfnah6otgqdembv9oecgianriyolirbqslbugbt6ex/adz4+7l =bzab -----end pgp signature-----  data hashed (in hex): 3031323334353637383961626364656604011102001b05024fed084d141c616263203c6d616b636d406161612e636f6d3e04ff00000021  r = 700580719365380086754774917458461236187098909186 s = 103881812262595813943381509986903840453887782603  w = 178510125628083028184051840492924307896586330444 // s^-1 mod q u1 = 78831508775508876446567239486098677466912246622 u2 = 572875590470993668032596348682349224460207395691 v = g^u1 * y^u2 % p % q = 700580719365380086754774917458461236187098909186  v == r 

what data did not include in hash / did wrong?

edit: here public key requested, though relevant values have been posted already)

-----begin pgp public key block----- version: bcpg v1.39  mqgibe5b0h8rbad533z5bk1ipbx02qyql0qoje4ufrimgdiwxuwmzzvl+r7vlurd grlsccbe6vooh7xqvzgzleby9wnzz9m+ebcfsvaykjs6fhlws6hg6irrns+b3jbf gfj8vngf9z7bhx+7y7nbk0imywkgnukcnav73t5fqui2faebn4c/yagjzwcgjcb7 3akwk9xvwvtcsimxxpyvkukealxsvb6coofetqq9cqhjp63fblvd94dhhmim0ch6 hw9jotxdk+cxfgg9ziwgon2pwbmjka/h4w5el6ts+yinar7i1ozkt6x16gjnquzz mlsplek+kikvn2anrapeooiinhre3zxd6qlj/4+ojn4ivwmseajpff4qngveu4rh xinybad2rnzreoa+wpnfz4ldt9nzxmxdxqme/l0j9xcvwhpgsxa/matqkimy7n49 7gt/m38f+trpbobag1o3bue99folyws4tbc+szmdhxoigzdairnqs2rv475e6ktj 7vd5cyvoka6+8sx1+hpcnlkhthb1ofkjrsyp6k0zkyc9adjbm7qtywjjidxtywtj bubhyweuy29tpohgbbmragagbqjoqdifaaojedbsjuxpd92grsqaoitbtbtoog7a /hcg2sa/abeqnwuxakcgr69vmsocwobp5wapk0usjm3bsbjmbe5b0h8qagculp7a lfo4xukgvcs4nvybpd0ka0m0wjndohrnsiz44x24vlfto0gruewjpmqrrlho8zlj s/bxo/bho6ypjn87af0vpv1hcq20mew2iujh3hbwthnwbwhtkdpxondjgzab7lsh ljuwv9z6wydnxj/sbeiv1gnpm0eleg8syhy5pcjmaf9qhehp2ecfqfewtanaola6 cu+ryhkpzai9nuwca7qd2d93/l08/+ztfvejzw1rwrj8qfldrtlpgrzigof/cxbr ieyegbecaayfak5b0h8acgkqmfilrc933yzrracfunwtjhhn+qseeojrwrvfmvzj br4an24ptpeen+i6r59o/sdmysahjulx =ssts -----end pgp public key block----- 

haven't got enough time details, guess you're applying (or not applying) padding correctly. cause right result come input lengths, not others.

i guess i'll more, wanted in under bounty wire :)

edit: ok, found error. not sure why you're getting it, if it's fixed, right answer comes out. in not-working example, calculate w (s^-1 mod q) as

w =  702955297882281869313155599553522395227576660460 // s^-1 mod q 

but get

w =  702955297882281869313155599553522395227576660458 

off 2! really, close values though. , can shown mine right:

s * your_w mod q = 308227306159276200906356361486529830038073078504 s * my_w mod q = 1 

if plug in w value, get

u1 = 536931432138658080437983667536052790245747416035 u2 = 591698847955233800072578903940910445457030802333 v = (g^u1 * y^u2) % p % q = 666804200764671083282351405489424949903645052927 r == v 

hope helps.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -