#ifndef _ISCSIT_AUTHCLIENT_H_
#define _ISCSIT_AUTHCLIENT_H_
#define ISCSI_AUTH_PASSED 0
#define ISCSI_AUTH_FAILED 1
enum { iscsitAuthStringMaxLength = 256 };
enum { AuthStringMaxLength = 256 };
enum { AuthStringBlockMaxLength = 1024 };
enum { AuthLargeBinaryMaxLength = 1024 };
enum { iscsitAuthChapResponseLength = 16 };
enum { iscsitAuthMethodMaxCount = 2 };
enum { iscsitAuthChapAlgorithmMd5 = 5 };
enum {
AKT_CHAP_A = 0,
AKT_CHAP_I,
AKT_CHAP_C,
AKT_CHAP_N,
AKT_CHAP_R,
AUTH_KEY_TYPE_MAX
};
typedef union auth_value {
uint32_t numeric;
char *string;
unsigned char *binary;
} auth_value_t;
typedef struct auth_key {
unsigned char present;
unsigned int len;
auth_value_t value;
} auth_key_t;
typedef struct iscsit_auth_key_block {
auth_key_t key[AUTH_KEY_TYPE_MAX];
} auth_key_block_t;
typedef struct auth_large_binary {
unsigned char largeBinary[AuthLargeBinaryMaxLength];
} auth_large_binary_t;
typedef enum {
AM_CHAP = 1,
AM_KRB5,
AM_SPKM1,
AM_SPKM2,
AM_SRP,
AM_NONE
} iscsit_auth_method_t;
typedef enum {
AP_AM_UNDECIDED = 0,
AP_AM_PROPOSED,
AP_AM_DECIDED,
AP_CHAP_A_WAITING,
AP_CHAP_A_RCVD,
AP_CHAP_R_WAITING,
AP_CHAP_R_RCVD,
AP_KRB_REQ_WAITING,
AP_KRB_REQ_RCVD,
AP_DONE
} iscsit_auth_phase_t;
typedef struct iscsit_auth_client {
iscsit_auth_phase_t phase;
iscsit_auth_method_t negotiatedMethod;
auth_large_binary_t auth_send_binary_block;
auth_key_block_t recvKeyBlock;
auth_key_block_t sendKeyBlock;
} iscsit_auth_client_t;
void
client_set_numeric_data(auth_key_block_t *keyBlock,
int key_type,
uint32_t numeric);
void
client_set_string_data(auth_key_block_t *keyBlock,
int key_type,
char *string);
void
client_set_binary_data(auth_key_block_t *keyBlock,
int key_type,
unsigned char *binary, unsigned int len);
void
client_get_numeric_data(auth_key_block_t *keyBlock,
int key_type,
uint32_t *numeric);
void
client_get_string_data(auth_key_block_t *keyBlock,
int key_type,
char **string);
void
client_get_binary_data(auth_key_block_t *keyBlock,
int key_type,
unsigned char **binary, unsigned int *len);
int
client_auth_key_present(auth_key_block_t *keyBlock,
int key_type);
void
client_compute_chap_resp(uchar_t *resp,
unsigned int chap_i,
uint8_t *password, int password_len,
uchar_t *chap_c, unsigned int challenge_len);
int
client_verify_chap_resp(char *target_chap_name, char *initiator_chap_name,
uint8_t *password, int password_len,
unsigned int chap_i, uchar_t *chap_c, unsigned int challenge_len,
uchar_t *chap_r, unsigned int resp_len);
void
auth_random_set_data(uchar_t *data, unsigned int length);
#endif