#include <openssl/opensslconf.h> /* for OPENSSL_NO_RSA */
#ifndef OPENSSL_NO_RSA
# include <stdio.h>
-# include "cryptlib.h"
+# include "internal/cryptlib.h"
# include <openssl/evp.h>
# include <openssl/rand.h>
# include <openssl/objects.h>
if (j > max)
max = j;
}
- s = (char *)OPENSSL_malloc(max * 2);
+ s = OPENSSL_malloc(max * 2);
if (s == NULL) {
PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE);
goto err;
EVP_EncodeInit(&ctx->encode);
- EVP_MD_CTX_init(&ctx->md);
- if (!EVP_SignInit(&ctx->md, md_type))
+ ctx->md = EVP_MD_CTX_new();
+ if (!EVP_SignInit(ctx->md, md_type))
goto err;
EVP_CIPHER_CTX_init(&ctx->cipher);
ret = npubk;
err:
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
return (ret);
}
int i, j;
*outl = 0;
- if (!EVP_SignUpdate(&ctx->md, in, inl))
+ if (!EVP_SignUpdate(ctx->md, in, inl))
return 0;
for (;;) {
if (inl <= 0)
i = RSA_size(priv->pkey.rsa);
if (i < 100)
i = 100;
- s = (unsigned char *)OPENSSL_malloc(i * 2);
+ s = OPENSSL_malloc(i * 2);
if (s == NULL) {
PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE);
goto err;
EVP_EncodeFinal(&ctx->encode, out, &j);
*outl += j;
- if (!EVP_SignFinal(&ctx->md, s, &i, priv))
+ if (!EVP_SignFinal(ctx->md, s, &i, priv))
goto err;
*sigl = EVP_EncodeBlock(sig, s, i);
ret = 1;
err:
- EVP_MD_CTX_cleanup(&ctx->md);
+ EVP_MD_CTX_free(ctx->md);
EVP_CIPHER_CTX_cleanup(&ctx->cipher);
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
return (ret);
}
#else /* !OPENSSL_NO_RSA */