~ubuntu-branches/ubuntu/trusty/nagios-plugins/trusty-proposed

« back to all changes in this revision

Viewing changes to gl/sha1.c

  • Committer: Package Import Robot
  • Author(s): Yolanda Robla
  • Date: 2013-12-11 10:09:01 UTC
  • mfrom: (12.2.22 sid)
  • Revision ID: package-import@ubuntu.com-20131211100901-g0kqwx300l24be53
Tags: 1.5-1ubuntu1
* Merge from Debian unstable (LP: #1259863).  Remaining changes:
  - debian/control, debian/rules, debian/nagios-plugins-extra.dirs
     + add package nagios-plugins-extra
     + Suggest nagios-plugins-contrib in the universe package (-extras).
  - debian/control
     - replaces on nagios-plugins-basic (<< 1.4.16-1ubuntu1)
     - conflicts and replaces on nagios-plugins-extra

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* sha1.c - Functions to compute SHA1 message digest of files or
2
2
   memory blocks according to the NIST specification FIPS-180-1.
3
3
 
4
 
   Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free
5
 
   Software Foundation, Inc.
 
4
   Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
6
5
 
7
6
   This program is free software; you can redistribute it and/or modify it
8
7
   under the terms of the GNU General Public License as published by the
15
14
   GNU General Public License for more details.
16
15
 
17
16
   You should have received a copy of the GNU General Public License
18
 
   along with this program; if not, write to the Free Software Foundation,
19
 
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
17
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
20
18
 
21
19
/* Written by Scott G. Miller
22
20
   Credits:
27
25
 
28
26
#include "sha1.h"
29
27
 
30
 
#include <stddef.h>
 
28
#include <stdalign.h>
 
29
#include <stdint.h>
31
30
#include <stdlib.h>
32
31
#include <string.h>
33
32
 
71
70
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
72
71
   If your architecture allows unaligned access this is equivalent to
73
72
   * (uint32_t *) cp = v  */
74
 
static inline void
 
73
static void
75
74
set_uint32 (char *cp, uint32_t v)
76
75
{
77
76
  memcpy (cp, &v, sizeof v);
242
241
  if (len >= 64)
243
242
    {
244
243
#if !_STRING_ARCH_unaligned
245
 
# define alignof(type) offsetof (struct { char c; type x; }, x)
246
 
# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
 
244
# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
247
245
      if (UNALIGNED_P (buffer))
248
246
        while (len > 64)
249
247
          {
307
305
  uint32_t c = ctx->C;
308
306
  uint32_t d = ctx->D;
309
307
  uint32_t e = ctx->E;
 
308
  uint32_t lolen = len;
310
309
 
311
310
  /* First increment the byte count.  RFC 1321 specifies the possible
312
311
     length of the file up to 2^64 bits.  Here we only compute the
313
312
     number of bytes.  Do a double word increment.  */
314
 
  ctx->total[0] += len;
315
 
  if (ctx->total[0] < len)
316
 
    ++ctx->total[1];
 
313
  ctx->total[0] += lolen;
 
314
  ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
317
315
 
318
316
#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
319
317