34 #include <linux/types.h>
35 #include <linux/module.h>
36 #include <linux/string.h>
42 # define RPCDBG_FACILITY RPCDBG_AUTH
47 #define TWRITE_STR(ptr, str, len) \
48 memcpy((ptr), (char *) (str), (len)); \
76 der_length_size(
int length)
80 else if (length < (1<<8))
86 else if (length < (1<<16))
88 else if (length < (1<<24))
96 der_write_length(
unsigned char **
buf,
int length)
98 if (length < (1<<7)) {
99 *(*buf)++ = (
unsigned char) length;
101 *(*buf)++ = (
unsigned char) (der_length_size(length)+127);
103 if (length >= (1<<24))
104 *(*buf)++ = (
unsigned char) (length>>24);
105 if (length >= (1<<16))
106 *(*buf)++ = (
unsigned char) ((length>>16)&0xff);
108 if (length >= (1<<8))
109 *(*buf)++ = (
unsigned char) ((length>>8)&0xff);
110 *(*buf)++ = (
unsigned char) (length&0xff);
118 der_read_length(
unsigned char **buf,
int *
bufsize)
128 if ((sf &= 0x7f) > ((*bufsize)-1))
134 ret = (ret<<8) + (*(*buf)++);
150 body_size += 2 + (
int) mech->len;
151 return 1 + der_length_size(body_size) + body_size;
163 der_write_length(buf, 2 + mech->len + body_size);
165 *(*buf)++ = (
unsigned char) mech->len;
166 TWRITE_STR(*buf, mech->data, ((
int) mech->len));
181 unsigned char **buf_in,
int toksize)
183 unsigned char *buf = *buf_in;
185 struct xdr_netobj toid;
188 if ((toksize-=1) < 0)
193 if ((seqsize = der_read_length(&buf, &toksize)) < 0)
196 if (seqsize != toksize)
199 if ((toksize-=1) < 0)
204 if ((toksize-=1) < 0)
208 if ((toksize-=toid.len) < 0)
219 if ((toksize-=2) < 0)
227 *body_size = toksize;