diff options
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_seal.c | 26 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_unseal.c | 16 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_wrap.c | 50 |
3 files changed, 46 insertions, 46 deletions
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c index 5f1d36dfbcf7..b8f42ef7178e 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seal.c +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c | |||
@@ -78,7 +78,7 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text, | |||
78 | struct krb5_ctx *ctx = gss_ctx->internal_ctx_id; | 78 | struct krb5_ctx *ctx = gss_ctx->internal_ctx_id; |
79 | char cksumdata[16]; | 79 | char cksumdata[16]; |
80 | struct xdr_netobj md5cksum = {.len = 0, .data = cksumdata}; | 80 | struct xdr_netobj md5cksum = {.len = 0, .data = cksumdata}; |
81 | unsigned char *ptr, *krb5_hdr, *msg_start; | 81 | unsigned char *ptr, *msg_start; |
82 | s32 now; | 82 | s32 now; |
83 | u32 seq_send; | 83 | u32 seq_send; |
84 | 84 | ||
@@ -87,36 +87,36 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text, | |||
87 | 87 | ||
88 | now = get_seconds(); | 88 | now = get_seconds(); |
89 | 89 | ||
90 | token->len = g_token_size(&ctx->mech_used, 24); | 90 | token->len = g_token_size(&ctx->mech_used, GSS_KRB5_TOK_HDR_LEN + 8); |
91 | 91 | ||
92 | ptr = token->data; | 92 | ptr = token->data; |
93 | g_make_token_header(&ctx->mech_used, 24, &ptr); | 93 | g_make_token_header(&ctx->mech_used, GSS_KRB5_TOK_HDR_LEN + 8, &ptr); |
94 | 94 | ||
95 | *ptr++ = (unsigned char) ((KG_TOK_MIC_MSG>>8)&0xff); | 95 | /* ptr now at header described in rfc 1964, section 1.2.1: */ |
96 | *ptr++ = (unsigned char) (KG_TOK_MIC_MSG&0xff); | 96 | ptr[0] = (unsigned char) ((KG_TOK_MIC_MSG >> 8) & 0xff); |
97 | ptr[1] = (unsigned char) (KG_TOK_MIC_MSG & 0xff); | ||
97 | 98 | ||
98 | /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */ | 99 | msg_start = ptr + GSS_KRB5_TOK_HDR_LEN + 8; |
99 | krb5_hdr = ptr - 2; | ||
100 | msg_start = krb5_hdr + 24; | ||
101 | 100 | ||
102 | *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5); | 101 | *(__be16 *)(ptr + 2) = htons(SGN_ALG_DES_MAC_MD5); |
103 | memset(krb5_hdr + 4, 0xff, 4); | 102 | memset(ptr + 4, 0xff, 4); |
104 | 103 | ||
105 | if (make_checksum("md5", krb5_hdr, 8, text, 0, &md5cksum)) | 104 | if (make_checksum("md5", ptr, 8, text, 0, &md5cksum)) |
106 | return GSS_S_FAILURE; | 105 | return GSS_S_FAILURE; |
107 | 106 | ||
108 | if (krb5_encrypt(ctx->seq, NULL, md5cksum.data, | 107 | if (krb5_encrypt(ctx->seq, NULL, md5cksum.data, |
109 | md5cksum.data, md5cksum.len)) | 108 | md5cksum.data, md5cksum.len)) |
110 | return GSS_S_FAILURE; | 109 | return GSS_S_FAILURE; |
111 | 110 | ||
112 | memcpy(krb5_hdr + 16, md5cksum.data + md5cksum.len - 8, 8); | 111 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data + md5cksum.len - 8, 8); |
113 | 112 | ||
114 | spin_lock(&krb5_seq_lock); | 113 | spin_lock(&krb5_seq_lock); |
115 | seq_send = ctx->seq_send++; | 114 | seq_send = ctx->seq_send++; |
116 | spin_unlock(&krb5_seq_lock); | 115 | spin_unlock(&krb5_seq_lock); |
117 | 116 | ||
118 | if (krb5_make_seq_num(ctx->seq, ctx->initiate ? 0 : 0xff, | 117 | if (krb5_make_seq_num(ctx->seq, ctx->initiate ? 0 : 0xff, |
119 | seq_send, krb5_hdr + 16, krb5_hdr + 8)) | 118 | seq_send, ptr + GSS_KRB5_TOK_HDR_LEN, |
119 | ptr + 8)) | ||
120 | return GSS_S_FAILURE; | 120 | return GSS_S_FAILURE; |
121 | 121 | ||
122 | return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; | 122 | return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; |
diff --git a/net/sunrpc/auth_gss/gss_krb5_unseal.c b/net/sunrpc/auth_gss/gss_krb5_unseal.c index d91a5d004803..066ec73c84d6 100644 --- a/net/sunrpc/auth_gss/gss_krb5_unseal.c +++ b/net/sunrpc/auth_gss/gss_krb5_unseal.c | |||
@@ -92,30 +92,30 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx, | |||
92 | read_token->len)) | 92 | read_token->len)) |
93 | return GSS_S_DEFECTIVE_TOKEN; | 93 | return GSS_S_DEFECTIVE_TOKEN; |
94 | 94 | ||
95 | if ((*ptr++ != ((KG_TOK_MIC_MSG>>8)&0xff)) || | 95 | if ((ptr[0] != ((KG_TOK_MIC_MSG >> 8) & 0xff)) || |
96 | (*ptr++ != ( KG_TOK_MIC_MSG &0xff)) ) | 96 | (ptr[1] != (KG_TOK_MIC_MSG & 0xff))) |
97 | return GSS_S_DEFECTIVE_TOKEN; | 97 | return GSS_S_DEFECTIVE_TOKEN; |
98 | 98 | ||
99 | /* XXX sanity-check bodysize?? */ | 99 | /* XXX sanity-check bodysize?? */ |
100 | 100 | ||
101 | signalg = ptr[0] + (ptr[1] << 8); | 101 | signalg = ptr[2] + (ptr[3] << 8); |
102 | if (signalg != SGN_ALG_DES_MAC_MD5) | 102 | if (signalg != SGN_ALG_DES_MAC_MD5) |
103 | return GSS_S_DEFECTIVE_TOKEN; | 103 | return GSS_S_DEFECTIVE_TOKEN; |
104 | 104 | ||
105 | sealalg = ptr[2] + (ptr[3] << 8); | 105 | sealalg = ptr[4] + (ptr[5] << 8); |
106 | if (sealalg != SEAL_ALG_NONE) | 106 | if (sealalg != SEAL_ALG_NONE) |
107 | return GSS_S_DEFECTIVE_TOKEN; | 107 | return GSS_S_DEFECTIVE_TOKEN; |
108 | 108 | ||
109 | if ((ptr[4] != 0xff) || (ptr[5] != 0xff)) | 109 | if ((ptr[6] != 0xff) || (ptr[7] != 0xff)) |
110 | return GSS_S_DEFECTIVE_TOKEN; | 110 | return GSS_S_DEFECTIVE_TOKEN; |
111 | 111 | ||
112 | if (make_checksum("md5", ptr - 2, 8, message_buffer, 0, &md5cksum)) | 112 | if (make_checksum("md5", ptr, 8, message_buffer, 0, &md5cksum)) |
113 | return GSS_S_FAILURE; | 113 | return GSS_S_FAILURE; |
114 | 114 | ||
115 | if (krb5_encrypt(ctx->seq, NULL, md5cksum.data, md5cksum.data, 16)) | 115 | if (krb5_encrypt(ctx->seq, NULL, md5cksum.data, md5cksum.data, 16)) |
116 | return GSS_S_FAILURE; | 116 | return GSS_S_FAILURE; |
117 | 117 | ||
118 | if (memcmp(md5cksum.data + 8, ptr + 14, 8)) | 118 | if (memcmp(md5cksum.data + 8, ptr + GSS_KRB5_TOK_HDR_LEN, 8)) |
119 | return GSS_S_BAD_SIG; | 119 | return GSS_S_BAD_SIG; |
120 | 120 | ||
121 | /* it got through unscathed. Make sure the context is unexpired */ | 121 | /* it got through unscathed. Make sure the context is unexpired */ |
@@ -127,7 +127,7 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx, | |||
127 | 127 | ||
128 | /* do sequencing checks */ | 128 | /* do sequencing checks */ |
129 | 129 | ||
130 | if (krb5_get_seq_num(ctx->seq, ptr + 14, ptr + 6, &direction, &seqnum)) | 130 | if (krb5_get_seq_num(ctx->seq, ptr + GSS_KRB5_TOK_HDR_LEN, ptr + 8, &direction, &seqnum)) |
131 | return GSS_S_FAILURE; | 131 | return GSS_S_FAILURE; |
132 | 132 | ||
133 | if ((ctx->initiate && direction != 0xff) || | 133 | if ((ctx->initiate && direction != 0xff) || |
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c index b00b1b426301..283cb25c6237 100644 --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c | |||
@@ -122,7 +122,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset, | |||
122 | char cksumdata[16]; | 122 | char cksumdata[16]; |
123 | struct xdr_netobj md5cksum = {.len = 0, .data = cksumdata}; | 123 | struct xdr_netobj md5cksum = {.len = 0, .data = cksumdata}; |
124 | int blocksize = 0, plainlen; | 124 | int blocksize = 0, plainlen; |
125 | unsigned char *ptr, *krb5_hdr, *msg_start; | 125 | unsigned char *ptr, *msg_start; |
126 | s32 now; | 126 | s32 now; |
127 | int headlen; | 127 | int headlen; |
128 | struct page **tmp_pages; | 128 | struct page **tmp_pages; |
@@ -149,26 +149,26 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset, | |||
149 | buf->len += headlen; | 149 | buf->len += headlen; |
150 | BUG_ON((buf->len - offset - headlen) % blocksize); | 150 | BUG_ON((buf->len - offset - headlen) % blocksize); |
151 | 151 | ||
152 | g_make_token_header(&kctx->mech_used, 24 + plainlen, &ptr); | 152 | g_make_token_header(&kctx->mech_used, |
153 | GSS_KRB5_TOK_HDR_LEN + 8 + plainlen, &ptr); | ||
153 | 154 | ||
154 | 155 | ||
155 | *ptr++ = (unsigned char) ((KG_TOK_WRAP_MSG>>8)&0xff); | 156 | /* ptr now at header described in rfc 1964, section 1.2.1: */ |
156 | *ptr++ = (unsigned char) (KG_TOK_WRAP_MSG&0xff); | 157 | ptr[0] = (unsigned char) ((KG_TOK_WRAP_MSG >> 8) & 0xff); |
158 | ptr[1] = (unsigned char) (KG_TOK_WRAP_MSG & 0xff); | ||
157 | 159 | ||
158 | /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */ | 160 | msg_start = ptr + 24; |
159 | krb5_hdr = ptr - 2; | ||
160 | msg_start = krb5_hdr + 24; | ||
161 | 161 | ||
162 | *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5); | 162 | *(__be16 *)(ptr + 2) = htons(SGN_ALG_DES_MAC_MD5); |
163 | memset(krb5_hdr + 4, 0xff, 4); | 163 | memset(ptr + 4, 0xff, 4); |
164 | *(__be16 *)(krb5_hdr + 4) = htons(SEAL_ALG_DES); | 164 | *(__be16 *)(ptr + 4) = htons(SEAL_ALG_DES); |
165 | 165 | ||
166 | make_confounder(msg_start, blocksize); | 166 | make_confounder(msg_start, blocksize); |
167 | 167 | ||
168 | /* XXXJBF: UGH!: */ | 168 | /* XXXJBF: UGH!: */ |
169 | tmp_pages = buf->pages; | 169 | tmp_pages = buf->pages; |
170 | buf->pages = pages; | 170 | buf->pages = pages; |
171 | if (make_checksum("md5", krb5_hdr, 8, buf, | 171 | if (make_checksum("md5", ptr, 8, buf, |
172 | offset + headlen - blocksize, &md5cksum)) | 172 | offset + headlen - blocksize, &md5cksum)) |
173 | return GSS_S_FAILURE; | 173 | return GSS_S_FAILURE; |
174 | buf->pages = tmp_pages; | 174 | buf->pages = tmp_pages; |
@@ -176,7 +176,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset, | |||
176 | if (krb5_encrypt(kctx->seq, NULL, md5cksum.data, | 176 | if (krb5_encrypt(kctx->seq, NULL, md5cksum.data, |
177 | md5cksum.data, md5cksum.len)) | 177 | md5cksum.data, md5cksum.len)) |
178 | return GSS_S_FAILURE; | 178 | return GSS_S_FAILURE; |
179 | memcpy(krb5_hdr + 16, md5cksum.data + md5cksum.len - 8, 8); | 179 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data + md5cksum.len - 8, 8); |
180 | 180 | ||
181 | spin_lock(&krb5_seq_lock); | 181 | spin_lock(&krb5_seq_lock); |
182 | seq_send = kctx->seq_send++; | 182 | seq_send = kctx->seq_send++; |
@@ -185,7 +185,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset, | |||
185 | /* XXX would probably be more efficient to compute checksum | 185 | /* XXX would probably be more efficient to compute checksum |
186 | * and encrypt at the same time: */ | 186 | * and encrypt at the same time: */ |
187 | if ((krb5_make_seq_num(kctx->seq, kctx->initiate ? 0 : 0xff, | 187 | if ((krb5_make_seq_num(kctx->seq, kctx->initiate ? 0 : 0xff, |
188 | seq_send, krb5_hdr + 16, krb5_hdr + 8))) | 188 | seq_send, ptr + GSS_KRB5_TOK_HDR_LEN, ptr + 8))) |
189 | return GSS_S_FAILURE; | 189 | return GSS_S_FAILURE; |
190 | 190 | ||
191 | if (gss_encrypt_xdr_buf(kctx->enc, buf, offset + headlen - blocksize, | 191 | if (gss_encrypt_xdr_buf(kctx->enc, buf, offset + headlen - blocksize, |
@@ -219,38 +219,38 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf) | |||
219 | buf->len - offset)) | 219 | buf->len - offset)) |
220 | return GSS_S_DEFECTIVE_TOKEN; | 220 | return GSS_S_DEFECTIVE_TOKEN; |
221 | 221 | ||
222 | if ((*ptr++ != ((KG_TOK_WRAP_MSG>>8)&0xff)) || | 222 | if ((ptr[0] != ((KG_TOK_WRAP_MSG >> 8) & 0xff)) || |
223 | (*ptr++ != (KG_TOK_WRAP_MSG &0xff)) ) | 223 | (ptr[1] != (KG_TOK_WRAP_MSG & 0xff))) |
224 | return GSS_S_DEFECTIVE_TOKEN; | 224 | return GSS_S_DEFECTIVE_TOKEN; |
225 | 225 | ||
226 | /* XXX sanity-check bodysize?? */ | 226 | /* XXX sanity-check bodysize?? */ |
227 | 227 | ||
228 | /* get the sign and seal algorithms */ | 228 | /* get the sign and seal algorithms */ |
229 | 229 | ||
230 | signalg = ptr[0] + (ptr[1] << 8); | 230 | signalg = ptr[2] + (ptr[3] << 8); |
231 | if (signalg != SGN_ALG_DES_MAC_MD5) | 231 | if (signalg != SGN_ALG_DES_MAC_MD5) |
232 | return GSS_S_DEFECTIVE_TOKEN; | 232 | return GSS_S_DEFECTIVE_TOKEN; |
233 | 233 | ||
234 | sealalg = ptr[2] + (ptr[3] << 8); | 234 | sealalg = ptr[4] + (ptr[5] << 8); |
235 | if (sealalg != SEAL_ALG_DES) | 235 | if (sealalg != SEAL_ALG_DES) |
236 | return GSS_S_DEFECTIVE_TOKEN; | 236 | return GSS_S_DEFECTIVE_TOKEN; |
237 | 237 | ||
238 | if ((ptr[4] != 0xff) || (ptr[5] != 0xff)) | 238 | if ((ptr[6] != 0xff) || (ptr[7] != 0xff)) |
239 | return GSS_S_DEFECTIVE_TOKEN; | 239 | return GSS_S_DEFECTIVE_TOKEN; |
240 | 240 | ||
241 | if (gss_decrypt_xdr_buf(kctx->enc, buf, | 241 | if (gss_decrypt_xdr_buf(kctx->enc, buf, |
242 | ptr + 22 - (unsigned char *)buf->head[0].iov_base)) | 242 | ptr + GSS_KRB5_TOK_HDR_LEN + 8 - (unsigned char *)buf->head[0].iov_base)) |
243 | return GSS_S_DEFECTIVE_TOKEN; | 243 | return GSS_S_DEFECTIVE_TOKEN; |
244 | 244 | ||
245 | if (make_checksum("md5", ptr - 2, 8, buf, | 245 | if (make_checksum("md5", ptr, 8, buf, |
246 | ptr + 22 - (unsigned char *)buf->head[0].iov_base, &md5cksum)) | 246 | ptr + GSS_KRB5_TOK_HDR_LEN + 8 - (unsigned char *)buf->head[0].iov_base, &md5cksum)) |
247 | return GSS_S_FAILURE; | 247 | return GSS_S_FAILURE; |
248 | 248 | ||
249 | if (krb5_encrypt(kctx->seq, NULL, md5cksum.data, | 249 | if (krb5_encrypt(kctx->seq, NULL, md5cksum.data, |
250 | md5cksum.data, md5cksum.len)) | 250 | md5cksum.data, md5cksum.len)) |
251 | return GSS_S_FAILURE; | 251 | return GSS_S_FAILURE; |
252 | 252 | ||
253 | if (memcmp(md5cksum.data + 8, ptr + 14, 8)) | 253 | if (memcmp(md5cksum.data + 8, ptr + GSS_KRB5_TOK_HDR_LEN, 8)) |
254 | return GSS_S_BAD_SIG; | 254 | return GSS_S_BAD_SIG; |
255 | 255 | ||
256 | /* it got through unscathed. Make sure the context is unexpired */ | 256 | /* it got through unscathed. Make sure the context is unexpired */ |
@@ -262,8 +262,8 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf) | |||
262 | 262 | ||
263 | /* do sequencing checks */ | 263 | /* do sequencing checks */ |
264 | 264 | ||
265 | if (krb5_get_seq_num(kctx->seq, ptr + 14, ptr + 6, &direction, | 265 | if (krb5_get_seq_num(kctx->seq, ptr + GSS_KRB5_TOK_HDR_LEN, ptr + 8, |
266 | &seqnum)) | 266 | &direction, &seqnum)) |
267 | return GSS_S_BAD_SIG; | 267 | return GSS_S_BAD_SIG; |
268 | 268 | ||
269 | if ((kctx->initiate && direction != 0xff) || | 269 | if ((kctx->initiate && direction != 0xff) || |
@@ -274,7 +274,7 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf) | |||
274 | * better to copy and encrypt at the same time. */ | 274 | * better to copy and encrypt at the same time. */ |
275 | 275 | ||
276 | blocksize = crypto_blkcipher_blocksize(kctx->enc); | 276 | blocksize = crypto_blkcipher_blocksize(kctx->enc); |
277 | data_start = ptr + 22 + blocksize; | 277 | data_start = ptr + GSS_KRB5_TOK_HDR_LEN + 8 + blocksize; |
278 | orig_start = buf->head[0].iov_base + offset; | 278 | orig_start = buf->head[0].iov_base + offset; |
279 | data_len = (buf->head[0].iov_base + buf->head[0].iov_len) - data_start; | 279 | data_len = (buf->head[0].iov_base + buf->head[0].iov_len) - data_start; |
280 | memmove(orig_start, data_start, data_len); | 280 | memmove(orig_start, data_start, data_len); |