6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2010 Emulex. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27
28 #include <emlxs.h>
29
30 #ifdef DHCHAP_SUPPORT
31
32 #include <md5.h>
33 #include <sha1.h>
34 #ifdef S10
35 #include <sha1_consts.h>
36 #else
37 #include <sys/sha1_consts.h>
38 #endif /* S10 */
39 #include <bignum.h>
40 #include <sys/time.h>
41
42 #ifdef S10
43 #define BIGNUM_CHUNK_32
44 #define BIG_CHUNK_TYPE uint32_t
45 #define CHARLEN2BIGNUMLEN(_val) (_val/4)
7584 restart:
7585
7586 emlxs_dhc_set_reauth_time(port, ndlp, ENABLE);
7587
7588 return;
7589
7590 } /* emlxs_dhc_reauth_timeout */
7591
7592
7593 static void
7594 emlxs_dhc_set_reauth_time(
7595 emlxs_port_t *port,
7596 emlxs_node_t *ndlp,
7597 uint32_t status)
7598 {
7599 emlxs_port_dhc_t *port_dhc = &port->port_dhc;
7600 emlxs_node_dhc_t *node_dhc = &ndlp->node_dhc;
7601 uint32_t drv_time;
7602 uint32_t timeout;
7603 uint32_t reauth_tmo;
7604 time_t last_auth_time;
7605
7606 node_dhc->flag &= ~NLP_SET_REAUTH_TIME;
7607
7608 if ((status == ENABLE) &&
7609 node_dhc->auth_cfg.reauthenticate_time_interval) {
7610
7611 timeout =
7612 (60 * node_dhc->auth_cfg.reauthenticate_time_interval);
7613 drv_time = DRV_TIME;
7614
7615 /* Get last successful auth time */
7616 if (ndlp->nlp_DID == FABRIC_DID) {
7617 last_auth_time = port_dhc->auth_time;
7618 } else if (node_dhc->parent_auth_cfg) {
7619 last_auth_time = node_dhc->parent_auth_cfg->auth_time;
7620 } else {
7621 last_auth_time = 0;
7622 }
7623
7624 if (last_auth_time) {
9639
9640 mutex_exit(&hba->auth_lock);
9641
9642 return (0);
9643
9644 } /* emlxs_dhc_set_auth_key() */
9645
9646
9647 /* Provides DFC support for emlxs_dfc_get_auth_status() */
9648 extern uint32_t
9649 emlxs_dhc_get_auth_status(emlxs_hba_t *hba, dfc_auth_status_t *fcsp_status)
9650 {
9651 emlxs_port_t *port = &PPORT;
9652 emlxs_config_t *cfg = &CFG;
9653 char s_lwwpn[64];
9654 char s_rwwpn[64];
9655 emlxs_auth_cfg_t *auth_cfg;
9656 dfc_auth_status_t *auth_status;
9657 NODELIST *ndlp;
9658 uint32_t rc;
9659 time_t auth_time;
9660 uint32_t update;
9661
9662 /* Return is authentication is not enabled */
9663 if (cfg[CFG_AUTH_ENABLE].current == 0) {
9664 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcsp_debug_msg,
9665 "emlxs_dhc_get_auth_status. Auth disabled.");
9666
9667 return (DFC_AUTH_AUTHENTICATION_DISABLED);
9668 }
9669 mutex_enter(&hba->auth_lock);
9670
9671 auth_cfg = emlxs_auth_cfg_get(hba, (uint8_t *)&fcsp_status->lwwpn,
9672 (uint8_t *)&fcsp_status->rwwpn);
9673
9674 if (!auth_cfg) {
9675 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_dfc_error_msg,
9676 "emlxs_dhc_get_auth_status: entry not found. %s:%s",
9677 emlxs_wwn_xlate(s_lwwpn, (uint8_t *)&fcsp_status->lwwpn),
9678 emlxs_wwn_xlate(s_rwwpn, (uint8_t *)&fcsp_status->rwwpn));
9679
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2010 Emulex. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
28 */
29
30
31 #include <emlxs.h>
32
33 #ifdef DHCHAP_SUPPORT
34
35 #include <md5.h>
36 #include <sha1.h>
37 #ifdef S10
38 #include <sha1_consts.h>
39 #else
40 #include <sys/sha1_consts.h>
41 #endif /* S10 */
42 #include <bignum.h>
43 #include <sys/time.h>
44
45 #ifdef S10
46 #define BIGNUM_CHUNK_32
47 #define BIG_CHUNK_TYPE uint32_t
48 #define CHARLEN2BIGNUMLEN(_val) (_val/4)
7587 restart:
7588
7589 emlxs_dhc_set_reauth_time(port, ndlp, ENABLE);
7590
7591 return;
7592
7593 } /* emlxs_dhc_reauth_timeout */
7594
7595
7596 static void
7597 emlxs_dhc_set_reauth_time(
7598 emlxs_port_t *port,
7599 emlxs_node_t *ndlp,
7600 uint32_t status)
7601 {
7602 emlxs_port_dhc_t *port_dhc = &port->port_dhc;
7603 emlxs_node_dhc_t *node_dhc = &ndlp->node_dhc;
7604 uint32_t drv_time;
7605 uint32_t timeout;
7606 uint32_t reauth_tmo;
7607 uint32_t last_auth_time;
7608
7609 node_dhc->flag &= ~NLP_SET_REAUTH_TIME;
7610
7611 if ((status == ENABLE) &&
7612 node_dhc->auth_cfg.reauthenticate_time_interval) {
7613
7614 timeout =
7615 (60 * node_dhc->auth_cfg.reauthenticate_time_interval);
7616 drv_time = DRV_TIME;
7617
7618 /* Get last successful auth time */
7619 if (ndlp->nlp_DID == FABRIC_DID) {
7620 last_auth_time = port_dhc->auth_time;
7621 } else if (node_dhc->parent_auth_cfg) {
7622 last_auth_time = node_dhc->parent_auth_cfg->auth_time;
7623 } else {
7624 last_auth_time = 0;
7625 }
7626
7627 if (last_auth_time) {
9642
9643 mutex_exit(&hba->auth_lock);
9644
9645 return (0);
9646
9647 } /* emlxs_dhc_set_auth_key() */
9648
9649
9650 /* Provides DFC support for emlxs_dfc_get_auth_status() */
9651 extern uint32_t
9652 emlxs_dhc_get_auth_status(emlxs_hba_t *hba, dfc_auth_status_t *fcsp_status)
9653 {
9654 emlxs_port_t *port = &PPORT;
9655 emlxs_config_t *cfg = &CFG;
9656 char s_lwwpn[64];
9657 char s_rwwpn[64];
9658 emlxs_auth_cfg_t *auth_cfg;
9659 dfc_auth_status_t *auth_status;
9660 NODELIST *ndlp;
9661 uint32_t rc;
9662 uint32_t auth_time;
9663 uint32_t update;
9664
9665 /* Return is authentication is not enabled */
9666 if (cfg[CFG_AUTH_ENABLE].current == 0) {
9667 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcsp_debug_msg,
9668 "emlxs_dhc_get_auth_status. Auth disabled.");
9669
9670 return (DFC_AUTH_AUTHENTICATION_DISABLED);
9671 }
9672 mutex_enter(&hba->auth_lock);
9673
9674 auth_cfg = emlxs_auth_cfg_get(hba, (uint8_t *)&fcsp_status->lwwpn,
9675 (uint8_t *)&fcsp_status->rwwpn);
9676
9677 if (!auth_cfg) {
9678 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_dfc_error_msg,
9679 "emlxs_dhc_get_auth_status: entry not found. %s:%s",
9680 emlxs_wwn_xlate(s_lwwpn, (uint8_t *)&fcsp_status->lwwpn),
9681 emlxs_wwn_xlate(s_rwwpn, (uint8_t *)&fcsp_status->rwwpn));
9682
|