Imported Upstream version 2.4.5p1
[debian/amanda] / server-src / dumper-krb4.c
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991,1994 University of Maryland
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: James da Silva, Systems Design and Analysis Group
24  *                         Computer Science Department
25  *                         University of Maryland at College Park
26  */
27 /*
28  * dumper-krb4.c - those bits of dumper code that deal with encrypting
29  *                 data streams over the network.  Even though these just
30  *                 call the underlying DES routines, the U.S. government
31  *                 considers this a munition.  Go figure.
32  */
33 #include "krb4-security.h"
34
35 /*
36  * NOTE:  This symbol must be the same as DATABUF_SIZE in
37  * client-src/sendbackup-krb4.c
38  * so that the encrypt/decrypt routines are working on the same sized buffers.
39  * Really, this should be moved out of dumper.c so that both programs can use
40  * the same symbol.  Hopefully that can be done later.  This is good enough
41  * to get encryption working for now...
42  *
43  *                  - Chris Ross (cross@uu.net)  4-Jun-1998
44  */
45 #define DATABUF_SIZE    DISK_BLOCK_BYTES
46
47 int kamanda_port;
48 CREDENTIALS cred;
49
50 des_key_schedule sched;
51
52 void decrypt_initialize()
53 {
54     des_key_sched(cred.session, sched);
55 }
56
57 decrypt_buffer(buffer, size)
58 char *buffer;
59 int size;
60 {
61     des_pcbc_encrypt((des_cblock *)buffer, 
62                      (des_cblock *)buffer, 
63                       size, sched, (des_cblock *)cred.session, DES_DECRYPT);
64 }
65
66 #define NAUGHTY_BITS_INITIALIZE         \
67     if(kencrypt) decrypt_initialize()
68
69 #define NAUGHTY_BITS                    \
70     if(kencrypt) decrypt_buffer(databuf, DATABUF_SIZE)