2 Unix SMB/CIFS implementation.
4 dcerpc schannel operations
6 Copyright (C) Andrew Tridgell 2004
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "lib/util/tevent_ntstatus.h"
26 #include "librpc/gen_ndr/ndr_schannel.h"
27 #include "auth/auth.h"
28 #include "auth/credentials/credentials.h"
29 #include "auth/gensec/gensec.h"
30 #include "auth/gensec/gensec_internal.h"
31 #include "auth/gensec/gensec_proto.h"
32 #include "../libcli/auth/schannel.h"
33 #include "librpc/gen_ndr/dcerpc.h"
34 #include "param/param.h"
35 #include "auth/gensec/gensec_toplevel_proto.h"
36 #include "lib/crypto/crypto.h"
37 #include "libds/common/roles.h"
39 struct schannel_state
{
40 struct gensec_security
*gensec
;
43 struct netlogon_creds_CredentialState
*creds
;
44 struct auth_user_info_dc
*user_info_dc
;
47 #define SETUP_SEQNUM(state, buf, initiator) do { \
48 uint8_t *_buf = buf; \
49 uint32_t _seq_num_low = (state)->seq_num & UINT32_MAX; \
50 uint32_t _seq_num_high = (state)->seq_num >> 32; \
52 _seq_num_high |= 0x80000000; \
54 RSIVAL(_buf, 0, _seq_num_low); \
55 RSIVAL(_buf, 4, _seq_num_high); \
58 static struct schannel_state
*netsec_create_state(
59 struct gensec_security
*gensec
,
60 struct netlogon_creds_CredentialState
*creds
,
63 struct schannel_state
*state
;
65 state
= talloc_zero(gensec
, struct schannel_state
);
70 state
->gensec
= gensec
;
71 state
->initiator
= initiator
;
72 state
->creds
= netlogon_creds_copy(state
, creds
);
73 if (state
->creds
== NULL
) {
78 gensec
->private_data
= state
;
83 static void netsec_offset_and_sizes(struct schannel_state
*state
,
85 uint32_t *_min_sig_size
,
86 uint32_t *_used_sig_size
,
87 uint32_t *_checksum_length
,
88 uint32_t *_confounder_ofs
)
90 uint32_t min_sig_size
;
91 uint32_t used_sig_size
;
92 uint32_t checksum_length
;
93 uint32_t confounder_ofs
;
95 if (state
->creds
->negotiate_flags
& NETLOGON_NEG_SUPPORTS_AES
) {
99 * Note: windows has a bug here and uses the old values...
101 * checksum_length = 32;
102 * confounder_ofs = 48;
118 *_min_sig_size
= min_sig_size
;
121 if (_used_sig_size
) {
122 *_used_sig_size
= used_sig_size
;
125 if (_checksum_length
) {
126 *_checksum_length
= checksum_length
;
129 if (_confounder_ofs
) {
130 *_confounder_ofs
= confounder_ofs
;
134 /*******************************************************************
135 Encode or Decode the sequence number (which is symmetric)
136 ********************************************************************/
137 static void netsec_do_seq_num(struct schannel_state
*state
,
138 const uint8_t *checksum
,
139 uint32_t checksum_length
,
142 if (state
->creds
->negotiate_flags
& NETLOGON_NEG_SUPPORTS_AES
) {
144 uint8_t iv
[AES_BLOCK_SIZE
];
146 AES_set_encrypt_key(state
->creds
->session_key
, 128, &key
);
148 memcpy(iv
+0, checksum
, 8);
149 memcpy(iv
+8, checksum
, 8);
151 aes_cfb8_encrypt(seq_num
, seq_num
, 8, &key
, iv
, AES_ENCRYPT
);
153 static const uint8_t zeros
[4];
154 uint8_t sequence_key
[16];
157 hmac_md5(state
->creds
->session_key
, zeros
, sizeof(zeros
), digest1
);
158 hmac_md5(digest1
, checksum
, checksum_length
, sequence_key
);
159 arcfour_crypt(seq_num
, sequence_key
, 8);
165 static void netsec_do_seal(struct schannel_state
*state
,
166 const uint8_t seq_num
[8],
167 uint8_t confounder
[8],
168 uint8_t *data
, uint32_t length
,
171 if (state
->creds
->negotiate_flags
& NETLOGON_NEG_SUPPORTS_AES
) {
173 uint8_t iv
[AES_BLOCK_SIZE
];
174 uint8_t sess_kf0
[16];
177 for (i
= 0; i
< 16; i
++) {
178 sess_kf0
[i
] = state
->creds
->session_key
[i
] ^ 0xf0;
181 AES_set_encrypt_key(sess_kf0
, 128, &key
);
183 memcpy(iv
+0, seq_num
, 8);
184 memcpy(iv
+8, seq_num
, 8);
187 aes_cfb8_encrypt(confounder
, confounder
, 8, &key
, iv
, AES_ENCRYPT
);
188 aes_cfb8_encrypt(data
, data
, length
, &key
, iv
, AES_ENCRYPT
);
190 aes_cfb8_encrypt(confounder
, confounder
, 8, &key
, iv
, AES_DECRYPT
);
191 aes_cfb8_encrypt(data
, data
, length
, &key
, iv
, AES_DECRYPT
);
194 uint8_t sealing_key
[16];
195 static const uint8_t zeros
[4];
197 uint8_t sess_kf0
[16];
200 for (i
= 0; i
< 16; i
++) {
201 sess_kf0
[i
] = state
->creds
->session_key
[i
] ^ 0xf0;
204 hmac_md5(sess_kf0
, zeros
, 4, digest2
);
205 hmac_md5(digest2
, seq_num
, 8, sealing_key
);
207 arcfour_crypt(confounder
, sealing_key
, 8);
208 arcfour_crypt(data
, sealing_key
, length
);
212 /*******************************************************************
213 Create a digest over the entire packet (including the data), and
214 MD5 it with the session key.
215 ********************************************************************/
216 static void netsec_do_sign(struct schannel_state
*state
,
217 const uint8_t *confounder
,
218 const uint8_t *data
, size_t length
,
222 if (state
->creds
->negotiate_flags
& NETLOGON_NEG_SUPPORTS_AES
) {
223 struct HMACSHA256Context ctx
;
225 hmac_sha256_init(state
->creds
->session_key
,
226 sizeof(state
->creds
->session_key
),
230 SSVAL(header
, 0, NL_SIGN_HMAC_SHA256
);
231 SSVAL(header
, 2, NL_SEAL_AES128
);
232 SSVAL(header
, 4, 0xFFFF);
233 SSVAL(header
, 6, 0x0000);
235 hmac_sha256_update(header
, 8, &ctx
);
236 hmac_sha256_update(confounder
, 8, &ctx
);
238 SSVAL(header
, 0, NL_SIGN_HMAC_SHA256
);
239 SSVAL(header
, 2, NL_SEAL_NONE
);
240 SSVAL(header
, 4, 0xFFFF);
241 SSVAL(header
, 6, 0x0000);
243 hmac_sha256_update(header
, 8, &ctx
);
246 hmac_sha256_update(data
, length
, &ctx
);
248 hmac_sha256_final(checksum
, &ctx
);
250 uint8_t packet_digest
[16];
251 static const uint8_t zeros
[4];
255 MD5Update(&ctx
, zeros
, 4);
257 SSVAL(header
, 0, NL_SIGN_HMAC_MD5
);
258 SSVAL(header
, 2, NL_SEAL_RC4
);
259 SSVAL(header
, 4, 0xFFFF);
260 SSVAL(header
, 6, 0x0000);
262 MD5Update(&ctx
, header
, 8);
263 MD5Update(&ctx
, confounder
, 8);
265 SSVAL(header
, 0, NL_SIGN_HMAC_MD5
);
266 SSVAL(header
, 2, NL_SEAL_NONE
);
267 SSVAL(header
, 4, 0xFFFF);
268 SSVAL(header
, 6, 0x0000);
270 MD5Update(&ctx
, header
, 8);
272 MD5Update(&ctx
, data
, length
);
273 MD5Final(packet_digest
, &ctx
);
275 hmac_md5(state
->creds
->session_key
,
276 packet_digest
, sizeof(packet_digest
),
281 static NTSTATUS
netsec_incoming_packet(struct schannel_state
*state
,
283 uint8_t *data
, size_t length
,
284 const uint8_t *whole_pdu
, size_t pdu_length
,
285 const DATA_BLOB
*sig
)
287 uint32_t min_sig_size
= 0;
289 uint8_t checksum
[32];
290 uint32_t checksum_length
= sizeof(checksum_length
);
291 uint8_t _confounder
[8];
292 uint8_t *confounder
= NULL
;
293 uint32_t confounder_ofs
= 0;
296 const uint8_t *sign_data
= NULL
;
297 size_t sign_length
= 0;
299 netsec_offset_and_sizes(state
,
306 if (sig
->length
< min_sig_size
) {
307 return NT_STATUS_ACCESS_DENIED
;
311 confounder
= _confounder
;
312 memcpy(confounder
, sig
->data
+confounder_ofs
, 8);
317 SETUP_SEQNUM(state
, seq_num
, !state
->initiator
);
320 netsec_do_seal(state
, seq_num
,
326 if (state
->gensec
->want_features
& GENSEC_FEATURE_SIGN_PKT_HEADER
) {
327 sign_data
= whole_pdu
;
328 sign_length
= pdu_length
;
331 sign_length
= length
;
334 netsec_do_sign(state
, confounder
,
335 sign_data
, sign_length
,
338 ret
= memcmp(checksum
, sig
->data
+16, checksum_length
);
340 dump_data_pw("calc digest:", checksum
, checksum_length
);
341 dump_data_pw("wire digest:", sig
->data
+16, checksum_length
);
342 return NT_STATUS_ACCESS_DENIED
;
345 netsec_do_seq_num(state
, checksum
, checksum_length
, seq_num
);
347 ret
= memcmp(seq_num
, sig
->data
+8, 8);
349 dump_data_pw("calc seq num:", seq_num
, 8);
350 dump_data_pw("wire seq num:", sig
->data
+8, 8);
351 return NT_STATUS_ACCESS_DENIED
;
357 static uint32_t netsec_outgoing_sig_size(struct schannel_state
*state
)
359 uint32_t sig_size
= 0;
361 netsec_offset_and_sizes(state
,
371 static NTSTATUS
netsec_outgoing_packet(struct schannel_state
*state
,
374 uint8_t *data
, size_t length
,
375 const uint8_t *whole_pdu
, size_t pdu_length
,
378 uint32_t min_sig_size
= 0;
379 uint32_t used_sig_size
= 0;
381 uint8_t checksum
[32];
382 uint32_t checksum_length
= sizeof(checksum_length
);
383 uint8_t _confounder
[8];
384 uint8_t *confounder
= NULL
;
385 uint32_t confounder_ofs
= 0;
387 const uint8_t *sign_data
= NULL
;
388 size_t sign_length
= 0;
390 netsec_offset_and_sizes(state
,
397 SETUP_SEQNUM(state
, seq_num
, state
->initiator
);
400 confounder
= _confounder
;
401 generate_random_buffer(confounder
, 8);
406 if (state
->gensec
->want_features
& GENSEC_FEATURE_SIGN_PKT_HEADER
) {
407 sign_data
= whole_pdu
;
408 sign_length
= pdu_length
;
411 sign_length
= length
;
414 netsec_do_sign(state
, confounder
,
415 sign_data
, sign_length
,
419 netsec_do_seal(state
, seq_num
,
425 netsec_do_seq_num(state
, checksum
, checksum_length
, seq_num
);
427 (*sig
) = data_blob_talloc_zero(mem_ctx
, used_sig_size
);
429 memcpy(sig
->data
, header
, 8);
430 memcpy(sig
->data
+8, seq_num
, 8);
431 memcpy(sig
->data
+16, checksum
, checksum_length
);
434 memcpy(sig
->data
+confounder_ofs
, confounder
, 8);
437 dump_data_pw("signature:", sig
->data
+ 0, 8);
438 dump_data_pw("seq_num :", sig
->data
+ 8, 8);
439 dump_data_pw("digest :", sig
->data
+16, checksum_length
);
440 dump_data_pw("confound :", sig
->data
+confounder_ofs
, 8);
445 _PUBLIC_ NTSTATUS
gensec_schannel_init(TALLOC_CTX
*ctx
);
447 static size_t schannel_sig_size(struct gensec_security
*gensec_security
, size_t data_size
)
449 struct schannel_state
*state
=
450 talloc_get_type_abort(gensec_security
->private_data
,
451 struct schannel_state
);
453 return netsec_outgoing_sig_size(state
);
456 struct schannel_update_state
{
461 static NTSTATUS
schannel_update_internal(struct gensec_security
*gensec_security
,
462 TALLOC_CTX
*out_mem_ctx
,
463 const DATA_BLOB in
, DATA_BLOB
*out
);
465 static struct tevent_req
*schannel_update_send(TALLOC_CTX
*mem_ctx
,
466 struct tevent_context
*ev
,
467 struct gensec_security
*gensec_security
,
470 struct tevent_req
*req
;
471 struct schannel_update_state
*state
= NULL
;
474 req
= tevent_req_create(mem_ctx
, &state
,
475 struct schannel_update_state
);
480 status
= schannel_update_internal(gensec_security
,
483 state
->status
= status
;
484 if (NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
485 status
= NT_STATUS_OK
;
487 if (tevent_req_nterror(req
, status
)) {
488 return tevent_req_post(req
, ev
);
491 tevent_req_done(req
);
492 return tevent_req_post(req
, ev
);
495 static NTSTATUS
schannel_update_internal(struct gensec_security
*gensec_security
,
496 TALLOC_CTX
*out_mem_ctx
,
497 const DATA_BLOB in
, DATA_BLOB
*out
)
499 struct schannel_state
*state
=
500 talloc_get_type(gensec_security
->private_data
,
501 struct schannel_state
);
503 enum ndr_err_code ndr_err
;
504 struct NL_AUTH_MESSAGE bind_schannel
= {};
505 struct NL_AUTH_MESSAGE bind_schannel_ack
;
506 struct netlogon_creds_CredentialState
*creds
;
507 const char *workstation
;
510 *out
= data_blob(NULL
, 0);
512 if (gensec_security
->dcerpc_auth_level
< DCERPC_AUTH_LEVEL_INTEGRITY
) {
513 switch (gensec_security
->gensec_role
) {
515 return NT_STATUS_INVALID_PARAMETER_MIX
;
517 return NT_STATUS_INVALID_PARAMETER
;
519 return NT_STATUS_INTERNAL_ERROR
;
522 switch (gensec_security
->gensec_role
) {
525 /* we could parse the bind ack, but we don't know what it is yet */
529 creds
= cli_credentials_get_netlogon_creds(gensec_security
->credentials
);
531 return NT_STATUS_INVALID_PARAMETER_MIX
;
534 state
= netsec_create_state(gensec_security
,
535 creds
, true /* initiator */);
537 return NT_STATUS_NO_MEMORY
;
540 bind_schannel
.MessageType
= NL_NEGOTIATE_REQUEST
;
542 bind_schannel
.Flags
= NL_FLAG_OEM_NETBIOS_DOMAIN_NAME
|
543 NL_FLAG_OEM_NETBIOS_COMPUTER_NAME
;
544 bind_schannel
.oem_netbios_domain
.a
= cli_credentials_get_domain(gensec_security
->credentials
);
545 bind_schannel
.oem_netbios_computer
.a
= creds
->computer_name
;
547 if (creds
->secure_channel_type
== SEC_CHAN_DNS_DOMAIN
) {
548 bind_schannel
.Flags
|= NL_FLAG_UTF8_DNS_DOMAIN_NAME
;
549 bind_schannel
.utf8_dns_domain
.u
= cli_credentials_get_realm(gensec_security
->credentials
);
551 bind_schannel
.Flags
|= NL_FLAG_UTF8_NETBIOS_COMPUTER_NAME
;
552 bind_schannel
.utf8_netbios_computer
.u
= creds
->computer_name
;
555 ndr_err
= ndr_push_struct_blob(out
, out_mem_ctx
, &bind_schannel
,
556 (ndr_push_flags_fn_t
)ndr_push_NL_AUTH_MESSAGE
);
557 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
558 status
= ndr_map_error2ntstatus(ndr_err
);
559 DEBUG(3, ("Could not create schannel bind: %s\n",
564 return NT_STATUS_MORE_PROCESSING_REQUIRED
;
568 /* no third leg on this protocol */
569 return NT_STATUS_INVALID_PARAMETER
;
572 /* parse the schannel startup blob */
573 ndr_err
= ndr_pull_struct_blob(&in
, out_mem_ctx
, &bind_schannel
,
574 (ndr_pull_flags_fn_t
)ndr_pull_NL_AUTH_MESSAGE
);
575 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
576 status
= ndr_map_error2ntstatus(ndr_err
);
577 DEBUG(3, ("Could not parse incoming schannel bind: %s\n",
582 if (bind_schannel
.Flags
& NL_FLAG_OEM_NETBIOS_DOMAIN_NAME
) {
583 domain
= bind_schannel
.oem_netbios_domain
.a
;
584 if (strcasecmp_m(domain
, lpcfg_workgroup(gensec_security
->settings
->lp_ctx
)) != 0) {
585 DEBUG(3, ("Request for schannel to incorrect domain: %s != our domain %s\n",
586 domain
, lpcfg_workgroup(gensec_security
->settings
->lp_ctx
)));
587 return NT_STATUS_LOGON_FAILURE
;
589 } else if (bind_schannel
.Flags
& NL_FLAG_UTF8_DNS_DOMAIN_NAME
) {
590 domain
= bind_schannel
.utf8_dns_domain
.u
;
591 if (strcasecmp_m(domain
, lpcfg_dnsdomain(gensec_security
->settings
->lp_ctx
)) != 0) {
592 DEBUG(3, ("Request for schannel to incorrect domain: %s != our domain %s\n",
593 domain
, lpcfg_dnsdomain(gensec_security
->settings
->lp_ctx
)));
594 return NT_STATUS_LOGON_FAILURE
;
597 DEBUG(3, ("Request for schannel to without domain\n"));
598 return NT_STATUS_LOGON_FAILURE
;
601 if (bind_schannel
.Flags
& NL_FLAG_OEM_NETBIOS_COMPUTER_NAME
) {
602 workstation
= bind_schannel
.oem_netbios_computer
.a
;
603 } else if (bind_schannel
.Flags
& NL_FLAG_UTF8_NETBIOS_COMPUTER_NAME
) {
604 workstation
= bind_schannel
.utf8_netbios_computer
.u
;
606 DEBUG(3, ("Request for schannel to without netbios workstation\n"));
607 return NT_STATUS_LOGON_FAILURE
;
610 status
= schannel_get_creds_state(out_mem_ctx
,
611 gensec_security
->settings
->lp_ctx
,
612 workstation
, &creds
);
613 if (!NT_STATUS_IS_OK(status
)) {
614 DEBUG(3, ("Could not find session key for attempted schannel connection from %s: %s\n",
615 workstation
, nt_errstr(status
)));
616 if (NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
617 return NT_STATUS_LOGON_FAILURE
;
622 state
= netsec_create_state(gensec_security
,
623 creds
, false /* not initiator */);
625 return NT_STATUS_NO_MEMORY
;
628 status
= auth_anonymous_user_info_dc(state
,
629 lpcfg_netbios_name(gensec_security
->settings
->lp_ctx
),
630 &state
->user_info_dc
);
631 if (!NT_STATUS_IS_OK(status
)) {
635 bind_schannel_ack
.MessageType
= NL_NEGOTIATE_RESPONSE
;
636 bind_schannel_ack
.Flags
= 0;
637 bind_schannel_ack
.Buffer
.dummy
= 0x6c0000; /* actually I think
642 ndr_err
= ndr_push_struct_blob(out
, out_mem_ctx
, &bind_schannel_ack
,
643 (ndr_push_flags_fn_t
)ndr_push_NL_AUTH_MESSAGE
);
644 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
645 status
= ndr_map_error2ntstatus(ndr_err
);
646 DEBUG(3, ("Could not return schannel bind ack for client %s: %s\n",
647 workstation
, nt_errstr(status
)));
653 return NT_STATUS_INVALID_PARAMETER
;
656 static NTSTATUS
schannel_update_recv(struct tevent_req
*req
,
657 TALLOC_CTX
*out_mem_ctx
,
660 struct schannel_update_state
*state
=
662 struct schannel_update_state
);
665 *out
= data_blob_null
;
667 if (tevent_req_is_nterror(req
, &status
)) {
668 tevent_req_received(req
);
672 status
= state
->status
;
673 talloc_steal(out_mem_ctx
, state
->out
.data
);
675 tevent_req_received(req
);
680 * Returns anonymous credentials for schannel, matching Win2k3.
684 static NTSTATUS
schannel_session_info(struct gensec_security
*gensec_security
,
686 struct auth_session_info
**_session_info
)
688 struct schannel_state
*state
=
689 talloc_get_type(gensec_security
->private_data
,
690 struct schannel_state
);
691 struct auth4_context
*auth_ctx
= gensec_security
->auth_context
;
692 struct auth_session_info
*session_info
= NULL
;
693 uint32_t session_info_flags
= 0;
696 if (auth_ctx
== NULL
) {
697 DEBUG(0, ("Cannot generate a session_info without the auth_context\n"));
698 return NT_STATUS_INTERNAL_ERROR
;
701 if (auth_ctx
->generate_session_info
== NULL
) {
702 DEBUG(0, ("Cannot generate a session_info without the generate_session_info hook\n"));
703 return NT_STATUS_INTERNAL_ERROR
;
706 if (gensec_security
->want_features
& GENSEC_FEATURE_UNIX_TOKEN
) {
707 session_info_flags
|= AUTH_SESSION_INFO_UNIX_TOKEN
;
710 session_info_flags
|= AUTH_SESSION_INFO_SIMPLE_PRIVILEGES
;
712 status
= auth_ctx
->generate_session_info(
716 state
->user_info_dc
->info
->account_name
,
719 if (!NT_STATUS_IS_OK(status
)) {
723 *_session_info
= session_info
;
728 * Reduce the attack surface by ensuring schannel is not availble when
731 static NTSTATUS
schannel_server_start(struct gensec_security
*gensec_security
)
733 enum server_role server_role
734 = lpcfg_server_role(gensec_security
->settings
->lp_ctx
);
736 switch (server_role
) {
737 case ROLE_DOMAIN_BDC
:
738 case ROLE_DOMAIN_PDC
:
739 case ROLE_ACTIVE_DIRECTORY_DC
:
742 return NT_STATUS_NOT_IMPLEMENTED
;
746 static NTSTATUS
schannel_client_start(struct gensec_security
*gensec_security
)
751 static bool schannel_have_feature(struct gensec_security
*gensec_security
,
754 if (gensec_security
->dcerpc_auth_level
>= DCERPC_AUTH_LEVEL_INTEGRITY
) {
755 if (feature
& GENSEC_FEATURE_SIGN
) {
759 if (gensec_security
->dcerpc_auth_level
== DCERPC_AUTH_LEVEL_PRIVACY
) {
760 if (feature
& GENSEC_FEATURE_SEAL
) {
764 if (feature
& GENSEC_FEATURE_DCE_STYLE
) {
767 if (feature
& GENSEC_FEATURE_SIGN_PKT_HEADER
) {
776 static NTSTATUS
schannel_unseal_packet(struct gensec_security
*gensec_security
,
777 uint8_t *data
, size_t length
,
778 const uint8_t *whole_pdu
, size_t pdu_length
,
779 const DATA_BLOB
*sig
)
781 struct schannel_state
*state
=
782 talloc_get_type_abort(gensec_security
->private_data
,
783 struct schannel_state
);
785 return netsec_incoming_packet(state
, true,
786 discard_const_p(uint8_t, data
),
788 whole_pdu
, pdu_length
,
793 check the signature on a packet
795 static NTSTATUS
schannel_check_packet(struct gensec_security
*gensec_security
,
796 const uint8_t *data
, size_t length
,
797 const uint8_t *whole_pdu
, size_t pdu_length
,
798 const DATA_BLOB
*sig
)
800 struct schannel_state
*state
=
801 talloc_get_type_abort(gensec_security
->private_data
,
802 struct schannel_state
);
804 return netsec_incoming_packet(state
, false,
805 discard_const_p(uint8_t, data
),
807 whole_pdu
, pdu_length
,
813 static NTSTATUS
schannel_seal_packet(struct gensec_security
*gensec_security
,
815 uint8_t *data
, size_t length
,
816 const uint8_t *whole_pdu
, size_t pdu_length
,
819 struct schannel_state
*state
=
820 talloc_get_type_abort(gensec_security
->private_data
,
821 struct schannel_state
);
823 return netsec_outgoing_packet(state
, mem_ctx
, true,
825 whole_pdu
, pdu_length
,
832 static NTSTATUS
schannel_sign_packet(struct gensec_security
*gensec_security
,
834 const uint8_t *data
, size_t length
,
835 const uint8_t *whole_pdu
, size_t pdu_length
,
838 struct schannel_state
*state
=
839 talloc_get_type_abort(gensec_security
->private_data
,
840 struct schannel_state
);
842 return netsec_outgoing_packet(state
, mem_ctx
, false,
843 discard_const_p(uint8_t, data
),
845 whole_pdu
, pdu_length
,
849 static const struct gensec_security_ops gensec_schannel_security_ops
= {
851 .auth_type
= DCERPC_AUTH_TYPE_SCHANNEL
,
852 .client_start
= schannel_client_start
,
853 .server_start
= schannel_server_start
,
854 .update_send
= schannel_update_send
,
855 .update_recv
= schannel_update_recv
,
856 .seal_packet
= schannel_seal_packet
,
857 .sign_packet
= schannel_sign_packet
,
858 .check_packet
= schannel_check_packet
,
859 .unseal_packet
= schannel_unseal_packet
,
860 .session_info
= schannel_session_info
,
861 .sig_size
= schannel_sig_size
,
862 .have_feature
= schannel_have_feature
,
864 .priority
= GENSEC_SCHANNEL
867 _PUBLIC_ NTSTATUS
gensec_schannel_init(TALLOC_CTX
*ctx
)
870 ret
= gensec_register(ctx
, &gensec_schannel_security_ops
);
871 if (!NT_STATUS_IS_OK(ret
)) {
872 DEBUG(0,("Failed to register '%s' gensec backend!\n",
873 gensec_schannel_security_ops
.name
));