I am computing a SignatureValue from a couple of digests and my private key
and the resultant keystring is much shorter than I am expecting.  The
returned keystring length is 128 but the string is only 20 chars:

My code that I am using is below.  The argv is a vector containg two digest
values in Base64 format.  The returned string from my method below I then
convert into a Base64 string before writing to the XML etc...

Can anyone please advise why I am getting a short signature value string?

CString CDigitalCerts::ComputeSignatureValue( vector<SDigestValue>&
vecBuffers )
{
        unsigned char*  pszSig;
        unsigned int    unLen = 0;
        
        if ( !m_pKey )
        {
                ReadPKCS12();
        }

        if ( m_pKey )
        {
                EVP_MD_CTX ctx;
                EVP_MD_CTX_init( &ctx );
                int res = EVP_SignInit_ex( &ctx, EVP_sha1(), NULL );

                int nSigSize = EVP_PKEY_size( m_pKey );
                pszSig = new unsigned char[ nSigSize * 2 ];

                //      Feed buffers in to be signed:
                size_t nCount = vecBuffers.size();

                for ( int n = 0; n < nCount; ++n )
                {
                        char* szBuffer = vecBuffers[n].sDigest.GetBuffer(0);
                        res = EVP_SignUpdate( &ctx, szBuffer, strlen(szBuffer) 
);
                }

                //      Compute signature:
                res = EVP_SignFinal( &ctx, pszSig, &unLen, m_pKey );

                if ( res != 0 )
                {
                        // ???
                }
        }

        pszSig[ unLen ] = '\0';
        CString sSigVal( pszSig );
        delete[] pszSig;
        return sSigVal;
}
-- 
View this message in context: 
http://www.nabble.com/Size-of-computed-signature-tf3820772.html#a10816944
Sent from the OpenSSL - Dev mailing list archive at Nabble.com.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to