diff options
Diffstat (limited to 'src/lib/des425/enc_dec.c')
-rw-r--r-- | src/lib/des425/enc_dec.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/lib/des425/enc_dec.c b/src/lib/des425/enc_dec.c new file mode 100644 index 000000000..ae271ad68 --- /dev/null +++ b/src/lib/des425/enc_dec.c @@ -0,0 +1,63 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1985, 1986, 1987, 1988, 1990 by the Massachusetts Institute + * of Technology. + * All Rights Reserved. + * + * These routines perform encryption and decryption using the DES + * private key algorithm, or else a subset of it -- fewer inner loops. + * (AUTH_DES_ITER defaults to 16, may be less.) + * + * Under U.S. law, this software may not be exported outside the US + * without license from the U.S. Commerce department. + * + * These routines form the library interface to the DES facilities. + * + * Originally written 8/85 by Steve Miller, MIT Project Athena. + * + * For copying and distribution information, please see the file + * <krb5/copyright.h>. + * + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_enc_dec_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include "des.h" +#include <krb5/ext-proto.h> + +/* + * This routine performs DES cipher-block-chaining operation, either + * encrypting from cleartext to ciphertext, if encrypt != 0 or + * decrypting from ciphertext to cleartext, if encrypt == 0. + * + * The key schedule is passed as an arg, as well as the cleartext or + * ciphertext. The cleartext and ciphertext should be in host order. + * + * NOTE-- the output is ALWAYS an multiple of 8 bytes long. If not + * enough space was provided, your program will get trashed. + * + * For encryption, the cleartext string is null padded, at the end, to + * an integral multiple of eight bytes. + * + * For decryption, the ciphertext will be used in integral multiples + * of 8 bytes, but only the first "length" bytes returned into the + * cleartext. + */ + +int +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 */ + mit_des_key_schedule key; /* precomputed key schedule */ + krb5_octet *iv; /* 8 bytes of ivec */ + int encrypt; /* 0 ==> decrypt, else encrypt */ +{ + return(mit_des_cbc_encrypt(in,out,length,key,iv,encrypt)); +} + |