2 Unix SMB/CIFS implementation.
4 RFC2478 Compliant SPNEGO implementation
6 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
8 Copyright (C) Stefan Metzmacher <metze@samba.org> 2004-2008
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "../libcli/auth/spnego.h"
27 #include "librpc/gen_ndr/ndr_dcerpc.h"
28 #include "auth/credentials/credentials.h"
29 #include "auth/gensec/gensec.h"
30 #include "auth/gensec/gensec_internal.h"
31 #include "param/param.h"
32 #include "lib/util/asn1.h"
36 _PUBLIC_ NTSTATUS
gensec_spnego_init(void);
38 enum spnego_state_position
{
48 enum spnego_message_type expected_packet
;
49 enum spnego_state_position state_position
;
50 struct gensec_security
*sub_sec_security
;
51 bool no_response_expected
;
58 * The following is used to implement
59 * the update token fragmentation
63 size_t out_max_length
;
69 static NTSTATUS
gensec_spnego_client_start(struct gensec_security
*gensec_security
)
71 struct spnego_state
*spnego_state
;
73 spnego_state
= talloc_zero(gensec_security
, struct spnego_state
);
75 return NT_STATUS_NO_MEMORY
;
78 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_INIT
;
79 spnego_state
->state_position
= SPNEGO_CLIENT_START
;
80 spnego_state
->sub_sec_security
= NULL
;
81 spnego_state
->no_response_expected
= false;
82 spnego_state
->mech_types
= data_blob(NULL
, 0);
83 spnego_state
->out_max_length
= gensec_max_update_size(gensec_security
);
84 spnego_state
->out_status
= NT_STATUS_MORE_PROCESSING_REQUIRED
;
86 gensec_security
->private_data
= spnego_state
;
90 static NTSTATUS
gensec_spnego_server_start(struct gensec_security
*gensec_security
)
92 struct spnego_state
*spnego_state
;
94 spnego_state
= talloc_zero(gensec_security
, struct spnego_state
);
96 return NT_STATUS_NO_MEMORY
;
99 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_INIT
;
100 spnego_state
->state_position
= SPNEGO_SERVER_START
;
101 spnego_state
->sub_sec_security
= NULL
;
102 spnego_state
->no_response_expected
= false;
103 spnego_state
->mech_types
= data_blob(NULL
, 0);
104 spnego_state
->out_max_length
= gensec_max_update_size(gensec_security
);
105 spnego_state
->out_status
= NT_STATUS_MORE_PROCESSING_REQUIRED
;
107 gensec_security
->private_data
= spnego_state
;
112 wrappers for the spnego_*() functions
114 static NTSTATUS
gensec_spnego_unseal_packet(struct gensec_security
*gensec_security
,
115 uint8_t *data
, size_t length
,
116 const uint8_t *whole_pdu
, size_t pdu_length
,
117 const DATA_BLOB
*sig
)
119 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
121 if (spnego_state
->state_position
!= SPNEGO_DONE
122 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
123 return NT_STATUS_INVALID_PARAMETER
;
126 return gensec_unseal_packet(spnego_state
->sub_sec_security
,
128 whole_pdu
, pdu_length
,
132 static NTSTATUS
gensec_spnego_check_packet(struct gensec_security
*gensec_security
,
133 const uint8_t *data
, size_t length
,
134 const uint8_t *whole_pdu
, size_t pdu_length
,
135 const DATA_BLOB
*sig
)
137 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
139 if (spnego_state
->state_position
!= SPNEGO_DONE
140 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
141 return NT_STATUS_INVALID_PARAMETER
;
144 return gensec_check_packet(spnego_state
->sub_sec_security
,
146 whole_pdu
, pdu_length
,
150 static NTSTATUS
gensec_spnego_seal_packet(struct gensec_security
*gensec_security
,
152 uint8_t *data
, size_t length
,
153 const uint8_t *whole_pdu
, size_t pdu_length
,
156 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
158 if (spnego_state
->state_position
!= SPNEGO_DONE
159 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
160 return NT_STATUS_INVALID_PARAMETER
;
163 return gensec_seal_packet(spnego_state
->sub_sec_security
,
166 whole_pdu
, pdu_length
,
170 static NTSTATUS
gensec_spnego_sign_packet(struct gensec_security
*gensec_security
,
172 const uint8_t *data
, size_t length
,
173 const uint8_t *whole_pdu
, size_t pdu_length
,
176 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
178 if (spnego_state
->state_position
!= SPNEGO_DONE
179 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
180 return NT_STATUS_INVALID_PARAMETER
;
183 return gensec_sign_packet(spnego_state
->sub_sec_security
,
186 whole_pdu
, pdu_length
,
190 static NTSTATUS
gensec_spnego_wrap(struct gensec_security
*gensec_security
,
195 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
197 if (spnego_state
->state_position
!= SPNEGO_DONE
198 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
199 DEBUG(1, ("gensec_spnego_wrap: wrong state for wrap\n"));
200 return NT_STATUS_INVALID_PARAMETER
;
203 return gensec_wrap(spnego_state
->sub_sec_security
,
207 static NTSTATUS
gensec_spnego_unwrap(struct gensec_security
*gensec_security
,
212 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
214 if (spnego_state
->state_position
!= SPNEGO_DONE
215 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
216 DEBUG(1, ("gensec_spnego_unwrap: wrong state for unwrap\n"));
217 return NT_STATUS_INVALID_PARAMETER
;
220 return gensec_unwrap(spnego_state
->sub_sec_security
,
224 static NTSTATUS
gensec_spnego_wrap_packets(struct gensec_security
*gensec_security
,
228 size_t *len_processed
)
230 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
232 if (spnego_state
->state_position
!= SPNEGO_DONE
233 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
234 DEBUG(1, ("gensec_spnego_wrap: wrong state for wrap\n"));
235 return NT_STATUS_INVALID_PARAMETER
;
238 return gensec_wrap_packets(spnego_state
->sub_sec_security
,
243 static NTSTATUS
gensec_spnego_packet_full_request(struct gensec_security
*gensec_security
,
244 DATA_BLOB blob
, size_t *size
)
246 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
248 if (spnego_state
->state_position
!= SPNEGO_DONE
249 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
250 DEBUG(1, ("gensec_spnego_unwrap: wrong state for unwrap\n"));
251 return NT_STATUS_INVALID_PARAMETER
;
254 return gensec_packet_full_request(spnego_state
->sub_sec_security
,
258 static NTSTATUS
gensec_spnego_unwrap_packets(struct gensec_security
*gensec_security
,
262 size_t *len_processed
)
264 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
266 if (spnego_state
->state_position
!= SPNEGO_DONE
267 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
268 DEBUG(1, ("gensec_spnego_unwrap: wrong state for unwrap\n"));
269 return NT_STATUS_INVALID_PARAMETER
;
272 return gensec_unwrap_packets(spnego_state
->sub_sec_security
,
277 static size_t gensec_spnego_sig_size(struct gensec_security
*gensec_security
, size_t data_size
)
279 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
281 if (spnego_state
->state_position
!= SPNEGO_DONE
282 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
286 return gensec_sig_size(spnego_state
->sub_sec_security
, data_size
);
289 static size_t gensec_spnego_max_input_size(struct gensec_security
*gensec_security
)
291 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
293 if (spnego_state
->state_position
!= SPNEGO_DONE
294 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
298 return gensec_max_input_size(spnego_state
->sub_sec_security
);
301 static size_t gensec_spnego_max_wrapped_size(struct gensec_security
*gensec_security
)
303 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
305 if (spnego_state
->state_position
!= SPNEGO_DONE
306 && spnego_state
->state_position
!= SPNEGO_FALLBACK
) {
310 return gensec_max_wrapped_size(spnego_state
->sub_sec_security
);
313 static NTSTATUS
gensec_spnego_session_key(struct gensec_security
*gensec_security
,
315 DATA_BLOB
*session_key
)
317 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
318 if (!spnego_state
->sub_sec_security
) {
319 return NT_STATUS_INVALID_PARAMETER
;
322 return gensec_session_key(spnego_state
->sub_sec_security
,
327 static NTSTATUS
gensec_spnego_session_info(struct gensec_security
*gensec_security
,
329 struct auth_session_info
**session_info
)
331 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
332 if (!spnego_state
->sub_sec_security
) {
333 return NT_STATUS_INVALID_PARAMETER
;
336 return gensec_session_info(spnego_state
->sub_sec_security
,
341 /** Fallback to another GENSEC mechanism, based on magic strings
343 * This is the 'fallback' case, where we don't get SPNEGO, and have to
344 * try all the other options (and hope they all have a magic string
348 static NTSTATUS
gensec_spnego_server_try_fallback(struct gensec_security
*gensec_security
,
349 struct spnego_state
*spnego_state
,
350 struct tevent_context
*ev
,
351 TALLOC_CTX
*out_mem_ctx
,
352 const DATA_BLOB in
, DATA_BLOB
*out
)
355 const struct gensec_security_ops
**all_ops
;
357 all_ops
= gensec_security_mechs(gensec_security
, out_mem_ctx
);
359 for (i
=0; all_ops
&& all_ops
[i
]; i
++) {
363 if (gensec_security
!= NULL
&&
364 !gensec_security_ops_enabled(all_ops
[i
], gensec_security
))
367 if (!all_ops
[i
]->oid
) {
372 for (j
=0; all_ops
[i
]->oid
[j
]; j
++) {
373 if (strcasecmp(GENSEC_OID_SPNEGO
,all_ops
[i
]->oid
[j
]) == 0) {
381 if (!all_ops
[i
]->magic
) {
385 nt_status
= all_ops
[i
]->magic(gensec_security
, &in
);
386 if (!NT_STATUS_IS_OK(nt_status
)) {
390 spnego_state
->state_position
= SPNEGO_FALLBACK
;
392 nt_status
= gensec_subcontext_start(spnego_state
,
394 &spnego_state
->sub_sec_security
);
396 if (!NT_STATUS_IS_OK(nt_status
)) {
399 /* select the sub context */
400 nt_status
= gensec_start_mech_by_ops(spnego_state
->sub_sec_security
,
402 if (!NT_STATUS_IS_OK(nt_status
)) {
405 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
406 ev
, out_mem_ctx
, in
, out
);
409 DEBUG(1, ("Failed to parse SPNEGO request\n"));
410 return NT_STATUS_INVALID_PARAMETER
;
414 Parse the netTokenInit, either from the client, to the server, or
415 from the server to the client.
418 static NTSTATUS
gensec_spnego_parse_negTokenInit(struct gensec_security
*gensec_security
,
419 struct spnego_state
*spnego_state
,
420 TALLOC_CTX
*out_mem_ctx
,
421 struct tevent_context
*ev
,
422 const char * const *mechType
,
423 const DATA_BLOB unwrapped_in
, DATA_BLOB
*unwrapped_out
)
426 NTSTATUS nt_status
= NT_STATUS_INVALID_PARAMETER
;
427 DATA_BLOB null_data_blob
= data_blob(NULL
,0);
430 const struct gensec_security_ops_wrapper
*all_sec
431 = gensec_security_by_oid_list(gensec_security
,
436 ok
= spnego_write_mech_types(spnego_state
,
438 &spnego_state
->mech_types
);
440 DEBUG(1, ("SPNEGO: Failed to write mechTypes\n"));
441 return NT_STATUS_NO_MEMORY
;
444 if (spnego_state
->state_position
== SPNEGO_SERVER_START
) {
446 for (j
=0; mechType
&& mechType
[j
]; j
++) {
447 for (i
=0; all_sec
&& all_sec
[i
].op
; i
++) {
448 if (strcmp(mechType
[j
], all_sec
[i
].oid
) != 0) {
452 nt_status
= gensec_subcontext_start(spnego_state
,
454 &spnego_state
->sub_sec_security
);
455 if (!NT_STATUS_IS_OK(nt_status
)) {
458 /* select the sub context */
459 nt_status
= gensec_start_mech_by_ops(spnego_state
->sub_sec_security
,
461 if (!NT_STATUS_IS_OK(nt_status
)) {
462 talloc_free(spnego_state
->sub_sec_security
);
463 spnego_state
->sub_sec_security
= NULL
;
468 /* no optimistic token */
469 spnego_state
->neg_oid
= all_sec
[i
].oid
;
470 *unwrapped_out
= data_blob_null
;
471 nt_status
= NT_STATUS_MORE_PROCESSING_REQUIRED
;
475 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
480 if (NT_STATUS_EQUAL(nt_status
, NT_STATUS_INVALID_PARAMETER
) ||
481 NT_STATUS_EQUAL(nt_status
, NT_STATUS_CANT_ACCESS_DOMAIN_INFO
)) {
482 /* Pretend we never started it (lets the first run find some incompatible demand) */
484 DEBUG(1, ("SPNEGO(%s) NEG_TOKEN_INIT failed to parse contents: %s\n",
485 spnego_state
->sub_sec_security
->ops
->name
, nt_errstr(nt_status
)));
486 talloc_free(spnego_state
->sub_sec_security
);
487 spnego_state
->sub_sec_security
= NULL
;
491 spnego_state
->neg_oid
= all_sec
[i
].oid
;
494 if (spnego_state
->sub_sec_security
) {
499 if (!spnego_state
->sub_sec_security
) {
500 DEBUG(1, ("SPNEGO: Could not find a suitable mechtype in NEG_TOKEN_INIT\n"));
501 return NT_STATUS_INVALID_PARAMETER
;
505 /* Having tried any optimistic token from the client (if we
506 * were the server), if we didn't get anywhere, walk our list
507 * in our preference order */
509 if (!spnego_state
->sub_sec_security
) {
510 for (i
=0; all_sec
&& all_sec
[i
].op
; i
++) {
511 nt_status
= gensec_subcontext_start(spnego_state
,
513 &spnego_state
->sub_sec_security
);
514 if (!NT_STATUS_IS_OK(nt_status
)) {
517 /* select the sub context */
518 nt_status
= gensec_start_mech_by_ops(spnego_state
->sub_sec_security
,
520 if (!NT_STATUS_IS_OK(nt_status
)) {
521 talloc_free(spnego_state
->sub_sec_security
);
522 spnego_state
->sub_sec_security
= NULL
;
526 spnego_state
->neg_oid
= all_sec
[i
].oid
;
528 /* only get the helping start blob for the first OID */
529 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
535 /* it is likely that a NULL input token will
536 * not be liked by most server mechs, but if
537 * we are in the client, we want the first
538 * update packet to be able to abort the use
540 if (spnego_state
->state_position
!= SPNEGO_SERVER_START
) {
541 if (NT_STATUS_EQUAL(nt_status
, NT_STATUS_INVALID_PARAMETER
) ||
542 NT_STATUS_EQUAL(nt_status
, NT_STATUS_NO_LOGON_SERVERS
) ||
543 NT_STATUS_EQUAL(nt_status
, NT_STATUS_TIME_DIFFERENCE_AT_DC
) ||
544 NT_STATUS_EQUAL(nt_status
, NT_STATUS_CANT_ACCESS_DOMAIN_INFO
)) {
545 /* Pretend we never started it (lets the first run find some incompatible demand) */
547 DEBUG(3, ("SPNEGO(%s) NEG_TOKEN_INIT failed: %s\n",
548 spnego_state
->sub_sec_security
->ops
->name
, nt_errstr(nt_status
)));
549 talloc_free(spnego_state
->sub_sec_security
);
550 spnego_state
->sub_sec_security
= NULL
;
559 if (spnego_state
->sub_sec_security
) {
560 /* it is likely that a NULL input token will
561 * not be liked by most server mechs, but this
562 * does the right thing in the CIFS client.
563 * just push us along the merry-go-round
564 * again, and hope for better luck next
567 if (NT_STATUS_EQUAL(nt_status
, NT_STATUS_INVALID_PARAMETER
)) {
568 *unwrapped_out
= data_blob(NULL
, 0);
569 nt_status
= NT_STATUS_MORE_PROCESSING_REQUIRED
;
572 if (!NT_STATUS_EQUAL(nt_status
, NT_STATUS_INVALID_PARAMETER
)
573 && !NT_STATUS_EQUAL(nt_status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)
574 && !NT_STATUS_IS_OK(nt_status
)) {
575 DEBUG(1, ("SPNEGO(%s) NEG_TOKEN_INIT failed: %s\n",
576 spnego_state
->sub_sec_security
->ops
->name
, nt_errstr(nt_status
)));
577 talloc_free(spnego_state
->sub_sec_security
);
578 spnego_state
->sub_sec_security
= NULL
;
580 /* We started the mech correctly, and the
581 * input from the other side was valid.
582 * Return the error (say bad password, invalid
587 return nt_status
; /* OK, INVALID_PARAMETER ore MORE PROCESSING */
590 DEBUG(1, ("SPNEGO: Could not find a suitable mechtype in NEG_TOKEN_INIT\n"));
591 /* we could re-negotiate here, but it would only work
592 * if the client or server lied about what it could
593 * support the first time. Lets keep this code to
599 /** create a negTokenInit
601 * This is the same packet, no matter if the client or server sends it first, but it is always the first packet
603 static NTSTATUS
gensec_spnego_create_negTokenInit(struct gensec_security
*gensec_security
,
604 struct spnego_state
*spnego_state
,
605 TALLOC_CTX
*out_mem_ctx
,
606 struct tevent_context
*ev
,
607 const DATA_BLOB in
, DATA_BLOB
*out
)
610 NTSTATUS nt_status
= NT_STATUS_INVALID_PARAMETER
;
611 DATA_BLOB null_data_blob
= data_blob(NULL
,0);
612 const char **mechTypes
= NULL
;
613 DATA_BLOB unwrapped_out
= data_blob(NULL
, 0);
614 const struct gensec_security_ops_wrapper
*all_sec
;
616 mechTypes
= gensec_security_oids(gensec_security
,
617 out_mem_ctx
, GENSEC_OID_SPNEGO
);
619 all_sec
= gensec_security_by_oid_list(gensec_security
,
623 for (i
=0; all_sec
&& all_sec
[i
].op
; i
++) {
624 struct spnego_data spnego_out
;
625 const char **send_mech_types
;
628 nt_status
= gensec_subcontext_start(spnego_state
,
630 &spnego_state
->sub_sec_security
);
631 if (!NT_STATUS_IS_OK(nt_status
)) {
634 /* select the sub context */
635 nt_status
= gensec_start_mech_by_ops(spnego_state
->sub_sec_security
,
637 if (!NT_STATUS_IS_OK(nt_status
)) {
638 talloc_free(spnego_state
->sub_sec_security
);
639 spnego_state
->sub_sec_security
= NULL
;
643 /* In the client, try and produce the first (optimistic) packet */
644 if (spnego_state
->state_position
== SPNEGO_CLIENT_START
) {
645 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
651 if (!NT_STATUS_EQUAL(nt_status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)
652 && !NT_STATUS_IS_OK(nt_status
)) {
653 DEBUG(1, ("SPNEGO(%s) creating NEG_TOKEN_INIT failed: %s\n",
654 spnego_state
->sub_sec_security
->ops
->name
, nt_errstr(nt_status
)));
655 talloc_free(spnego_state
->sub_sec_security
);
656 spnego_state
->sub_sec_security
= NULL
;
657 /* Pretend we never started it (lets the first run find some incompatible demand) */
663 spnego_out
.type
= SPNEGO_NEG_TOKEN_INIT
;
665 send_mech_types
= gensec_security_oids_from_ops_wrapped(out_mem_ctx
,
668 ok
= spnego_write_mech_types(spnego_state
,
670 &spnego_state
->mech_types
);
672 DEBUG(1, ("SPNEGO: Failed to write mechTypes\n"));
673 return NT_STATUS_NO_MEMORY
;
676 /* List the remaining mechs as options */
677 spnego_out
.negTokenInit
.mechTypes
= send_mech_types
;
678 spnego_out
.negTokenInit
.reqFlags
= null_data_blob
;
679 spnego_out
.negTokenInit
.reqFlagsPadding
= 0;
681 if (spnego_state
->state_position
== SPNEGO_SERVER_START
) {
682 spnego_out
.negTokenInit
.mechListMIC
683 = data_blob_string_const(ADS_IGNORE_PRINCIPAL
);
685 spnego_out
.negTokenInit
.mechListMIC
= null_data_blob
;
688 spnego_out
.negTokenInit
.mechToken
= unwrapped_out
;
690 if (spnego_write_data(out_mem_ctx
, out
, &spnego_out
) == -1) {
691 DEBUG(1, ("Failed to write NEG_TOKEN_INIT\n"));
692 return NT_STATUS_INVALID_PARAMETER
;
696 spnego_state
->neg_oid
= all_sec
[i
].oid
;
698 if (NT_STATUS_IS_OK(nt_status
)) {
699 spnego_state
->no_response_expected
= true;
702 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
704 talloc_free(spnego_state
->sub_sec_security
);
705 spnego_state
->sub_sec_security
= NULL
;
707 DEBUG(1, ("Failed to setup SPNEGO negTokenInit request: %s\n", nt_errstr(nt_status
)));
712 /** create a server negTokenTarg
714 * This is the case, where the client is the first one who sends data
717 static NTSTATUS
gensec_spnego_server_negTokenTarg(struct spnego_state
*spnego_state
,
718 TALLOC_CTX
*out_mem_ctx
,
720 const DATA_BLOB unwrapped_out
,
721 DATA_BLOB mech_list_mic
,
724 struct spnego_data spnego_out
;
725 DATA_BLOB null_data_blob
= data_blob(NULL
, 0);
728 spnego_out
.type
= SPNEGO_NEG_TOKEN_TARG
;
729 spnego_out
.negTokenTarg
.responseToken
= unwrapped_out
;
730 spnego_out
.negTokenTarg
.mechListMIC
= null_data_blob
;
731 spnego_out
.negTokenTarg
.supportedMech
= NULL
;
733 if (NT_STATUS_EQUAL(nt_status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
734 spnego_out
.negTokenTarg
.supportedMech
= spnego_state
->neg_oid
;
735 spnego_out
.negTokenTarg
.negResult
= SPNEGO_ACCEPT_INCOMPLETE
;
736 spnego_state
->state_position
= SPNEGO_SERVER_TARG
;
737 } else if (NT_STATUS_IS_OK(nt_status
)) {
738 if (unwrapped_out
.data
) {
739 spnego_out
.negTokenTarg
.supportedMech
= spnego_state
->neg_oid
;
741 spnego_out
.negTokenTarg
.negResult
= SPNEGO_ACCEPT_COMPLETED
;
742 spnego_out
.negTokenTarg
.mechListMIC
= mech_list_mic
;
743 spnego_state
->state_position
= SPNEGO_DONE
;
745 spnego_out
.negTokenTarg
.negResult
= SPNEGO_REJECT
;
746 DEBUG(2, ("SPNEGO login failed: %s\n", nt_errstr(nt_status
)));
747 spnego_state
->state_position
= SPNEGO_DONE
;
750 if (spnego_write_data(out_mem_ctx
, out
, &spnego_out
) == -1) {
751 DEBUG(1, ("Failed to write SPNEGO reply to NEG_TOKEN_TARG\n"));
752 return NT_STATUS_INVALID_PARAMETER
;
755 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_TARG
;
761 static NTSTATUS
gensec_spnego_update(struct gensec_security
*gensec_security
, TALLOC_CTX
*out_mem_ctx
,
762 struct tevent_context
*ev
,
763 const DATA_BLOB in
, DATA_BLOB
*out
)
765 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
766 DATA_BLOB null_data_blob
= data_blob(NULL
, 0);
767 DATA_BLOB mech_list_mic
= data_blob(NULL
, 0);
768 DATA_BLOB unwrapped_out
= data_blob(NULL
, 0);
769 struct spnego_data spnego_out
;
770 struct spnego_data spnego
;
774 *out
= data_blob(NULL
, 0);
777 out_mem_ctx
= spnego_state
;
780 /* and switch into the state machine */
782 switch (spnego_state
->state_position
) {
783 case SPNEGO_FALLBACK
:
784 return gensec_update_ev(spnego_state
->sub_sec_security
, ev
,
785 out_mem_ctx
, in
, out
);
786 case SPNEGO_SERVER_START
:
791 len
= spnego_read_data(gensec_security
, in
, &spnego
);
793 return gensec_spnego_server_try_fallback(gensec_security
, spnego_state
,
794 out_mem_ctx
, ev
, in
, out
);
796 /* client sent NegTargetInit, we send NegTokenTarg */
798 /* OK, so it's real SPNEGO, check the packet's the one we expect */
799 if (spnego
.type
!= spnego_state
->expected_packet
) {
800 DEBUG(1, ("Invalid SPNEGO request: %d, expected %d\n", spnego
.type
,
801 spnego_state
->expected_packet
));
802 dump_data(1, in
.data
, in
.length
);
803 spnego_free_data(&spnego
);
804 return NT_STATUS_INVALID_PARAMETER
;
807 nt_status
= gensec_spnego_parse_negTokenInit(gensec_security
,
811 spnego
.negTokenInit
.mechTypes
,
812 spnego
.negTokenInit
.mechToken
,
815 nt_status
= gensec_spnego_server_negTokenTarg(spnego_state
,
822 spnego_free_data(&spnego
);
826 nt_status
= gensec_spnego_create_negTokenInit(gensec_security
, spnego_state
,
827 out_mem_ctx
, ev
, in
, out
);
828 spnego_state
->state_position
= SPNEGO_SERVER_START
;
829 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_INIT
;
834 case SPNEGO_CLIENT_START
:
836 /* The server offers a list of mechanisms */
838 const char *my_mechs
[] = {NULL
, NULL
};
839 NTSTATUS nt_status
= NT_STATUS_INVALID_PARAMETER
;
842 /* client to produce negTokenInit */
843 nt_status
= gensec_spnego_create_negTokenInit(gensec_security
, spnego_state
,
844 out_mem_ctx
, ev
, in
, out
);
845 spnego_state
->state_position
= SPNEGO_CLIENT_TARG
;
846 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_TARG
;
850 len
= spnego_read_data(gensec_security
, in
, &spnego
);
853 DEBUG(1, ("Invalid SPNEGO request:\n"));
854 dump_data(1, in
.data
, in
.length
);
855 return NT_STATUS_INVALID_PARAMETER
;
858 /* OK, so it's real SPNEGO, check the packet's the one we expect */
859 if (spnego
.type
!= spnego_state
->expected_packet
) {
860 DEBUG(1, ("Invalid SPNEGO request: %d, expected %d\n", spnego
.type
,
861 spnego_state
->expected_packet
));
862 dump_data(1, in
.data
, in
.length
);
863 spnego_free_data(&spnego
);
864 return NT_STATUS_INVALID_PARAMETER
;
867 if (spnego
.negTokenInit
.targetPrincipal
868 && strcmp(spnego
.negTokenInit
.targetPrincipal
, ADS_IGNORE_PRINCIPAL
) != 0) {
869 DEBUG(5, ("Server claims it's principal name is %s\n", spnego
.negTokenInit
.targetPrincipal
));
870 if (lpcfg_client_use_spnego_principal(gensec_security
->settings
->lp_ctx
)) {
871 gensec_set_target_principal(gensec_security
, spnego
.negTokenInit
.targetPrincipal
);
875 nt_status
= gensec_spnego_parse_negTokenInit(gensec_security
,
879 spnego
.negTokenInit
.mechTypes
,
880 spnego
.negTokenInit
.mechToken
,
883 if (!NT_STATUS_EQUAL(nt_status
, NT_STATUS_MORE_PROCESSING_REQUIRED
) && !NT_STATUS_IS_OK(nt_status
)) {
884 spnego_free_data(&spnego
);
888 my_mechs
[0] = spnego_state
->neg_oid
;
890 spnego_out
.type
= SPNEGO_NEG_TOKEN_INIT
;
891 spnego_out
.negTokenInit
.mechTypes
= my_mechs
;
892 spnego_out
.negTokenInit
.reqFlags
= null_data_blob
;
893 spnego_out
.negTokenInit
.reqFlagsPadding
= 0;
894 spnego_out
.negTokenInit
.mechListMIC
= null_data_blob
;
895 spnego_out
.negTokenInit
.mechToken
= unwrapped_out
;
897 if (spnego_write_data(out_mem_ctx
, out
, &spnego_out
) == -1) {
898 DEBUG(1, ("Failed to write SPNEGO reply to NEG_TOKEN_INIT\n"));
899 return NT_STATUS_INVALID_PARAMETER
;
903 spnego_state
->expected_packet
= SPNEGO_NEG_TOKEN_TARG
;
904 spnego_state
->state_position
= SPNEGO_CLIENT_TARG
;
906 if (NT_STATUS_IS_OK(nt_status
)) {
907 spnego_state
->no_response_expected
= true;
910 spnego_free_data(&spnego
);
911 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
913 case SPNEGO_SERVER_TARG
:
916 bool new_spnego
= false;
919 return NT_STATUS_INVALID_PARAMETER
;
922 len
= spnego_read_data(gensec_security
, in
, &spnego
);
925 DEBUG(1, ("Invalid SPNEGO request:\n"));
926 dump_data(1, in
.data
, in
.length
);
927 return NT_STATUS_INVALID_PARAMETER
;
930 /* OK, so it's real SPNEGO, check the packet's the one we expect */
931 if (spnego
.type
!= spnego_state
->expected_packet
) {
932 DEBUG(1, ("Invalid SPNEGO request: %d, expected %d\n", spnego
.type
,
933 spnego_state
->expected_packet
));
934 dump_data(1, in
.data
, in
.length
);
935 spnego_free_data(&spnego
);
936 return NT_STATUS_INVALID_PARAMETER
;
939 if (!spnego_state
->sub_sec_security
) {
940 DEBUG(1, ("SPNEGO: Did not setup a mech in NEG_TOKEN_INIT\n"));
941 spnego_free_data(&spnego
);
942 return NT_STATUS_INVALID_PARAMETER
;
945 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
947 spnego
.negTokenTarg
.responseToken
,
949 if (NT_STATUS_IS_OK(nt_status
) && spnego
.negTokenTarg
.mechListMIC
.length
> 0) {
951 nt_status
= gensec_check_packet(spnego_state
->sub_sec_security
,
952 spnego_state
->mech_types
.data
,
953 spnego_state
->mech_types
.length
,
954 spnego_state
->mech_types
.data
,
955 spnego_state
->mech_types
.length
,
956 &spnego
.negTokenTarg
.mechListMIC
);
957 if (!NT_STATUS_IS_OK(nt_status
)) {
958 DEBUG(2,("GENSEC SPNEGO: failed to verify mechListMIC: %s\n",
959 nt_errstr(nt_status
)));
962 if (NT_STATUS_IS_OK(nt_status
) && new_spnego
) {
963 nt_status
= gensec_sign_packet(spnego_state
->sub_sec_security
,
965 spnego_state
->mech_types
.data
,
966 spnego_state
->mech_types
.length
,
967 spnego_state
->mech_types
.data
,
968 spnego_state
->mech_types
.length
,
970 if (!NT_STATUS_IS_OK(nt_status
)) {
971 DEBUG(2,("GENSEC SPNEGO: failed to sign mechListMIC: %s\n",
972 nt_errstr(nt_status
)));
976 nt_status
= gensec_spnego_server_negTokenTarg(spnego_state
,
983 spnego_free_data(&spnego
);
987 case SPNEGO_CLIENT_TARG
:
991 return NT_STATUS_INVALID_PARAMETER
;
994 len
= spnego_read_data(gensec_security
, in
, &spnego
);
997 DEBUG(1, ("Invalid SPNEGO request:\n"));
998 dump_data(1, in
.data
, in
.length
);
999 return NT_STATUS_INVALID_PARAMETER
;
1002 /* OK, so it's real SPNEGO, check the packet's the one we expect */
1003 if (spnego
.type
!= spnego_state
->expected_packet
) {
1004 DEBUG(1, ("Invalid SPNEGO request: %d, expected %d\n", spnego
.type
,
1005 spnego_state
->expected_packet
));
1006 dump_data(1, in
.data
, in
.length
);
1007 spnego_free_data(&spnego
);
1008 return NT_STATUS_INVALID_PARAMETER
;
1011 if (spnego
.negTokenTarg
.negResult
== SPNEGO_REJECT
) {
1012 spnego_free_data(&spnego
);
1013 return NT_STATUS_LOGON_FAILURE
;
1016 /* Server didn't like our choice of mech, and chose something else */
1017 if ((spnego
.negTokenTarg
.negResult
== SPNEGO_ACCEPT_INCOMPLETE
) &&
1018 spnego
.negTokenTarg
.supportedMech
&&
1019 strcmp(spnego
.negTokenTarg
.supportedMech
, spnego_state
->neg_oid
) != 0) {
1020 DEBUG(3,("GENSEC SPNEGO: client preferred mech (%s) not accepted, server wants: %s\n",
1021 gensec_get_name_by_oid(gensec_security
, spnego
.negTokenTarg
.supportedMech
),
1022 gensec_get_name_by_oid(gensec_security
, spnego_state
->neg_oid
)));
1024 talloc_free(spnego_state
->sub_sec_security
);
1025 nt_status
= gensec_subcontext_start(spnego_state
,
1027 &spnego_state
->sub_sec_security
);
1028 if (!NT_STATUS_IS_OK(nt_status
)) {
1029 spnego_free_data(&spnego
);
1032 /* select the sub context */
1033 nt_status
= gensec_start_mech_by_oid(spnego_state
->sub_sec_security
,
1034 spnego
.negTokenTarg
.supportedMech
);
1035 if (!NT_STATUS_IS_OK(nt_status
)) {
1036 spnego_free_data(&spnego
);
1040 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
1042 spnego
.negTokenTarg
.responseToken
,
1044 spnego_state
->neg_oid
= talloc_strdup(spnego_state
, spnego
.negTokenTarg
.supportedMech
);
1045 } else if (spnego_state
->no_response_expected
) {
1046 if (spnego
.negTokenTarg
.negResult
!= SPNEGO_ACCEPT_COMPLETED
) {
1047 DEBUG(3,("GENSEC SPNEGO: client GENSEC accepted, but server rejected (bad password?)\n"));
1048 nt_status
= NT_STATUS_INVALID_PARAMETER
;
1049 } else if (spnego
.negTokenTarg
.responseToken
.length
) {
1050 DEBUG(2,("GENSEC SPNEGO: client GENSEC accepted, but server continued negotiation!\n"));
1051 nt_status
= NT_STATUS_INVALID_PARAMETER
;
1053 nt_status
= NT_STATUS_OK
;
1055 if (NT_STATUS_IS_OK(nt_status
) && spnego
.negTokenTarg
.mechListMIC
.length
> 0) {
1056 nt_status
= gensec_check_packet(spnego_state
->sub_sec_security
,
1057 spnego_state
->mech_types
.data
,
1058 spnego_state
->mech_types
.length
,
1059 spnego_state
->mech_types
.data
,
1060 spnego_state
->mech_types
.length
,
1061 &spnego
.negTokenTarg
.mechListMIC
);
1062 if (!NT_STATUS_IS_OK(nt_status
)) {
1063 DEBUG(2,("GENSEC SPNEGO: failed to verify mechListMIC: %s\n",
1064 nt_errstr(nt_status
)));
1068 bool new_spnego
= false;
1070 nt_status
= gensec_update_ev(spnego_state
->sub_sec_security
,
1072 spnego
.negTokenTarg
.responseToken
,
1075 if (NT_STATUS_IS_OK(nt_status
)
1076 && spnego
.negTokenTarg
.negResult
!= SPNEGO_ACCEPT_COMPLETED
) {
1077 new_spnego
= gensec_have_feature(spnego_state
->sub_sec_security
,
1078 GENSEC_FEATURE_NEW_SPNEGO
);
1080 if (NT_STATUS_IS_OK(nt_status
) && new_spnego
) {
1081 nt_status
= gensec_sign_packet(spnego_state
->sub_sec_security
,
1083 spnego_state
->mech_types
.data
,
1084 spnego_state
->mech_types
.length
,
1085 spnego_state
->mech_types
.data
,
1086 spnego_state
->mech_types
.length
,
1088 if (!NT_STATUS_IS_OK(nt_status
)) {
1089 DEBUG(2,("GENSEC SPNEGO: failed to sign mechListMIC: %s\n",
1090 nt_errstr(nt_status
)));
1093 if (NT_STATUS_IS_OK(nt_status
)) {
1094 spnego_state
->no_response_expected
= true;
1098 spnego_free_data(&spnego
);
1100 if (!NT_STATUS_EQUAL(nt_status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)
1101 && !NT_STATUS_IS_OK(nt_status
)) {
1102 DEBUG(1, ("SPNEGO(%s) login failed: %s\n",
1103 spnego_state
->sub_sec_security
->ops
->name
,
1104 nt_errstr(nt_status
)));
1108 if (unwrapped_out
.length
|| mech_list_mic
.length
) {
1110 spnego_out
.type
= SPNEGO_NEG_TOKEN_TARG
;
1111 spnego_out
.negTokenTarg
.negResult
= SPNEGO_NONE_RESULT
;
1112 spnego_out
.negTokenTarg
.supportedMech
= NULL
;
1113 spnego_out
.negTokenTarg
.responseToken
= unwrapped_out
;
1114 spnego_out
.negTokenTarg
.mechListMIC
= mech_list_mic
;
1116 if (spnego_write_data(out_mem_ctx
, out
, &spnego_out
) == -1) {
1117 DEBUG(1, ("Failed to write SPNEGO reply to NEG_TOKEN_TARG\n"));
1118 return NT_STATUS_INVALID_PARAMETER
;
1121 spnego_state
->state_position
= SPNEGO_CLIENT_TARG
;
1122 nt_status
= NT_STATUS_MORE_PROCESSING_REQUIRED
;
1125 /* all done - server has accepted, and we agree */
1126 *out
= null_data_blob
;
1128 if (spnego
.negTokenTarg
.negResult
!= SPNEGO_ACCEPT_COMPLETED
) {
1129 /* unless of course it did not accept */
1130 DEBUG(1,("gensec_update ok but not accepted\n"));
1131 nt_status
= NT_STATUS_INVALID_PARAMETER
;
1134 spnego_state
->state_position
= SPNEGO_DONE
;
1140 /* We should not be called after we are 'done' */
1141 return NT_STATUS_INVALID_PARAMETER
;
1143 return NT_STATUS_INVALID_PARAMETER
;
1146 static NTSTATUS
gensec_spnego_update_in(struct gensec_security
*gensec_security
,
1147 const DATA_BLOB in
, DATA_BLOB
*full_in
)
1149 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1154 *full_in
= data_blob_null
;
1156 if (spnego_state
->in_needed
== 0) {
1160 * try to work out the size of the full
1161 * input token, it might be fragmented
1163 status
= asn1_peek_full_tag(in
, ASN1_APPLICATION(0), &size
);
1164 if (!NT_STATUS_IS_OK(status
) &&
1165 !NT_STATUS_EQUAL(status
, STATUS_MORE_ENTRIES
)) {
1166 status
= asn1_peek_full_tag(in
, ASN1_CONTEXT(1), &size
);
1169 if (NT_STATUS_IS_OK(status
) ||
1170 NT_STATUS_EQUAL(status
, STATUS_MORE_ENTRIES
)) {
1171 spnego_state
->in_needed
= size
;
1174 * If it is not an asn1 message
1175 * just call the next layer.
1177 spnego_state
->in_needed
= in
.length
;
1181 if (spnego_state
->in_needed
> UINT16_MAX
) {
1183 * limit the incoming message to 0xFFFF
1184 * to avoid DoS attacks.
1186 return NT_STATUS_INVALID_BUFFER_SIZE
;
1189 if ((spnego_state
->in_needed
> 0) && (in
.length
== 0)) {
1191 * If we reach this, we know we got at least
1192 * part of an asn1 message, getting 0 means
1193 * the remote peer wants us to spin.
1195 return NT_STATUS_INVALID_PARAMETER
;
1198 expected
= spnego_state
->in_needed
- spnego_state
->in_frag
.length
;
1199 if (in
.length
> expected
) {
1201 * we got more than expected
1203 return NT_STATUS_INVALID_PARAMETER
;
1206 if (in
.length
== spnego_state
->in_needed
) {
1208 * if the in.length contains the full blob
1211 * Note: this implies spnego_state->in_frag.length == 0,
1212 * but we do not need to check this explicitly
1213 * because we already know that we did not get
1214 * more than expected.
1217 return NT_STATUS_OK
;
1220 ok
= data_blob_append(spnego_state
, &spnego_state
->in_frag
,
1221 in
.data
, in
.length
);
1223 return NT_STATUS_NO_MEMORY
;
1226 if (spnego_state
->in_needed
> spnego_state
->in_frag
.length
) {
1227 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
1230 *full_in
= spnego_state
->in_frag
;
1231 return NT_STATUS_OK
;
1234 static NTSTATUS
gensec_spnego_update_out(struct gensec_security
*gensec_security
,
1235 TALLOC_CTX
*out_mem_ctx
,
1238 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1239 DATA_BLOB out
= data_blob_null
;
1241 *_out
= data_blob_null
;
1243 if (spnego_state
->out_frag
.length
== 0) {
1244 return spnego_state
->out_status
;
1248 * There is still more data to be delivered
1249 * to the remote peer.
1252 if (spnego_state
->out_frag
.length
<= spnego_state
->out_max_length
) {
1254 * Fast path, we can deliver everything
1257 *_out
= spnego_state
->out_frag
;
1258 talloc_steal(out_mem_ctx
, _out
->data
);
1259 spnego_state
->out_frag
= data_blob_null
;
1260 return spnego_state
->out_status
;
1263 out
= spnego_state
->out_frag
;
1266 * copy the remaining bytes
1268 spnego_state
->out_frag
= data_blob_talloc(spnego_state
,
1269 out
.data
+ spnego_state
->out_max_length
,
1270 out
.length
- spnego_state
->out_max_length
);
1271 if (spnego_state
->out_frag
.data
== NULL
) {
1272 return NT_STATUS_NO_MEMORY
;
1276 * truncate the buffer
1278 data_blob_realloc(spnego_state
, &out
, spnego_state
->out_max_length
);
1280 talloc_steal(out_mem_ctx
, out
.data
);
1282 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
1285 static NTSTATUS
gensec_spnego_update_wrapper(struct gensec_security
*gensec_security
,
1286 TALLOC_CTX
*out_mem_ctx
,
1287 struct tevent_context
*ev
,
1288 const DATA_BLOB in
, DATA_BLOB
*out
)
1290 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1291 DATA_BLOB full_in
= data_blob_null
;
1294 *out
= data_blob_null
;
1296 if (spnego_state
->out_frag
.length
> 0) {
1297 if (in
.length
> 0) {
1298 return NT_STATUS_INVALID_PARAMETER
;
1301 return gensec_spnego_update_out(gensec_security
,
1306 status
= gensec_spnego_update_in(gensec_security
,
1308 if (!NT_STATUS_IS_OK(status
)) {
1312 status
= gensec_spnego_update(gensec_security
,
1315 &spnego_state
->out_frag
);
1316 data_blob_free(&spnego_state
->in_frag
);
1317 spnego_state
->in_needed
= 0;
1318 if (!NT_STATUS_IS_OK(status
) &&
1319 !NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1323 spnego_state
->out_status
= status
;
1325 return gensec_spnego_update_out(gensec_security
,
1330 static void gensec_spnego_want_feature(struct gensec_security
*gensec_security
,
1333 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1335 if (!spnego_state
|| !spnego_state
->sub_sec_security
) {
1336 gensec_security
->want_features
|= feature
;
1340 gensec_want_feature(spnego_state
->sub_sec_security
,
1344 static bool gensec_spnego_have_feature(struct gensec_security
*gensec_security
,
1347 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1348 if (!spnego_state
->sub_sec_security
) {
1352 return gensec_have_feature(spnego_state
->sub_sec_security
,
1356 static NTTIME
gensec_spnego_expire_time(struct gensec_security
*gensec_security
)
1358 struct spnego_state
*spnego_state
= (struct spnego_state
*)gensec_security
->private_data
;
1360 if (!spnego_state
->sub_sec_security
) {
1361 return GENSEC_EXPIRE_TIME_INFINITY
;
1364 return gensec_expire_time(spnego_state
->sub_sec_security
);
1367 static const char *gensec_spnego_oids
[] = {
1372 static const struct gensec_security_ops gensec_spnego_security_ops
= {
1374 .sasl_name
= "GSS-SPNEGO",
1375 .auth_type
= DCERPC_AUTH_TYPE_SPNEGO
,
1376 .oid
= gensec_spnego_oids
,
1377 .client_start
= gensec_spnego_client_start
,
1378 .server_start
= gensec_spnego_server_start
,
1379 .update
= gensec_spnego_update_wrapper
,
1380 .seal_packet
= gensec_spnego_seal_packet
,
1381 .sign_packet
= gensec_spnego_sign_packet
,
1382 .sig_size
= gensec_spnego_sig_size
,
1383 .max_wrapped_size
= gensec_spnego_max_wrapped_size
,
1384 .max_input_size
= gensec_spnego_max_input_size
,
1385 .check_packet
= gensec_spnego_check_packet
,
1386 .unseal_packet
= gensec_spnego_unseal_packet
,
1387 .packet_full_request
= gensec_spnego_packet_full_request
,
1388 .wrap
= gensec_spnego_wrap
,
1389 .unwrap
= gensec_spnego_unwrap
,
1390 .wrap_packets
= gensec_spnego_wrap_packets
,
1391 .unwrap_packets
= gensec_spnego_unwrap_packets
,
1392 .session_key
= gensec_spnego_session_key
,
1393 .session_info
= gensec_spnego_session_info
,
1394 .want_feature
= gensec_spnego_want_feature
,
1395 .have_feature
= gensec_spnego_have_feature
,
1396 .expire_time
= gensec_spnego_expire_time
,
1398 .priority
= GENSEC_SPNEGO
1401 _PUBLIC_ NTSTATUS
gensec_spnego_init(void)
1404 ret
= gensec_register(&gensec_spnego_security_ops
);
1405 if (!NT_STATUS_IS_OK(ret
)) {
1406 DEBUG(0,("Failed to register '%s' gensec backend!\n",
1407 gensec_spnego_security_ops
.name
));