~ubuntu-branches/ubuntu/natty/curl/natty-proposed

« back to all changes in this revision

Viewing changes to lib/md5.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-05-24 21:12:19 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090524211219-7jgcwuhl04ixuqsm
Tags: upstream-7.19.5
ImportĀ upstreamĀ versionĀ 7.19.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: md5.c,v 1.12 2007-11-07 09:21:35 bagder Exp $
 
21
 * $Id: md5.c,v 1.15 2009-02-12 20:48:44 danf Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
25
25
 
26
26
#ifndef CURL_DISABLE_CRYPTO_AUTH
27
27
 
28
 
#if !defined(USE_SSLEAY) || !defined(USE_OPENSSL)
29
 
/* This code segment is only used if OpenSSL is not provided, as if it is
30
 
   we use the MD5-function provided there instead. No good duplicating
31
 
   code! */
 
28
#include <string.h>
 
29
 
 
30
#include "curl_md5.h"
 
31
 
 
32
#ifdef USE_GNUTLS
 
33
 
 
34
#include <gcrypt.h>
 
35
 
 
36
void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
 
37
                const unsigned char *input)
 
38
{
 
39
  gcry_md_hd_t ctx;
 
40
  gcry_md_open(&ctx, GCRY_MD_MD5, 0);
 
41
  gcry_md_write(ctx, input, (unsigned int)strlen((char *)input));
 
42
  memcpy (outbuffer, gcry_md_read (ctx, 0), 16);
 
43
  gcry_md_close(ctx);
 
44
}
 
45
 
 
46
#else
 
47
 
 
48
#ifdef USE_SSLEAY
 
49
/* When OpenSSL is available we use the MD5-function from OpenSSL */
 
50
 
 
51
#  ifdef USE_OPENSSL
 
52
#    include <openssl/md5.h>
 
53
#  else
 
54
#    include <md5.h>
 
55
#  endif
 
56
 
 
57
#else /* USE_SSLEAY */
 
58
/* When OpenSSL is not available we use this code segment */
32
59
 
33
60
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
34
61
rights reserved.
52
79
documentation and/or software.
53
80
 */
54
81
 
55
 
#include <string.h>
56
 
 
57
82
/* UINT4 defines a four byte word */
58
83
typedef unsigned int UINT4;
59
84
 
332
357
      (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
333
358
}
334
359
 
335
 
#else
336
 
/* If OpenSSL is present */
337
 
#include <openssl/md5.h>
338
 
#include <string.h>
339
 
#endif
340
 
 
341
 
#include "md5.h"
 
360
#endif /* USE_SSLEAY */
342
361
 
343
362
void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
344
363
                const unsigned char *input)
349
368
  MD5_Final(outbuffer, &ctx);
350
369
}
351
370
 
352
 
#endif
 
371
#endif /* USE_GNUTLS */
 
372
 
 
373
#endif /* CURL_DISABLE_CRYPTO_AUTH */