From b32b9b5ff08d5ed2059b0551adaaeaef4ac71379 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 30 Sep 1992 14:05:27 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2450 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/md5/md5crypto.c | 64 ++++++++++++++++++++++++++++++++++ src/lib/crypto/md5/md5glue.c | 38 ++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/lib/crypto/md5/md5crypto.c create mode 100644 src/lib/crypto/md5/md5glue.c diff --git a/src/lib/crypto/md5/md5crypto.c b/src/lib/crypto/md5/md5crypto.c new file mode 100644 index 000000000..9dcb8694e --- /dev/null +++ b/src/lib/crypto/md5/md5crypto.c @@ -0,0 +1,64 @@ +#if !defined(lint) && !defined(SABER) +static char rcsid_md5crypto_c[] = "$Id$"; +#endif + +#include +#include +#include + +#include "../des/des_int.h" /* we cheat a bit and call it directly... */ + +static krb5_error_code +md5_crypto_sum_func(in, in_length, seed, seed_length, outcksum) +krb5_pointer in; +size_t in_length; +krb5_pointer seed; +size_t seed_length; +krb5_checksum *outcksum; +{ + krb5_octet outtmp[RSA_MD5_DES_CKSUM_LENGTH]; + krb5_octet *input = (krb5_octet *)in; + krb5_encrypt_block eblock; + krb5_keyblock keyblock; + krb5_error_code retval; + + MD5_CTX working; + + MD5Init(&working); + MD5Update(&working, input, in_length); + MD5Final(&working); + + outcksum->checksum_type = CKSUMTYPE_RSA_MD5_DES; + outcksum->length = RSA_MD5_DES_CKSUM_LENGTH; + + memcpy((char *)outtmp, (char *)&working.digest[0], 16); + + memset((char *)&working, 0, sizeof(working)); + + keyblock.length = seed_length; + keyblock.contents = (krb5_octet *)seed; + keyblock.keytype = KEYTYPE_DES; + + if (retval = mit_des_process_key(&eblock, &keyblock)) + return retval; + /* now encrypt it */ + retval = mit_des_cbc_encrypt(&outtmp[0], + outcksum->contents, + RSA_MD5_DES_CKSUM_LENGTH, + (struct mit_des_ks_struct *)eblock.priv, + keyblock.contents, + MIT_DES_ENCRYPT); + if (retval) { + (void) mit_des_finish_key(&eblock); + return retval; + } + return mit_des_finish_key(&eblock); +} + + +krb5_checksum_entry rsa_md5_des_cksumtable_entry = { + md5_crypto_sum_func, + RSA_MD5_DES_CKSUM_LENGTH, + 1, /* is collision proof */ + 1, /* uses key */ +}; diff --git a/src/lib/crypto/md5/md5glue.c b/src/lib/crypto/md5/md5glue.c new file mode 100644 index 000000000..a5453570a --- /dev/null +++ b/src/lib/crypto/md5/md5glue.c @@ -0,0 +1,38 @@ +#if !defined(lint) && !defined(SABER) +static char rcsid_md5glue_c[] = "$Id$"; +#endif + +#include +#include +#include + +static krb5_error_code +md5_sum_func(in, in_length, seed, seed_length, outcksum) +krb5_pointer in; +size_t in_length; +krb5_pointer seed; +size_t seed_length; +krb5_checksum *outcksum; +{ + krb5_octet *input = (krb5_octet *)in; + MD5_CTX working; + + MD5Init(&working); + MD5Update(&working, input, in_length); + MD5Final(&working); + + outcksum->checksum_type = CKSUMTYPE_RSA_MD5; + outcksum->length = RSA_MD5_CKSUM_LENGTH; + + memcpy((char *)outcksum->contents, (char *)&working.digest[0], 16); + + memset((char *)&working, 0, sizeof(working)); + return 0; +} + +krb5_checksum_entry rsa_md5_cksumtable_entry = { + md5_sum_func, + RSA_MD5_CKSUM_LENGTH, + 1, /* is collision proof */ + 0, /* doesn't use key */ +}; -- 2.26.2