+Fri Apr 12 21:27:35 1996 Richard Basch <basch@lehman.com>
+
+ * rsa-md5.h md5crypto.c md5glue.c md5.c t_cksum.c t_mddriver.c:
+ Renamed the global functions to be krb5_<name>
+
Thu Mar 28 09:50:58 1996 Richard Basch <basch@lehman.com>
* md5crypto.c: Added support for CKSUMTYPE_RSA_MD5_DES3
***********************************************************************
** Message-digest routines: **
** To form the message digest for a message M **
- ** (1) Initialize a context buffer mdContext using MD5Init **
- ** (2) Call MD5Update on mdContext and M **
- ** (3) Call MD5Final on mdContext **
+ ** (1) Initialize a context buffer mdContext using krb5_MD5Init **
+ ** (2) Call krb5_MD5Update on mdContext and M **
+ ** (3) Call krb5_MD5Final on mdContext **
** The message digest is now in mdContext->digest[0...15] **
***********************************************************************
*/
(a) += (b); \
}
-/* The routine MD5Init initializes the message-digest context
+/* The routine krb5_MD5Init initializes the message-digest context
mdContext. All fields are set to zero.
*/
void
-MD5Init (mdContext)
-MD5_CTX FAR *mdContext;
+krb5_MD5Init (mdContext)
+krb5_MD5_CTX FAR *mdContext;
{
mdContext->i[0] = mdContext->i[1] = (krb5_ui_4)0;
mdContext->buf[3] = UL(0x10325476);
}
-/* The routine MD5Update updates the message-digest context to
+/* The routine krb5_MD5Update updates the message-digest context to
account for the presence of each of the characters inBuf[0..inLen-1]
in the message whose digest is being computed.
*/
void
-MD5Update (mdContext, inBuf, inLen)
-MD5_CTX FAR *mdContext;
+krb5_MD5Update (mdContext, inBuf, inLen)
+krb5_MD5_CTX FAR *mdContext;
unsigned char FAR *inBuf;
unsigned int inLen;
{
}
}
-/* The routine MD5Final terminates the message-digest computation and
+/* The routine krb5_MD5Final terminates the message-digest computation and
ends with the desired message digest in mdContext->digest[0...15].
*/
void
-MD5Final (mdContext)
-MD5_CTX FAR *mdContext;
+krb5_MD5Final (mdContext)
+krb5_MD5_CTX FAR *mdContext;
{
krb5_ui_4 in[16];
int mdi;
/* pad out to 56 mod 64 */
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
- MD5Update (mdContext, PADDING, padLen);
+ krb5_MD5Update (mdContext, PADDING, padLen);
/* append length in bits and transform */
for (i = 0, ii = 0; i < 14; i++, ii += 4)
/* Windows needs to these prototypes for the assignment below */
krb5_error_code
-md5_crypto_sum_func PROTOTYPE((krb5_pointer in, size_t in_length,
+krb5_md5_crypto_sum_func PROTOTYPE((krb5_pointer in, size_t in_length,
krb5_pointer seed, size_t seed_length, krb5_checksum FAR *outcksum));
krb5_error_code
-md5_crypto_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in,
+krb5_md5_crypto_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in,
size_t in_length, krb5_pointer seed, size_t seed_length));
/*
*
* If MD5_K5BETA_COMPAT is defined, then compatability mode is enabled. That
* means that both checksum functions are compiled and available for use and
- * the additional interface md5_crypto_compat_ctl() is defined.
+ * the additional interface krb5_md5_crypto_compat_ctl() is defined.
*
* If MD5_K5BETA_COMPAT_DEF is defined and compatability mode is enabled, then
* the compatible behaviour becomes the default.
*/
static void
-md5_calculate_cksum(md5ctx, in, in_length, confound, confound_length)
- MD5_CTX *md5ctx;
+krb5_md5_calculate_cksum(md5ctx, in, in_length, confound, confound_length)
+ krb5_MD5_CTX *md5ctx;
krb5_pointer in;
size_t in_length;
krb5_pointer confound;
size_t confound_length;
{
- MD5Init(md5ctx);
+ krb5_MD5Init(md5ctx);
if (confound && confound_length)
- MD5Update(md5ctx, confound, confound_length);
- MD5Update(md5ctx, in, in_length);
- MD5Final(md5ctx);
+ krb5_MD5Update(md5ctx, confound, confound_length);
+ krb5_MD5Update(md5ctx, in, in_length);
+ krb5_MD5Final(md5ctx);
}
#ifdef MD5_K5BETA_COMPAT
krb5_error_code
-md5_crypto_compat_sum_func(in, in_length, seed, seed_length, outcksum)
+krb5_md5_crypto_compat_sum_func(in, in_length, seed, seed_length, outcksum)
krb5_pointer in;
size_t in_length;
krb5_pointer seed;
krb5_keyblock keyblock;
krb5_error_code retval;
- MD5_CTX working;
+ krb5_MD5_CTX working;
- MD5Init(&working);
- MD5Update(&working, input, in_length);
- MD5Final(&working);
+ krb5_MD5Init(&working);
+ krb5_MD5Update(&working, input, in_length);
+ krb5_MD5Final(&working);
outcksum->checksum_type = CKSUMTYPE_RSA_MD5_DES;
outcksum->length = RSA_MD5_DES_CKSUM_LENGTH;
#endif /* MD5_K5BETA_COMPAT */
krb5_error_code
-md5_crypto_sum_func(in, in_length, seed, seed_length, outcksum)
+krb5_md5_crypto_sum_func(in, in_length, seed, seed_length, outcksum)
krb5_pointer in;
size_t in_length;
krb5_pointer seed;
krb5_error_code retval;
size_t i;
- MD5_CTX working;
+ krb5_MD5_CTX working;
/* Generate the confounder in place */
if (retval = krb5_random_confounder(RSA_MD5_DES_CONFOUND_LENGTH,
return(retval);
/* Calculate the checksum */
- md5_calculate_cksum(&working,
+ krb5_md5_calculate_cksum(&working,
(krb5_pointer) outtmp,
(size_t) RSA_MD5_DES_CONFOUND_LENGTH,
in,
}
krb5_error_code
-md5_crypto_verify_func(cksum, in, in_length, seed, seed_length)
+krb5_md5_crypto_verify_func(cksum, in, in_length, seed, seed_length)
krb5_checksum FAR *cksum;
krb5_pointer in;
size_t in_length;
krb5_error_code retval;
size_t i;
- MD5_CTX working;
+ krb5_MD5_CTX working;
retval = 0;
if (cksum->checksum_type == CKSUMTYPE_RSA_MD5_DES) {
*/
/* Recalculate the checksum with no confounder */
- md5_calculate_cksum(&working,
+ krb5_md5_calculate_cksum(&working,
(krb5_pointer) NULL,
(size_t) 0,
in,
return(retval);
/* Now that we have the decrypted checksum, try to regenerate it */
- md5_calculate_cksum(&working,
+ krb5_md5_calculate_cksum(&working,
(krb5_pointer) outtmp,
(size_t) RSA_MD5_DES_CONFOUND_LENGTH,
in,
return(retval);
/* Now that we have the decrypted checksum, try to regenerate it */
- md5_calculate_cksum(&working,
+ krb5_md5_calculate_cksum(&working,
(krb5_pointer) outtmp,
(size_t) RSA_MD5_DES_CONFOUND_LENGTH,
in,
#if defined(MD5_K5BETA_COMPAT) && defined(MD5_K5BETA_COMPAT_DEF)
{
0,
- md5_crypto_compat_sum_func,
- md5_crypto_verify_func,
+ krb5_md5_crypto_compat_sum_func,
+ krb5_md5_crypto_verify_func,
RSA_MD5_DES_CKSUM_LENGTH,
1, /* is collision proof */
1, /* uses key */
#else /* MD5_K5BETA_COMPAT && MD5_K5BETA_COMPAT_DEF */
{
0,
- md5_crypto_sum_func,
- md5_crypto_verify_func,
+ krb5_md5_crypto_sum_func,
+ krb5_md5_crypto_verify_func,
RSA_MD5_DES_CKSUM_LENGTH+RSA_MD5_DES_CONFOUND_LENGTH,
1, /* is collision proof */
1, /* uses key */
* Turn on/off compatible checksum generation.
*/
void
-md5_crypto_compat_ctl(scompat)
+krb5_md5_crypto_compat_ctl(scompat)
krb5_boolean scompat;
{
if (scompat) {
- rsa_md5_des_cksumtable_entry.sum_func = md5_crypto_compat_sum_func;
+ rsa_md5_des_cksumtable_entry.sum_func = krb5_md5_crypto_compat_sum_func;
rsa_md5_des_cksumtable_entry.checksum_length =
RSA_MD5_DES_CKSUM_LENGTH;
}
else {
- rsa_md5_des_cksumtable_entry.sum_func = md5_crypto_sum_func;
+ rsa_md5_des_cksumtable_entry.sum_func = krb5_md5_crypto_sum_func;
rsa_md5_des_cksumtable_entry.checksum_length =
RSA_MD5_DES_CKSUM_LENGTH + RSA_MD5_DES_CONFOUND_LENGTH;
}
/* Windows needs to these prototypes for the assignment below */
krb5_error_code
-md5_sum_func PROTOTYPE((krb5_pointer in, size_t in_length,
+krb5_md5_sum_func PROTOTYPE((krb5_pointer in, size_t in_length,
krb5_pointer seed, size_t seed_length, krb5_checksum *outcksum));
krb5_error_code
-md5_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in,
+krb5_md5_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in,
size_t in_length, krb5_pointer seed, size_t seed_length));
krb5_error_code
-md5_sum_func(in, in_length, seed, seed_length, outcksum)
+krb5_md5_sum_func(in, in_length, seed, seed_length, outcksum)
krb5_pointer in;
size_t in_length;
krb5_pointer seed;
krb5_checksum FAR *outcksum;
{
krb5_octet *input = (krb5_octet *)in;
- MD5_CTX working;
+ krb5_MD5_CTX working;
- MD5Init(&working);
- MD5Update(&working, input, in_length);
- MD5Final(&working);
+ krb5_MD5Init(&working);
+ krb5_MD5Update(&working, input, in_length);
+ krb5_MD5Final(&working);
outcksum->checksum_type = CKSUMTYPE_RSA_MD5;
outcksum->length = RSA_MD5_CKSUM_LENGTH;
}
krb5_error_code
-md5_verify_func(cksum, in, in_length, seed, seed_length)
+krb5_md5_verify_func(cksum, in, in_length, seed, seed_length)
krb5_checksum FAR *cksum;
krb5_pointer in;
size_t in_length;
size_t seed_length;
{
krb5_octet *input = (krb5_octet *)in;
- MD5_CTX working;
+ krb5_MD5_CTX working;
krb5_error_code retval;
retval = 0;
if (cksum->checksum_type == CKSUMTYPE_RSA_MD5) {
if (cksum->length == RSA_MD5_CKSUM_LENGTH) {
- MD5Init(&working);
- MD5Update(&working, input, in_length);
- MD5Final(&working);
+ krb5_MD5Init(&working);
+ krb5_MD5Update(&working, input, in_length);
+ krb5_MD5Final(&working);
if (memcmp((char *) cksum->contents,
(char *) &working.digest[0],
krb5_checksum_entry rsa_md5_cksumtable_entry = {
0,
- md5_sum_func,
- md5_verify_func,
+ krb5_md5_sum_func,
+ krb5_md5_verify_func,
RSA_MD5_CKSUM_LENGTH,
1, /* is collision proof */
0, /* doesn't use key */
krb5_ui_4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
-} MD5_CTX;
+} krb5_MD5_CTX;
#if (defined(__STDC__) || defined(_WINDOWS)) && !defined(KRB5_NO_PROTOTYPES)
-extern void MD5Init(MD5_CTX FAR *);
-extern void MD5Update (MD5_CTX FAR *, unsigned char FAR *, unsigned int);
-extern void MD5Final (MD5_CTX FAR *);
+extern void krb5_MD5Init(krb5_MD5_CTX FAR *);
+extern void krb5_MD5Update(krb5_MD5_CTX FAR *,unsigned char FAR *,unsigned int);
+extern void krb5_MD5Final(krb5_MD5_CTX FAR *);
#else
-extern void MD5Init();
-extern void MD5Update ();
-extern void MD5Final ();
+extern void krb5_MD5Init();
+extern void krb5_MD5Update();
+extern void krb5_MD5Final();
#endif
#define RSA_MD5_CKSUM_LENGTH 16
#else /* MD4_K5BETA_COMPAT */
#undef K5BETA_COMPAT
#endif /* MD4_K5BETA_COMPAT */
-#define CKSUM_FUNCTION md4_crypto_sum_func
-#define COMPAT_FUNCTION md4_crypto_compat_sum_func
-#define VERIFY_FUNCTION md4_crypto_verify_func
+#define CKSUM_FUNCTION krb5_md4_crypto_sum_func
+#define COMPAT_FUNCTION krb5_md4_crypto_compat_sum_func
+#define VERIFY_FUNCTION krb5_md4_crypto_verify_func
#endif /* MD == 4 */
#if MD == 5
#else /* MD5_K5BETA_COMPAT */
#undef K5BETA_COMPAT
#endif /* MD5_K5BETA_COMPAT */
-#define CKSUM_FUNCTION md5_crypto_sum_func
-#define COMPAT_FUNCTION md5_crypto_compat_sum_func
-#define VERIFY_FUNCTION md5_crypto_verify_func
+#define CKSUM_FUNCTION krb5_md5_crypto_sum_func
+#define COMPAT_FUNCTION krb5_md5_crypto_compat_sum_func
+#define VERIFY_FUNCTION krb5_md5_crypto_verify_func
#endif /* MD == 5 */
static void
};
#if MD == 2
-#define MD_CTX MD2_CTX
-#define MDInit MD2Init
-#define MDUpdate MD2Update
-#define MDFinal MD2Final
+#define MD_CTX krb5_MD2_CTX
+#define MDInit krb5_MD2Init
+#define MDUpdate krb5_MD2Update
+#define MDFinal krb5_MD2Final
#endif
#if MD == 4
-#define MD_CTX MD4_CTX
-#define MDInit MD4Init
-#define MDUpdate MD4Update
-#define MDFinal MD4Final
+#define MD_CTX krb5_MD4_CTX
+#define MDInit krb5_MD4Init
+#define MDUpdate krb5_MD4Update
+#define MDFinal krb5_MD4Final
#define HAVE_TEST_SUITE
/* Test suite from RFC 1320 */
#endif
#if MD == 5
-#define MD_CTX MD5_CTX
-#define MDInit MD5Init
-#define MDUpdate MD5Update
-#define MDFinal MD5Final
+#define MD_CTX krb5_MD5_CTX
+#define MDInit krb5_MD5Init
+#define MDUpdate krb5_MD5Update
+#define MDFinal krb5_MD5Final
#define HAVE_TEST_SUITE
/* Test suite from RFC 1321 */