📄 iscsiauthclientglue.c
字号:
/* * iSCSI connection daemon * Copyright (C) 2001 Cisco Systems, Inc. * maintained by linux-iscsi@cisco.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * See the file COPYING included with this distribution for more details. * * $Id: iscsiAuthClientGlue.c,v 1.7 2002/09/23 18:23:57 smferris Exp $ * */#include "iscsiAuthClient.h"#include "iscsi-platform.h"intiscsiAuthClientChapAuthRequest( IscsiAuthClient *client, char *username, unsigned int id, unsigned char *challengeData, unsigned int challengeLength, unsigned char *responseData, unsigned int responseLength){ return iscsiAuthStatusFail;}voidiscsiAuthClientChapAuthCancel(IscsiAuthClient *client){}intiscsiAuthClientTextToNumber(const char *text, unsigned long *pNumber){ char *pEnd; unsigned long number; if (text[0] == '0' && (text[1] == 'x' || text[1] == 'X')) { number = iscsi_strtoul(text + 2, &pEnd, 16); } else { number = iscsi_strtoul(text, &pEnd, 10); } if (*text != '\0' && *pEnd == '\0') { *pNumber = number; return 0; /* No error */ } else { return 1; /* Error */ }}voidiscsiAuthClientNumberToText(unsigned long number, char *text, unsigned int length){ iscsi_sprintf(text, "%lu", number);}voidiscsiAuthRandomSetData(unsigned char *data, unsigned int length){#if defined(LINUX) && defined(__KERNEL__) get_random_bytes(data, length);#else long r; unsigned n; while (length > 0) { r = rand(); r = r ^ (r >> 8); r = r ^ (r >> 4); n = r & 0x7; r = rand(); r = r ^ (r >> 8); r = r ^ (r >> 5); n = (n << 3) | (r & 0x7); r = rand(); r = r ^ (r >> 8); r = r ^ (r >> 5); n = (n << 2) | (r & 0x3); *data++ = n; length--; }#endif}voidiscsiAuthMd5Init(IscsiAuthMd5Context *context){ MD5Init(context);}voidiscsiAuthMd5Update( IscsiAuthMd5Context *context, unsigned char *data, unsigned int length){ MD5Update(context, data, length);}voidiscsiAuthMd5Final(unsigned char *hash, IscsiAuthMd5Context *context){ MD5Final(hash, context);}intiscsiAuthClientData( unsigned char *outData, unsigned int *outLength, unsigned char *inData, unsigned int inLength){ if (*outLength < inLength) return 1; /* error */ memcpy(outData, inData, inLength); *outLength = inLength; return 0; /* no error */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -