1 /* The rxkad security object. This contains packet processing routines that
2 * are prohibited from being exported. */
5 ****************************************************************************
6 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
8 * Permission to use, copy, modify, and distribute this software and its *
9 * documentation for any purpose and without fee is hereby granted, *
10 * provided that the above copyright notice appear in all copies and *
11 * that both that copyright notice and this permission notice appear in *
12 * supporting documentation, and that the name of IBM not be used in *
13 * advertising or publicity pertaining to distribution of the software *
14 * without specific, written prior permission. *
16 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
19 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
20 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
21 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
22 ****************************************************************************
28 #include "../afs/param.h"
29 #include "../afs/stds.h"
31 #include "../h/types.h"
33 #include "../netinet/in.h"
35 #include "../afs/sysincludes.h"
41 #include <afs/param.h>
43 #include <sys/types.h>
48 #include <netinet/in.h>
52 #include "private_data.h"
53 #define XPRT_RXKAD_CRYPT
55 #include "../afs/permit_xprt.h"
57 #include "../permit_xprt.h"
62 afs_int32 rxkad_DecryptPacket (conn, schedule, ivec, len, packet)
63 IN struct rx_connection *conn;
64 IN fc_KeySchedule *schedule;
65 IN fc_InitializationVector *ivec;
67 INOUT struct rx_packet *packet;
70 struct rx_securityClass *obj;
71 struct rxkad_cprivate *tp; /* s & c have type at same offset */
75 if (!xprt_CryptOK (conn)) return RXKADILLEGALLEVEL;
76 obj = rx_SecurityObjectOf(conn);
77 tp = (struct rxkad_cprivate *)obj->privateData;
79 rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += len;
82 bcopy ((void *)ivec, (void *)xor, sizeof(xor));
83 for (i = 0; len ; i++) {
84 data = rx_data(packet, i, tlen);
87 tlen = MIN(len, tlen);
88 fc_cbc_encrypt (data, data, tlen, schedule, xor, DECRYPT);
91 /* Do this if packet checksums are ever enabled (below), but
92 * current version just passes zero
94 cksum = ntohl(rx_GetInt32(packet, 1));
100 afs_int32 rxkad_EncryptPacket (conn, schedule, ivec, len, packet)
101 IN struct rx_connection *conn;
102 IN fc_KeySchedule *schedule;
103 IN fc_InitializationVector *ivec;
105 INOUT struct rx_packet *packet;
108 struct rx_securityClass *obj;
109 struct rxkad_cprivate *tp; /* s & c have type at same offset */
113 if (!xprt_CryptOK (conn)) return RXKADILLEGALLEVEL;
114 obj = rx_SecurityObjectOf(conn);
115 tp = (struct rxkad_cprivate *)obj->privateData;
117 rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] += len;
123 * Future option to add cksum here, but for now we just put 0
125 rx_PutInt32(packet, 1*sizeof(afs_int32), 0);
127 bcopy ((void *)ivec, (void *)xor, sizeof(xor));
128 for (i = 0; len ; i++) {
129 data = rx_data(packet, i, tlen);
132 tlen = MIN(len, tlen);
133 fc_cbc_encrypt (data, data, tlen, schedule, xor, ENCRYPT);