b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * This file and its contents are supplied under the terms of the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You may only use this file in accordance with the terms of version
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * 1.0 of the CDDL.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * A full copy of the text of the CDDL should have accompanied this
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * source. A copy of the CDDL is also available via the Internet at
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Helper functions for SMB signing using the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Kernel Cryptographic Framework (KCF)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * There are two implementations of these functions:
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * This one (for kernel) and another for user space:
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * See: lib/smbsrv/libfksmbsrv/common/fksmb_sign_pkcs.c
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * SMB1 signing helpers:
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * (getmech, init, update, final)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross return (-1);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Start the KCF session, load the key
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosssmb_md5_init(smb_sign_ctx_t *ctxp, smb_sign_mech_t *mech)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Digest one segment
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosssmb_md5_update(smb_sign_ctx_t ctx, void *buf, size_t len)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Get the final digest.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosssmb_md5_final(smb_sign_ctx_t ctx, uint8_t *digest16)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * SMB2 signing helpers:
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * (getmech, init, update, final)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (-1);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Start the KCF session, load the key
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rosssmb2_hmac_init(smb_sign_ctx_t *ctxp, smb_sign_mech_t *mech,
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross rv = crypto_mac_init(mech, &ckey, NULL, ctxp, NULL);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Digest one segment
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rosssmb2_hmac_update(smb_sign_ctx_t ctx, uint8_t *in, size_t len)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Note, the SMB2 signature is the first 16 bytes of the
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * 32-byte SHA256 HMAC digest.