4 * Copyright 1985, 1986, 1987, 1988, 1990 by the Massachusetts Institute
8 * These routines perform encryption and decryption using the DES
9 * private key algorithm, or else a subset of it -- fewer inner loops.
10 * (AUTH_DES_ITER defaults to 16, may be less.)
12 * Under U.S. law, this software may not be exported outside the US
13 * without license from the U.S. Commerce department.
15 * These routines form the library interface to the DES facilities.
17 * Originally written 8/85 by Steve Miller, MIT Project Athena.
19 * Export of this software from the United States of America may
20 * require a specific license from the United States Government.
21 * It is the responsibility of any person or organization contemplating
22 * export to obtain such a license before exporting.
24 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
25 * distribute this software and its documentation for any purpose and
26 * without fee is hereby granted, provided that the above copyright
27 * notice appear in all copies and that both that copyright notice and
28 * this permission notice appear in supporting documentation, and that
29 * the name of M.I.T. not be used in advertising or publicity pertaining
30 * to distribution of the software without specific, written prior
31 * permission. M.I.T. makes no representations about the suitability of
32 * this software for any purpose. It is provided "as is" without express
33 * or implied warranty.
40 #include <krb5/ext-proto.h>
43 * This routine performs DES cipher-block-chaining operation, either
44 * encrypting from cleartext to ciphertext, if encrypt != 0 or
45 * decrypting from ciphertext to cleartext, if encrypt == 0.
47 * The key schedule is passed as an arg, as well as the cleartext or
48 * ciphertext. The cleartext and ciphertext should be in host order.
50 * NOTE-- the output is ALWAYS an multiple of 8 bytes long. If not
51 * enough space was provided, your program will get trashed.
53 * For encryption, the cleartext string is null padded, at the end, to
54 * an integral multiple of eight bytes.
56 * For decryption, the ciphertext will be used in integral multiples
57 * of 8 bytes, but only the first "length" bytes returned into the
62 des_cbc_encrypt(in,out,length,key,iv,encrypt)
63 krb5_octet *in; /* >= length bytes of input text */
64 krb5_octet *out; /* >= length bytes of output text */
65 register long length; /* in bytes */
66 mit_des_key_schedule key; /* precomputed key schedule */
67 krb5_octet *iv; /* 8 bytes of ivec */
68 int encrypt; /* 0 ==> decrypt, else encrypt */
70 return(mit_des_cbc_encrypt(in,out,length,key,iv,encrypt));