Skip to content

Commit

Permalink
SUNRPC: Update the spkm3 code to use the make_checksum interface
Browse files Browse the repository at this point in the history
 Also update the tokenlen calculations to accomodate g_token_size().

 Signed-off-by: Andy Adamson <andros@citi.umich.edu>
 Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
 Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
J. Bruce Fields authored and Trond Myklebust committed Jan 6, 2006
1 parent 26c78e1 commit 9eed129
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/linux/sunrpc/gss_spkm3.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struc
#define CKSUMTYPE_RSA_MD5 0x0007

s32 make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
struct xdr_netobj *cksum);
int body_offset, struct xdr_netobj *cksum);
void asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits);
int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen,
int explen);
Expand Down
11 changes: 5 additions & 6 deletions net/sunrpc/auth_gss/gss_spkm3_seal.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spkm3_make_token(struct spkm3_ctx *ctx,
char tokhdrbuf[25];
struct xdr_netobj md5cksum = {.len = 0, .data = NULL};
struct xdr_netobj mic_hdr = {.len = 0, .data = tokhdrbuf};
int tmsglen, tokenlen = 0;
int tokenlen = 0;
unsigned char *ptr;
s32 now;
int ctxelen = 0, ctxzbit = 0;
Expand Down Expand Up @@ -92,24 +92,23 @@ spkm3_make_token(struct spkm3_ctx *ctx,
}

if (toktype == SPKM_MIC_TOK) {
tmsglen = 0;
/* Calculate checksum over the mic-header */
asn1_bitstring_len(&ctx->ctx_id, &ctxelen, &ctxzbit);
spkm3_mic_header(&mic_hdr.data, &mic_hdr.len, ctx->ctx_id.data,
ctxelen, ctxzbit);

if (make_checksum(checksum_type, mic_hdr.data, mic_hdr.len,
text, &md5cksum))
text, 0, &md5cksum))
goto out_err;

asn1_bitstring_len(&md5cksum, &md5elen, &md5zbit);
tokenlen = 10 + ctxelen + 1 + 2 + md5elen + 1;
tokenlen = 10 + ctxelen + 1 + md5elen + 1;

/* Create token header using generic routines */
token->len = g_token_size(&ctx->mech_used, tokenlen + tmsglen);
token->len = g_token_size(&ctx->mech_used, tokenlen);

ptr = token->data;
g_make_token_header(&ctx->mech_used, tokenlen + tmsglen, &ptr);
g_make_token_header(&ctx->mech_used, tokenlen, &ptr);

spkm3_make_mic_token(&ptr, tokenlen, &mic_hdr, &md5cksum, md5elen, md5zbit);
} else if (toktype == SPKM_WRAP_TOK) { /* Not Supported */
Expand Down
3 changes: 2 additions & 1 deletion net/sunrpc/auth_gss/gss_spkm3_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct
* *tokp points to the beginning of the SPKM_MIC token described
* in rfc 2025, section 3.2.1:
*
* toklen is the inner token length
*/
void
spkm3_make_mic_token(unsigned char **tokp, int toklen, struct xdr_netobj *mic_hdr, struct xdr_netobj *md5cksum, int md5elen, int md5zbit)
{
unsigned char *ict = *tokp;

*(u8 *)ict++ = 0xa4;
*(u8 *)ict++ = toklen - 2;
*(u8 *)ict++ = toklen;
memcpy(ict, mic_hdr->data, mic_hdr->len);
ict += mic_hdr->len;

Expand Down
2 changes: 1 addition & 1 deletion net/sunrpc/auth_gss/gss_spkm3_unseal.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spkm3_read_token(struct spkm3_ctx *ctx,
ret = GSS_S_DEFECTIVE_TOKEN;
code = make_checksum(CKSUMTYPE_RSA_MD5, ptr + 2,
mic_hdrlen + 2,
message_buffer, &md5cksum);
message_buffer, 0, &md5cksum);

if (code)
goto out;
Expand Down

0 comments on commit 9eed129

Please sign in to comment.