Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 1 | /* 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 | |
| 34 | struct ksmbd_session; |
| 35 | struct ksmbd_conn; |
| 36 | struct kvec; |
| 37 | |
Namjae Jeon | 070fb21 | 2021-05-26 17:57:12 +0900 | [diff] [blame] | 38 | int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov, |
| 39 | unsigned int nvec, int enc); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 40 | void ksmbd_copy_gss_neg_header(void *buf); |
Namjae Jeon | 070fb21 | 2021-05-26 17:57:12 +0900 | [diff] [blame] | 41 | int ksmbd_auth_ntlmv2(struct ksmbd_session *sess, struct ntlmv2_resp *ntlmv2, |
Namjae Jeon | ce53d36 | 2021-12-15 14:57:27 +0900 | [diff] [blame] | 42 | int blen, char *domain_name, char *cryptkey); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 43 | int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, |
Namjae Jeon | ce53d36 | 2021-12-15 14:57:27 +0900 | [diff] [blame] | 44 | int blob_len, struct ksmbd_conn *conn, |
| 45 | struct ksmbd_session *sess); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 46 | int ksmbd_decode_ntlmssp_neg_blob(struct negotiate_message *negblob, |
Namjae Jeon | ce53d36 | 2021-12-15 14:57:27 +0900 | [diff] [blame] | 47 | int blob_len, struct ksmbd_conn *conn); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 48 | unsigned int |
| 49 | ksmbd_build_ntlmssp_challenge_blob(struct challenge_message *chgblob, |
Namjae Jeon | ce53d36 | 2021-12-15 14:57:27 +0900 | [diff] [blame] | 50 | struct ksmbd_conn *conn); |
Namjae Jeon | 070fb21 | 2021-05-26 17:57:12 +0900 | [diff] [blame] | 51 | int ksmbd_krb5_authenticate(struct ksmbd_session *sess, char *in_blob, |
| 52 | int in_len, char *out_blob, int *out_len); |
| 53 | int ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, |
| 54 | int n_vec, char *sig); |
| 55 | int ksmbd_sign_smb3_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, |
| 56 | int n_vec, char *sig); |
Namjae Jeon | f5a544e | 2021-06-18 10:04:19 +0900 | [diff] [blame] | 57 | int ksmbd_gen_smb30_signingkey(struct ksmbd_session *sess, |
| 58 | struct ksmbd_conn *conn); |
| 59 | int ksmbd_gen_smb311_signingkey(struct ksmbd_session *sess, |
| 60 | struct ksmbd_conn *conn); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 61 | int ksmbd_gen_smb30_encryptionkey(struct ksmbd_session *sess); |
| 62 | int ksmbd_gen_smb311_encryptionkey(struct ksmbd_session *sess); |
Namjae Jeon | 070fb21 | 2021-05-26 17:57:12 +0900 | [diff] [blame] | 63 | int ksmbd_gen_preauth_integrity_hash(struct ksmbd_conn *conn, char *buf, |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 64 | __u8 *pi_hash); |
| 65 | int ksmbd_gen_sd_hash(struct ksmbd_conn *conn, char *sd_buf, int len, |
Namjae Jeon | 070fb21 | 2021-05-26 17:57:12 +0900 | [diff] [blame] | 66 | __u8 *pi_hash); |
Namjae Jeon | e2f3448 | 2021-03-16 10:49:09 +0900 | [diff] [blame] | 67 | #endif |