2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* The rxkad security object. This contains packet processing routines that
11 * are prohibited from being exported. */
14 #include <afsconfig.h>
16 #include "afs/param.h"
18 #include <afs/param.h>
26 #if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
30 #include "netinet/in.h"
32 #include "afs/sysincludes.h"
37 #include <sys/types.h>
43 #include <netinet/in.h>
47 #include <des/stats.h>
48 #include "private_data.h"
49 #define XPRT_RXKAD_CRYPT
52 rxkad_DecryptPacket(const struct rx_connection *conn,
53 const fc_KeySchedule * schedule,
54 const fc_InitializationVector * ivec, const int inlen,
55 struct rx_packet *packet)
58 struct rx_securityClass *obj;
59 struct rxkad_cprivate *tp; /* s & c have type at same offset */
65 obj = rx_SecurityObjectOf(conn);
66 tp = (struct rxkad_cprivate *)obj->privateData;
67 ADD_RXKAD_STATS(bytesDecrypted[rxkad_TypeIndex(tp->type)],len);
68 memcpy((void *)xor, (void *)ivec, sizeof(xor));
69 for (i = 0; len; i++) {
70 data = rx_data(packet, i, tlen);
73 tlen = MIN(len, tlen);
74 fc_cbc_encrypt(data, data, tlen, *schedule, xor, DECRYPT);
77 /* Do this if packet checksums are ever enabled (below), but
78 * current version just passes zero
80 cksum = ntohl(rx_GetInt32(packet, 1));
86 rxkad_EncryptPacket(const struct rx_connection * conn,
87 const fc_KeySchedule * schedule,
88 const fc_InitializationVector * ivec, const int inlen,
89 struct rx_packet * packet)
92 struct rx_securityClass *obj;
93 struct rxkad_cprivate *tp; /* s & c have type at same offset */
99 obj = rx_SecurityObjectOf(conn);
100 tp = (struct rxkad_cprivate *)obj->privateData;
101 ADD_RXKAD_STATS(bytesEncrypted[rxkad_TypeIndex(tp->type)],len);
105 * * Future option to add cksum here, but for now we just put 0
107 rx_PutInt32(packet, 1 * sizeof(afs_int32), 0);
109 memcpy((void *)xor, (void *)ivec, sizeof(xor));
110 for (i = 0; len; i++) {
111 data = rx_data(packet, i, tlen);
114 tlen = MIN(len, tlen);
115 fc_cbc_encrypt(data, data, tlen, *schedule, xor, ENCRYPT);