summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/p_seal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/p_seal.c')
-rw-r--r--src/lib/libcrypto/evp/p_seal.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c
index 2fd1d7e0c2..5570ca3745 100644
--- a/src/lib/libcrypto/evp/p_seal.c
+++ b/src/lib/libcrypto/evp/p_seal.c
@@ -59,14 +59,14 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#ifndef NO_RSA 62#ifndef OPENSSL_NO_RSA
63#include <openssl/rsa.h> 63#include <openssl/rsa.h>
64#endif 64#endif
65#include <openssl/evp.h> 65#include <openssl/evp.h>
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68 68
69int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, 69int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
70 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) 70 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk)
71 { 71 {
72 unsigned char key[EVP_MAX_KEY_LENGTH]; 72 unsigned char key[EVP_MAX_KEY_LENGTH];
@@ -74,15 +74,16 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
74 74
75 if(type) { 75 if(type) {
76 EVP_CIPHER_CTX_init(ctx); 76 EVP_CIPHER_CTX_init(ctx);
77 if(!EVP_EncryptInit(ctx,type,NULL,NULL)) return 0; 77 if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0;
78 } 78 }
79 if (npubk <= 0) return(0); 79 if ((npubk <= 0) || !pubk)
80 return 1;
80 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) 81 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0)
81 return(0); 82 return 0;
82 if (EVP_CIPHER_CTX_iv_length(ctx)) 83 if (EVP_CIPHER_CTX_iv_length(ctx))
83 RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx)); 84 RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx));
84 85
85 if(!EVP_EncryptInit(ctx,NULL,key,iv)) return 0; 86 if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0;
86 87
87 for (i=0; i<npubk; i++) 88 for (i=0; i<npubk; i++)
88 { 89 {
@@ -107,6 +108,6 @@ int inl;
107 108
108void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) 109void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
109 { 110 {
110 EVP_EncryptFinal(ctx,out,outl); 111 EVP_EncryptFinal_ex(ctx,out,outl);
111 EVP_EncryptInit(ctx,NULL,NULL,NULL); 112 EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL);
112 } 113 }