Merge of IET r326: OpenSSL dependency removal by utilizing the md5/sha1

code from the current kernel version.



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1651 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2010-04-23 11:31:15 +00:00
parent 7d218fb344
commit 49e1187137
3 changed files with 24 additions and 16 deletions
+2 -2
View File
@@ -15,7 +15,7 @@
# GNU General Public License for more details.
SRCS_D = iscsid.c iscsi_scstd.c conn.c session.c target.c message.c ctldev.c \
log.c chap.c event.c param.c config.c isns.c
log.c chap.c event.c param.c config.c isns.c md5.o sha1.o
OBJS_D = $(SRCS_D:.c=.o)
SRCS_ADM = iscsi_adm.c param.c
@@ -30,7 +30,7 @@ CFLAGS += -O2 -fno-inline -Wall -Wextra -Wstrict-prototypes -Wno-sign-compare \
CFLAGS += -D_GNU_SOURCE # required for glibc >= 2.8
PROGRAMS = iscsi-scstd iscsi-scst-adm
LIBS = -lcrypto
LIBS =
all: $(PROGRAMS)
+14 -14
View File
@@ -27,8 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include "sha1.h"
#include "md5.h"
#include "iscsid.h"
@@ -310,25 +310,25 @@ static inline void chap_encode_string(u8 *intnum, int buf_len, char *encode_buf,
static inline void chap_calc_digest_md5(char chap_id, const char *secret, int secret_len,
const u8 *challenge, int challenge_len, u8 *digest)
{
MD5_CTX ctx;
struct md5_ctx ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, &chap_id, 1);
MD5_Update(&ctx, secret, secret_len);
MD5_Update(&ctx, challenge, challenge_len);
MD5_Final(digest, &ctx);
md5_init(&ctx);
md5_update(&ctx, &chap_id, 1);
md5_update(&ctx, secret, secret_len);
md5_update(&ctx, challenge, challenge_len);
md5_final(&ctx, digest);
}
static inline void chap_calc_digest_sha1(char chap_id, const char *secret, int secret_len,
const u8 *challenge, int challenge_len, u8 *digest)
{
SHA_CTX ctx;
struct sha1_ctx ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, &chap_id, 1);
SHA1_Update(&ctx, secret, secret_len);
SHA1_Update(&ctx, challenge, challenge_len);
SHA1_Final(digest, &ctx);
sha1_init(&ctx);
sha1_update(&ctx, &chap_id, 1);
sha1_update(&ctx, secret, secret_len);
sha1_update(&ctx, challenge, challenge_len);
sha1_final(&ctx, digest);
}
static int chap_initiator_auth_create_challenge(struct connection *conn)
+8
View File
@@ -24,11 +24,19 @@
#include <inttypes.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#define cpu_to_le16(x) bswap_16(x)
#define le16_to_cpu(x) bswap_16(x)
#define cpu_to_le32(x) bswap_32(x)
#define le32_to_cpu(x) bswap_32(x)
#define cpu_to_be16(x) (x)
#define be16_to_cpu(x) (x)
#define cpu_to_be32(x) (x)
#define be32_to_cpu(x) (x)
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#define cpu_to_le16(x) (x)
#define le16_to_cpu(x) (x)
#define cpu_to_le32(x) (x)
#define le32_to_cpu(x) (x)
#define cpu_to_be16(x) bswap_16(x)
#define be16_to_cpu(x) bswap_16(x)
#define cpu_to_be32(x) bswap_32(x)