~ubuntu-branches/ubuntu/trusty/iscsitarget/trusty

« back to all changes in this revision

Viewing changes to usr/chap.c

  • Committer: Colin Watson
  • Date: 2010-08-16 20:59:52 UTC
  • mfrom: (2.1.9 sid)
  • Revision ID: cjwatson@canonical.com-20100816205952-hyytf817ju6wk1bj
merge from Debian 1.4.20.2-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <stdio.h>
18
18
#include <stdlib.h>
19
19
#include <string.h>
20
 
#include <openssl/sha.h>
21
 
#include <openssl/md5.h>
 
20
#include "sha1.h"
 
21
#include "md5.h"
22
22
 
23
23
#include "iscsid.h"
24
24
 
300
300
 
301
301
static inline void chap_calc_digest_md5(char chap_id, char *secret, int secret_len, u8 *challenge, int challenge_len, u8 *digest)
302
302
{
303
 
        MD5_CTX ctx;
 
303
        struct md5_ctx ctx;
304
304
 
305
 
        MD5_Init(&ctx);
306
 
        MD5_Update(&ctx, &chap_id, 1);
307
 
        MD5_Update(&ctx, secret, secret_len);
308
 
        MD5_Update(&ctx, challenge, challenge_len);
309
 
        MD5_Final(digest, &ctx);
 
305
        md5_init(&ctx);
 
306
        md5_update(&ctx, &chap_id, 1);
 
307
        md5_update(&ctx, secret, secret_len);
 
308
        md5_update(&ctx, challenge, challenge_len);
 
309
        md5_final(&ctx, digest);
310
310
}
311
311
 
312
312
static inline void chap_calc_digest_sha1(char chap_id, char *secret, int secret_len, u8 *challenge, int challenge_len, u8 *digest)
313
313
{
314
 
        SHA_CTX ctx;
 
314
        struct sha1_ctx ctx;
315
315
 
316
 
        SHA1_Init(&ctx);
317
 
        SHA1_Update(&ctx, &chap_id, 1);
318
 
        SHA1_Update(&ctx, secret, secret_len);
319
 
        SHA1_Update(&ctx, challenge, challenge_len);
320
 
        SHA1_Final(digest, &ctx);
 
316
        sha1_init(&ctx);
 
317
        sha1_update(&ctx, &chap_id, 1);
 
318
        sha1_update(&ctx, secret, secret_len);
 
319
        sha1_update(&ctx, challenge, challenge_len);
 
320
        sha1_final(&ctx, digest);
321
321
}
322
322
 
323
323
static int chap_initiator_auth_create_challenge(struct connection *conn)