2 Unix SMB/CIFS implementation.
4 server side dcerpc authentication code - crypto support
6 Copyright (C) Andrew Tridgell 2004
7 Copyright (C) Stefan (metze) Metzmacher 2004
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 2 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, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 this provides a crypto interface to the various backends (such as
26 NTLMSSP and SCHANNEL) for the rpc server code
32 startup the cryptographic side of an authenticated dcerpc server
34 NTSTATUS dcesrv_crypto_select_type(struct dcesrv_connection *dce_conn,
35 struct dcesrv_auth *auth)
37 if (auth->auth_info->auth_level != DCERPC_AUTH_LEVEL_INTEGRITY &&
38 auth->auth_info->auth_level != DCERPC_AUTH_LEVEL_PRIVACY) {
39 DEBUG(2,("auth_level %d not supported in dcesrv auth\n",
40 auth->auth_info->auth_level));
41 return NT_STATUS_INVALID_PARAMETER;
44 if (auth->crypto_ctx.ops != NULL) {
46 * this this function should not be called
47 * twice per dcesrv_connection!
49 * so we need to find out the right
50 * dcerpc error to return
56 * maybe a dcesrv_crypto_find_backend_by_type() whould be better here
57 * to make thinks more generic
59 auth->crypto_ctx.ops = dcesrv_crypto_backend_bytype(auth->auth_info->auth_type);
60 if (auth->crypto_ctx.ops == NULL) {
61 DEBUG(2,("dcesrv auth_type %d not supported\n", auth->auth_info->auth_type));
62 return NT_STATUS_INVALID_PARAMETER;
71 NTSTATUS dcesrv_crypto_start(struct dcesrv_auth *auth, DATA_BLOB *auth_blob)
73 return auth->crypto_ctx.ops->start(auth, auth_blob);
79 NTSTATUS dcesrv_crypto_update(struct dcesrv_auth *auth,
80 TALLOC_CTX *out_mem_ctx,
81 const DATA_BLOB in, DATA_BLOB *out)
83 return auth->crypto_ctx.ops->update(auth, out_mem_ctx, in, out);
87 get auth_session_info state
89 NTSTATUS dcesrv_crypto_session_info(struct dcesrv_auth *auth, struct auth_session_info **session_info)
91 return auth->crypto_ctx.ops->session_info(auth, session_info);
97 NTSTATUS dcesrv_crypto_seal(struct dcesrv_auth *auth, TALLOC_CTX *sig_mem_ctx,
98 uint8_t *data, size_t length, DATA_BLOB *sig)
100 return auth->crypto_ctx.ops->seal(auth, sig_mem_ctx, data, length, sig);
106 NTSTATUS dcesrv_crypto_sign(struct dcesrv_auth *auth, TALLOC_CTX *sig_mem_ctx,
107 const uint8_t *data, size_t length, DATA_BLOB *sig)
109 return auth->crypto_ctx.ops->sign(auth, sig_mem_ctx, data, length, sig);
113 check a packet signature
115 NTSTATUS dcesrv_crypto_check_sig(struct dcesrv_auth *auth, TALLOC_CTX *sig_mem_ctx,
116 const uint8_t *data, size_t length, const DATA_BLOB *sig)
118 return auth->crypto_ctx.ops->check_sig(auth, sig_mem_ctx, data, length, sig);
124 NTSTATUS dcesrv_crypto_unseal(struct dcesrv_auth *auth, TALLOC_CTX *sig_mem_ctx,
125 uint8_t *data, size_t length, DATA_BLOB *sig)
127 return auth->crypto_ctx.ops->unseal(auth, sig_mem_ctx, data, length, sig);
133 void dcesrv_crypto_end(struct dcesrv_auth *auth)
135 auth->crypto_ctx.ops->end(auth);
138 const struct dcesrv_crypto_ops *dcesrv_crypto_backend_bytype(uint8_t auth_type)
141 case DCERPC_AUTH_TYPE_SCHANNEL:
142 return dcesrv_crypto_schannel_get_ops();
143 case DCERPC_AUTH_TYPE_NTLMSSP:
144 return dcesrv_crypto_ntlmssp_get_ops();