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>
24 #include "../afs/stds.h"
26 #include "../h/types.h"
28 #include "../netinet/in.h"
30 #include "../afs/sysincludes.h"
35 #include <sys/types.h>
40 #include <netinet/in.h>
44 #include "private_data.h"
45 #define XPRT_RXKAD_CRYPT
47 afs_int32 rxkad_DecryptPacket (conn, schedule, ivec, len, packet)
48 IN struct rx_connection *conn;
49 IN fc_KeySchedule *schedule;
50 IN fc_InitializationVector *ivec;
52 INOUT struct rx_packet *packet;
55 struct rx_securityClass *obj;
56 struct rxkad_cprivate *tp; /* s & c have type at same offset */
60 obj = rx_SecurityObjectOf(conn);
61 tp = (struct rxkad_cprivate *)obj->privateData;
63 rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += len;
66 memcpy((void *)xor, (void *)ivec, sizeof(xor));
67 for (i = 0; len ; i++) {
68 data = rx_data(packet, i, tlen);
71 tlen = MIN(len, tlen);
72 fc_cbc_encrypt (data, data, tlen, schedule, xor, DECRYPT);
75 /* Do this if packet checksums are ever enabled (below), but
76 * current version just passes zero
78 cksum = ntohl(rx_GetInt32(packet, 1));
83 afs_int32 rxkad_EncryptPacket (conn, schedule, ivec, len, packet)
84 IN struct rx_connection *conn;
85 IN fc_KeySchedule *schedule;
86 IN fc_InitializationVector *ivec;
88 INOUT struct rx_packet *packet;
91 struct rx_securityClass *obj;
92 struct rxkad_cprivate *tp; /* s & c have type at same offset */
96 obj = rx_SecurityObjectOf(conn);
97 tp = (struct rxkad_cprivate *)obj->privateData;
99 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);