Browse Source

Make the 2nd arg to SHA1Transform const again and unifdef SHA1HANDSOFF.

It was defined before and there is no need to for this knob...
OPENBSD_3_6
millert 20 years ago
parent
commit
f181b464e0
3 changed files with 9 additions and 16 deletions
  1. +2
    -2
      src/include/sha1.h
  2. +2
    -2
      src/lib/libc/hash/sha1.3
  3. +5
    -12
      src/lib/libc/hash/sha1.c

+ 2
- 2
src/include/sha1.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: sha1.h,v 1.21 2004/05/03 18:05:08 millert Exp $ */
/* $OpenBSD: sha1.h,v 1.22 2004/05/05 17:09:45 millert Exp $ */
/* /*
* SHA-1 in C * SHA-1 in C
@ -24,7 +24,7 @@ typedef struct {
__BEGIN_DECLS __BEGIN_DECLS
void SHA1Init(SHA1_CTX *); void SHA1Init(SHA1_CTX *);
void SHA1Pad(SHA1_CTX *); void SHA1Pad(SHA1_CTX *);
void SHA1Transform(u_int32_t [5], u_int8_t [SHA1_BLOCK_LENGTH])
void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
__attribute__((__bounded__(__minbytes__,1,5))) __attribute__((__bounded__(__minbytes__,1,5)))
__attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH))); __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t) void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t)


+ 2
- 2
src/lib/libc/hash/sha1.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: sha1.3,v 1.31 2004/05/03 18:10:07 millert Exp $
.\" $OpenBSD: sha1.3,v 1.32 2004/05/05 17:09:46 millert Exp $
.\" .\"
.\" Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com> .\" Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
.\" .\"
@ -43,7 +43,7 @@
.Ft void .Ft void
.Fn SHA1Final "u_int8_t digest[SHA1_DIGEST_LENGTH]" "SHA1_CTX *context" .Fn SHA1Final "u_int8_t digest[SHA1_DIGEST_LENGTH]" "SHA1_CTX *context"
.Ft void .Ft void
.Fn SHA1Transform "u_int32_t state[5]" "u_int8_t buffer[SHA1_BLOCK_LENGTH]"
.Fn SHA1Transform "u_int32_t state[5]" "const u_int8_t buffer[SHA1_BLOCK_LENGTH]"
.Ft "char *" .Ft "char *"
.Fn SHA1End "SHA1_CTX *context" "char *buf" .Fn SHA1End "SHA1_CTX *context" "char *buf"
.Ft "char *" .Ft "char *"


+ 5
- 12
src/lib/libc/hash/sha1.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: sha1.c,v 1.17 2004/05/03 18:05:08 millert Exp $ */
/* $OpenBSD: sha1.c,v 1.18 2004/05/05 17:09:46 millert Exp $ */
/* /*
* SHA-1 in C * SHA-1 in C
@ -15,11 +15,9 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$OpenBSD: sha1.c,v 1.17 2004/05/03 18:05:08 millert Exp $";
static const char rcsid[] = "$OpenBSD: sha1.c,v 1.18 2004/05/05 17:09:46 millert Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#define SHA1HANDSOFF /* Copies data before messing with it. */
#include <sys/param.h> #include <sys/param.h>
#include <string.h> #include <string.h>
#include <sha1.h> #include <sha1.h>
@ -52,22 +50,17 @@ static char rcsid[] = "$OpenBSD: sha1.c,v 1.17 2004/05/03 18:05:08 millert Exp $
* Hash a single 512-bit block. This is the core of the algorithm. * Hash a single 512-bit block. This is the core of the algorithm.
*/ */
void void
SHA1Transform(u_int32_t state[5], u_int8_t buffer[SHA1_BLOCK_LENGTH])
SHA1Transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH])
{ {
u_int32_t a, b, c, d, e; u_int32_t a, b, c, d, e;
u_int8_t workspace[SHA1_BLOCK_LENGTH];
typedef union { typedef union {
u_int8_t c[64]; u_int8_t c[64];
u_int32_t l[16]; u_int32_t l[16];
} CHAR64LONG16; } CHAR64LONG16;
CHAR64LONG16 *block;
CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
#ifdef SHA1HANDSOFF
u_int8_t workspace[SHA1_BLOCK_LENGTH];
block = (CHAR64LONG16 *)workspace;
(void)memcpy(block, buffer, SHA1_BLOCK_LENGTH); (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
#else
block = (CHAR64LONG16 *)buffer;
#endif
/* Copy context->state[] to working vars */ /* Copy context->state[] to working vars */
a = state[0]; a = state[0];


Loading…
Cancel
Save