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>
15 #include <afs/param.h>
21 #if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
24 #include "netinet/in.h"
26 #include "afs/sysincludes.h"
34 #include <rx/rx_packet.h>
35 #include <rx/rxkad_stats.h>
36 #include "private_data.h"
37 #define XPRT_RXKAD_CRYPT
40 rxkad_DecryptPacket(const struct rx_connection
*conn
,
41 const fc_KeySchedule
* schedule
,
42 const fc_InitializationVector
* ivec
, const int inlen
,
43 struct rx_packet
*packet
)
46 struct rx_securityClass
*obj
;
47 struct rxkad_cprivate
*tp
; /* s & c have type at same offset */
53 obj
= rx_SecurityObjectOf(conn
);
54 tp
= (struct rxkad_cprivate
*)obj
->privateData
;
55 ADD_RXKAD_STATS(bytesDecrypted
[rxkad_TypeIndex(tp
->type
)],len
);
56 memcpy((void *)xor, (void *)ivec
, sizeof(xor));
57 for (i
= 0; len
; i
++) {
58 data
= rx_data(packet
, i
, tlen
);
61 tlen
= MIN(len
, tlen
);
62 fc_cbc_encrypt(data
, data
, tlen
, *schedule
, xor, DECRYPT
);
65 /* Do this if packet checksums are ever enabled (below), but
66 * current version just passes zero
68 cksum = ntohl(rx_GetInt32(packet, 1));
74 rxkad_EncryptPacket(const struct rx_connection
* conn
,
75 const fc_KeySchedule
* schedule
,
76 const fc_InitializationVector
* ivec
, const int inlen
,
77 struct rx_packet
* packet
)
80 struct rx_securityClass
*obj
;
81 struct rxkad_cprivate
*tp
; /* s & c have type at same offset */
87 obj
= rx_SecurityObjectOf(conn
);
88 tp
= (struct rxkad_cprivate
*)obj
->privateData
;
89 ADD_RXKAD_STATS(bytesEncrypted
[rxkad_TypeIndex(tp
->type
)],len
);
93 * * Future option to add cksum here, but for now we just put 0
95 rx_PutInt32(packet
, 1 * sizeof(afs_int32
), 0);
97 memcpy((void *)xor, (void *)ivec
, sizeof(xor));
98 for (i
= 0; len
; i
++) {
99 data
= rx_data(packet
, i
, tlen
);
102 tlen
= MIN(len
, tlen
);
103 fc_cbc_encrypt(data
, data
, tlen
, *schedule
, xor, ENCRYPT
);