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. */
16 #include "../afs/param.h"
17 #include "../afs/stds.h"
19 #include "../h/types.h"
21 #include "../netinet/in.h"
23 #include "../afs/sysincludes.h"
29 #include <afs/param.h>
31 #include <sys/types.h>
36 #include <netinet/in.h>
40 #include "private_data.h"
41 #define XPRT_RXKAD_CRYPT
43 #include "../afs/permit_xprt.h"
45 #include "../permit_xprt.h"
49 afs_int32 rxkad_DecryptPacket (conn, schedule, ivec, len, packet)
50 IN struct rx_connection *conn;
51 IN fc_KeySchedule *schedule;
52 IN fc_InitializationVector *ivec;
54 INOUT struct rx_packet *packet;
57 struct rx_securityClass *obj;
58 struct rxkad_cprivate *tp; /* s & c have type at same offset */
62 obj = rx_SecurityObjectOf(conn);
63 tp = (struct rxkad_cprivate *)obj->privateData;
65 rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += len;
68 bcopy ((void *)ivec, (void *)xor, 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));
85 afs_int32 rxkad_EncryptPacket (conn, schedule, ivec, len, packet)
86 IN struct rx_connection *conn;
87 IN fc_KeySchedule *schedule;
88 IN fc_InitializationVector *ivec;
90 INOUT struct rx_packet *packet;
93 struct rx_securityClass *obj;
94 struct rxkad_cprivate *tp; /* s & c have type at same offset */
98 obj = rx_SecurityObjectOf(conn);
99 tp = (struct rxkad_cprivate *)obj->privateData;
101 rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] += len;
107 * Future option to add cksum here, but for now we just put 0
109 rx_PutInt32(packet, 1*sizeof(afs_int32), 0);
111 bcopy ((void *)ivec, (void *)xor, sizeof(xor));
112 for (i = 0; len ; i++) {
113 data = rx_data(packet, i, tlen);
116 tlen = MIN(len, tlen);
117 fc_cbc_encrypt (data, data, tlen, schedule, xor, ENCRYPT);