parent
6adb9b8ccd
commit
ae1da536bb
@ -0,0 +1,26 @@
|
||||
/* public domain sha224 implementation based on fips180-3 */
|
||||
#include <stdint.h>
|
||||
#include "../sha224.h"
|
||||
|
||||
extern void sha256_sum_n(void *, uint8_t *, int n);
|
||||
|
||||
void
|
||||
sha224_init(void *ctx)
|
||||
{
|
||||
struct sha224 *s = ctx;
|
||||
s->len = 0;
|
||||
s->h[0] = 0xc1059ed8;
|
||||
s->h[1] = 0x367cd507;
|
||||
s->h[2] = 0x3070dd17;
|
||||
s->h[3] = 0xf70e5939;
|
||||
s->h[4] = 0xffc00b31;
|
||||
s->h[5] = 0x68581511;
|
||||
s->h[6] = 0x64f98fa7;
|
||||
s->h[7] = 0xbefa4fa4;
|
||||
}
|
||||
|
||||
void
|
||||
sha224_sum(void *ctx, uint8_t md[SHA224_DIGEST_LENGTH])
|
||||
{
|
||||
sha256_sum_n(ctx, md, 8);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/* public domain sha384 implementation based on fips180-3 */
|
||||
#include <stdint.h>
|
||||
#include "../sha384.h"
|
||||
|
||||
extern void sha512_sum_n(void *, uint8_t *, int n);
|
||||
|
||||
void
|
||||
sha384_init(void *ctx)
|
||||
{
|
||||
struct sha384 *s = ctx;
|
||||
s->len = 0;
|
||||
s->h[0] = 0xcbbb9d5dc1059ed8ULL;
|
||||
s->h[1] = 0x629a292a367cd507ULL;
|
||||
s->h[2] = 0x9159015a3070dd17ULL;
|
||||
s->h[3] = 0x152fecd8f70e5939ULL;
|
||||
s->h[4] = 0x67332667ffc00b31ULL;
|
||||
s->h[5] = 0x8eb44a8768581511ULL;
|
||||
s->h[6] = 0xdb0c2e0d64f98fa7ULL;
|
||||
s->h[7] = 0x47b5481dbefa4fa4ULL;
|
||||
}
|
||||
|
||||
void
|
||||
sha384_sum(void *ctx, uint8_t md[SHA384_DIGEST_LENGTH])
|
||||
{
|
||||
sha512_sum_n(ctx, md, 6);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/* public domain sha224 implementation based on fips180-3 */
|
||||
|
||||
#include "sha256.h"
|
||||
|
||||
#define sha224 sha256 /*struct*/
|
||||
|
||||
enum { SHA224_DIGEST_LENGTH = 28 };
|
||||
|
||||
/* reset state */
|
||||
void sha224_init(void *ctx);
|
||||
/* process message */
|
||||
#define sha224_update sha256_update
|
||||
/* get message digest */
|
||||
/* state is ruined after sum, keep a copy if multiple sum is needed */
|
||||
/* part of the message might be left in s, zero it if secrecy is needed */
|
||||
void sha224_sum(void *ctx, uint8_t md[SHA224_DIGEST_LENGTH]);
|
@ -0,0 +1,32 @@
|
||||
.Dd 2016-02-24
|
||||
.Dt SHA224SUM 1
|
||||
.Os sbase
|
||||
.Sh NAME
|
||||
.Nm sha224sum
|
||||
.Nd compute or check SHA-224 message digests
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl c
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
writes SHA-224 (224-bit) checksums of each
|
||||
.Ar file
|
||||
to stdout.
|
||||
If no
|
||||
.Ar file
|
||||
is given
|
||||
.Nm
|
||||
reads from stdin.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c
|
||||
Read list of SHA-224 checksums from each
|
||||
.Ar file
|
||||
and check them.
|
||||
If no
|
||||
.Ar file
|
||||
is given
|
||||
.Nm
|
||||
reads from stdin.
|
||||
.El
|
@ -0,0 +1,41 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "crypt.h"
|
||||
#include "sha224.h"
|
||||
#include "util.h"
|
||||
|
||||
static struct sha224 s;
|
||||
struct crypt_ops sha224_ops = {
|
||||
sha224_init,
|
||||
sha224_update,
|
||||
sha224_sum,
|
||||
&s,
|
||||
};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s [-c] [file ...]\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
|
||||
uint8_t md[SHA224_DIGEST_LENGTH];
|
||||
|
||||
ARGBEGIN {
|
||||
case 'c':
|
||||
cryptfunc = cryptcheck;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
} ARGEND
|
||||
|
||||
ret |= cryptfunc(argc, argv, &sha224_ops, md, sizeof(md));
|
||||
ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
|
||||
|
||||
return ret;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/* public domain sha512 implementation based on fips180-3 */
|
||||
|
||||
#include "sha512.h"
|
||||
|
||||
#define sha384 sha512 /*struct*/
|
||||
|
||||
enum { SHA384_DIGEST_LENGTH = 48 };
|
||||
|
||||
/* reset state */
|
||||
void sha384_init(void *ctx);
|
||||
/* process message */
|
||||
#define sha384_update sha512_update
|
||||
/* get message digest */
|
||||
/* state is ruined after sum, keep a copy if multiple sum is needed */
|
||||
/* part of the message might be left in s, zero it if secrecy is needed */
|
||||
void sha384_sum(void *ctx, uint8_t md[SHA384_DIGEST_LENGTH]);
|
@ -0,0 +1,32 @@
|
||||
.Dd 2016-02-24
|
||||
.Dt SHA384SUM 1
|
||||
.Os sbase
|
||||
.Sh NAME
|
||||
.Nm sha384sum
|
||||
.Nd compute or check SHA-384 message digests
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl c
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
writes SHA-384 (384-bit) checksums of each
|
||||
.Ar file
|
||||
to stdout.
|
||||
If no
|
||||
.Ar file
|
||||
is given
|
||||
.Nm
|
||||
reads from stdin.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c
|
||||
Read list of SHA-384 checksums from each
|
||||
.Ar file
|
||||
and check them.
|
||||
If no
|
||||
.Ar file
|
||||
is given
|
||||
.Nm
|
||||
reads from stdin.
|
||||
.El
|
@ -0,0 +1,41 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "crypt.h"
|
||||
#include "sha384.h"
|
||||
#include "util.h"
|
||||
|
||||
static struct sha384 s;
|
||||
struct crypt_ops sha384_ops = {
|
||||
sha384_init,
|
||||
sha384_update,
|
||||
sha384_sum,
|
||||
&s,
|
||||
};
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s [-c] [file ...]\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
|
||||
uint8_t md[SHA384_DIGEST_LENGTH];
|
||||
|
||||
ARGBEGIN {
|
||||
case 'c':
|
||||
cryptfunc = cryptcheck;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
} ARGEND
|
||||
|
||||
ret |= cryptfunc(argc, argv, &sha384_ops, md, sizeof(md));
|
||||
ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue