Skip to content

Commit

Permalink
Deprecate the low level DES functions.
Browse files Browse the repository at this point in the history
Use of the low level DES functions has been informally discouraged for a
long time. We now formally deprecate them.

Applications should instead use the EVP APIs, e.g. EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_EncryptFinal_ex, and the equivalently named decrypt
functions.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #10858)
  • Loading branch information
paulidale committed Jan 24, 2020
1 parent f6edde4 commit c6fec81
Show file tree
Hide file tree
Showing 43 changed files with 393 additions and 148 deletions.
15 changes: 9 additions & 6 deletions apps/passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* https://www.openssl.org/source/license.html
*/

/* We need to use some deprecated APIs */
#define OPENSSL_SUPPRESS_DEPRECATED

#include <string.h>

#include "apps.h"
Expand All @@ -16,7 +19,7 @@
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
# include <openssl/des.h>
#endif
#include <openssl/md5.h>
Expand Down Expand Up @@ -82,7 +85,7 @@ const OPTIONS passwd_options[] = {
{"apr1", OPT_APR1, '-', "MD5-based password algorithm, Apache variant"},
{"1", OPT_1, '-', "MD5-based password algorithm"},
{"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
{"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
#endif

Expand Down Expand Up @@ -168,7 +171,7 @@ int passwd_main(int argc, char **argv)
mode = passwd_aixmd5;
break;
case OPT_CRYPT:
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (mode != passwd_unset)
goto opthelp;
mode = passwd_crypt;
Expand Down Expand Up @@ -205,7 +208,7 @@ int passwd_main(int argc, char **argv)
mode = passwd_crypt;
}

#ifdef OPENSSL_NO_DES
#if defined(OPENSSL_NO_DES) || defined(OPENSSL_NO_DEPRECATED_3_0)
if (mode == passwd_crypt)
goto opthelp;
#endif
Expand Down Expand Up @@ -798,7 +801,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
size_t saltlen = 0;
size_t i;

#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (mode == passwd_crypt)
saltlen = 2;
#endif /* !OPENSSL_NO_DES */
Expand Down Expand Up @@ -841,7 +844,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
assert(strlen(passwd) <= pw_maxlen);

/* now compute password hash */
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (mode == passwd_crypt)
hash = DES_crypt(passwd, *salt_p);
#endif
Expand Down
14 changes: 7 additions & 7 deletions apps/speed.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static const OPT_PAIR doit_choices[] = {
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
{"rc4", D_RC4},
#endif
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
{"des-cbc", D_CBC_DES},
{"des-ede3", D_EDE3_DES},
#endif
Expand Down Expand Up @@ -729,7 +729,7 @@ static int RC4_loop(void *args)
}
#endif

#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
static unsigned char DES_iv[8];
static DES_key_schedule sch[3];
static int DES_ncbc_encrypt_loop(void *args)
Expand Down Expand Up @@ -1722,7 +1722,7 @@ int speed_main(int argc, char **argv)
doit[i] = 1;
continue;
}
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (strcmp(algo, "des") == 0) {
doit[D_CBC_DES] = doit[D_EDE3_DES] = 1;
continue;
Expand Down Expand Up @@ -1945,7 +1945,7 @@ int speed_main(int argc, char **argv)
loopargs[i].dsa_key[2] = get_dsa(2048);
}
#endif
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (doit[D_CBC_DES] || doit[D_EDE3_DES]) {
static DES_cblock keys[] = {
{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 }, /* keys[0] */
Expand Down Expand Up @@ -2001,7 +2001,7 @@ int speed_main(int argc, char **argv)
CAST_set_key(&cast_ks, 16, key16);
#endif
#ifndef SIGALRM
# ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
BIO_printf(bio_err, "First we calculate the approximate speed ...\n");
count = 10;
do {
Expand Down Expand Up @@ -2397,7 +2397,7 @@ int speed_main(int argc, char **argv)
}
}
#endif
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
if (doit[D_CBC_DES]) {
for (testnum = 0; testnum < size_num; testnum++) {
print_message(names[D_CBC_DES], c[D_CBC_DES][testnum],
Expand Down Expand Up @@ -3501,7 +3501,7 @@ int speed_main(int argc, char **argv)
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
printf("%s ", RC4_options());
#endif
#ifndef OPENSSL_NO_DES
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
printf("%s ", DES_options());
#endif
#ifndef OPENSSL_NO_DEPRECATED_3_0
Expand Down
6 changes: 0 additions & 6 deletions apps/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#include <openssl/evp.h>
#include <openssl/crypto.h>
#include <openssl/bn.h>
#ifndef OPENSSL_NO_DES
# include <openssl/des.h>
#endif

typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
Expand Down Expand Up @@ -117,9 +114,6 @@ int version_main(int argc, char **argv)
if (options) {
printf("options: ");
printf(" %s", BN_options());
#ifndef OPENSSL_NO_DES
printf(" %s", DES_options());
#endif
printf("\n");
}
if (cflags)
Expand Down
7 changes: 7 additions & 0 deletions crypto/des/build.info
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ SOURCE[../../providers/libfips.a]=$COMMON
DEFINE[../../libcrypto]=$DESDEF
DEFINE[../../providers/libfips.a]=$DESDEF

IF[{- $disabled{"deprecated"}
&& !$disabled{"mdc2"}
&& (defined $config{"api"} && $config{"api"} >= 30000) -}]
SOURCE[../../providers/liblegacy.a]=set_key.c $DESASM
DEFINE[../../providers/liblegacy.a]=$DESDEF
ENDIF

GENERATE[des_enc-sparc.S]=asm/des_enc.m4
GENERATE[dest4-sparcv9.S]=asm/dest4-sparcv9.pl
INCLUDE[dest4-sparcv9.o]=..
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/cbc_cksm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/cbc_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#define CBC_ENC_C__DONT_UPDATE_IV

#include "ncbc_enc.c" /* des_cbc_encrypt */
6 changes: 6 additions & 0 deletions crypto/des/cfb64ede.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/cfb64enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/cfb_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "e_os.h"
#include "des_local.h"
#include <assert.h>
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/des_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include <openssl/crypto.h>
#include "des_local.h"
#include "spr.h"
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/ecb3_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/ecb_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"
#include <openssl/opensslv.h>
#include <openssl/bio.h>
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/fcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

/* NOCW */
#include <stdio.h>
#ifdef _OSD_POSIX
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/fcrypt_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include <stdio.h>

#define DES_FCRYPT
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/ofb64ede.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/ofb64enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/ofb_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/pcbc_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
Expand Down
7 changes: 7 additions & 0 deletions crypto/des/qud_cksm.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
* only based on the code in this paper and is almost definitely not the same
* as the MIT implementation.
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include "des_local.h"

#define Q_B0(a) (((DES_LONG)(a)))
Expand Down
6 changes: 6 additions & 0 deletions crypto/des/rand_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include <openssl/des.h>
#include <openssl/rand.h>

Expand Down
7 changes: 7 additions & 0 deletions crypto/des/set_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
* 1.1 added norm_expand_bits
* 1.0 First working version
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include <openssl/crypto.h>
#include "des_local.h"

Expand Down
6 changes: 6 additions & 0 deletions crypto/des/str2key.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* https://www.openssl.org/source/license.html
*/

/*
* DES low level APIs are deprecated for public use, but still ok for internal
* use.
*/
#include "internal/deprecated.h"

#include <openssl/crypto.h>
#include "des_local.h"

Expand Down

0 comments on commit c6fec81

Please sign in to comment.