Skip to content

Commit

Permalink
0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Phipps committed Jan 15, 2006
1 parent 9548a8e commit 8c0e9c4
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 83 deletions.
17 changes: 10 additions & 7 deletions c/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zsync 0.1.1
zsync 0.1.2
===========

zsync is a file transfer program. It allows you to download a file from a
Expand Down Expand Up @@ -87,6 +87,13 @@ bits:

zsync -i <(zcat big-0.1.tar.gz) http://example.com/downloads/big-0.2.tar.zsync

Feedback, Support
-----------------

Mail zsync-users@lists.sourceforge.net if you have questions about zsync. And
join the mailing list if you are using it a lot or are interested in the
ongoing development.

Copyright, Author, Acknowledgements
-----------------------------------

Expand All @@ -110,10 +117,6 @@ emacs, the essential development tools. Also I would thank Sourceforge for
providing the hosting facilities for the downloads and mailing list, and the
compile farm for testing portability.

Feedback, Support
-----------------

Mail zsync-users@lists.sourceforge.net if you have questions about zsync. And
join the mailing list if you are using it a lot or are interested in the
ongoing development.
Also, thanks to �rsek L�szl�, saul@alien-science.org, Kent Mein for useful
feedback about previous versions.

10 changes: 2 additions & 8 deletions c/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@
#include <fcntl.h>
#include <errno.h>

#include "config.h"
#include <arpa/inet.h>

/* htons - where to get this? */
#ifdef HAVE_HTONS_IN_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_HTONS_IN_SYS_PARAM_H
#include <sys/param.h>
#endif
#include "config.h"

#include "zsync.h"
#include "libzmap/zmap.h"
Expand Down
8 changes: 1 addition & 7 deletions c/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AC_CONFIG_AUX_DIR(autotools)
dnl --- Set version strings
MAJOR_VERSION=0
MINOR_VERSION=1
MICRO_VERSION=1
MICRO_VERSION=2
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION

AC_SUBST(VERSION)
Expand Down Expand Up @@ -34,12 +34,6 @@ dnl --- Header files, typedefs, structures, libraries
AC_TYPE_SIZE_T
dnl Solaris needs -lsocket
AC_CHECK_LIB(socket,socket)
AC_EGREP_HEADER(htons,netinet/in.h,
AC_DEFINE([HAVE_HTONS_IN_NETINET_IN_H],[],[htons is defined in netinet/in.h (Linux)]),
AC_EGREP_HEADER(htons,sys/param.h,
AC_DEFINE([HAVE_HTONS_IN_SYS_PARAM_H],[],[htons is defined in sys/param.h (BSD)]),
echo "could not find header for htons definition"
))

dnl --- output
AC_SUBST(ac_aux_dir)
Expand Down
27 changes: 17 additions & 10 deletions c/libhash/md4.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ static const char rcsid[] = "$OpenBSD: md4.c,v 1.6 2004/05/28 15:10:27 millert E
#include <string.h>
#include <md4.h>

/* Map Solaris endian stuff to something useful */
#ifdef _BIG_ENDIAN
#define LITTLE_ENDIAN 0
#define BIG_ENDIAN 1
#define BYTE_ORDER 1
#endif

#define PUT_64BIT_LE(cp, value) do { \
(cp)[7] = (value) >> 56; \
(cp)[6] = (value) >> 48; \
Expand All @@ -42,7 +49,7 @@ static const char rcsid[] = "$OpenBSD: md4.c,v 1.6 2004/05/28 15:10:27 millert E
(cp)[1] = (value) >> 8; \
(cp)[0] = (value); } while (0)

static u_int8_t PADDING[MD4_BLOCK_LENGTH] = {
static uint8_t PADDING[MD4_BLOCK_LENGTH] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Expand Down Expand Up @@ -76,7 +83,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *input, size_t len)
need = MD4_BLOCK_LENGTH - have;

/* Update bitcount */
ctx->count += (u_int64_t)len << 3;
ctx->count += (uint64_t)len << 3;

if (len >= need) {
if (have != 0) {
Expand Down Expand Up @@ -107,7 +114,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *input, size_t len)
void
MD4Pad(MD4_CTX *ctx)
{
u_int8_t count[8];
uint8_t count[8];
size_t padlen;

/* Convert count to 8 bytes in little endian order. */
Expand Down Expand Up @@ -156,19 +163,19 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
* the data and converts bytes into longwords for this routine.
*/
void
MD4Transform(u_int32_t state[4], const u_int8_t block[MD4_BLOCK_LENGTH])
MD4Transform(uint32_t state[4], const uint8_t block[MD4_BLOCK_LENGTH])
{
u_int32_t a, b, c, d, in[MD4_BLOCK_LENGTH / 4];
uint32_t a, b, c, d, in[MD4_BLOCK_LENGTH / 4];

#if BYTE_ORDER == LITTLE_ENDIAN
memcpy(in, block, sizeof(in));
#else
for (a = 0; a < MD4_BLOCK_LENGTH / 4; a++) {
in[a] = (u_int32_t)(
(u_int32_t)(block[a * 4 + 0]) |
(u_int32_t)(block[a * 4 + 1]) << 8 |
(u_int32_t)(block[a * 4 + 2]) << 16 |
(u_int32_t)(block[a * 4 + 3]) << 24);
in[a] = (uint32_t)(
(uint32_t)(block[a * 4 + 0]) |
(uint32_t)(block[a * 4 + 1]) << 8 |
(uint32_t)(block[a * 4 + 2]) << 16 |
(uint32_t)(block[a * 4 + 3]) << 24);
}
#endif

Expand Down
26 changes: 15 additions & 11 deletions c/libhash/md4.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,31 @@
#ifndef _MD4_H_
#define _MD4_H_

#include "config.h"

#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <sys/types.h>
#endif

#define MD4_BLOCK_LENGTH 64
#define MD4_DIGEST_LENGTH 16
#define MD4_DIGEST_STRING_LENGTH (MD4_DIGEST_LENGTH * 2 + 1)

typedef struct MD4Context {
u_int32_t state[4]; /* state */
u_int64_t count; /* number of bits, mod 2^64 */
u_int8_t buffer[MD4_BLOCK_LENGTH]; /* input buffer */
uint32_t state[4]; /* state */
uint64_t count; /* number of bits, mod 2^64 */
uint8_t buffer[MD4_BLOCK_LENGTH]; /* input buffer */
} MD4_CTX;

#include <sys/cdefs.h>

__BEGIN_DECLS
void MD4Init(MD4_CTX *);
void MD4Update(MD4_CTX *, const u_int8_t *, size_t)
void MD4Update(MD4_CTX *, const uint8_t *, size_t)
__attribute__((__bounded__(__string__,2,3)));
void MD4Pad(MD4_CTX *);
void MD4Final(u_int8_t [MD4_DIGEST_LENGTH], MD4_CTX *)
void MD4Final(uint8_t [MD4_DIGEST_LENGTH], MD4_CTX *)
__attribute__((__bounded__(__minbytes__,1,MD4_DIGEST_LENGTH)));
void MD4Transform(u_int32_t [4], const u_int8_t [MD4_BLOCK_LENGTH])
void MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
__attribute__((__bounded__(__minbytes__,1,4)))
__attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH)));
char *MD4End(MD4_CTX *, char *)
Expand All @@ -44,9 +49,8 @@ char *MD4File(const char *, char *)
__attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
char *MD4FileChunk(const char *, char *, off_t, off_t)
__attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
char *MD4Data(const u_int8_t *, size_t, char *)
char *MD4Data(const uint8_t *, size_t, char *)
__attribute__((__bounded__(__string__,1,2)))
__attribute__((__bounded__(__minbytes__,3,MD4_DIGEST_STRING_LENGTH)));
__END_DECLS

#endif /* _MD4_H_ */
37 changes: 22 additions & 15 deletions c/libhash/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ static const char rcsid[] = "$OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert

#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

/* Map Solaris endian stuff to something useful */
#ifdef _BIG_ENDIAN
#define LITTLE_ENDIAN 0
#define BIG_ENDIAN 1
#define BYTE_ORDER 1
#endif

/*
* blk0() and blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
Expand All @@ -50,13 +57,13 @@ static const char rcsid[] = "$OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert
* Hash a single 512-bit block. This is the core of the algorithm.
*/
void
SHA1Transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH])
SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
{
u_int32_t a, b, c, d, e;
u_int8_t workspace[SHA1_BLOCK_LENGTH];
uint32_t a, b, c, d, e;
uint8_t workspace[SHA1_BLOCK_LENGTH];
typedef union {
u_int8_t c[64];
u_int32_t l[16];
uint8_t c[64];
uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;

Expand Down Expand Up @@ -124,7 +131,7 @@ SHA1Init(SHA1_CTX *context)
* Run your data through this.
*/
void
SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len)
{
size_t i, j;

Expand All @@ -134,7 +141,7 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
(void)memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->buffer);
for ( ; i + 63 < len; i += 64)
SHA1Transform(context->state, (u_int8_t *)&data[i]);
SHA1Transform(context->state, (uint8_t *)&data[i]);
j = 0;
} else {
i = 0;
Expand All @@ -149,28 +156,28 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
void
SHA1Pad(SHA1_CTX *context)
{
u_int8_t finalcount[8];
u_int i;
uint8_t finalcount[8];
uint i;

for (i = 0; i < 8; i++) {
finalcount[i] = (u_int8_t)((context->count >>
finalcount[i] = (uint8_t)((context->count >>
((7 - (i & 7)) * 8)) & 255); /* Endian independent */
}
SHA1Update(context, (u_int8_t *)"\200", 1);
SHA1Update(context, (uint8_t *)"\200", 1);
while ((context->count & 504) != 448)
SHA1Update(context, (u_int8_t *)"\0", 1);
SHA1Update(context, (uint8_t *)"\0", 1);
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
}

void
SHA1Final(u_int8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
{
u_int i;
uint i;

SHA1Pad(context);
if (digest) {
for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
digest[i] = (u_int8_t)
digest[i] = (uint8_t)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
memset(context, 0, sizeof(*context));
Expand Down
26 changes: 15 additions & 11 deletions c/libhash/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,42 @@
#ifndef _SHA1_H
#define _SHA1_H

#include "config.h"

#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <sys/types.h>
#endif

#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)

typedef struct {
u_int32_t state[5];
u_int64_t count;
u_int8_t buffer[SHA1_BLOCK_LENGTH];
uint32_t state[5];
uint64_t count;
uint8_t buffer[SHA1_BLOCK_LENGTH];
} SHA1_CTX;

#include <sys/cdefs.h>

__BEGIN_DECLS
void SHA1Init(SHA1_CTX *);
void SHA1Pad(SHA1_CTX *);
void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH])
__attribute__((__bounded__(__minbytes__,1,5)))
__attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t)
void SHA1Update(SHA1_CTX *, const uint8_t *, size_t)
__attribute__((__bounded__(__string__,2,3)));
void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
__attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
char *SHA1End(SHA1_CTX *, char *)
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
char *SHA1File(const char *, char *)
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
char *SHA1FileChunk(const char *, char *, off_t, off_t)
__attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
char *SHA1Data(const u_int8_t *, size_t, char *)
char *SHA1Data(const uint8_t *, size_t, char *)
__attribute__((__bounded__(__string__,1,2)))
__attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
__END_DECLS

#define HTONDIGEST(x) do { \
x[0] = htonl(x[0]); \
Expand Down
8 changes: 1 addition & 7 deletions c/libzmap/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@

#include "zmap.h"

/* htons - where to get this? */
#ifdef HAVE_HTONS_IN_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_HTONS_IN_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <arpa/inet.h>

struct zmapentry {
long long inbits;
Expand Down
6 changes: 6 additions & 0 deletions c/libzmap/zmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
* COPYING file for details.
*/

#include "config.h"

#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <sys/types.h>
#endif

struct gzblock {
uint16_t inbitoffset;
Expand Down
8 changes: 1 addition & 7 deletions c/make.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@

#include "config.h"

/* htons - where to get this? */
#ifdef HAVE_HTONS_IN_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_HTONS_IN_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <arpa/inet.h>

#include "zsync.h"

Expand Down

0 comments on commit 8c0e9c4

Please sign in to comment.