#include <krb5/ext-proto.h>
#include <krb5/krb5_err.h>
-#include <krb5/des.h>
-
-extern void des_cbc_cksum();
-extern int des_key_sched();
+#include "des_int.h"
/*
produces cbc cheksum of sequence "in" of the length "in_length"
OLDDECLARG(size_t, key_size)
OLDDECLARG(krb5_checksum *, cksum)
{
- struct des_ks_struct *schedule; /* pointer to key schedules */
+ struct mit_des_ks_struct *schedule; /* pointer to key schedules */
krb5_octet *contents;
- if (key_size != sizeof(des_cblock))
+ if (key_size != sizeof(mit_des_cblock))
return KRB5_BAD_KEYSIZE;
- if (!(schedule = (struct des_ks_struct *) malloc(sizeof(des_key_schedule))))
+ if (!(schedule = (struct mit_des_ks_struct *) malloc(sizeof(mit_des_key_schedule))))
return ENOMEM;
-#define cleanup() { bzero((char *)schedule, sizeof(des_key_schedule));\
+#define cleanup() { bzero((char *)schedule, sizeof(mit_des_key_schedule));\
free( (char *) schedule); }
- switch (des_key_sched ((krb5_octet *)key, schedule)) {
+ switch (mit_des_key_sched ((krb5_octet *)key, schedule)) {
case -1:
cleanup();
return KRB5DES_BAD_KEYPAR; /* XXX error code-bad key parity */
;
}
- if (!(contents = (krb5_octet *) malloc(sizeof(des_cblock)))) {
+ if (!(contents = (krb5_octet *) malloc(sizeof(mit_des_cblock)))) {
cleanup();
return ENOMEM;
}
- des_cbc_cksum((krb5_octet *)in, contents, in_length,
+ mit_des_cbc_cksum((krb5_octet *)in, contents, in_length,
schedule, (krb5_octet *)key);
cksum->checksum_type = CKSUMTYPE_DESCBC;
- cksum->length = sizeof(des_cblock);
+ cksum->length = sizeof(mit_des_cblock);
cksum->contents = contents;
cleanup();
#include <strings.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
-#include "des_internal.h"
+#include "des_int.h"
-extern int des_debug;
-extern int des_debug_print();
-extern int des_ecb_encrypt();
+extern int mit_des_debug;
/*
* This routine performs DES cipher-block-chaining checksum operation,
*/
void
-des_cbc_cksum(in,out,length,key,iv)
+mit_des_cbc_cksum(in,out,length,key,iv)
krb5_octet *in; /* >= length bytes of inputtext */
krb5_octet *out; /* >= length bytes of outputtext */
register long length; /* in bytes */
- des_key_schedule key; /* precomputed key schedule */
+ mit_des_key_schedule key; /* precomputed key schedule */
krb5_octet *iv; /* 8 bytes of ivec */
{
register unsigned long *input = (unsigned long *) in;
*(t_in_p+j)= 0;
#ifdef DEBUG
- if (des_debug)
- des_debug_print("clear",length,t_input[0],t_input[1]);
+ if (mit_des_debug)
+ mit_des_debug_print("clear",length,t_input[0],t_input[1]);
#endif
/* do the xor for cbc into the temp */
t_input[0] ^= t_output[0] ;
t_input[1] ^= t_output[1] ;
/* encrypt */
- (void) des_ecb_encrypt(t_input,t_output,key,1);
+ (void) mit_des_ecb_encrypt(t_input,t_output,key,1);
#ifdef DEBUG
- if (des_debug) {
- des_debug_print("xor'ed",i,t_input[0],t_input[1]);
- des_debug_print("cipher",i,t_output[0],t_output[1]);
+ if (mit_des_debug) {
+ mit_des_debug_print("xor'ed",i,t_input[0],t_input[1]);
+ mit_des_debug_print("cipher",i,t_output[0],t_output[1]);
}
#else
#ifdef lint
#include <krb5/copyright.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
+#include <krb5/mit-des.h>
extern krb5_error_code mit_des_encrypt_func PROTOTYPE((const krb5_pointer,
krb5_pointer,
mit_des_init_random_key,
mit_des_finish_random_key,
mit_des_random_key,
- sizeof(des_cblock),
+ sizeof(mit_des_cblock),
0,
- sizeof(des_cblock),
+ sizeof(mit_des_cblock),
ETYPE_DES_CBC_CRC,
KEYTYPE_DES
};
krb5_checksum * ));
-krb5_checksum_entry des_cbc_cksumtable_entry = {
+krb5_checksum_entry mit_des_cbc_cksumtable_entry = {
mit_des_cbc_checksum,
- sizeof(des_cblock)
+ sizeof(mit_des_cblock)
};
#include <stdio.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
-#include "des_internal.h"
+#include "des_int.h"
#include "s_table.h"
#include "p_table.h"
#ifdef DEBUG
-#define DBG_PRINT(s) if (des_debug & 2) \
- des_debug_print(s,i,L1&0xffff,(L1>>16)&0xffff, \
+#define DBG_PRINT(s) if (mit_des_debug & 2) \
+ mit_des_debug_print(s,i,L1&0xffff,(L1>>16)&0xffff, \
R1&0xffff,(R1>>16)&0xffff)
#else
#define DBG_PRINT(s)
#endif
-extern int des_debug;
-extern des_cblock_print_file ();
-extern des_debug_print ();
+extern int mit_des_debug;
int
-des_ecb_encrypt(clear, cipher, schedule, encrypt)
+mit_des_ecb_encrypt(clear, cipher, schedule, encrypt)
unsigned long *clear;
unsigned long *cipher;
int encrypt; /* 0 ==> decrypt, else encrypt */
- register des_key_schedule schedule; /* r11 */
+ register mit_des_key_schedule schedule; /* r11 */
{
/* better pass 8 bytes, length not checked here */
}
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
printf("All values printed from low byte (bit 0)");
printf(" --> high byte (bit 63)\n");
i = 0;
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
printf("iter = %2d before IP\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
DBG_PRINT("before IP");
for (i = 0; i <= (AUTH_DES_ITER-1); i++) {
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
printf("iter = %2d start loop\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
DBG_PRINT("start loop");
}
R1 = R2;
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("after e");
printf("iter = %2d after e\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
/* dont have to reset input to L1, R1 */
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("after xor");
printf("iter = %2d after xor\n\t\tL1 R1 =",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
#endif
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("after s");
printf("iter = %2d after s\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
R1 = R2;
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("after p");
printf("iter = %2d after p\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
R1 = R2;
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("before FP");
printf("iter = %2d before FP\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
}
#ifdef DEBUG
- if (des_debug & 2) {
+ if (mit_des_debug & 2) {
L1 = L2;
R1 = R2;
dbg_tmp[0] = L1;
dbg_tmp[1] = R1;
DBG_PRINT("done");
printf("iter = %2d done\n\t\tL1 R1 = ",i);
- des_cblock_print_file (dbg_tmp, stdout);
+ mit_des_cblock_print_file (dbg_tmp, stdout);
}
#endif
#include <krb5/config.h>
#include <krb5/osconf.h>
+#include <krb5/mit-des.h>
/*
* number of iterations of the inner
/* cbc_cksum.c */
-krb5_error_code mit_des_cbc_checksum
+extern krb5_error_code mit_des_cbc_checksum
PROTOTYPE((krb5_pointer, size_t,krb5_pointer,size_t, krb5_checksum * ));
/* cksum.c */
-void mit_des_cbc_cksum
+extern void mit_des_cbc_cksum
PROTOTYPE((krb5_octet *, krb5_octet *, long , mit_des_key_schedule ,
krb5_octet *));
/* des.c */
-int des_ecb_encrypt
- PROTOTYPE((unsigned long *, unsigned long *, des_key_schedule , int ));
+extern int mit_des_ecb_encrypt
+ PROTOTYPE((unsigned long *, unsigned long *, mit_des_key_schedule , int ));
/* enc_dec.c */
-krb5_error_code mit_des_encrypt_func
+extern krb5_error_code mit_des_encrypt_func
PROTOTYPE(( krb5_pointer, krb5_pointer, size_t, krb5_encrypt_block *,
krb5_pointer ));
-krb5_error_code mit_des_decrypt_func
+extern krb5_error_code mit_des_decrypt_func
PROTOTYPE(( krb5_pointer, krb5_pointer, size_t, krb5_encrypt_block *,
krb5_pointer ));
-krb5_error_code mit_des_cbc_encrypt
+extern krb5_error_code mit_des_cbc_encrypt
PROTOTYPE((krb5_octet *, krb5_octet *, long, mit_des_key_schedule,
krb5_octet *, int));
/* fin_rndkey.c */
-krb5_error_code mit_des_finish_random_key
+extern krb5_error_code mit_des_finish_random_key
PROTOTYPE(( krb5_pointer *));
/* finish_key.c */
-krb5_error_code mit_des_finish_key
+extern krb5_error_code mit_des_finish_key
PROTOTYPE(( krb5_encrypt_block *));
/* init_rkey.c */
-krb5_error_code mit_des_init_random_key
+extern krb5_error_code mit_des_init_random_key
PROTOTYPE(( krb5_keyblock *, krb5_pointer *));
/* key_parity.c */
-void mit_des_fixup_key_parity PROTOTYPE((mit_des_cblock ));
-int mit_des_check_key_parity PROTOTYPE((mit_des_cblock ));
+extern void mit_des_fixup_key_parity PROTOTYPE((mit_des_cblock ));
+extern int mit_des_check_key_parity PROTOTYPE((mit_des_cblock ));
/* key_sched.c */
-int mit_des_key_sched PROTOTYPE((mit_des_cblock , mit_des_key_schedule ));
+extern int mit_des_key_sched
+ PROTOTYPE((mit_des_cblock , mit_des_key_schedule ));
/* new_rnd_key.c */
-int mit_des_new_random_key PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *));
-void mit_des_init_random_number_generator
- PROTOTYPE((mit_des_cblock, mit_des_random_key_seed));
-void mit_des_set_random_generator_seed
+extern int mit_des_new_random_key
PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *));
-void mit_des_set_sequence_number
+extern void mit_des_init_random_number_generator
+ PROTOTYPE((mit_des_cblock, mit_des_random_key_seed *));
+extern void mit_des_set_random_generator_seed
PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *));
-void mit_des_generate_random_block
+extern void mit_des_set_sequence_number
+ PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *));
+extern void mit_des_generate_random_block
PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *));
/* process_ky.c */
-krb5_error_code mit_des_process_key
+extern krb5_error_code mit_des_process_key
PROTOTYPE(( krb5_encrypt_block *, krb5_keyblock *));
/* random_key.c */
-krb5_error_code mit_des_random_key
+extern krb5_error_code mit_des_random_key
PROTOTYPE(( krb5_pointer , krb5_keyblock **));
/* string2key.c */
-krb5_error_code mit_des_string_to_key
+extern krb5_error_code mit_des_string_to_key
PROTOTYPE((krb5_keytype, krb5_keyblock *, krb5_data *, krb5_principal ));
/* weak_key.c */
-int mit_des_is_weak_key PROTOTYPE((mit_des_cblock ));
+extern int mit_des_is_weak_key PROTOTYPE((mit_des_cblock ));
+
+/* misc.c */
+extern void swap_bits PROTOTYPE((char *));
+extern unsigned long long_swap_bits PROTOTYPE((unsigned long ));
+extern unsigned long swap_six_bits_to_ansi PROTOTYPE((unsigned long ));
+extern unsigned long swap_four_bits_to_ansi PROTOTYPE((unsigned long ));
+extern unsigned long swap_bit_pos_1 PROTOTYPE((unsigned long ));
+extern unsigned long swap_bit_pos_0 PROTOTYPE((unsigned long ));
+extern unsigned long swap_bit_pos_0_to_ansi PROTOTYPE((unsigned long ));
+extern unsigned long rev_swap_bit_pos_0 PROTOTYPE((unsigned long ));
+extern unsigned long swap_byte_bits PROTOTYPE((unsigned long ));
+extern unsigned long swap_long_bytes_bit_number PROTOTYPE((unsigned long ));
+#ifdef FILE
+/* XXX */
+extern void test_set PROTOTYPE((FILE *, const char *, int, const char *, int));
+#endif
#undef P
#endif /*DES_INTERNAL_DEFS*/
#include <krb5/krb5.h>
#include <krb5/ext-proto.h>
-#include <krb5/des.h>
+#include "des_int.h"
#ifdef DEBUG
#include <stdio.h>
-extern int des_debug;
-extern int des_debug_print();
+extern int mit_des_debug;
#endif
OLDDECLARG(krb5_encrypt_block *, key)
OLDDECLARG(krb5_pointer, ivec)
{
- krb5_error_code des_cbc_encrypt();
krb5_octet *iv;
if ( ivec == 0 )
iv = (krb5_octet *)ivec;
/* XXX should check that key sched is valid here? */
- return (des_cbc_encrypt((krb5_octet *)in,
+ return (mit_des_cbc_encrypt((krb5_octet *)in,
(krb5_octet *)out,
size,
- (struct des_ks_struct *)key->priv,
+ (struct mit_des_ks_struct *)key->priv,
iv,
- DES_ENCRYPT));
+ MIT_DES_ENCRYPT));
}
/*
OLDDECLARG(krb5_encrypt_block *, key)
OLDDECLARG(krb5_pointer, ivec)
{
- krb5_error_code des_cbc_encrypt();
krb5_octet *iv;
if ( ivec == 0 )
iv = (krb5_octet *)ivec;
/* XXX should check that key sched is valid here? */
- return (des_cbc_encrypt ((krb5_octet *)in,
+ return (mit_des_cbc_encrypt ((krb5_octet *)in,
(krb5_octet *)out,
size,
- (struct des_ks_struct *)key->priv,
+ (struct mit_des_ks_struct *)key->priv,
iv,
- DES_DECRYPT));
+ MIT_DES_DECRYPT));
}
/*
* This routine performs DES cipher-block-chaining operation, either
*/
krb5_error_code
-des_cbc_encrypt(in,out,length,key,iv,encrypt)
+mit_des_cbc_encrypt(in,out,length,key,iv,encrypt)
krb5_octet *in; /* >= length bytes of input text */
krb5_octet *out; /* >= length bytes of output text */
register long length; /* in bytes */
- int encrypt; /* 0 ==> decrypt, else encrypt */
- des_key_schedule key; /* precomputed key schedule */
+ mit_des_key_schedule key; /* precomputed key schedule */
krb5_octet *iv; /* 8 bytes of ivec */
+ int encrypt; /* 0 ==> decrypt, else encrypt */
{
- int des_ecb_encrypt();
+ int mit_des_ecb_encrypt();
register unsigned long *input = (unsigned long *) in;
register unsigned long *output = (unsigned long *) out;
*(t_in_p+j)= 0;
#ifdef DEBUG
- if (des_debug)
- des_debug_print("clear",length,t_input[0],t_input[1]);
+ if (mit_des_debug)
+ mit_des_debug_print("clear",length,t_input[0],t_input[1]);
#endif
/* do the xor for cbc into the temp */
t_input[0] ^= t_output[0];
t_input[1] ^= t_output[1];
/* encrypt */
- (void) des_ecb_encrypt(t_input,t_output,key,encrypt);
+ (void) mit_des_ecb_encrypt(t_input,t_output,key,encrypt);
/* copy temp output and save it for cbc */
#ifdef MUSTALIGN
if ((long) output & 3) {
}
#ifdef DEBUG
- if (des_debug) {
- des_debug_print("xor'ed",i,t_input[0],t_input[1]);
- des_debug_print("cipher",i,t_output[0],t_output[1]);
+ if (mit_des_debug) {
+ mit_des_debug_print("xor'ed",i,t_input[0],t_input[1]);
+ mit_des_debug_print("cipher",i,t_output[0],t_output[1]);
}
#endif
}
/* no padding for decrypt */
#ifdef DEBUG
- if (des_debug)
- des_debug_print("cipher",i,t_input[0],t_input[1]);
+ if (mit_des_debug)
+ mit_des_debug_print("cipher",i,t_input[0],t_input[1]);
#else
#ifdef lint
i = i;
#endif
#endif
/* encrypt */
- (void) des_ecb_encrypt(t_input,t_output,key,encrypt);
+ (void) mit_des_ecb_encrypt(t_input,t_output,key,encrypt);
#ifdef DEBUG
- if (des_debug)
- des_debug_print("out pre xor",i,t_output[0],t_output[1]);
+ if (mit_des_debug)
+ mit_des_debug_print("out pre xor",i,t_output[0],t_output[1]);
#endif
/* do the xor for cbc into the output */
t_output[0] ^= xor_0;
xor_0 = t_input[0];
xor_1 = t_input[1];
#ifdef DEBUG
- if (des_debug)
- des_debug_print("clear",i,t_output[0],t_output[1]);
+ if (mit_des_debug)
+ mit_des_debug_print("clear",i,t_output[0],t_output[1]);
#endif
}
return 0;
#include <sys/errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
+#include <krb5/mit-des.h>
#include <krb5/ext-proto.h>
/*
krb5_error_code mit_des_finish_random_key (DECLARG(krb5_pointer *, seed))
OLDDECLARG(krb5_pointer *, seed)
{
- bzero( (char *)*seed, sizeof(des_random_key_seed) );
+ bzero( (char *)*seed, sizeof(mit_des_random_key_seed) );
free((char *)*seed);
*seed = 0;
return 0; /* XXX init_random_key */
#include <krb5/krb5.h>
#include <krb5/ext-proto.h>
-#include <krb5/des.h>
+#include <krb5/mit-des.h>
/*
does any necessary clean-up on the eblock (such as releasing
krb5_error_code mit_des_finish_key (DECLARG(krb5_encrypt_block *,eblock))
OLDDECLARG(krb5_encrypt_block *,eblock)
{
- bzero((char *)eblock->priv, sizeof(des_key_schedule));
+ bzero((char *)eblock->priv, sizeof(mit_des_key_schedule));
free(eblock->priv);
eblock->priv = 0;
/* free/clear other stuff here? */
#include <sys/errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
#include <krb5/ext-proto.h>
#include <krb5/krb5_err.h>
-extern void des_init_random_number_generator();
+#include "des_int.h"
/*
initialize the random key generator using the encryption key,
OLDDECLARG(krb5_keyblock *,seedblock)
OLDDECLARG(krb5_pointer *,seed)
{
- des_random_key_seed * p_seed;
+ mit_des_random_key_seed * p_seed;
if (seedblock->keytype != KEYTYPE_DES)
return KRB5_BAD_KEYTYPE; /* XXX error code bad keytype */
- if ( !(p_seed = (des_random_key_seed *)
- malloc(sizeof(des_random_key_seed))) )
+ if ( !(p_seed = (mit_des_random_key_seed *)
+ malloc(sizeof(mit_des_random_key_seed))) )
return ENOMEM;
- bzero( (char *)p_seed, sizeof(des_random_key_seed) );
- des_init_random_number_generator(seedblock->contents, p_seed);
+ bzero( (char *)p_seed, sizeof(mit_des_random_key_seed) );
+ mit_des_init_random_number_generator(seedblock->contents, p_seed);
*seed = (krb5_pointer) p_seed;
return 0;
}
#include <mit-copyright.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
-#include "des_internal.h"
+#include "des_int.h"
#include "odd.h" /* Load compile-time generated odd_parity table */
* vax order.
*/
void
-des_fixup_key_parity(key)
- register des_cblock key;
+mit_des_fixup_key_parity(key)
+ register mit_des_cblock key;
{
int i;
- for (i=0; i<sizeof(des_cblock); i++)
+ for (i=0; i<sizeof(mit_des_cblock); i++)
key[i] = odd_parity[key[i]];
return;
* correct des parity.
*/
int
-des_check_key_parity(key)
- register des_cblock key;
+mit_des_check_key_parity(key)
+ register mit_des_cblock key;
{
int i;
- for (i=0; i<sizeof(des_cblock); i++)
+ for (i=0; i<sizeof(mit_des_cblock); i++)
if (key[i] != odd_parity[key[i]])
return(0);
#endif /* !lint & !SABER */
#include <mit-copyright.h>
-#include "des_internal.h"
#include <stdio.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
+#include "des_int.h"
#include "key_perm.h"
-extern int des_debug;
-extern rev_swap_bit_pos_0();
-extern int des_check_key_parity();
-extern int des_is_weak_key();
+extern int mit_des_debug;
typedef char key[64];
/* the following are really void but cc86 doesnt allow it */
-void make_key_sched();
-
+static void make_key_sched PROTOTYPE((key, mit_des_key_schedule));
int
-des_key_sched(k,schedule)
- register des_cblock k; /* r11 */
- des_key_schedule schedule;
+mit_des_key_sched(k,schedule)
+ register mit_des_cblock k; /* r11 */
+ mit_des_key_schedule schedule;
{
/* better pass 8 bytes, length not checked here */
n = n; /* fool it in case of VAXASM */
#endif
#ifdef DEBUG
- if (des_debug)
+ if (mit_des_debug)
fprintf(stderr,"\n\ninput key, left to right = ");
#endif
- if (!des_check_key_parity(k)) /* bad parity --> return -1 */
+ if (!mit_des_check_key_parity(k)) /* bad parity --> return -1 */
return(-1);
do {
/* get next input key byte */
#ifdef DEBUG
- if (des_debug)
+ if (mit_des_debug)
fprintf(stderr,"%02x ",*k & 0xff);
#endif
temp = (unsigned int) ((unsigned char) *k++);
} while (--i > 0);
#ifdef DEBUG
- if (des_debug) {
+ if (mit_des_debug) {
p_char = k_char;
fprintf(stderr,"\nKey bits, from zero to 63");
for (i = 0; i <= 7; i++) {
#endif
/* check against weak keys */
- k -= sizeof(des_cblock);
+ k -= sizeof(mit_des_cblock);
- if (des_is_weak_key(k))
+ if (mit_des_is_weak_key(k))
return(-2);
make_key_sched(k_char,schedule);
static void
make_key_sched(Key,Schedule)
register key Key; /* r11 */
- des_key_schedule Schedule;
+ mit_des_key_schedule Schedule;
{
/*
* The key has been converted to an array to make this run faster;
} while (--iter > 0);
#ifdef DEBUG
- if (des_debug) {
+ if (mit_des_debug) {
char *n;
int q;
fprintf(stderr,"\nKey Schedule, left to right");
*/
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "tables.h"
void gen(stream)
#include <stdio.h>
#include <krb5/krb5.h>
#include <krb5/ext-proto.h>
-#include "des_internal.h"
+#include "des_int.h"
#include "tables.h"
-extern unsigned int swap_bit_pos_0_to_ansi PROTOTYPE((unsigned int));
-extern long swap_long_bytes();
-extern unsigned long swap_long_bytes_bit_number();
-extern void test_set PROTOTYPE((FILE *, char const *, int,
- char const *, int));
-
void gen (stream)
FILE * stream;
{
#include <mit-copyright.h>
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "tables.h"
-extern long swap_bit_pos_0();
-extern long rev_swap_bit_pos_0();
-extern void test_set();
-extern unsigned long swap_long_bytes_bit_number();
-unsigned long swap_bit_pos_0_to_ansi();
#define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
#include <mit-copyright.h>
#include <stdio.h>
#include <errno.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#ifndef lint
static char rcsid[]=
#endif /* lint */
char *progname;
-extern char *errmsg();
extern int errno;
-extern long swap_bit_pos_1();
-extern long swap_bit_pos_0();
int sflag;
int vflag;
int dflag;
int ks_perm[16+1][48+1];
-int des_debug;
+int mit_des_debug;
void gen(stream)
FILE *stream;
* start at iter = 1, not zero.
*/
for (iter = 1; iter <= 16; iter++) {
- if (des_debug) {
+ if (mit_des_debug) {
/* for debugging */
printf(
"/* DEBUG-- start iteration = %d shifts = %d",
}
- if (des_debug) {
+ if (mit_des_debug) {
/* for debugging */
printf("/* DEBUG:\n");
printf(" * after shifts, iteration = %d shifts = %d",
#include <krb5/copyright.h>
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "tables.h"
void gen(stream)
#include <mit-copyright.h>
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "tables.h"
-extern unsigned long swap_byte_bits();
-extern unsigned long rev_swap_bit_pos_0();
static unsigned char P_temp[32];
static unsigned long P_prime[4][256];
#include <mit-copyright.h>
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "s_table.h"
void gen(stream)
#include <mit-copyright.h>
#include <stdio.h>
-#include "des_internal.h"
+#include <krb5/krb5.h>
+#include "des_int.h"
#include "tables.h"
-extern unsigned long swap_bit_pos_0();
-extern unsigned long swap_six_bits_to_ansi();
-extern unsigned long swap_four_bits_to_ansi();
char temp[8][64];
-int des_debug;
+int mit_des_debug;
void gen(stream)
FILE *stream;
m = S[i][l];
/* restore in host order */
n = swap_four_bits_to_ansi(m);
- if (des_debug)
+ if (mit_des_debug)
fprintf(stderr,
"i = %d, j = %d, k = %d, l = %d, m = %d, n = %d\n",
i,j,k,l,m,n);
#include <krb5/krb5.h>
#include <krb5/ext-proto.h>
-#include <krb5/des.h>
-#include "des_internal.h"
+#include "des_int.h"
/*
* The DES algorithm is defined in terms of MSBFIRST, so sometimes,
*/
register y,z;
- /* always do it, only used by des_make_key_perm.c so far */
+ /* always do it, only used by mit_des_make_key_perm.c so far */
y = (x-1)/8;
z = (x-1)%8;
}
extern void gen PROTOTYPE((FILE *));
-int des_debug;
+int mit_des_debug;
char const *whoami;
void
arg = *argv;
if (*arg == '-') {
if (!strcmp(arg, "-d") && !strcmp(arg, "-debug"))
- des_debug++;
+ mit_des_debug++;
else {
fprintf(stderr, "%s: unknown control argument %s\n",
whoami, arg);
#include <mit-copyright.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
-#include "des_internal.h"
-
-extern void des_fixup_key_parity();
-extern int des_is_weak_key();
-extern int des_ecb_encrypt();
-extern int des_key_sched();
-void des_set_random_generator_seed(), des_set_sequence_number();
-void des_generate_random_block();
+#include "des_int.h"
/*
- * des_new_random_key: create a random des key
+ * mit_des_new_random_key: create a random des key
*
- * Requires: des_set_random_number_generater_seed must be at called least
+ * Requires: mit_des_set_random_number_generater_seed must be at called least
* once before this routine is called.
*
* Notes: the returned key has correct parity and is guarenteed not
- * to be a weak des key. Des_generate_random_block is used to
+ * to be a weak des key. Mit_Des_generate_random_block is used to
* provide the random bits.
*/
int
-des_new_random_key(key, p_seed)
- des_cblock key;
- des_random_key_seed *p_seed;
+mit_des_new_random_key(key, p_seed)
+ mit_des_cblock key;
+ mit_des_random_key_seed *p_seed;
{
do {
- des_generate_random_block(key, p_seed);
- des_fixup_key_parity(key);
- } while (des_is_weak_key(key));
+ mit_des_generate_random_block(key, p_seed);
+ mit_des_fixup_key_parity(key);
+ } while (mit_des_is_weak_key(key));
return(0);
}
/*
- * des_init_random_number_generator:
+ * mit_des_init_random_number_generator:
*
* This routine takes a secret key possibly shared by a number
* of servers and uses it to generate a random number stream that is
* This routine is used for example, by the kerberos server(s) with the
* key in question being the kerberos master key.
*
- * Note: this routine calls des_set_random_generator_seed.
+ * Note: this routine calls mit_des_set_random_generator_seed.
*/
#ifndef BSDUNIX
you lose... (aka, you get to implement an analog of this for your
#include <sys/time.h>
#include <krb5/ext-proto.h>
-extern long gethostid();
+extern long gethostid(); /* XXX */
-void des_init_random_number_generator(key,p_seed)
- des_cblock key;
- des_random_key_seed *p_seed;
+void mit_des_init_random_number_generator(key,p_seed)
+ mit_des_cblock key;
+ mit_des_random_key_seed *p_seed;
{
struct { /* This must be 64 bits exactly */
long process_id;
long host_id;
} seed;
struct timeval time; /* this must also be 64 bits exactly */
- des_cblock new_key;
+ mit_des_cblock new_key;
/*
* use a host id and process id in generating the seed to ensure
* Generate a tempory value that depends on the key, host_id, and
* process_id such that it gives no useful information about the key:
*/
- des_set_random_generator_seed(key, p_seed);
- des_set_sequence_number((unsigned char *)&seed, p_seed);
- des_new_random_key(new_key, p_seed);
+ mit_des_set_random_generator_seed(key, p_seed);
+ mit_des_set_sequence_number((unsigned char *)&seed, p_seed);
+ mit_des_new_random_key(new_key, p_seed);
/*
* use it to select a random stream:
*/
- des_set_random_generator_seed(new_key, p_seed);
+ mit_des_set_random_generator_seed(new_key, p_seed);
/*
* use a time stamp to ensure that a server started later does not reuse
* an old stream:
*/
gettimeofday(&time, (struct timezone *)0);
- des_set_sequence_number((unsigned char *)&time, p_seed);
+ mit_des_set_sequence_number((unsigned char *)&time, p_seed);
/*
* use the time stamp finally to select the final seed using the
* current random number stream:
*/
- des_new_random_key(new_key, p_seed);
- des_set_random_generator_seed(new_key, p_seed);
+ mit_des_new_random_key(new_key, p_seed);
+ mit_des_set_random_generator_seed(new_key, p_seed);
}
#endif /* ifdef BSDUNIX */
*/
/*
- * des_set_random_generator_seed: this routine is used to select a random
+ * mit_des_set_random_generator_seed: this routine is used to select a random
* number stream. The stream that results is
* totally determined by the passed in key.
* (I.e., calling this routine again with the
* weak des key.
*/
void
-des_set_random_generator_seed(key, p_seed)
- des_cblock key;
- des_random_key_seed *p_seed;
+mit_des_set_random_generator_seed(key, p_seed)
+ mit_des_cblock key;
+ mit_des_random_key_seed *p_seed;
{
register int i;
/* select the new stream: (note errors are not possible here...) */
- des_key_sched(key, p_seed->random_sequence_key);
+ mit_des_key_sched(key, p_seed->random_sequence_key);
/* "seek" to the start of the stream: */
for (i=0; i<8; i++)
}
/*
- * des_set_sequence_number: this routine is used to set the sequence number
+ * mit_des_set_sequence_number: this routine is used to set the sequence number
* of the current random number stream. This routine
* may be used to "seek" within the current random
* number stream.
*
- * Note that des_set_random_generator_seed resets the sequence number to 0.
+ * Note that mit_des_set_random_generator_seed resets the sequence number to 0.
*/
void
-des_set_sequence_number(new_sequence_number, p_seed)
- des_cblock new_sequence_number;
- des_random_key_seed *p_seed;
+mit_des_set_sequence_number(new_sequence_number, p_seed)
+ mit_des_cblock new_sequence_number;
+ mit_des_random_key_seed *p_seed;
{
bcopy((char *)new_sequence_number, (char *)p_seed->sequence_number,
sizeof(p_seed->sequence_number));
}
/*
- * des_generate_random_block: routine to return the next random number
+ * mit_des_generate_random_block: routine to return the next random number
* from the current random number stream.
* The returned number is 64 bits long.
*
- * Requires: des_set_random_generator_seed must have been called at least once
+ * Requires: mit_des_set_random_generator_seed must have been called at least once
* before this routine is called.
*/
-void des_generate_random_block(block, p_seed)
- des_cblock block;
- des_random_key_seed *p_seed;
+void mit_des_generate_random_block(block, p_seed)
+ mit_des_cblock block;
+ mit_des_random_key_seed *p_seed;
{
int i;
/*
* Encrypt the sequence number to get the new random block:
*/
- des_ecb_encrypt((unsigned long *)p_seed->sequence_number,
+ mit_des_ecb_encrypt((unsigned long *)p_seed->sequence_number,
(unsigned long *)block,
p_seed->random_sequence_key, 1);
#include <sys/errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
#include <krb5/ext-proto.h>
#include <krb5/krb5_err.h>
-extern int des_key_sched();
+#include "des_int.h"
+
/*
does any necessary key preprocessing (such as computing key
schedules for DES).
OLDDECLARG(krb5_encrypt_block *, eblock)
OLDDECLARG(krb5_keyblock *,keyblock)
{
- struct des_ks_struct *schedule; /* pointer to key schedules */
+ struct mit_des_ks_struct *schedule; /* pointer to key schedules */
- if (keyblock->length != sizeof (des_cblock))
+ if (keyblock->length != sizeof (mit_des_cblock))
return KRB5_BAD_KEYSIZE; /* XXX error code-bad key size */
- if ( !(schedule = (struct des_ks_struct *) malloc(sizeof(des_key_schedule))) )
+ if ( !(schedule = (struct mit_des_ks_struct *) malloc(sizeof(mit_des_key_schedule))) )
return ENOMEM;
#define cleanup() { free( (char *) schedule); }
- switch (des_key_sched (keyblock->contents, schedule)) {
+ switch (mit_des_key_sched (keyblock->contents, schedule)) {
case -1:
cleanup();
return KRB5DES_BAD_KEYPAR; /* XXX error code-bad key parity */
#include <sys/errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
#include <krb5/ext-proto.h>
-extern int des_new_random_key();
-
+#include "des_int.h"
/*
generate a random encryption key, allocating storage for it and
filling in the keyblock address in *keyblock
if (!(randkey = (krb5_keyblock *)malloc(sizeof(*randkey))))
return ENOMEM;
- if (!(randkey->contents = (krb5_octet *)malloc(sizeof(des_cblock)))) {
+ if (!(randkey->contents = (krb5_octet *)malloc(sizeof(mit_des_cblock)))) {
free((char *)randkey);
return ENOMEM;
}
- randkey->length = sizeof(des_cblock);
+ randkey->length = sizeof(mit_des_cblock);
randkey->keytype = KEYTYPE_DES;
- des_new_random_key(randkey->contents, (des_random_key_seed *) seed);
+ mit_des_new_random_key(randkey->contents, (mit_des_random_key_seed *) seed);
*keyblock = randkey;
return 0;
}
#include <sys/errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
#include <krb5/krb5_err.h>
#include <krb5/ext-proto.h>
-#include "des_internal.h"
+#include "des_int.h"
#ifdef DEBUG
#include <stdio.h>
extern int des_debug;
-extern int des_debug_print();
#endif
-extern void des_fixup_key_parity();
-extern int des_key_sched();
-extern void des_cbc_cksum();
/*
converts the string pointed to by "data" into an encryption key
of type "keytype". *keyblock is filled in with the key info;
static int forward;
register char *p_char;
static char k_char[64];
- static des_key_schedule key_sked;
+ static mit_des_key_schedule key_sked;
#define min(A, B) ((A) < (B) ? (A): (B))
if ( keytype != KEYTYPE_DES )
return (KRB5_PROG_KEYTYPE_NOSUPP);
- if ( !(keyblock->contents = (krb5_octet *)malloc(sizeof(des_cblock))) )
+ if ( !(keyblock->contents = (krb5_octet *)malloc(sizeof(mit_des_cblock))) )
return(ENOMEM);
-#define cleanup() {bzero(keyblock->contents, sizeof(des_cblock));\
+#define cleanup() {bzero(keyblock->contents, sizeof(mit_des_cblock));\
(void) free((char *) keyblock->contents);}
keyblock->keytype = KEYTYPE_DES;
- keyblock->length = sizeof(des_cblock);
+ keyblock->length = sizeof(mit_des_cblock);
key = keyblock->contents;
bzero(copystr, sizeof(copystr));
(void) strncpy(copystr, data->data, min(data->length,511));
bzero(k_char,sizeof(k_char));
#ifdef DEBUG
- if (des_debug)
+ if (mit_des_debug)
fprintf(stdout,
"\n\ninput str length = %d string = %s\nstring = 0x ",
length,str);
/* get next input key byte */
temp = (unsigned int) *str++;
#ifdef DEBUG
- if (des_debug)
+ if (mit_des_debug)
fprintf(stdout,"%02x ",temp & 0xff);
#endif
/* loop through bits within byte, ignore parity */
forward = !forward;
}
- /* now stuff into the key des_cblock, and force odd parity */
+ /* now stuff into the key mit_des_cblock, and force odd parity */
p_char = k_char;
k_p = (unsigned char *) key;
}
/* fix key parity */
- des_fixup_key_parity(key);
+ mit_des_fixup_key_parity(key);
/* Now one-way encrypt it with the folded key */
- (void) des_key_sched(key, key_sked);
- (void) des_cbc_cksum((krb5_octet *)copystr, key, length, key_sked, key);
+ (void) mit_des_key_sched(key, key_sked);
+ (void) mit_des_cbc_cksum((krb5_octet *)copystr, key, length, key_sked, key);
/* erase key_sked */
bzero((char *)key_sked, sizeof(key_sked));
/* now fix up key parity again */
- des_fixup_key_parity(key);
+ mit_des_fixup_key_parity(key);
#ifdef DEBUG
- if (des_debug)
+ if (mit_des_debug)
fprintf(stdout,
"\nResulting string_to_key = 0x%x 0x%x\n",
*((unsigned long *) key),
#include <string.h>
#include <errno.h>
#include <krb5/krb5.h>
-#include <krb5/des.h>
+#include <krb5/mit-des.h>
#include <krb5/krb5_err.h>
+#include <com_err.h>
-extern void com_err();
extern int errno;
extern krb5_cryptosystem_entry mit_des_cryptosystem_entry;
-extern des_cbc_cksum();
-extern des_ecb_encrypt();
-extern exit();
char *progname;
int nflag = 2;
int vflag;
int mflag;
int zflag;
int pid;
-int des_debug;
+int mit_des_debug;
krb5_encrypt_block eblock;
krb5_keyblock keyblock;
};
unsigned char key2[8] = { 0x08,0x19,0x2a,0x3b,0x4c,0x5d,0x6e,0x7f };
unsigned char key3[8] = { 0x80,1,1,1,1,1,1,1 };
-des_cblock s_key;
+mit_des_cblock s_key;
unsigned char default_ivec[8] = {
0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef
};
/* debug flag */
case 'd':
- des_debug=3;
+ mit_des_debug=3;
continue;
case 'z':
eblock.crypto_entry = &mit_des_cryptosystem_entry;
keyblock.keytype = KEYTYPE_DES;
- keyblock.length = sizeof (des_cblock);
+ keyblock.length = sizeof (mit_des_cblock);
/* use known input and key */
printf("\tchecksum\t58 d2 e7 7e 86 06 27 33, ");
printf("or some part thereof\n");
input = clear_text2;
- des_cbc_cksum(input,cipher_text,(long) strlen(input),eblock.priv,ivec,1);
+ mit_des_cbc_cksum(input,cipher_text,(long) strlen(input),eblock.priv,ivec,1);
printf("ACTUAL CBC checksum\n");
printf("\t\tencrypted cksum = (low to high bytes)\n\t\t");
for (j = 0; j<=7; j++)
char *out;
{
for (i =1; i<=nflag; i++) {
- des_ecb_encrypt(in,out,(struct des_ks_struct *)eblock.priv,1);
- if (des_debug) {
+ mit_des_ecb_encrypt(in,out,(struct mit_des_ks_struct *)eblock.priv,1);
+ if (mit_des_debug) {
printf("\nclear %s\n",in);
for (j = 0; j<=7; j++)
printf("%02 X ",in[j] & 0xff);
/* try to invert it */
{
for (i =1; i<=nflag; i++) {
- des_ecb_encrypt(out,in,(struct des_ks_struct *)eblock.priv,0);
- if (des_debug) {
+ mit_des_ecb_encrypt(out,in,(struct mit_des_ks_struct *)eblock.priv,0);
+ if (mit_des_debug) {
printf("clear %s\n",in);
for (j = 0; j<=7; j++)
printf("%02X ",in[j] & 0xff);
#endif /* !lint & !SABER */
#include <krb5/krb5.h>
-#include <krb5/des.h>
#include <krb5/ext-proto.h>
-#include "des_internal.h"
+#include "des_int.h"
/*
* The following are the weak DES keys:
*/
-static des_cblock weak[16] = {
+static mit_des_cblock weak[16] = {
/* weak keys */
{0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
{0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
};
/*
- * des_is_weak_key: returns true iff key is a [semi-]weak des key.
+ * mit_des_is_weak_key: returns true iff key is a [semi-]weak des key.
*
* Requires: key has correct odd parity.
*/
int
-des_is_weak_key(key)
- des_cblock key;
+mit_des_is_weak_key(key)
+ mit_des_cblock key;
{
int i;
- des_cblock *weak_p = weak;
+ mit_des_cblock *weak_p = weak;
- for (i = 0; i < (sizeof(weak)/sizeof(des_cblock)); i++) {
- if (!bcmp((char *)weak_p++,(char *)key,sizeof(des_cblock)))
+ for (i = 0; i < (sizeof(weak)/sizeof(mit_des_cblock)); i++) {
+ if (!bcmp((char *)weak_p++,(char *)key,sizeof(mit_des_cblock)))
return 1;
}