summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/fs/smbclnt/netsmb/smb_signing.h
blob: 81217d518217783330bbf034c8bfa658e38cb5d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
 */

#ifndef _SMB_SIGNING_H_
#define	_SMB_SIGNING_H_

/*
 * SMB signing routines used in {smb,smb2}_sign.c
 * Two implementations of these (kernel/user) in:
 *	uts/common/fs/smbclnt/netsmb/smb_sign_kcf.c
 *	lib/smbclnt/libfknsmb/common/fksmb_sign_pkcs.c
 */

#ifdef	_KERNEL
#include <sys/crypto/api.h>
#else
#include <security/cryptoki.h>
#include <security/pkcs11.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define	MD5_DIGEST_LENGTH	16	/* MD5 digest length in bytes */
#define	SHA256_DIGEST_LENGTH	32	/* SHA256 digest length in bytes */
#define	SMB2_SIG_SIZE		16

#ifdef	_KERNEL
/* KCF variant */
typedef crypto_mechanism_t	smb_sign_mech_t;
typedef crypto_context_t	smb_sign_ctx_t;
#else	/* _KERNEL */
/* PKCS11 variant */
typedef CK_MECHANISM		smb_sign_mech_t;
typedef CK_SESSION_HANDLE	smb_sign_ctx_t;
#endif	/* _KERNEL */

struct smb_mac_ops;

/*
 * SMB signing routines used in smb_signing.c
 */

int smb_md5_getmech(smb_sign_mech_t *);
int smb_md5_init(smb_sign_ctx_t *, smb_sign_mech_t *);
int smb_md5_update(smb_sign_ctx_t, void *, size_t);
int smb_md5_final(smb_sign_ctx_t, uint8_t *);

/*
 * SMB2 signing routines used in smb2_signing.c
 */

int smb2_hmac_getmech(smb_sign_mech_t *);
int smb2_hmac_init(smb_sign_ctx_t *, smb_sign_mech_t *, uint8_t *, size_t);
int smb2_hmac_update(smb_sign_ctx_t, uint8_t *, size_t);
int smb2_hmac_final(smb_sign_ctx_t, uint8_t *);

int smb3_cmac_getmech(smb_sign_mech_t *);
int smb3_cmac_init(smb_sign_ctx_t *, smb_sign_mech_t *, uint8_t *, size_t);
int smb3_cmac_update(smb_sign_ctx_t, uint8_t *, size_t);
int smb3_cmac_final(smb_sign_ctx_t, uint8_t *);

#ifdef __cplusplus
}
#endif

#endif /* _SMB_SIGNING_H_ */