fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
1a1a84a324206b6b1f5f704ab166c4ebf78aed76Peter Dunlap * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file implements the iSCSI CHAP authentication method based.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The code in this file is meant to be platform independent, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * makes use of only limited library functions, presently only string.h.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Platform dependent routines are defined in iscsiAuthClient.h, but
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * implemented in another file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This code in this files assumes a single thread of execution
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for each IscsiAuthClient structure, and does no locking.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "iscsi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "iscsiAuthClient.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct iscsiAuthKeyInfo_t {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsiAuthKeyInfo_t IscsiAuthKeyInfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIscsiAuthClientGlobalStats iscsiAuthClientGlobalStats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: The ordering of this table must match the order
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * defined by IscsiAuthKeyType in iscsiAuthClient.h.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IscsiAuthKeyInfo iscsiAuthClientKeyInfo[iscsiAuthKeyTypeMaxCount] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"AuthMethod"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP_A"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP_N"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP_R"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP_I"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP_C"}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char iscsiAuthClientHexString[] = "0123456789abcdefABCDEF";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char iscsiAuthClientBase64String[] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char iscsiAuthClientAuthMethodChapOptionName[] = "CHAP";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckString(const char *s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int maxLength, unsigned int *pOutLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!s) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (length = 0; length < maxLength; length++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*s++ == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pOutLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pOutLength = length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientStringCopy(char *stringOut, const char *stringIn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int length)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!stringOut || !stringIn || length == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((*stringOut++ = *stringIn++) != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (--length == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stringOut--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *stringOut = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientStringAppend(char *stringOut, const char *stringIn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int length)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!stringOut || !stringIn || length == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*stringOut++ != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (--length == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stringOut--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *stringOut = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stringOut--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((*stringOut++ = *stringIn++) != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (--length == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stringOut--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *stringOut = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientStringIndex(const char *s, int c)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*s != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*s++ == c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckNodeType(int nodeType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodeType == iscsiAuthNodeTypeInitiator ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckVersion(int value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (value == iscsiAuthVersionDraft8 || value == iscsiAuthVersionRfc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckNegRole(int value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (value == iscsiAuthNegRoleOriginator ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value == iscsiAuthNegRoleResponder) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckAuthMethodOption(int value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (value == iscsiAuthOptionNone || value == iscsiAuthMethodChap) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientAuthMethodOptionToText(IscsiAuthClient * client, int value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthOptionReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = client->rejectOptionName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthOptionNone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = client->noneOptionName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthMethodChap:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = iscsiAuthClientAuthMethodChapOptionName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckChapAlgorithmOption(int chapAlgorithm)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapAlgorithm == iscsiAuthOptionNone ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapAlgorithm == iscsiAuthChapAlgorithmMd5) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientDataToHex(unsigned char *data, unsigned int dataLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *text, unsigned int textLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned long n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!text || textLength == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!data || dataLength == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = '0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = 'x';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (dataLength > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientHexString[(n >> 4) & 0xf];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientHexString[n & 0xf];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientDataToBase64(unsigned char *data, unsigned int dataLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *text, unsigned int textLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned long n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!text || textLength == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!data || dataLength == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = '0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = 'b';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (dataLength >= 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 5) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = (n << 8) | *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = (n << 8) | *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength -= 3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 18) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 12) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 6) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[n & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 5) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = n << 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 6) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[n & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = '=';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = '=';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (dataLength == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (textLength < 5) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = (n << 8) | *data++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = n << 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 12) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[(n >> 6) & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = iscsiAuthClientBase64String[n & 0x3f];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++ = '=';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientDataToText(int base64, unsigned char *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int dataLength, char *text, unsigned int textLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (base64) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientDataToBase64(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte data, dataLength, text, textLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientDataToHex(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte data, dataLength, text, textLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientHexToData(const char *text, unsigned int textLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *data, unsigned int *pDataLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int n1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int n2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int dataLength = *pDataLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((textLength % 2) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = iscsiAuthClientStringIndex(iscsiAuthClientHexString,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *text++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, bad character */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 15)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i -= 6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n2 = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, too much data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*text != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = iscsiAuthClientStringIndex(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientHexString, *text++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, bad character */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 15)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i -= 6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n1 = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*text == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, odd string length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = iscsiAuthClientStringIndex(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientHexString, *text++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, bad character */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 15)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i -= 6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n2 = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, too much data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = (n1 << 4) | n2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength >= *pDataLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, no data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pDataLength = *pDataLength - dataLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE); /* no error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientBase64ToData(const char *text, unsigned int textLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *data, unsigned int *pDataLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int dataLength = *pDataLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength = textLength; /* not used */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*text != '\0' && *text != '=') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = iscsiAuthClientStringIndex(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientBase64String, *text++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, bad character */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = (n << 6 | (unsigned int)i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count >= 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, too much data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n >> 16;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n >> 8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength -= 3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*text != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*text++ != '=') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, bad pad */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do nothing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* EMPTY */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (count == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, too much data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = n >> 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (count == 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength < 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, too much data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = n >> 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n >> 8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *data++ = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dataLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* bad encoding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dataLength >= *pDataLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE); /* error, no data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pDataLength = *pDataLength - dataLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE); /* no error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientTextToData(const char *text, unsigned char *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int *dataLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int textLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientCheckString(text,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 2 + 2 * iscsiAuthLargeBinaryMaxLength + 1, &textLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (text[0] == '0' && (text[1] == 'x' || text[1] == 'X')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * skip prefix
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte text += 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientHexToData(text,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength, data, dataLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (text[0] == '0' && (text[1] == 'b' || text[1] == 'B')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * skip prefix
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte text += 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength -= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientBase64ToData(text,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte textLength, data, dataLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = TRUE; /* prefix not recognized. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IscsiAuthDebugStatus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientChapComputeResponse(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int remoteAuthentication, unsigned int id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *challengeData, unsigned int challengeLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *responseData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char idData[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthMd5Context context;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char outData[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int outLength = iscsiAuthStringMaxLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client->passwordPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthDebugStatusLocalPasswordNotSet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMd5Init(&context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id byte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idData[0] = id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMd5Update(&context, idData, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * decrypt password
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientData(outData, &outLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->passwordData, client->passwordLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthDebugStatusPasswordDecryptFailed);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!remoteAuthentication && !client->ipSec && outLength < 12) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthDebugStatusPasswordTooShortWithNoIpSec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * shared secret
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMd5Update(&context, outData, outLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * clear decrypted password
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(outData, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * challenge value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMd5Update(&context, challengeData, challengeLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMd5Final(responseData, &context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthDebugStatusNotSet); /* no error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientInitKeyBlock(IscsiAuthKeyBlock * keyBlock)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *stringBlock = keyBlock->stringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(keyBlock, sizeof (*keyBlock));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->stringBlock = stringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetKeyValue(IscsiAuthKeyBlock * keyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType, const char *keyValue)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *string;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyBlock->key[keyType].valueSet) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->duplicateSet = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->key[keyType].valueSet = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!keyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientCheckString(keyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStringMaxLength, &length)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->stringTooLong = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length += 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((keyBlock->blockLength + length) > iscsiAuthStringBlockMaxLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->tooMuchData = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string = &keyBlock->stringBlock[keyBlock->blockLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientStringCopy(string, keyValue, length)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->tooMuchData = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->blockLength += length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->key[keyType].string = string;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->key[keyType].present = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetKeyValue(IscsiAuthKeyBlock * keyBlock, int keyType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyBlock->key[keyType].processed = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!keyBlock->key[keyType].present) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (keyBlock->key[keyType].string);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckKey(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *negotiatedOption,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *optionList, const char *(*valueToText) (IscsiAuthClient *, int))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *keyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue = iscsiAuthClientGetKeyValue(&client->recvKeyBlock, keyType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!keyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *negotiatedOption = iscsiAuthOptionNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*keyValue != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*keyValue != '\0' && *keyValue != ',') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue[length++] = *keyValue++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*keyValue == ',')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue[length++] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < optionCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *s = (*valueToText) (client, optionList[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(client->scratchKeyValue, s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *negotiatedOption = optionList[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *negotiatedOption = iscsiAuthOptionReject;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetKey(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *optionList, const char *(*valueToText) (IscsiAuthClient *, int))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optionCount == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No valid options to send, but we always want to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * send something.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock, keyType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->noneOptionName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optionCount == 1 && optionList[0] == iscsiAuthOptionNotPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock, keyType, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < optionCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *s = (*valueToText) (client, optionList[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringCopy(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringAppend(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ",", iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringAppend(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyType, client->scratchKeyValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckAuthMethodKey(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckKey(client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeAuthMethod,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->negotiatedAuthMethod,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidList, iscsiAuthClientAuthMethodOptionToText);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetAuthMethodKey(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int authMethodCount, int *authMethodList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKey(client, iscsiAuthKeyTypeAuthMethod,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authMethodCount, authMethodList,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientAuthMethodOptionToText);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckChapAlgorithmKey(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *keyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned long number;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue = iscsiAuthClientGetKeyValue(&client->recvKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!keyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedChapAlgorithm = iscsiAuthOptionNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*keyValue != '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*keyValue != '\0' && *keyValue != ',') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue[length++] = *keyValue++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*keyValue == ',')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue[length++] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientTextToNumber(client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &number)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < client->chapAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (number == (unsigned long)client->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapAlgorithmList[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedChapAlgorithm = number;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedChapAlgorithm = iscsiAuthOptionReject;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetChapAlgorithmKey(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int chapAlgorithmCount, int *chapAlgorithmList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapAlgorithmCount == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapAlgorithmCount == 1 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapAlgorithmList[0] == iscsiAuthOptionNotPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapAlgorithmCount == 1 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapAlgorithmList[0] == iscsiAuthOptionReject) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm, client->rejectOptionName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < chapAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char s[20];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNumberToText(chapAlgorithmList[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s, sizeof (s));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringCopy(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue, s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringAppend(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ",", iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringAppend(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm, client->scratchKeyValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientNextPhase(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->phase) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseConfigure:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseNegotiate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseNegotiate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseAuthenticate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionReject ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionNotPresent ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedAuthMethod == iscsiAuthOptionNone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusPass;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->negotiatedAuthMethod) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthOptionReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthMethodReject;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthOptionNotPresent:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthMethodNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthOptionNone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthMethodNone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthMethodChap) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateSendAlgorithm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateSendAlgorithm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusAuthMethodBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseAuthenticate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseDone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientLocalAuthentication(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int chapIdentifier;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char responseData[iscsiAuthChapResponseLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned long number;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthDebugStatus debugStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *chapIdentifierKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *chapChallengeKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->localState) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthLocalStateSendAlgorithm:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetChapAlgorithmKey(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client, client->chapAlgorithmCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->chapAlgorithmList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateRecvAlgorithm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthLocalStateRecvAlgorithm:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckChapAlgorithmKey(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetChapAlgorithmKey(client, 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->negotiatedChapAlgorithm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make sure only supported CHAP algorithm is used.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->negotiatedChapAlgorithm ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionNotPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapAlgorithmExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->negotiatedChapAlgorithm ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionReject) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapAlgorithmReject;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->negotiatedChapAlgorithm !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthChapAlgorithmMd5) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapAlgorithmBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateRecvChallenge;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthLocalStateRecvChallenge:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapIdentifierKeyValue = iscsiAuthClientGetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->recvKeyBlock, iscsiAuthKeyTypeChapIdentifier);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapChallengeKeyValue = iscsiAuthClientGetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->recvKeyBlock, iscsiAuthKeyTypeChapChallenge);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!chapIdentifierKeyValue && !chapChallengeKeyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!chapIdentifierKeyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapIdentifierExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!chapChallengeKeyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapChallengeExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientTextToNumber(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapIdentifierKeyValue, &number);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status || (255 < number)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapIdentifierBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapIdentifier = number;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvChapChallengeStatus) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapChallengeBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.length ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcmp(client->recvChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapChallengeReflected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte debugStatus = iscsiAuthClientChapComputeResponse(client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FALSE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapIdentifier,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.length, responseData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (debugStatus != iscsiAuthDebugStatusNotSet) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = debugStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientDataToText(client->base64,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte responseData, iscsiAuthChapResponseLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapResponse, client->scratchKeyValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapUsername, client->username);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->localState = iscsiAuthLocalStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthLocalStateDone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthLocalStateError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRemoteAuthentication(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char idData[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char responseData[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int responseLength = iscsiAuthStringMaxLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char myResponseData[iscsiAuthChapResponseLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthDebugStatus debugStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *chapResponseKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *chapUsernameKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->remoteState) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateSendAlgorithm:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateSendChallenge;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateSendChallenge:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client->authRemote) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusPass;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthRemoteFalse;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthRandomSetData(idData, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapIdentifier = idData[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNumberToText(client->sendChapIdentifier,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->scratchKeyValue, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapIdentifier, client->scratchKeyValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length = client->chapChallengeLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthRandomSetData(client->sendChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapChallenge, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateRecvResponse;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateRecvResponse:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapResponseKeyValue = iscsiAuthClientGetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->recvKeyBlock, iscsiAuthKeyTypeChapResponse);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapUsernameKeyValue = iscsiAuthClientGetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->recvKeyBlock, iscsiAuthKeyTypeChapUsername);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!chapResponseKeyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapResponseExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!chapUsernameKeyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapUsernameExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientTextToData(chapResponseKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte responseData, &responseLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusChapResponseBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (responseLength == iscsiAuthChapResponseLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte debugStatus = iscsiAuthClientChapComputeResponse(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client, TRUE, client->sendChapIdentifier,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length, myResponseData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if the same CHAP secret is being used for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * authentication in both directions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (debugStatus == iscsiAuthDebugStatusNotSet &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcmp(myResponseData, responseData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthChapResponseLength) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthRemoteStateError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusPasswordIdentical;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsiAuthClientStringCopy(client->chapUsername,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapUsernameKeyValue, iscsiAuthStringMaxLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* To verify the target's response. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientChapAuthRequest(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client, client->chapUsername, client->sendChapIdentifier,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length, responseData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte responseLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == iscsiAuthStatusInProgress) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientGlobalStats.requestSent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateAuthRequest;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = (IscsiAuthStatus) status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authResponseFlag = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateAuthRequest:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client->remoteAuthStatus already set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authServerErrorFlag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthServerError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->remoteAuthStatus == iscsiAuthStatusPass) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusAuthPass;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->remoteAuthStatus == iscsiAuthStatusFail) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusAuthFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusAuthStatusBad;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState = iscsiAuthRemoteStateDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateDone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthRemoteStateError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientHandshake(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Should only happen if authentication
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * protocol error occured.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->remoteState == iscsiAuthRemoteStateAuthRequest) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Defer until authentication response received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from internal authentication service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Target should only have set T bit on response if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator set it on previous message.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvKeyBlock.transitBit &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->transitBitSentFlag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusTbitSetIllegal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseNegotiate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Should only happen if waiting for peer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to send AuthMethod key or set Transit Bit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->remoteState == iscsiAuthRemoteStateRecvResponse ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState == iscsiAuthRemoteStateDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvKeyBlock.transitBit) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->remoteState !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthRemoteStateDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto recvTransitBitError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->remoteState == iscsiAuthRemoteStateDone &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus != iscsiAuthStatusPass) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Authentication failed, don't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do T bit handshake.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Target can only set T bit on response if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator set it on current message.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvKeyBlock.transitBit) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvKeyBlock.transitBit) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto recvTransitBitError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForterecvTransitBitError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Target set T bit on response but
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator was not done with authentication.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusTbitSetPremature;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRecvEndStatus(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int authStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Perform sanity check against configured parameters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote && !client->authResponseFlag &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus == iscsiAuthStatusPass) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthPassNotValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = client->remoteAuthStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->remoteState == iscsiAuthRemoteStateAuthRequest) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusInProgress;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusContinue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authStatus != iscsiAuthStatusInProgress) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvInProgressFlag = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authStatus == iscsiAuthStatusContinue ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus == iscsiAuthStatusPass) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->sendKeyBlock.duplicateSet) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusSendDuplicateSetKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->sendKeyBlock.stringTooLong) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusSendStringTooLong;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->sendKeyBlock.tooMuchData) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusSendTooMuchData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check that all incoming keys have been processed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (keyType = iscsiAuthKeyTypeFirst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyType < iscsiAuthKeyTypeMaxCount; keyType++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvKeyBlock.key[keyType].present &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvKeyBlock.key[keyType].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte processed == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType < iscsiAuthKeyTypeMaxCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusUnexpectedKeyPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authStatus != iscsiAuthStatusPass &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus != iscsiAuthStatusContinue &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus != iscsiAuthStatusInProgress) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int authMethodKeyPresent = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int chapAlgorithmKeyPresent = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Suppress send keys on error, except
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for AuthMethod and CHAP_A.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientGetKeyValue(&client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeAuthMethod)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authMethodKeyPresent = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (iscsiAuthClientGetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapAlgorithmKeyPresent = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientInitKeyBlock(&client->sendKeyBlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authMethodKeyPresent &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionReject) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeAuthMethod,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->rejectOptionName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (chapAlgorithmKeyPresent &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedChapAlgorithm ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionReject) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->sendKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthKeyTypeChapAlgorithm,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->rejectOptionName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (authStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRecvBegin(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvInProgressFlag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvInProgressFlag = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseConfigure) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->transitBitSentFlag = client->sendKeyBlock.transitBit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientInitKeyBlock(&client->recvKeyBlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientInitKeyBlock(&client->sendKeyBlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRecvEnd(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthClientCallback * callback, void *userHandle, void *messageHandle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nextPhaseFlag = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase == iscsiAuthPhaseError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!callback || !client->recvInProgressFlag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->recvEndCount > iscsiAuthRecvEndMaxCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusRecvMessageCountLimit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->recvKeyBlock.duplicateSet) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusRecvDuplicateSetKeyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->recvKeyBlock.stringTooLong) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusRecvStringTooLong;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (client->recvKeyBlock.tooMuchData) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus = iscsiAuthDebugStatusRecvTooMuchData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvEndCount++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->userHandle = userHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->messageHandle = messageHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->phase) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseNegotiate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckAuthMethodKey(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authMethodValidNegRole ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthNegRoleResponder) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionNotPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvKeyBlock.transitBit == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No AuthMethod key from peer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on first message, try moving
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the process along by sending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the AuthMethod key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidNegRole =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthNegRoleOriginator;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodKey(client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special case if peer sent no
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AuthMethod key, but did set Transit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bit, allowing this side to do a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * null authentication, and compelete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the iSCSI security phase without
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * either side sending the AuthMethod
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Send response to AuthMethod key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodKey(client, 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->negotiatedAuthMethod);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nextPhaseFlag = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->negotiatedAuthMethod ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthOptionNotPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->debugStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthDebugStatusAuthMethodExpected;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseAuthenticate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseDone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->phase) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseNegotiate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nextPhaseFlag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientNextPhase(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseAuthenticate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must call iscsiAuthClientLocalAuthentication()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before iscsiAuthClientRemoteAuthentication()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to insure processing of the CHAP algorithm key,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and to avoid leaving an in progress request to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * authentication service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientLocalAuthentication(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->localState != iscsiAuthLocalStateError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientRemoteAuthentication(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->localState == iscsiAuthLocalStateError ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState == iscsiAuthRemoteStateError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = iscsiAuthStatusFail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseDone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client->debugStatus should already be set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthPhaseDone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientHandshake(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthClientRecvEndStatus(client));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientAuthResponse(IscsiAuthClient * client, int authStatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientGlobalStats.responseReceived++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client->recvInProgressFlag ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteState != iscsiAuthRemoteStateAuthRequest) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->remoteAuthStatus = (IscsiAuthStatus) authStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authResponseFlag = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientRemoteAuthentication(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientHandshake(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authStatus = iscsiAuthClientRecvEndStatus(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->callback(client->userHandle, client->messageHandle, authStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetKeyName(int keyType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType < iscsiAuthKeyTypeFirst || keyType > iscsiAuthKeyTypeLast) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthClientKeyInfo[keyType].name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetNextKeyType(int *pKeyType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType = *pKeyType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType >= iscsiAuthKeyTypeLast) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType < iscsiAuthKeyTypeFirst) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyType = iscsiAuthKeyTypeFirst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyType++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pKeyType = keyType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientKeyNameToKeyType(const char *keyName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int keyType = iscsiAuthKeyTypeNone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iscsiAuthClientGetNextKeyType(&keyType) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStatusNoError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *keyName2 = iscsiAuthClientGetKeyName(keyType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!keyName2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthKeyTypeNone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(keyName, keyName2) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (keyType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthKeyTypeNone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRecvKeyValue(IscsiAuthClient * client, int keyType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *userKeyValue)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType < iscsiAuthKeyTypeFirst || keyType > iscsiAuthKeyTypeLast) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType == iscsiAuthKeyTypeChapChallenge) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.length =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthLargeBinaryMaxLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallengeStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientTextToData(userKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->recvChapChallenge.length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userKeyValue = "";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetKeyValue(&client->recvKeyBlock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyType, userKeyValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSendKeyValue(IscsiAuthClient * client, int keyType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *keyPresent, char *userKeyValue, unsigned int maxLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *keyValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType < iscsiAuthKeyTypeFirst || keyType > iscsiAuthKeyTypeLast) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue = iscsiAuthClientGetKeyValue(&client->sendKeyBlock, keyType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (keyType == iscsiAuthKeyTypeChapChallenge) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientDataToText(client->base64,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.largeBinary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userKeyValue, maxLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientStringCopy(userKeyValue,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte keyValue, maxLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *keyPresent = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *keyPresent = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientRecvTransitBit(IscsiAuthClient * client, int value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvKeyBlock.transitBit = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvKeyBlock.transitBit = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSendTransitBit(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->sendKeyBlock.transitBit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientInit(int nodeType, int bufferDescCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthBufferDesc * bufferDesc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthClient *client;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthStringBlock *recvStringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthStringBlock *sendStringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthLargeBinary *recvChapChallenge;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthLargeBinary *sendChapChallenge;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int valueList[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bufferDescCount != 5 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!bufferDesc[0].address ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc[0].length != sizeof (*client)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client = (IscsiAuthClient *) bufferDesc[0].address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bufferDesc[1].address == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc[1].length != sizeof (*recvStringBlock)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte recvStringBlock = (IscsiAuthStringBlock *) bufferDesc[1].address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bufferDesc[2].address == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc[2].length != sizeof (*sendStringBlock)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sendStringBlock = (IscsiAuthStringBlock *) bufferDesc[2].address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bufferDesc[3].address == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc[3].length != sizeof (*recvChapChallenge)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte recvChapChallenge = (IscsiAuthLargeBinary *) bufferDesc[3].address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bufferDesc[4].address == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufferDesc[4].length != sizeof (*sendChapChallenge)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sendChapChallenge = (IscsiAuthLargeBinary *) bufferDesc[4].address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(client, sizeof (*client));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(recvStringBlock, sizeof (*recvStringBlock));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(sendStringBlock, sizeof (*sendStringBlock));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(recvChapChallenge, sizeof (*recvChapChallenge));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(sendChapChallenge, sizeof (*sendChapChallenge));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvKeyBlock.stringBlock = recvStringBlock->stringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.stringBlock = sendStringBlock->stringBlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->recvChapChallenge.largeBinary = recvChapChallenge->largeBinary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendChapChallenge.largeBinary = sendChapChallenge->largeBinary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientCheckNodeType(nodeType)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->signature = iscsiAuthClientSignature;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->nodeType = (IscsiAuthNodeType) nodeType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Assume bi-directional authentication enabled. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authRemote = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->passwordPresent = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->version = iscsiAuthVersionRfc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->chapChallengeLength = iscsiAuthChapResponseLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->ipSec = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->base64 = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseConfigure;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedAuthMethod = iscsiAuthOptionNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->negotiatedChapAlgorithm = iscsiAuthOptionNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodNegRole = iscsiAuthNegRoleOriginator;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initial value ignored for Target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodNegRole = iscsiAuthNegRoleResponder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* All supported authentication methods */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valueList[0] = iscsiAuthMethodChap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valueList[1] = iscsiAuthOptionNone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must call after setting authRemote, password,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * version and authMethodNegRole
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientSetAuthMethodList(client, 2, valueList) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStatusNoError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valueList[0] = iscsiAuthChapAlgorithmMd5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientSetChapAlgorithmList(client, 1, valueList) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStatusNoError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientFinish(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientChapAuthCancel(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(client, sizeof (*client));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetOptionList(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int *optionList,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int *clientOptionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *clientOptionList,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionMaxCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*checkOption) (int),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*checkList) (unsigned int optionCount, const int *optionList))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionCount > optionMaxCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < optionCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*checkOption) (optionList[i])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for duplicate entries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < optionCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < optionCount; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j == i)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optionList[i] == optionList[j]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for key specific constraints.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (checkList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*checkList) (optionCount, optionList)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < optionCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clientOptionList[i] = optionList[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *clientOptionCount = optionCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetAuthMethodValid(IscsiAuthClient * client)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const char rejectOptionNameDraft8[] = "reject";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const char rejectOptionNameRfc[] = "Reject";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const char noneOptionNameDraft8[] = "none";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const char noneOptionNameRfc[] = "None";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int option = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->version == iscsiAuthVersionDraft8) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->rejectOptionName = rejectOptionNameDraft8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->noneOptionName = noneOptionNameDraft8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->rejectOptionName = rejectOptionNameRfc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->noneOptionName = noneOptionNameRfc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Following checks may need to be revised if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * authentication options other than CHAP and none
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If initiator doing authentication,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * don't offer authentication option none.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!client->passwordPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If initiator password not set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only offer authentication option none.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If target doing authentication,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * don't accept authentication option none.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If target not doing authentication,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only accept authentication option none.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < client->authMethodCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (option == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authMethodList[i] == iscsiAuthOptionNone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (option == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authMethodList[i] != iscsiAuthOptionNone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidList[j++] = client->authMethodList[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidCount = j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientInitKeyBlock(&client->sendKeyBlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initiator wants to authenticate target,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * always send AuthMethod key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidNegRole =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthNegRoleOriginator;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidNegRole =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodNegRole;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->sendKeyBlock.transitBit = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidNegRole = iscsiAuthNegRoleResponder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authMethodValidNegRole == iscsiAuthNegRoleOriginator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodKey(client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodValidList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int value = iscsiAuthOptionNotPresent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodKey(client, 1, &value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckAuthMethodList(unsigned int optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int *optionList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!optionList || optionCount < 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optionList[optionCount - 1] != iscsiAuthOptionNone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (optionCount - 1); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optionList[i] != iscsiAuthOptionNone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetAuthMethodList(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionCount, const int *optionList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = iscsiAuthClientSetOptionList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client, optionCount, optionList, &client->authMethodCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodList, iscsiAuthMethodMaxCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckAuthMethodOption,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckAuthMethodList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != iscsiAuthStatusNoError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting authMethod affects authMethodValid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodValid(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetAuthMethodNegRole(IscsiAuthClient * client, int negRole)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckNegRole(negRole) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->nodeType != iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authMethodNegRole = (IscsiAuthNegRole) negRole;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting negRole affects authMethodValid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodValid(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckChapAlgorithmList(unsigned int optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int *optionList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!optionList || optionCount < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetChapAlgorithmList(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int optionCount, const int *optionList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthClientSetOptionList(client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &client->chapAlgorithmCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->chapAlgorithmList,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthChapAlgorithmMaxCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckChapAlgorithmOption,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckChapAlgorithmList));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetUsername(IscsiAuthClient * client, const char *username)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckString(username, iscsiAuthStringMaxLength, 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientStringCopy(client->username, username,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStringMaxLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetPassword(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const unsigned char *passwordData, unsigned int passwordLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte passwordLength > iscsiAuthStringMaxLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(passwordData, client->passwordData, passwordLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->passwordLength = passwordLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->passwordLength > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->passwordPresent = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->passwordPresent = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting password may affect authMethodValid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodValid(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetAuthRemote(IscsiAuthClient * client, int authRemote)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->authRemote = authRemote;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setting authRemote may affect authMethodValid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodValid(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetGlueHandle(IscsiAuthClient * client, void *glueHandle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->glueHandle = glueHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetMethodListName(IscsiAuthClient *client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *methodListName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckString(methodListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStringMaxLength, 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientStringCopy(client->methodListName, methodListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthStringMaxLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetVersion(IscsiAuthClient * client, int version)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientCheckVersion(version)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->version = (IscsiAuthVersion) version;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsiAuthClientSetAuthMethodValid(client);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetIpSec(IscsiAuthClient * client, int ipSec)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->ipSec = ipSec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetBase64(IscsiAuthClient * client, int base64)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->base64 = base64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSetChapChallengeLength(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int chapChallengeLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapChallengeLength < iscsiAuthChapResponseLength ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapChallengeLength > iscsiAuthLargeBinaryMaxLength) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->chapChallengeLength = chapChallengeLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientCheckPasswordNeeded(IscsiAuthClient *client, int *passwordNeeded)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->authRemote && !client->passwordPresent) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *passwordNeeded = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *passwordNeeded = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *passwordNeeded = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetAuthPhase(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->phase;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetAuthStatus(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->remoteAuthStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientAuthStatusPass(int authStatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authStatus == iscsiAuthStatusPass) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetAuthMethod(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->negotiatedAuthMethod;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetChapAlgorithm(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->negotiatedChapAlgorithm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetChapUsername(IscsiAuthClient * client,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *value, unsigned int maxLength)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscsiAuthClientStringCopy(value, client->chapUsername, maxLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientSendStatusCode(IscsiAuthClient * client, int *statusCode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseConfigure &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseNegotiate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseAuthenticate &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->remoteAuthStatus) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusPass:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0000; /* no error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusFail:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (client->debugStatus) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthFail:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Authentication error with peer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0201;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapIdentifierExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapResponseExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapUsernameExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Missing parameter with peer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0207;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodNotPresent:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodNone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeReflected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordIdentical:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Could not authenticate with peer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0201;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusLocalPasswordNotSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local password not set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0200;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0201;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapIdentifierBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapResponseBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusUnexpectedKeyPresent:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusTbitSetIllegal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusTbitSetPremature:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvMessageCountLimit:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvDuplicateSetKeyValue:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvStringTooLong:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvTooMuchData:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Other error with peer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0200;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusNotSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthPass:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthRemoteFalse:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordDecryptFailed:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordTooShortWithNoIpSec:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthServerError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthStatusBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthPassNotValid:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendDuplicateSetKeyValue:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendStringTooLong:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendTooMuchData:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Error on this side.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0200;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusNoError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusContinue:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthStatusInProgress:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bad authStatus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->nodeType == iscsiAuthNodeTypeInitiator) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0200;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Initiator error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *statusCode = 0x0300;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Target error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientGetDebugStatus(IscsiAuthClient * client, int *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!client || client->signature != iscsiAuthClientSignature) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (client->phase != iscsiAuthPhaseDone) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte client->phase = iscsiAuthPhaseError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = client->debugStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iscsiAuthStatusNoError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiscsiAuthClientDebugStatusToText(int debugStatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (debugStatus) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusNotSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Debug status not set";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthPass:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Authentication request passed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthRemoteFalse:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Authentication not enabled";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthFail:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Authentication request failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "AuthMethod bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP algorithm bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordDecryptFailed:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Decrypt password failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordTooShortWithNoIpSec:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Local password too short with no IPSec";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthServerError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Unexpected error from authentication server";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthStatusBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Authentication request status bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthPassNotValid:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Authentication pass status not valid";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendDuplicateSetKeyValue:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Same key set more than once on send";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendStringTooLong:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Key value too long on send";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusSendTooMuchData:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Too much data on send";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "AuthMethod key expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP algorithm key expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapIdentifierExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP identifier expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP challenge expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapResponseExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP response expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapUsernameExpected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP username expected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodNotPresent:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "AuthMethod key not present";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "AuthMethod negotiation failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusAuthMethodNone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "AuthMethod negotiated to none";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapAlgorithmReject:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP algorithm negotiation failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeReflected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP challange reflected";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusPasswordIdentical:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Local password same as remote";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusLocalPasswordNotSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Local password not set";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapIdentifierBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP identifier bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapChallengeBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP challenge bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusChapResponseBad:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "CHAP response bad";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusUnexpectedKeyPresent:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Unexpected key present";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusTbitSetIllegal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "T bit set on response, but not on previous message";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusTbitSetPremature:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "T bit set on response, but authenticaton not complete";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvMessageCountLimit:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Message count limit reached on receive";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvDuplicateSetKeyValue:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Same key set more than once on receive";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvStringTooLong:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Key value too long on receive";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iscsiAuthDebugStatusRecvTooMuchData:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Too much data on receive";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = "Unknown error";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}