static struct iscsi_chap *chap_server_open( struct iscsi_conn *conn, struct iscsi_node_auth *auth, const char *a_str, char *aic_str, unsigned int *aic_len) { int ret; struct iscsi_chap *chap; if (!(auth->naf_flags & NAF_USERID_SET) || !(auth->naf_flags & NAF_PASSWORD_SET)) { pr_err("CHAP user or password not set for" " Initiator ACL\n"); return NULL; } conn->auth_protocol = kzalloc(sizeof(struct iscsi_chap), GFP_KERNEL); if (!conn->auth_protocol) return NULL; chap = conn->auth_protocol; ret = chap_check_algorithm(a_str); switch (ret) { case CHAP_DIGEST_MD5: pr_debug("[server] Got CHAP_A=5\n"); /* * Send back CHAP_A set to MD5. */ *aic_len = sprintf(aic_str, "CHAP_A=5"); *aic_len += 1; chap->digest_type = CHAP_DIGEST_MD5; pr_debug("[server] Sending CHAP_A=%d\n", chap->digest_type); break; case CHAP_DIGEST_UNKNOWN: default: pr_err("Unsupported CHAP_A value\n"); kfree(conn->auth_protocol); return NULL; } /* * Set Identifier. */ chap->id = conn->tpg->tpg_chap_id++; *aic_len += sprintf(aic_str + *aic_len, "CHAP_I=%d", chap->id); *aic_len += 1; pr_debug("[server] Sending CHAP_I=%d\n", chap->id); /* * Generate Challenge. */ if (chap_gen_challenge(conn, 1, aic_str, aic_len) < 0) { kfree(conn->auth_protocol); return NULL; } return chap; }
static struct iscsi_chap *chap_server_open( struct iscsi_conn *conn, struct iscsi_node_auth *auth, const char *a_str, char *aic_str, unsigned int *aic_len) { struct iscsi_chap *chap; if (!(auth->naf_flags & NAF_USERID_SET) || !(auth->naf_flags & NAF_PASSWORD_SET)) { pr_err("CHAP user or password not set for" " Initiator ACL\n"); return NULL; } conn->auth_protocol = kzalloc(sizeof(struct iscsi_chap), GFP_KERNEL); if (!conn->auth_protocol) return NULL; chap = conn->auth_protocol; /* * We only support MD5 MDA presently. */ if (strncmp(a_str, "CHAP_A=5", 8)) { pr_err("CHAP_A is not MD5.\n"); return NULL; } pr_debug("[server] Got CHAP_A=5\n"); /* * Send back CHAP_A set to MD5. */ *aic_len = sprintf(aic_str, "CHAP_A=5"); *aic_len += 1; chap->digest_type = CHAP_DIGEST_MD5; pr_debug("[server] Sending CHAP_A=%d\n", chap->digest_type); /* * Set Identifier. */ chap->id = ISCSI_TPG_C(conn)->tpg_chap_id++; *aic_len += sprintf(aic_str + *aic_len, "CHAP_I=%d", chap->id); *aic_len += 1; pr_debug("[server] Sending CHAP_I=%d\n", chap->id); /* * Generate Challenge. */ chap_gen_challenge(conn, 1, aic_str, aic_len); return chap; }