What is the format of ECDSA signature?

225 views
Skip to first unread message

王祥

unread,
Jul 17, 2018, 7:21:01 PM7/17/18
to Crypto++ Users
Hi guys, 


I tried to call DSAConvertSignatureFormat with the signature generated by the two following ways, 
************
byte signature[0x40];
DSAConvertSignatureFormat(signature, sizeof(signature), DSA_DER,
    (byte*)signatureDSA_DER.c_str(), signatureDSA_DER.size(), DSA_DER);
************

the BERDecodeErr was thrown.
What is the format of the signatures generated in the following format?

************
size_t siglen = signer.MaxSignatureLength();
string signatureDSA_DER(siglen, 0x00);
siglen = signer.SignMessage(prng, (const byte*)content.c_str(), content.size(), (byte*)&signatureDSA_DER[0]);
signatureDSA_DER.resize(siglen);
************
string signatureDSA_DER;
StringSource s(content, true /*pump all*/,
    new SignerFilter(prng,
        signer,
        new StringSink(signatureDSA_DER)
    ) // SignerFilter
); // StringSource
************

Best Regards,

王祥

unread,
Jul 18, 2018, 12:45:45 AM7/18/18
to Crypto++ Users
Hi all, 
I found that the default format is P1363.
Since I am signing the message using crypto++ ecdsa, and verify the signature with Go, I need to change the signature format from P1363 to DER.


However, the length below is 0, does anybody know if there is something wrong?
// Determine size of required buffer
auto length = DSAConvertSignatureFormat(NULL, 0, DSA_DER,
            (byte*)signatureP1363.c_str(), signatureP1363.size(), DSA_P1363);


王祥於 2018年7月18日星期三 UTC+8上午7時21分01秒寫道:

Jeffrey Walton

unread,
Jul 18, 2018, 2:40:18 AM7/18/18
to Crypto++ Users


On Wednesday, July 18, 2018 at 12:45:45 AM UTC-4, 王祥 wrote:
Hi all, 
I found that the default format is P1363.
Since I am signing the message using crypto++ ecdsa, and verify the signature with Go, I need to change the signature format from P1363 to DER.


However, the length below is 0, does anybody know if there is something wrong?
// Determine size of required buffer
auto length = DSAConvertSignatureFormat(NULL, 0, DSA_DER,
            (byte*)signatureP1363.c_str(), signatureP1363.size(), DSA_P1363);

You should probably show the data in signatureP1363 . It sounds like signatureP1363 is empty.

Jeff

Jeffrey Walton

unread,
Jul 18, 2018, 2:42:50 AM7/18/18
to Crypto++ Users


On Wednesday, July 18, 2018 at 2:40:18 AM UTC-4, Jeffrey Walton wrote:

On Wednesday, July 18, 2018 at 12:45:45 AM UTC-4, 王祥 wrote:
Hi all, 
I found that the default format is P1363.
Since I am signing the message using crypto++ ecdsa, and verify the signature with Go, I need to change the signature format from P1363 to DER.
...

However, the length below is 0, does anybody know if there is something wrong?
// Determine size of required buffer
auto length = DSAConvertSignatureFormat(NULL, 0, DSA_DER,
            (byte*)signatureP1363.c_str(), signatureP1363.size(), DSA_P1363);

You should probably show the data in signatureP1363 . It sounds like signatureP1363 is empty.

By the way, here is the source code to DSAConvertSignatureFormat: https://github.com/weidai11/cryptopp/blob/master/dsa.cpp

Jeff

王祥

unread,
Jul 18, 2018, 4:17:43 AM7/18/18
to Crypto++ Users
Hi Jeff,
Thank you very much for the prompt reply.
still facing the same problem.
I am sure that the P1316 signature is not empty.

I am sorry that I am not very familiar with the ECDSA and hence not able to debug the code of DSAConvertSignatureFormat...
Thank you very much in advance for your insights!

Best Regards,

Jeffrey Walton於 2018年7月18日星期三 UTC+8下午2時42分50秒寫道:
CryptoPPInteropSign.cpp
pictures_p1316 signature is not empty.docx
Reply all
Reply to author
Forward
0 new messages