View | Details | Raw Unified | Return to bug 94921
Collapse All | Expand All

(-)sysdep-FIXED/common/libsysdep/sha1.c (-5 / +5 lines)
Lines 46-67 A million repetitions of "a" Link Here
46
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
46
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
47
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
47
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
48
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
48
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
49
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
49
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
50
50
51
51
52
/* Hash a single 512-bit block. This is the core of the algorithm. */
52
/* Hash a single 512-bit block. This is the core of the algorithm. */
53
53
54
void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
54
void SHA1Transform(UINT4 state[5], unsigned char buffer[64])
55
{
55
{
56
unsigned long a, b, c, d, e;
56
UINT4 a, b, c, d, e;
57
typedef union {
57
typedef union {
58
    unsigned char c[64];
58
    unsigned char c[64];
59
    unsigned long l[16];
59
    UINT4 l[16];
60
} CHAR64LONG16;
60
} CHAR64LONG16;
61
CHAR64LONG16* block;
61
CHAR64LONG16* block;
62
#ifdef SHA1HANDSOFF
62
#ifdef SHA1HANDSOFF
63
static CHAR64LONG16 workspace;
63
static CHAR64LONG16 workspace;
64
    block = &workspace;
64
    block = &workspace;
65
    memcpy(block, buffer, 64);
65
    memcpy(block, buffer, 64);
66
#else
66
#else
67
    block = (CHAR64LONG16*)buffer;
67
    block = (CHAR64LONG16*)buffer;
Lines 118-134 void SHA1Init(SHA1_CTX* context) Link Here
118
}
118
}
119
119
120
120
121
/* Run your data through this. */
121
/* Run your data through this. */
122
122
123
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
123
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
124
{
124
{
125
unsigned int i;
125
unsigned int i;
126
unsigned long j;
126
UINT4 j;
127
127
128
    j = context->count[0];
128
    j = context->count[0];
129
    if ((context->count[0] += len << 3) < j) context->count[1] += (len>>29)+1;
129
    if ((context->count[0] += len << 3) < j) context->count[1] += (len>>29)+1;
130
    j = (j >> 3) & 63;
130
    j = (j >> 3) & 63;
131
    if ((j + len) > 63) {
131
    if ((j + len) > 63) {
132
        memcpy(&context->buffer[j], data, (i = 64-j));
132
        memcpy(&context->buffer[j], data, (i = 64-j));
133
        SHA1Transform(context->state, context->buffer);
133
        SHA1Transform(context->state, context->buffer);
134
        for ( ; i + 63 < len; i += 64) {
134
        for ( ; i + 63 < len; i += 64) {
Lines 140-156 unsigned long j; Link Here
140
    memcpy(&context->buffer[j], &data[i], len - i);
140
    memcpy(&context->buffer[j], &data[i], len - i);
141
}
141
}
142
142
143
143
144
/* Add padding and return the message digest. */
144
/* Add padding and return the message digest. */
145
145
146
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
146
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
147
{
147
{
148
unsigned long i, j;
148
UINT4 i, j;
149
unsigned char finalcount[8];
149
unsigned char finalcount[8];
150
150
151
    for (i = 0; i < 8; i++) {
151
    for (i = 0; i < 8; i++) {
152
        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
152
        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
153
         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
153
         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
154
    }
154
    }
155
    SHA1Update(context, (unsigned char *)"\200", 1);
155
    SHA1Update(context, (unsigned char *)"\200", 1);
156
    while ((context->count[0] & 504) != 448) {
156
    while ((context->count[0] & 504) != 448) {
(-)sysdep-FIXED/common/md5.h (-2 / +4 lines)
Lines 7-30 Link Here
7
     function argument prototyping.
7
     function argument prototyping.
8
   The following makes PROTOTYPES default to 0 if it has not already
8
   The following makes PROTOTYPES default to 0 if it has not already
9
     been defined with C compiler flags.
9
     been defined with C compiler flags.
10
 */
10
 */
11
#ifndef PROTOTYPES
11
#ifndef PROTOTYPES
12
#define PROTOTYPES 1
12
#define PROTOTYPES 1
13
#endif
13
#endif
14
14
15
#include <sys/types.h>
16
15
/* POINTER defines a generic pointer type */
17
/* POINTER defines a generic pointer type */
16
typedef unsigned char *POINTER;
18
typedef unsigned char *POINTER;
17
19
18
/* UINT2 defines a two byte word */
20
/* UINT2 defines a two byte word */
19
typedef unsigned short int UINT2;
21
typedef u_int16_t UINT2;
20
22
21
/* UINT4 defines a four byte word */
23
/* UINT4 defines a four byte word */
22
typedef unsigned long int UINT4;
24
typedef u_int32_t UINT4;
23
25
24
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
26
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
25
   If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
27
   If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
26
     returns an empty list.
28
     returns an empty list.
27
 */
29
 */
28
30
29
#if PROTOTYPES
31
#if PROTOTYPES
30
#define PROTO_LIST(list) list
32
#define PROTO_LIST(list) list
(-)sysdep-FIXED/common/sha1.h (-3 / +7 lines)
Lines 1-18 Link Here
1
/*	$OpenBSD: sha1.h,v 1.2 2001/01/28 22:38:47 niklas Exp $	*/
1
/*	$OpenBSD: sha1.h,v 1.2 2001/01/28 22:38:47 niklas Exp $	*/
2
2
3
/*
3
/*
4
SHA-1 in C
4
SHA-1 in C
5
By Steve Reid <steve@edmweb.com>
5
By Steve Reid <steve@edmweb.com>
6
100% Public Domain
6
100% Public Domain
7
*/
7
*/
8
8
9
#include <sys/types.h>
10
11
typedef u_int32_t UINT4;
12
9
typedef struct {
13
typedef struct {
10
    unsigned long state[5];
14
    UINT4 state[5];
11
    unsigned long count[2];
15
    UINT4 count[2];
12
    unsigned char buffer[64];
16
    unsigned char buffer[64];
13
} SHA1_CTX;
17
} SHA1_CTX;
14
18
15
void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);
19
void SHA1Transform(UINT4 state[5], unsigned char buffer[64]);
16
void SHA1Init(SHA1_CTX* context);
20
void SHA1Init(SHA1_CTX* context);
17
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
21
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
18
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
22
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);

Return to bug 94921