projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
It was pointed out to me that if the requested size is 0, we shouldn't
[openssl.git]
/
crypto
/
evp
/
evp_enc.c
diff --git
a/crypto/evp/evp_enc.c
b/crypto/evp/evp_enc.c
index be0758a87965feeb7b0c0494c3002213cd5571e9..cecb09cbe775e6cc10a68a3396787532b906a119 100644
(file)
--- a/
crypto/evp/evp_enc.c
+++ b/
crypto/evp/evp_enc.c
@@
-148,7
+148,19
@@
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
#endif
ctx->cipher=cipher;
#endif
ctx->cipher=cipher;
- ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
+ if (ctx->cipher->ctx_size)
+ {
+ ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
+ if (!ctx->cipher_data)
+ {
+ EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+ }
+ else
+ {
+ ctx->cipher_data = NULL;
+ }
ctx->key_len = cipher->key_len;
ctx->flags = 0;
if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
ctx->key_len = cipher->key_len;
ctx->flags = 0;
if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
@@
-187,7
+199,8
@@
skip_to_init:
case EVP_CIPH_CBC_MODE:
case EVP_CIPH_CBC_MODE:
- OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv);
+ OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <=
+ (int)sizeof(ctx->iv));
if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
break;
if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
break;
@@
-274,7
+287,7
@@
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
}
i=ctx->buf_len;
bl=ctx->cipher->block_size;
}
i=ctx->buf_len;
bl=ctx->cipher->block_size;
- OPENSSL_assert(bl <=
sizeof ctx->buf
);
+ OPENSSL_assert(bl <=
(int)sizeof(ctx->buf)
);
if (i != 0)
{
if (i+inl < bl)
if (i != 0)
{
if (i+inl < bl)
@@
-320,7
+333,8
@@
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
- int i,n,b,bl,ret;
+ int n,ret;
+ unsigned int i, b, bl;
b=ctx->cipher->block_size;
OPENSSL_assert(b <= sizeof ctx->buf);
b=ctx->cipher->block_size;
OPENSSL_assert(b <= sizeof ctx->buf);
@@
-356,7
+370,8
@@
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
const unsigned char *in, int inl)
{
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
const unsigned char *in, int inl)
{
- int b, fix_len;
+ int fix_len;
+ unsigned int b;
if (inl == 0)
{
if (inl == 0)
{
@@
-409,8
+424,8
@@
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
- int i,
b
;
-
int n
;
+ int i,
n
;
+
unsigned int b
;
*outl=0;
b=ctx->cipher->block_size;
*outl=0;
b=ctx->cipher->block_size;
@@
-433,7
+448,7
@@
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
}
OPENSSL_assert(b <= sizeof ctx->final);
n=ctx->final[b-1];
}
OPENSSL_assert(b <= sizeof ctx->final);
n=ctx->final[b-1];
- if (n > b)
+ if (n >
(int)
b)
{
EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
return(0);
{
EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
return(0);