Hello,
sorry for the first incomplete message :-/

I'm a bit confused about the behavior of EVP_DigestInit_ex when no md is given :

int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
        {
#ifndef OPENSSL_NO_ENGINE
          (...)
        if (type)
                {
                  (...)
                }
        else
        if(!ctx->digest)
                {
                EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_NO_DIGEST_SET);
                return 0;
                }
// so we want to keep the old digest if type is NULL
#endif
        if (ctx->digest != type)
                {
                 (...)
                ctx->digest=type;
                 (...)
                }
// but if a digest is already set, and type is NULL, digest will be set to 
NULL...
// Wouldn't it make more sense to keep existing old digest if type is NULL?
// and should the the if statements look more like this :

#ifndef OPENSSL_NO_ENGINE
          (...)
        if (type)
                {
                  (...)
                }
#endif
        if(!type && !ctx->digest)
                {
                EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_NO_DIGEST_SET);
                return 0;
                }

        if (type && (ctx->digest != type))
                {
                 (...)
                ctx->digest=type;
                 (...)
                }


Thanks for your answer
Nicolas
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to