blob: 95629651cf266fcceb7b4249094ed5e523b92b0c [file] [log] [blame]
Namjae Jeone2f34482021-03-16 10:49:09 +09001/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
4 */
5
6#ifndef __AUTH_H__
7#define __AUTH_H__
8
9#include "ntlmssp.h"
10
11#ifdef CONFIG_SMB_SERVER_KERBEROS5
12#define AUTH_GSS_LENGTH 96
13#define AUTH_GSS_PADDING 0
14#else
15#define AUTH_GSS_LENGTH 74
16#define AUTH_GSS_PADDING 6
17#endif
18
19#define CIFS_HMAC_MD5_HASH_SIZE (16)
20#define CIFS_NTHASH_SIZE (16)
21
22/*
23 * Size of the ntlm client response
24 */
25#define CIFS_AUTH_RESP_SIZE 24
26#define CIFS_SMB1_SIGNATURE_SIZE 8
27#define CIFS_SMB1_SESSKEY_SIZE 16
28
29#define KSMBD_AUTH_NTLMSSP 0x0001
30#define KSMBD_AUTH_KRB5 0x0002
31#define KSMBD_AUTH_MSKRB5 0x0004
32#define KSMBD_AUTH_KRB5U2U 0x0008
33
34struct ksmbd_session;
35struct ksmbd_conn;
36struct kvec;
37
Namjae Jeon070fb212021-05-26 17:57:12 +090038int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov,
39 unsigned int nvec, int enc);
Namjae Jeone2f34482021-03-16 10:49:09 +090040void ksmbd_copy_gss_neg_header(void *buf);
Namjae Jeon070fb212021-05-26 17:57:12 +090041int ksmbd_auth_ntlmv2(struct ksmbd_session *sess, struct ntlmv2_resp *ntlmv2,
Namjae Jeonce53d362021-12-15 14:57:27 +090042 int blen, char *domain_name, char *cryptkey);
Namjae Jeone2f34482021-03-16 10:49:09 +090043int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
Namjae Jeonce53d362021-12-15 14:57:27 +090044 int blob_len, struct ksmbd_conn *conn,
45 struct ksmbd_session *sess);
Namjae Jeone2f34482021-03-16 10:49:09 +090046int ksmbd_decode_ntlmssp_neg_blob(struct negotiate_message *negblob,
Namjae Jeonce53d362021-12-15 14:57:27 +090047 int blob_len, struct ksmbd_conn *conn);
Namjae Jeone2f34482021-03-16 10:49:09 +090048unsigned int
49ksmbd_build_ntlmssp_challenge_blob(struct challenge_message *chgblob,
Namjae Jeonce53d362021-12-15 14:57:27 +090050 struct ksmbd_conn *conn);
Namjae Jeon070fb212021-05-26 17:57:12 +090051int ksmbd_krb5_authenticate(struct ksmbd_session *sess, char *in_blob,
52 int in_len, char *out_blob, int *out_len);
53int ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov,
54 int n_vec, char *sig);
55int ksmbd_sign_smb3_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov,
56 int n_vec, char *sig);
Namjae Jeonf5a544e2021-06-18 10:04:19 +090057int ksmbd_gen_smb30_signingkey(struct ksmbd_session *sess,
58 struct ksmbd_conn *conn);
59int ksmbd_gen_smb311_signingkey(struct ksmbd_session *sess,
60 struct ksmbd_conn *conn);
Namjae Jeone2f34482021-03-16 10:49:09 +090061int ksmbd_gen_smb30_encryptionkey(struct ksmbd_session *sess);
62int ksmbd_gen_smb311_encryptionkey(struct ksmbd_session *sess);
Namjae Jeon070fb212021-05-26 17:57:12 +090063int ksmbd_gen_preauth_integrity_hash(struct ksmbd_conn *conn, char *buf,
Namjae Jeone2f34482021-03-16 10:49:09 +090064 __u8 *pi_hash);
65int ksmbd_gen_sd_hash(struct ksmbd_conn *conn, char *sd_buf, int len,
Namjae Jeon070fb212021-05-26 17:57:12 +090066 __u8 *pi_hash);
Namjae Jeone2f34482021-03-16 10:49:09 +090067#endif