Commit bfb0641f authored by Richard Levitte's avatar Richard Levitte
Browse files

Cleanup: fix all sources that used EVP_MD_CTX_(create|init|destroy)



Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 959ed531
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -322,7 +322,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
    salt_len = strlen(salt_out);
    assert(salt_len <= 8);

    md = EVP_MD_CTX_create();
    md = EVP_MD_CTX_new();
    if (md == NULL)
        return NULL;
    EVP_DigestInit_ex(md, EVP_md5(), NULL);
@@ -332,7 +332,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
    EVP_DigestUpdate(md, "$", 1);
    EVP_DigestUpdate(md, salt_out, salt_len);

    md2 = EVP_MD_CTX_create();
    md2 = EVP_MD_CTX_new();
    if (md2 == NULL)
        return NULL;
    EVP_DigestInit_ex(md2, EVP_md5(), NULL);
@@ -364,8 +364,8 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
                         (i & 1) ? sizeof buf : passwd_len);
        EVP_DigestFinal_ex(md2, buf, NULL);
    }
    EVP_MD_CTX_destroy(md2);
    EVP_MD_CTX_destroy(md);
    EVP_MD_CTX_free(md2);
    EVP_MD_CTX_free(md);

    {
        /* transform buf into output string */
+6 −6
Original line number Diff line number Diff line
@@ -1511,7 +1511,7 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
                 STACK_OF(OPENSSL_STRING) *sigopts)
{
    int rv;
    EVP_MD_CTX *mctx = EVP_MD_CTX_create();
    EVP_MD_CTX *mctx = EVP_MD_CTX_new();

    rv = do_sign_init(mctx, pkey, md, sigopts);
    /* Note: X509_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
@@ -1520,7 +1520,7 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
    if (rv > 0)
        rv = X509_sign_ctx(x, mctx);
    else
        EVP_MD_CTX_destroy(mctx);
        EVP_MD_CTX_free(mctx);
    return rv > 0 ? 1 : 0;
}

@@ -1528,7 +1528,7 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
                     STACK_OF(OPENSSL_STRING) *sigopts)
{
    int rv;
    EVP_MD_CTX *mctx = EVP_MD_CTX_create();
    EVP_MD_CTX *mctx = EVP_MD_CTX_new();
    rv = do_sign_init(mctx, pkey, md, sigopts);
    /* Note: X509_REQ_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
     * the EVP_MD_CTX we send it, so only destroy it here if the former
@@ -1536,7 +1536,7 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
    if (rv > 0)
        rv = X509_REQ_sign_ctx(x, mctx);
    else
        EVP_MD_CTX_destroy(mctx);
        EVP_MD_CTX_free(mctx);
    return rv > 0 ? 1 : 0;
}

@@ -1544,7 +1544,7 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
                     STACK_OF(OPENSSL_STRING) *sigopts)
{
    int rv;
    EVP_MD_CTX *mctx = EVP_MD_CTX_create();
    EVP_MD_CTX *mctx = EVP_MD_CTX_new();
    rv = do_sign_init(mctx, pkey, md, sigopts);
    /* Note: X509_CRL_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
     * the EVP_MD_CTX we send it, so only destroy it here if the former
@@ -1552,6 +1552,6 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
    if (rv > 0)
        rv = X509_CRL_sign_ctx(x, mctx);
    else
        EVP_MD_CTX_destroy(mctx);
        EVP_MD_CTX_free(mctx);
    return rv > 0 ? 1 : 0;
}
+3 −3
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
        return 0;

    if (input) {
        EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
        EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
        unsigned char buffer[4096];
        int length;

@@ -535,10 +535,10 @@ static int create_digest(BIO *input, char *digest, const EVP_MD *md,
            EVP_DigestUpdate(md_ctx, buffer, length);
        }
        if (!EVP_DigestFinal(md_ctx, *md_value, NULL)) {
            EVP_MD_CTX_destroy(md_ctx);
            EVP_MD_CTX_free(md_ctx);
            return 0;
        }
        EVP_MD_CTX_destroy(md_ctx);
        EVP_MD_CTX_free(md_ctx);
    } else {
        long digest_len;
        *md_value = string_to_hex(digest, &digest_len);
+5 −5
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
              ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey,
              const EVP_MD *type)
{
    EVP_MD_CTX *ctx = EVP_MD_CTX_create();
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    unsigned char *p, *buf_in = NULL, *buf_out = NULL;
    int i, inl = 0, outl = 0, outll = 0;
    X509_ALGOR *a;
@@ -205,7 +205,7 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
    signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
    signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
 err:
    EVP_MD_CTX_destroy(ctx);
    EVP_MD_CTX_free(ctx);
    OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
    OPENSSL_clear_free((char *)buf_out, outll);
    return (outl);
@@ -217,14 +217,14 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,
                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *asn,
                   EVP_PKEY *pkey, const EVP_MD *type)
{
    EVP_MD_CTX *ctx = EVP_MD_CTX_create();
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();

    if (ctx == NULL) {
        ASN1err(ASN1_F_ASN1_ITEM_SIGN, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    if (!EVP_DigestSignInit(ctx, NULL, type, NULL, pkey)) {
        EVP_MD_CTX_destroy(ctx);
        EVP_MD_CTX_free(ctx);
        return 0;
    }
    return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, ctx);
@@ -315,7 +315,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
    signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
    signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
 err:
    EVP_MD_CTX_destroy(ctx);
    EVP_MD_CTX_free(ctx);
    OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
    OPENSSL_clear_free((char *)buf_out, outll);
    return (outl);
+4 −4
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@
int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
                char *data, EVP_PKEY *pkey)
{
    EVP_MD_CTX *ctx = EVP_MD_CTX_create();
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    const EVP_MD *type;
    unsigned char *p, *buf_in = NULL;
    int ret = -1, i, inl;
@@ -126,7 +126,7 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
    }
    ret = 1;
 err:
    EVP_MD_CTX_destroy(ctx);
    EVP_MD_CTX_free(ctx);
    return (ret);
}

@@ -151,7 +151,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
        return -1;
    }

    ctx = EVP_MD_CTX_create();
    ctx = EVP_MD_CTX_new();
    if (ctx == NULL) {
        ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_MALLOC_FAILURE);
        goto err;
@@ -225,6 +225,6 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
    }
    ret = 1;
 err:
    EVP_MD_CTX_destroy(ctx);
    EVP_MD_CTX_free(ctx);
    return (ret);
}
Loading