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KmF+
C1rDNy+pAQfj3y23mwJd2aDHV94Hx9G6cS+cTv30BDVqlHEV3dKEdJE+LlhTt4f/
UIcCbZebWsAThpbethX7X/mPPVqv3GkD+ug=
-----END PUBLIC KEY-----

Based on this key, i implemented the rho attack and CRT reconstruction to retrieve the secret key (The order is a composite square free value). I was able to retrieve it, and successfully defined the whole set of parameters. I tried to put them in openssl in C, and then write both private and public keys in pem files. I have the private key:

-----BEGIN DSA PRIVATE KEY-----
MIIDVQIBAAKCAQEAjz1UqHxIftsBiyv9VDhG8e0eWIAqeSVa4YJQUtkGcXYmJ5fS
Qh1bhUAv7zsRXjZj/RlMb9b3EOyY69CdurHVAxYPnT92QzInfesFsfDLpjTGIq6p
80zKSgsvspNHlKvGn2DdCRfpO4Zl7yT0dnQrJ9SlvZyM7IcqWYsquDwM0lbK5WQa
egrjqZfodgGHyNcT0nAeF7exIQ/cqPK4js0tIIdBiL4+CyiPD8vPe33bDCMfD2aZ
jphJMU7fOwMb6epLtdZnW7yITezVwHPAf/jDraEhbCynSIQW21n+RkRmPGpqQ0c0
v+vmUszeiMNROxz7X3g4OPrqWUDU3reZM/R02QIhAKtzRKBUPHymZVNaoRB0RD5F
N9QVLwOB+hcl+LfUqOTPAoIBAG0zsCCcEGjqOBte9DgfeRtmhaKY58ItmiK9Zi97
mf/1MSzRZTeyIhlUVNO8E5ovgldPr1sjefWqpeFjgnIkFq2odp1QT04nQBN/CFBm
ZKuX93X+Qi9Ocqootf8zk0uj2MMKDUdBky9mBkJfEnYtWCktf4llRWxx9SmZhXay
mlJJnPhDq7bHF8HD0ISC+W1R/C6zzwHUz9o1z4ceDhgPV7tpClu7cotlKpS0/lbo
S8oaSIUMdMQQTfvkz87s+8N1UDKXTRMC8c1DjXFWxZ/bdsZ+IXW73q5Mf9pIZeQC
QQsbgYDlUG7zQsUQYI5TfjCZVLzQ7UfYAx+h21oUiSmLCXgCggEAdwnqz2ZSk2wu
QC1AT22FefZkwBkSmpTAM10wITHWx+F0dO1LL+HKNFj/taPKwGt6HICGKTRuO6xX
R9vkkKpa/753hLZixO4iJufId6NvxYlT2mpywBfr5C8zteujV3tuajkuc8GDmBFW
sd/i3jg4bFLB8S0WASYLgG6UzauBgl8KOrXcksSfshzb/ZEswxRmdUUbRX2qcsh1
IDWf6TQ84TVc6DY2DkDaVnKx4j7fnhr/OuoqYX4LWsM3L6kBB+PfLbebAl3ZoMdX
3gfH0bpxL5xO/fQENWqUcRXd0oR0kT4uWFO3h/9QhwJtl5tawBOGlt62Fftf+Y89
Wq/caQP66AIgWGLo9aNI/8KYT04goCRusBKkQ/zjyxvlpw7OFZ5T9jg=
-----END DSA PRIVATE KEY-----

However, I am not able to sign correctly using it. I immediatly get Verification Failure. I know that these are the set of parameters:

//In hexadecimal
char * str_q = "AB7344A0543C7CA665535AA11074443E4537D4152F0381FA1725F8B7D4A8E4CF";
char * str_public_key = "7709EACF6652936C2E402D404F6D8579F664C019129A94C0335D302131D6C7E17474ED4B2FE1CA3458FFB5A3CAC06B7A1C808629346E3BAC5747DBE490AA5AFFBE7784B662C4EE2226E7C877A36FC58953DA6A72C017EBE42F33B5EBA3577B6E6A392E73C183981156B1DFE2DE38386C52C1F12D1601260B806E94CDAB81825F0A3AB5DC92C49FB21CDBFD912CC3146675451B457DAA72C87520359FE9343CE1355CE836360E40DA5672B1E23EDF9E1AFF3AEA2A617E0B5AC3372FA90107E3DF2DB79B025DD9A0C757DE07C7D1BA712F9C4EFDF404356A947115DDD28474913E2E5853B787FF5087026D979B5AC0138696DEB615FB5FF98F3D5AAFDC6903FAE8";
char * str_p = "8F3D54A87C487EDB018B2BFD543846F1ED1E58802A79255AE1825052D9067176262797D2421D5B85402FEF3B115E3663FD194C6FD6F710EC98EBD09DBAB1D503160F9D3F764332277DEB05B1F0CBA634C622AEA9F34CCA4A0B2FB2934794ABC69F60DD0917E93B8665EF24F476742B27D4A5BD9C8CEC872A598B2AB83C0CD256CAE5641A7A0AE3A997E8760187C8D713D2701E17B7B1210FDCA8F2B88ECD2D20874188BE3E0B288F0FCBCF7B7DDB0C231F0F66998E9849314EDF3B031BE9EA4BB5D6675BBC884DECD5C073C07FF8C3ADA1216C2CA7488416DB59FE4644663C6A6A434734BFEBE652CCDE88C3513B1CFB5F783838FAEA5940D4DEB79933F474D9";
char * str_g = "6D33B0209C1068EA381B5EF4381F791B6685A298E7C22D9A22BD662F7B99FFF5312CD16537B222195454D3BC139A2F82574FAF5B2379F5AAA5E16382722416ADA8769D504F4E2740137F08506664AB97F775FE422F4E72AA28B5FF33934BA3D8C30A0D4741932F6606425F12762D58292D7F8965456C71F529998576B29A52499CF843ABB6C717C1C3D08482F96D51FC2EB3CF01D4CFDA35CF871E0E180F57BB690A5BBB728B652A94B4FE56E84BCA1A48850C74C4104DFBE4CFCEECFBC3755032974D1302F1CD438D7156C59FDB76C67E2175BBDEAE4C7FDA4865E402410B1B8180E5506EF342C510608E537E309954BCD0ED47D8031FA1DB5A1489298B0978";
//In decimal
char * str_secret_key = "39978289515211046318557374739709642911277040124672026432986393822391386240568";

I don't understand what I'm doing wrong. I got the key parameters, created the private key, MADE SURE it corresponds to the given public key (which is true). But still the commands using

openssl dgst -sha256 -sign private_key_file -out sig_file text
openssl dgst -sha256 -verify public_key_file -signature sig_file text

output "Verification Failure" !

migrated from crypto.stackexchange.com Oct 1 at 19:37

This question came from our site for software developers, mathematicians and others interested in cryptography.

  • The two key files you posted work okay for me, with several OpenSSL versions. Check to make sure what you are running -- how/by who was it built? do you have any alias, shell function, etc? – dave_thompson_085 Oct 2 at 6:37
  • @dave_thompson_085 Apparently the problem was with my OpenSSL version. I have a dual boot ubuntu/Windows. It wasn't working with OpenSSL Ubuntu, however it worked on OpenSSL Windows. I'm not sure why exactly though. Thanks ! – abdul rahman taleb Oct 9 at 9:01

Your Answer

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

Browse other questions tagged or ask your own question.