drivers/target/iscsi/iscsi_target_auth.c
Source file repositories/reference/linux-study-clean/drivers/target/iscsi/iscsi_target_auth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/iscsi/iscsi_target_auth.c- Extension
.c- Size
- 14867 bytes
- Lines
- 625
- Domain
- Driver Families
- Bucket
- drivers/target
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/hash.hcrypto/utils.hlinux/kernel.hlinux/string.hlinux/err.hlinux/hex.hlinux/random.hlinux/scatterlist.htarget/iscsi/iscsi_target_core.hiscsi_target_nego.hiscsi_target_auth.h
Detected Declarations
function chap_gen_challengefunction chap_test_algorithmfunction chap_check_algorithmfunction chap_closefunction chap_base64_decodefunction chap_server_compute_hashfunction chap_main_loop
Annotated Snippet
if (chap_test_algorithm(digest_name) < 0) {
pr_err("failed to allocate %s algo\n", digest_name);
} else {
r = digest_type;
goto out;
}
}
out:
kfree(orig);
return r;
}
static void chap_close(struct iscsit_conn *conn)
{
kfree(conn->auth_protocol);
conn->auth_protocol = NULL;
}
static struct iscsi_chap *chap_server_open(
struct iscsit_conn *conn,
struct iscsi_node_auth *auth,
const char *a_str,
char *aic_str,
unsigned int *aic_len)
{
int digest_type;
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_obj(struct iscsi_chap);
if (!conn->auth_protocol)
return NULL;
chap = conn->auth_protocol;
digest_type = chap_check_algorithm(a_str);
switch (digest_type) {
case CHAP_DIGEST_MD5:
chap->digest_size = MD5_SIGNATURE_SIZE;
break;
case CHAP_DIGEST_SHA1:
chap->digest_size = SHA1_SIGNATURE_SIZE;
break;
case CHAP_DIGEST_SHA256:
chap->digest_size = SHA256_SIGNATURE_SIZE;
break;
case CHAP_DIGEST_SHA3_256:
chap->digest_size = SHA3_256_SIGNATURE_SIZE;
break;
case CHAP_DIGEST_UNKNOWN:
default:
pr_err("Unsupported CHAP_A value\n");
chap_close(conn);
return NULL;
}
chap->digest_name = chap_get_digest_name(digest_type);
/* Tie the challenge length to the digest size */
chap->challenge_len = chap->digest_size;
pr_debug("[server] Got CHAP_A=%d\n", digest_type);
*aic_len = sprintf(aic_str, "CHAP_A=%d", digest_type);
*aic_len += 1;
pr_debug("[server] Sending CHAP_A=%d\n", digest_type);
/*
* 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) {
chap_close(conn);
return NULL;
}
return chap;
}
static const char base64_lookup_table[] =
Annotation
- Immediate include surface: `crypto/hash.h`, `crypto/utils.h`, `linux/kernel.h`, `linux/string.h`, `linux/err.h`, `linux/hex.h`, `linux/random.h`, `linux/scatterlist.h`.
- Detected declarations: `function chap_gen_challenge`, `function chap_test_algorithm`, `function chap_check_algorithm`, `function chap_close`, `function chap_base64_decode`, `function chap_server_compute_hash`, `function chap_main_loop`.
- Atlas domain: Driver Families / drivers/target.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.