1b819cea2SGordon Ross /* 2b819cea2SGordon Ross * This file and its contents are supplied under the terms of the 3b819cea2SGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0. 4b819cea2SGordon Ross * You may only use this file in accordance with the terms of version 5b819cea2SGordon Ross * 1.0 of the CDDL. 6b819cea2SGordon Ross * 7b819cea2SGordon Ross * A full copy of the text of the CDDL should have accompanied this 8b819cea2SGordon Ross * source. A copy of the CDDL is also available via the Internet at 9b819cea2SGordon Ross * http://www.illumos.org/license/CDDL. 10b819cea2SGordon Ross */ 11b819cea2SGordon Ross 12b819cea2SGordon Ross /* 13b819cea2SGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 14b819cea2SGordon Ross */ 15b819cea2SGordon Ross 16b819cea2SGordon Ross #ifndef _SMB_SIGNING_H_ 17b819cea2SGordon Ross #define _SMB_SIGNING_H_ 18b819cea2SGordon Ross 19*a90cf9f2SGordon Ross /* 20*a90cf9f2SGordon Ross * SMB signing routines used in {smb,smb2}_signing.c 21*a90cf9f2SGordon Ross * Two implementations of these (kernel/user) in: 22*a90cf9f2SGordon Ross * uts/common/fs/smbsrv/smb_sign_kcf.c 23*a90cf9f2SGordon Ross * lib/smbsrv/libfksmbsrv/common/fksmb_sign_pkcs.c 24*a90cf9f2SGordon Ross */ 25*a90cf9f2SGordon Ross 26b819cea2SGordon Ross #ifdef _KERNEL 27b819cea2SGordon Ross #include <sys/crypto/api.h> 28b819cea2SGordon Ross #else 29b819cea2SGordon Ross #include <security/cryptoki.h> 30b819cea2SGordon Ross #include <security/pkcs11.h> 31b819cea2SGordon Ross #endif 32b819cea2SGordon Ross 3312b65585SGordon Ross #ifdef __cplusplus 3412b65585SGordon Ross extern "C" { 3512b65585SGordon Ross #endif 3612b65585SGordon Ross 37b819cea2SGordon Ross #define MD5_DIGEST_LENGTH 16 /* MD5 digest length in bytes */ 38*a90cf9f2SGordon Ross #define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */ 39*a90cf9f2SGordon Ross #define SMB2_SIG_SIZE 16 40b819cea2SGordon Ross 41b819cea2SGordon Ross #ifdef _KERNEL 42b819cea2SGordon Ross /* KCF variant */ 43b819cea2SGordon Ross typedef crypto_mechanism_t smb_sign_mech_t; 44b819cea2SGordon Ross typedef crypto_context_t smb_sign_ctx_t; 45b819cea2SGordon Ross #else /* _KERNEL */ 46b819cea2SGordon Ross /* PKCS11 variant */ 47b819cea2SGordon Ross typedef CK_MECHANISM smb_sign_mech_t; 48b819cea2SGordon Ross typedef CK_SESSION_HANDLE smb_sign_ctx_t; 49b819cea2SGordon Ross #endif /* _KERNEL */ 50b819cea2SGordon Ross 51b819cea2SGordon Ross /* 52*a90cf9f2SGordon Ross * SMB signing routines used in smb_signing.c 53b819cea2SGordon Ross */ 54b819cea2SGordon Ross 55b819cea2SGordon Ross int smb_md5_getmech(smb_sign_mech_t *); 56b819cea2SGordon Ross int smb_md5_init(smb_sign_ctx_t *, smb_sign_mech_t *); 57b819cea2SGordon Ross int smb_md5_update(smb_sign_ctx_t, void *, size_t); 58b819cea2SGordon Ross int smb_md5_final(smb_sign_ctx_t, uint8_t *); 59b819cea2SGordon Ross 60*a90cf9f2SGordon Ross /* 61*a90cf9f2SGordon Ross * SMB2 signing routines used in smb2_signing.c 62*a90cf9f2SGordon Ross */ 63*a90cf9f2SGordon Ross 64*a90cf9f2SGordon Ross int smb2_hmac_getmech(smb_sign_mech_t *); 65*a90cf9f2SGordon Ross int smb2_hmac_init(smb_sign_ctx_t *, smb_sign_mech_t *, uint8_t *, size_t); 66*a90cf9f2SGordon Ross int smb2_hmac_update(smb_sign_ctx_t, uint8_t *, size_t); 67*a90cf9f2SGordon Ross int smb2_hmac_final(smb_sign_ctx_t, uint8_t *); 68*a90cf9f2SGordon Ross 6912b65585SGordon Ross #ifdef __cplusplus 7012b65585SGordon Ross } 7112b65585SGordon Ross #endif 7212b65585SGordon Ross 73b819cea2SGordon Ross #endif /* _SMB_SIGNING_H_ */ 74