~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/sha1.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

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