Commit dbad1690 authored by Ben Laurie's avatar Ben Laurie
Browse files

Really add the EVP and all of the DES changes.

parent 3ba5d1cf
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -12,6 +12,15 @@
         *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
         +) applies to 0.9.7 only

  +) Rationalise EVP so it can be extended: don't include a union of
     cipher/digest structures, add init/cleanup functions. This also reduces
     the number of header dependencies.
     [Ben Laurie]

  +) Make DES key schedule conform to the usual scheme, as well as correcting
     its structure.
     [Ben Laurie]

  +) Enhanced support for IA-64 Unix platforms (well, Linux and HP-UX).
     [Andy Polyakov]

+408 −666

File changed.

Preview size limit exceeded, changes collapsed.

+11 −12
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/rand.h>

#ifndef OPENSSL_NO_DES
# include <openssl/des.h>
#endif
#ifndef NO_MD5CRYPT_1
# include <openssl/evp.h>
# include <openssl/md5.h>
#endif


@@ -311,7 +311,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
	unsigned char buf[MD5_DIGEST_LENGTH];
	char *salt_out;
	int n, i;
	EVP_MD_CTX md;
	EVP_MD_CTX md,md2;
	size_t passwd_len, salt_len;

	passwd_len = strlen(passwd);
@@ -326,6 +326,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
	salt_len = strlen(salt_out);
	assert(salt_len <= 8);
	
	EVP_MD_CTX_init(&md);
	EVP_DigestInit(&md,EVP_md5());
	EVP_DigestUpdate(&md, passwd, passwd_len);
	EVP_DigestUpdate(&md, "$", 1);
@@ -333,15 +334,13 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
	EVP_DigestUpdate(&md, "$", 1);
	EVP_DigestUpdate(&md, salt_out, salt_len);
	
	 {
		EVP_MD_CTX md2;

	EVP_MD_CTX_init(&md2);
	EVP_DigestInit(&md2,EVP_md5());
	EVP_DigestUpdate(&md2, passwd, passwd_len);
	EVP_DigestUpdate(&md2, salt_out, salt_len);
	EVP_DigestUpdate(&md2, passwd, passwd_len);
	EVP_DigestFinal(&md2, buf, NULL);
	 }

	for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
		EVP_DigestUpdate(&md, buf, sizeof buf);
	EVP_DigestUpdate(&md, buf, i);
@@ -356,8 +355,6 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)

	for (i = 0; i < 1000; i++)
		{
		EVP_MD_CTX md2;

		EVP_DigestInit(&md2,EVP_md5());
		EVP_DigestUpdate(&md2, (i & 1) ? (unsigned char *) passwd : buf,
		                       (i & 1) ? passwd_len : sizeof buf);
@@ -369,6 +366,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
		                       (i & 1) ? sizeof buf : passwd_len);
		EVP_DigestFinal(&md2, buf, NULL);
		}
	EVP_MD_CTX_cleanup(&md2);
	
	 {
		/* transform buf into output string */
@@ -406,6 +404,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
		*output = 0;
		assert(strlen(out_buf) < sizeof(out_buf));
	 }
	EVP_MD_CTX_cleanup(&md);

	return out_buf;
	}
+9 −7
Original line number Diff line number Diff line
@@ -787,9 +787,9 @@ int MAIN(int argc, char **argv)
#endif

#ifndef OPENSSL_NO_DES
	des_set_key_unchecked(&key,sch);
	des_set_key_unchecked(&key2,sch2);
	des_set_key_unchecked(&key3,sch3);
	des_set_key_unchecked(&key,&sch);
	des_set_key_unchecked(&key2,&sch2);
	des_set_key_unchecked(&key3,&sch3);
#endif
#ifndef OPENSSL_NO_IDEA
	idea_set_encrypt_key(key16,&idea_ks);
@@ -990,6 +990,8 @@ int MAIN(int argc, char **argv)
	if (doit[D_HMAC])
		{
		HMAC_CTX hctx;

		HMAC_CTX_init(&hctx);
		HMAC_Init(&hctx,(unsigned char *)"This is a key...",
			16,EVP_md5());

@@ -1008,7 +1010,7 @@ int MAIN(int argc, char **argv)
				count,names[D_HMAC],d);
			results[D_HMAC][j]=((double)count)/d*lengths[j];
			}
		HMAC_cleanup(&hctx);
		HMAC_CTX_cleanup(&hctx);
		}
#endif
#ifndef OPENSSL_NO_SHA
@@ -1068,7 +1070,7 @@ int MAIN(int argc, char **argv)
			print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
			Time_F(START,usertime);
			for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
				des_ncbc_encrypt(buf,buf,lengths[j],sch,
				des_ncbc_encrypt(buf,buf,lengths[j],&sch,
						 &iv,DES_ENCRYPT);
			d=Time_F(STOP,usertime);
			BIO_printf(bio_err,"%ld %s's in %.2fs\n",
@@ -1085,7 +1087,7 @@ int MAIN(int argc, char **argv)
			Time_F(START,usertime);
			for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
				des_ede3_cbc_encrypt(buf,buf,lengths[j],
						     sch,sch2,sch3,
						     &sch,&sch2,&sch3,
						     &iv,DES_ENCRYPT);
			d=Time_F(STOP,usertime);
			BIO_printf(bio_err,"%ld %s's in %.2fs\n",
+5 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@
#include "apps.h"
#include <openssl/evp.h>
#include <openssl/crypto.h>
#include <openssl/md2.h>
#include <openssl/rc4.h>
#include <openssl/des.h>
#include <openssl/idea.h>
#include <openssl/blowfish.h>

#undef PROG
#define PROG	version_main
Loading