diff options
Diffstat (limited to 'src/lib/libcrypto/evp/p_seal.c')
-rw-r--r-- | src/lib/libcrypto/evp/p_seal.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c index 09a408de35..37e547fe72 100644 --- a/src/lib/libcrypto/evp/p_seal.c +++ b/src/lib/libcrypto/evp/p_seal.c | |||
@@ -58,35 +58,36 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "rand.h" | 61 | #include <openssl/rand.h> |
62 | #include "rsa.h" | 62 | #ifndef OPENSSL_NO_RSA |
63 | #include "evp.h" | 63 | #include <openssl/rsa.h> |
64 | #include "objects.h" | 64 | #endif |
65 | #include "x509.h" | 65 | #include <openssl/evp.h> |
66 | #include <openssl/objects.h> | ||
67 | #include <openssl/x509.h> | ||
66 | 68 | ||
67 | int EVP_SealInit(ctx,type,ek,ekl,iv,pubk,npubk) | 69 | int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, |
68 | EVP_CIPHER_CTX *ctx; | 70 | int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) |
69 | EVP_CIPHER *type; | ||
70 | unsigned char **ek; | ||
71 | int *ekl; | ||
72 | unsigned char *iv; | ||
73 | EVP_PKEY **pubk; | ||
74 | int npubk; | ||
75 | { | 71 | { |
76 | unsigned char key[EVP_MAX_KEY_LENGTH]; | 72 | unsigned char key[EVP_MAX_KEY_LENGTH]; |
77 | int i; | 73 | int i; |
78 | 74 | ||
79 | if (npubk <= 0) return(0); | 75 | if(type) { |
80 | RAND_bytes(key,EVP_MAX_KEY_LENGTH); | 76 | EVP_CIPHER_CTX_init(ctx); |
81 | if (type->iv_len > 0) | 77 | if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0; |
82 | RAND_bytes(iv,type->iv_len); | 78 | } |
79 | if ((npubk <= 0) || !pubk) | ||
80 | return 1; | ||
81 | if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) | ||
82 | return 0; | ||
83 | if (EVP_CIPHER_CTX_iv_length(ctx)) | ||
84 | RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx)); | ||
83 | 85 | ||
84 | EVP_CIPHER_CTX_init(ctx); | 86 | if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0; |
85 | EVP_EncryptInit(ctx,type,key,iv); | ||
86 | 87 | ||
87 | for (i=0; i<npubk; i++) | 88 | for (i=0; i<npubk; i++) |
88 | { | 89 | { |
89 | ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_key_length(type), | 90 | ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_CTX_key_length(ctx), |
90 | pubk[i]); | 91 | pubk[i]); |
91 | if (ekl[i] <= 0) return(-1); | 92 | if (ekl[i] <= 0) return(-1); |
92 | } | 93 | } |
@@ -105,11 +106,10 @@ int inl; | |||
105 | } | 106 | } |
106 | */ | 107 | */ |
107 | 108 | ||
108 | void EVP_SealFinal(ctx,out,outl) | 109 | int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
109 | EVP_CIPHER_CTX *ctx; | ||
110 | unsigned char *out; | ||
111 | int *outl; | ||
112 | { | 110 | { |
113 | EVP_EncryptFinal(ctx,out,outl); | 111 | int i; |
114 | EVP_EncryptInit(ctx,NULL,NULL,NULL); | 112 | i = EVP_EncryptFinal_ex(ctx,out,outl); |
113 | EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL); | ||
114 | return i; | ||
115 | } | 115 | } |