*** empty log message ***
authorTheodore Tso <tytso@mit.edu>
Wed, 30 Sep 1992 14:05:27 +0000 (14:05 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 30 Sep 1992 14:05:27 +0000 (14:05 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2450 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/md5/md5crypto.c [new file with mode: 0644]
src/lib/crypto/md5/md5glue.c [new file with mode: 0644]

diff --git a/src/lib/crypto/md5/md5crypto.c b/src/lib/crypto/md5/md5crypto.c
new file mode 100644 (file)
index 0000000..9dcb869
--- /dev/null
@@ -0,0 +1,64 @@
+#if !defined(lint) && !defined(SABER)
+static char rcsid_md5crypto_c[] = "$Id$";
+#endif
+
+#include <krb5/krb5.h>
+#include <krb5/ext-proto.h>
+#include <krb5/rsa-md5.h>
+
+#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 (file)
index 0000000..a545357
--- /dev/null
@@ -0,0 +1,38 @@
+#if !defined(lint) && !defined(SABER)
+static char rcsid_md5glue_c[] = "$Id$";
+#endif
+
+#include <krb5/krb5.h>
+#include <krb5/ext-proto.h>
+#include <krb5/rsa-md5.h>
+
+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 */
+};