summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/p_seal.c
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:50 +0000
committermarkus <>2002-09-05 12:51:50 +0000
commit15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch)
treebf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/evp/p_seal.c
parent027351f729b9e837200dae6e1520cda6577ab930 (diff)
downloadopenbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/evp/p_seal.c')
-rw-r--r--src/lib/libcrypto/evp/p_seal.c52
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
67int EVP_SealInit(ctx,type,ek,ekl,iv,pubk,npubk) 69int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
68EVP_CIPHER_CTX *ctx; 70 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk)
69EVP_CIPHER *type;
70unsigned char **ek;
71int *ekl;
72unsigned char *iv;
73EVP_PKEY **pubk;
74int 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
108void EVP_SealFinal(ctx,out,outl) 109int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
109EVP_CIPHER_CTX *ctx;
110unsigned char *out;
111int *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 }