Sorry if this is a dumb question, I'm not sure why EVP_SignInit_ext() is giving me unhandled exception error. My code is a very simple testing code:

        char * clearText = "testing openssl";
        char cryptText[MAX_LEN];
        char buf[MAX_LEN];
        unsigned char ubuf[MAX_LEN];
        unsigned char sig[MAX_LEN];
        unsigned int sigLen;

        EVP_PKEY key;
        EVP_MD_CTX sctx, vctx;

        int ret = EVP_PKEY_assign_RSA(&key, RSA_generate_key(1024, RSA_3, 0, 
0));
        if (ret != 1)
                std::cout << "Generate rsa key failed..." << std::endl;

        EVP_SignInit_ex(&sctx, EVP_sha1(), NULL);
        EVP_SignUpdate(&sctx, clearText, strlen(clearText));
        memset(sig, 0, MAX_LEN);
        ret = EVP_SignFinal(&sctx, sig, &sigLen, &key);
        if (ret != 1)
                std::cout << "Signing failed..." << std::endl;

        EVP_VerifyInit_ex(&vctx, EVP_sha1(), NULL);
        EVP_VerifyUpdate(&vctx, clearText, strlen(clearText));
        ret = EVP_VerifyFinal(&vctx, sig, sigLen, &key);
        if (ret == 1)
                std::cout << "Signature is valid" << std::endl;
        else if (ret == 0)
                std::cout << "Signature is invalid..." << std::endl;
        else
                std::cout << "Verification failed..." << std::endl;

Everytime I get to EVP_SignInit_ex(), I get the error:

Unhandled exception at 0x1003dee6 in test.exe: 0xC0000005: Access violation reading location 0xcccccccc.

This code is basically copied from the sample. Is there anyting I need to initialize before that as well?

thanks in advance

cc

_________________________________________________________________
Donít just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to