EXTRA_mutt_SOURCES = browser.h mbyte.h mutt_idna.c mutt_idna.h \
mutt_lua.c mutt_sasl.c mutt_notmuch.c mutt_ssl.c mutt_ssl_gnutls.c \
- remailer.c remailer.h resize.c sha1.c url.h utf8.c wcwidth.c
+ remailer.c remailer.h resize.c url.h utf8.c wcwidth.c
EXTRA_DIST = account.h attach.h bcache.h browser.h buffer.h buffy.h \
ChangeLog.md charset.h CODE_OF_CONDUCT.md compress.h copy.h \
mutt_socket.h mutt_ssl.h mutt_tunnel.h mx.h myvar.h nntp.h OPS \
OPS.CRYPT OPS.MIX OPS.NOTMUCH OPS.PGP OPS.SIDEBAR OPS.SMIME pager.h \
pgpewrap.c pop.h protos.h README.md README.SSL remailer.c remailer.h \
- rfc1524.h rfc2047.h rfc2231.h rfc3676.h rfc822.h sha1.h sidebar.h \
+ rfc1524.h rfc2047.h rfc2231.h rfc3676.h rfc822.h sidebar.h \
sort.h txt2c.c txt2c.sh version.h \
keymap_alldefs.h
EXTRA_SCRIPTS =
-pgpring_SOURCES = extlib.c lib.c pgppubring.c sha1.c
+pgpring_SOURCES = extlib.c lib.c pgppubring.c
pgpring_LDADD = $(LIBOBJS) $(NCRYPT_LIBS) $(INTLLIBS) $(LIBLIB)
pgpring_DEPENDENCIES = $(LIBOBJS) $(NCRYPT_DEPS) $(INTLDEPS) $(LIBLIBDEPS)
AUTOMAKE_OPTIONS = 1.6 foreign
-EXTRA_DIST = lib.h lib_ascii.h lib_base64.h lib_date.h lib_exit.h lib_md5.h
+EXTRA_DIST = lib.h lib_ascii.h lib_base64.h lib_date.h lib_exit.h lib_md5.h lib_sha1.h
AM_CPPFLAGS = -I$(top_srcdir)
noinst_LIBRARIES = liblib.a
noinst_HEADERS =
-liblib_a_SOURCES = lib_ascii.c lib_base64.c lib_date.c lib_exit.c lib_md5.c
+liblib_a_SOURCES = lib_ascii.c lib_base64.c lib_date.c lib_exit.c lib_md5.c lib_sha1.c
* -# @subpage date
* -# @subpage exit
* -# @subpage md5
+ * -# @subpage sha1
*/
#ifndef _LIB_LIB_H
#include "lib_date.h"
#include "lib_exit.h"
#include "lib_md5.h"
+#include "lib_sha1.h"
#endif /* _LIB_LIB_H */
* @file
* Calculate the SHA1 checksum of a buffer
*
- * SHA-1 in C
+ * @authors
+ * Steve Reid <steve@edmweb.com>
+ * Thomas Roessler <roessler@does-not-exist.org>
*
- * By Steve Reid <steve@edmweb.com>, with small changes to make it
- * fit into mutt by Thomas Roessler <roessler@does-not-exist.org>.
+ * @copyright
+ * Public Domain
+ */
+
+/**
+ * @page sha1 Calculate the SHA1 checksum of a buffer
+ *
+ * Calculate the SHA1 cryptographic hash of a string, according to RFC3174.
*
- * 100% Public Domain.
+ * | Function | Description
+ * | :--------------- | :----------------------------------------
+ * | sha1_final() | Add padding and return the message digest
+ * | sha1_init() | Initialize new context
+ * | sha1_transform() | Hash a single 512-bit block
+ * | sha1_update() | Run your data through this
*
- * Test Vectors (from FIPS PUB 180-1)
- * "abc"
- * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
- * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
- * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
- * A million repetitions of "a"
- * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ * Test Vectors (from FIPS PUB 180-1):
+ * - "abc" yields `A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D`
+ * - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" yields `84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1`
+ * - A million repetitions of "a" yields `34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F`
*/
#include "config.h"
#include <string.h>
-#include "sha1.h"
+#include "lib_sha1.h"
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
w = rol(w, 30);
-
/**
* sha1_transform - Hash a single 512-bit block
+ * @param state Internal state of the transform
+ * @param buffer Data to transform
*
* This is the core of the algorithm.
*/
memset(block, '\0', sizeof(block));
}
-
/**
* sha1_init - Initialize new context
+ * @param context SHA1 context
*/
void sha1_init(struct Sha1Ctx *context)
{
context->count[0] = context->count[1] = 0;
}
-
/**
* sha1_update - Run your data through this
+ * @param context SHA1 context
+ * @param data Data to be hashed
+ * @param len Length of data
*/
void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len)
{
memcpy(&context->buffer[j], &data[i], len - i);
}
-
/**
* sha1_final - Add padding and return the message digest
+ * @param[out] digest Message digest (SHA1 sum)
+ * @param[in] context SHA1 context
*/
void sha1_final(unsigned char digest[20], struct Sha1Ctx *context)
{
--- /dev/null
+/**
+ * @file
+ * Calculate the SHA1 checksum of a buffer
+ *
+ * @authors
+ * Copyright (C) 2000 Steve Reid <steve@edmweb.com>
+ * Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * 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, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIB_SHA1_H
+#define _LIB_SHA1_H
+
+#include <stdint.h>
+
+/**
+ * struct Sha1Ctx - Cursor for the SHA1 hashing
+ */
+struct Sha1Ctx
+{
+ uint32_t state[5];
+ uint32_t count[2];
+ unsigned char buffer[64];
+};
+
+void sha1_final(unsigned char digest[20], struct Sha1Ctx *context);
+void sha1_init(struct Sha1Ctx *context);
+void sha1_transform(uint32_t state[5], const unsigned char buffer[64]);
+void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len);
+
+#define SHA_DIGEST_LENGTH 20
+
+#endif /* _LIB_SHA1_H */
#include "ncrypt/ncrypt.h"
#include "ncrypt/pgplib.h"
#include "ncrypt/pgppacket.h"
-#include "sha1.h"
extern char *optarg;
extern int optind;
lib/lib_date.c
lib/lib_exit.c
lib/lib_md5.c
+lib/lib_sha1.c
main.c
mbox.c
mbyte.c
score.c
send.c
sendlib.c
-sha1.c
sidebar.c
signal.c
smtp.c
+++ /dev/null
-/**
- * @file
- * Calculate the SHA1 checksum of a buffer
- *
- * SHA-1 in C
- *
- * By Steve Reid <steve@edmweb.com>, with small changes to make it
- * fit into mutt by Thomas Roessler <roessler@does-not-exist.org>.
- */
-
-#ifndef _MUTT_SHA1_H
-#define _MUTT_SHA1_H
-
-#include <stdint.h>
-
-/**
- * struct Sha1Ctx - Cursor for the SHA1 hashing
- */
-struct Sha1Ctx
-{
- uint32_t state[5];
- uint32_t count[2];
- unsigned char buffer[64];
-};
-
-void sha1_transform(uint32_t state[5], const unsigned char buffer[64]);
-void sha1_init(struct Sha1Ctx *context);
-void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len);
-void sha1_final(unsigned char digest[20], struct Sha1Ctx *context);
-
-#define SHA_DIGEST_LENGTH 20
-
-#endif /* _MUTT_SHA1_H */