X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=sha1x.h;fp=sha1x.h;h=f1d5dca523077a528f87f9093884795ad5755056;hb=7f6a0a82eafb84548e5a298485533a2fd506f98d;hp=0000000000000000000000000000000000000000;hpb=a38e8ca995bf1a5d20dc81bed265fc8a58cec2b5;p=onak.git diff --git a/sha1x.h b/sha1x.h new file mode 100644 index 0000000..f1d5dca --- /dev/null +++ b/sha1x.h @@ -0,0 +1,40 @@ +/* + * sha1x.h - Double width SHA-1 as per PGP 5.5 + * + * Copyright 2013 Jonathan McDowell + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __SHA1X_H__ +#define __SHA1X_H__ + +#include +#include + +#ifdef HAVE_NETTLE +#include +#else +#include "sha1.h" +#endif + +#define SHA1X_DIGEST_SIZE (2 * SHA1_DIGEST_SIZE) + +struct sha1x_ctx { + struct sha1_ctx a, b, c, d; + bool odd; + unsigned char result[SHA1X_DIGEST_SIZE]; +}; + +void sha1x_init(struct sha1x_ctx *ctx); +void sha1x_update(struct sha1x_ctx *ctx, unsigned length, const uint8_t *data); +void sha1x_digest(struct sha1x_ctx *ctx, unsigned length, uint8_t *digest); + +#endif /* __SHA1X_H__ */