projects
/
cyrus-sasl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use draft-josefsson-gss-capsulate-01 if present
[cyrus-sasl.git]
/
plugins
/
gs2.c
diff --git
a/plugins/gs2.c
b/plugins/gs2.c
index
5afe7bb
..
1b6dc6a
100644
(file)
--- a/
plugins/gs2.c
+++ b/
plugins/gs2.c
@@
-1013,6
+1013,7
@@
gs2_verify_initial_message(context_t *text,
unsigned inlen,
gss_buffer_t token)
{
unsigned inlen,
gss_buffer_t token)
{
+ OM_uint32 major, minor;
char *p = (char *)in;
unsigned remain = inlen;
int ret;
char *p = (char *)in;
unsigned remain = inlen;
int ret;
@@
-1088,32
+1089,29
@@
gs2_verify_initial_message(context_t *text,
if (ret != SASL_OK)
return ret;
if (ret != SASL_OK)
return ret;
- buf.length = remain;
- buf.value = p;
-
if (text->gs2_flags & GS2_NONSTD_FLAG) {
if (text->gs2_flags & GS2_NONSTD_FLAG) {
- token->value = text->utils->malloc(buf.length);
- if (token->value == NULL)
- return SASL_NOMEM;
-
- token->length = buf.length;
- memcpy(token->value, buf.value, buf.length);
+ buf.length = remain;
+ buf.value = p;
} else {
} else {
-
unsigned int token_size
;
+
gss_buffer_desc tmp
;
- /* create a properly formed GSS token */
- token_size = gs2_token_size(text->mechanism, buf.length);
- token->value = text->utils->malloc(token_size);
- if (token->value == NULL)
+ tmp.length = remain;
+ tmp.value = p;
+
+ major = gss_encapsulate_token(&tmp, text->mechanism, &buf);
+ if (GSS_ERROR(major))
return SASL_NOMEM;
return SASL_NOMEM;
+ }
+
+ token->value = text->utils->malloc(buf.length);
+ if (token->value == NULL)
+ return SASL_NOMEM;
- token->length = token_size;
+ token->length = buf.length;
+ memcpy(token->value, buf.value, buf.length);
- p = (char *)token->value;
- gs2_make_token_header(text->mechanism, buf.length,
- (unsigned char **)&p);
- memcpy(p, buf.value, buf.length);
- }
+ if ((text->gs2_flags & GS2_NONSTD_FLAG) == 0)
+ gss_release_buffer(&minor, &buf);
return SASL_OK;
}
return SASL_OK;
}
@@
-1231,36
+1229,32
@@
gs2_make_message(context_t *text,
unsigned *outlen)
{
OM_uint32 major, minor;
unsigned *outlen)
{
OM_uint32 major, minor;
- unsigned char *mech_token_data;
- size_t mech_token_size;
- char *p;
- unsigned header_len = 0;
int ret;
int ret;
-
- mech_token_size = token->length;
- mech_token_data = (unsigned char *)token->value;
+ unsigned header_len = 0;
+ gss_buffer_desc decap_token = GSS_C_EMPTY_BUFFER;
if (initialContextToken) {
header_len = *outlen;
if (initialContextToken) {
header_len = *outlen;
- major = gs2_verify_token_header(&minor, text->mechanism,
- &mech_token_size, &mech_token_data,
- token->length);
+ major = gss_decapsulate_token(token, text->mechanism, &decap_token);
if ((major == GSS_S_DEFECTIVE_TOKEN &&
(text->plug.client->features & SASL_FEAT_GSS_FRAMING)) ||
GSS_ERROR(major))
return SASL_FAIL;
if ((major == GSS_S_DEFECTIVE_TOKEN &&
(text->plug.client->features & SASL_FEAT_GSS_FRAMING)) ||
GSS_ERROR(major))
return SASL_FAIL;
+
+ token = &decap_token;
}
ret = _plug_buf_alloc(text->utils, out, outlen,
}
ret = _plug_buf_alloc(text->utils, out, outlen,
- header_len +
mech_token_size
);
+ header_len +
token->length
);
if (ret != 0)
return ret;
if (ret != 0)
return ret;
-
p = *out + header_len
;
-
memcpy(p, mech_token_data, mech_token_size)
;
+
memcpy(*out + header_len, token->value, token->length)
;
+
*outlen = header_len + token->length
;
- *outlen = header_len + mech_token_size;
+ if (initialContextToken)
+ gss_release_buffer(&minor, &decap_token);
return SASL_OK;
}
return SASL_OK;
}