Adapt PEM routines to the opaque EVP_ENCODE_CTX
[openssl.git] / crypto / pem / pem_seal.c
index d0db77783219ed3a9bf25b49707fcccee8183f73..f7c9e3f8186bed167115a20c3a771bd3006741f4 100644 (file)
@@ -91,7 +91,8 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
         goto err;
     }
 
-    EVP_EncodeInit(&ctx->encode);
+    ctx->encode = EVP_ENCODE_CTX_new();
+    EVP_EncodeInit(ctx->encode);
 
     ctx->md = EVP_MD_CTX_new();
     if (!EVP_SignInit(ctx->md, md_type))
@@ -135,7 +136,7 @@ int PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
             i = inl;
         if (!EVP_EncryptUpdate(&ctx->cipher, buffer, &j, in, i))
             return 0;
-        EVP_EncodeUpdate(&ctx->encode, out, &j, buffer, j);
+        EVP_EncodeUpdate(ctx->encode, out, &j, buffer, j);
         *outl += j;
         out += j;
         in += i;
@@ -166,10 +167,10 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
 
     if (!EVP_EncryptFinal_ex(&ctx->cipher, s, (int *)&i))
         goto err;
-    EVP_EncodeUpdate(&ctx->encode, out, &j, s, i);
+    EVP_EncodeUpdate(ctx->encode, out, &j, s, i);
     *outl = j;
     out += j;
-    EVP_EncodeFinal(&ctx->encode, out, &j);
+    EVP_EncodeFinal(ctx->encode, out, &j);
     *outl += j;
 
     if (!EVP_SignFinal(ctx->md, s, &i, priv))
@@ -178,6 +179,7 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
 
     ret = 1;
  err:
+    EVP_ENCODE_CTX_free(ctx->encode);
     EVP_MD_CTX_free(ctx->md);
     EVP_CIPHER_CTX_cleanup(&ctx->cipher);
     OPENSSL_free(s);