Skip to content

Commit a14a996

Browse files
committed
Return confidentiality status.
And make sure it is tested so it does not regress. Thanks to Jordan Borean for spotting this. Signed-off-by: Simo Sorce <[email protected]>
1 parent 1381897 commit a14a996

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

src/gss_signseal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ uint32_t gssntlm_wrap(uint32_t *minor_status,
161161
return GSSERRS(retmin, GSS_S_FAILURE);
162162
}
163163

164+
if (conf_state) {
165+
*conf_state = 1;
166+
}
164167
return GSSERRS(0, GSS_S_COMPLETE);
165168
}
166169

@@ -217,6 +220,9 @@ uint32_t gssntlm_unwrap(uint32_t *minor_status,
217220
return GSSERRS(0, GSS_S_BAD_SIG);
218221
}
219222

223+
if (conf_state) {
224+
*conf_state = 1;
225+
}
220226
return GSSERRS(0, GSS_S_COMPLETE);
221227
}
222228

tests/ntlmssptest.c

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ int test_gssapi_1(bool user_env_file, bool use_cb, bool no_seal)
14811481
gss_buffer_desc pwbuf;
14821482
gss_buffer_desc nbuf;
14831483
uint32_t retmin, retmaj;
1484-
const char *msg = "Sample, signature checking, message.";
1484+
const char *msg = "Sample, payload checking, message.";
14851485
gss_buffer_desc message = { strlen(msg), discard_const(msg) };
14861486
gss_buffer_desc ctx_token;
14871487
gss_OID actual_mech = GSS_C_NO_OID;
@@ -1494,6 +1494,7 @@ int test_gssapi_1(bool user_env_file, bool use_cb, bool no_seal)
14941494
};
14951495
uint32_t ssf, expect_ssf;
14961496
uint32_t req_flags;
1497+
int conf_state;
14971498
int ret;
14981499

14991500
setenv("NTLM_USER_FILE", TEST_USER_FILE, 0);
@@ -1720,24 +1721,62 @@ int test_gssapi_1(bool user_env_file, bool use_cb, bool no_seal)
17201721

17211722
gss_release_buffer(&retmin, &srv_token);
17221723

1723-
retmaj = gssntlm_wrap(&retmin, cli_ctx, 1, 0, &message, NULL, &cli_token);
1724+
retmaj = gssntlm_wrap(&retmin, cli_ctx, 1, 0, &message, &conf_state,
1725+
&cli_token);
17241726
if (retmaj != GSS_S_COMPLETE) {
17251727
print_gss_error("gssntlm_wrap(cli) failed!",
17261728
retmaj, retmin);
17271729
ret = EINVAL;
17281730
goto done;
17291731
}
1732+
if (conf_state == 0) {
1733+
fprintf(stderr, "WARN: gssntlm_wrap(cli) returned 0 conf_state!\n");
1734+
fflush(stderr);
1735+
}
17301736

17311737
retmaj = gssntlm_unwrap(&retmin, srv_ctx,
1732-
&cli_token, &srv_token, NULL, NULL);
1738+
&cli_token, &srv_token, &conf_state, NULL);
17331739
if (retmaj != GSS_S_COMPLETE) {
17341740
print_gss_error("gssntlm_unwrap(srv) failed!",
17351741
retmaj, retmin);
17361742
ret = EINVAL;
17371743
goto done;
17381744
}
1745+
if (conf_state == 0) {
1746+
fprintf(stderr, "WARN: gssntlm_wrap(srv) returned 0 conf_state!\n");
1747+
fflush(stderr);
1748+
}
17391749

1740-
if (memcmp(message.value, srv_token.value, srv_token.length) != 0) {
1750+
gss_release_buffer(&retmin, &cli_token);
1751+
gss_release_buffer(&retmin, &srv_token);
1752+
1753+
retmaj = gssntlm_wrap(&retmin, srv_ctx, 1, 0, &message, &conf_state,
1754+
&srv_token);
1755+
if (retmaj != GSS_S_COMPLETE) {
1756+
print_gss_error("gssntlm_wrap(srv) failed!",
1757+
retmaj, retmin);
1758+
ret = EINVAL;
1759+
goto done;
1760+
}
1761+
if (conf_state == 0) {
1762+
fprintf(stderr, "WARN: gssntlm_wrap(srv) returned 0 conf_state!\n");
1763+
fflush(stderr);
1764+
}
1765+
1766+
retmaj = gssntlm_unwrap(&retmin, cli_ctx,
1767+
&srv_token, &cli_token, &conf_state, NULL);
1768+
if (retmaj != GSS_S_COMPLETE) {
1769+
print_gss_error("gssntlm_unwrap(cli) failed!",
1770+
retmaj, retmin);
1771+
ret = EINVAL;
1772+
goto done;
1773+
}
1774+
if (conf_state == 0) {
1775+
fprintf(stderr, "WARN: gssntlm_wrap(cli) returned 0 conf_state!\n");
1776+
fflush(stderr);
1777+
}
1778+
1779+
if (memcmp(message.value, cli_token.value, cli_token.length) != 0) {
17411780
print_gss_error("sealing and unsealing failed to return the "
17421781
"same result",
17431782
retmaj, retmin);

0 commit comments

Comments
 (0)