projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Final cleanup after move to leaner EVP_PKEY methods
[openssl.git]
/
crypto
/
evp
/
e_des3.c
diff --git
a/crypto/evp/e_des3.c
b/crypto/evp/e_des3.c
index a8429136588a577f9112c74458dfe25a24bab424..8f9eab427e756b2c9e504d8bd3aa0f4185b82389 100644
(file)
--- a/
crypto/evp/e_des3.c
+++ b/
crypto/evp/e_des3.c
@@
-1,7
+1,7
@@
/*
/*
- * Copyright 1995-201
6
The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-201
9
The OpenSSL Project Authors. All Rights Reserved.
*
*
- * Licensed under the
OpenSSL license
(the "License"). You may not use
+ * Licensed under the
Apache License 2.0
(the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
@@
-12,13
+12,14
@@
#ifndef OPENSSL_NO_DES
# include <openssl/evp.h>
# include <openssl/objects.h>
#ifndef OPENSSL_NO_DES
# include <openssl/evp.h>
# include <openssl/objects.h>
-# include "
internal/evp_int
.h"
+# include "
crypto/evp
.h"
# include <openssl/des.h>
# include <openssl/rand.h>
# include <openssl/des.h>
# include <openssl/rand.h>
+# include "evp_local.h"
typedef struct {
union {
typedef struct {
union {
-
double align
;
+
OSSL_UNION_ALIGN
;
DES_key_schedule ks[3];
} ks;
union {
DES_key_schedule ks[3];
} ks;
union {
@@
-279,15
+280,17
@@
static int des3_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
{
DES_cblock *deskey = ptr;
{
DES_cblock *deskey = ptr;
+ int kl;
switch (type) {
case EVP_CTRL_RAND_KEY:
switch (type) {
case EVP_CTRL_RAND_KEY:
- if (RAND_bytes(ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0)
+ kl = EVP_CIPHER_CTX_key_length(ctx);
+ if (kl < 0 || RAND_priv_bytes(ptr, kl) <= 0)
return 0;
DES_set_odd_parity(deskey);
return 0;
DES_set_odd_parity(deskey);
- if (
EVP_CIPHER_CTX_key_length(ctx)
>= 16)
+ if (
kl
>= 16)
DES_set_odd_parity(deskey + 1);
DES_set_odd_parity(deskey + 1);
- if (
EVP_CIPHER_CTX_key_length(ctx)
>= 24)
+ if (
kl
>= 24)
DES_set_odd_parity(deskey + 2);
return 1;
DES_set_odd_parity(deskey + 2);
return 1;
@@
-392,6
+395,12
@@
static int des_ede3_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
*/
if (inl >= EVP_MAXCHUNK || inl % 8)
return -1;
*/
if (inl >= EVP_MAXCHUNK || inl % 8)
return -1;
+
+ if (is_partially_overlapping(out, in, inl)) {
+ EVPerr(EVP_F_DES_EDE3_WRAP_CIPHER, EVP_R_PARTIALLY_OVERLAPPING);
+ return 0;
+ }
+
if (EVP_CIPHER_CTX_encrypting(ctx))
return des_ede3_wrap(ctx, out, in, inl);
else
if (EVP_CIPHER_CTX_encrypting(ctx))
return des_ede3_wrap(ctx, out, in, inl);
else