Add sha-2 (commit 61155d)
Unfortunatley the sha2 project does not have versioned releases so we use the latest commit. We have also manually added a frontend to sha-2 to allow us to invoke it from the command line, thanks bittrof for the help!
This commit is contained in:
parent
44bad278e0
commit
92cb05442e
|
@ -0,0 +1,22 @@
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
|
||||||
|
this software, either in source code form or as a compiled binary, for any
|
||||||
|
purpose, commercial or non-commercial, and by any means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
|
software dedicate any and all copyright interest in the software to the public
|
||||||
|
domain. We make this dedication for the benefit of the public at large and
|
||||||
|
to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of relinquishment
|
||||||
|
in perpetuity of all present and future rights to this software under copyright
|
||||||
|
law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||||
|
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||||
|
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org/>
|
|
@ -17,3 +17,4 @@ ecb5c6469d732bcf01d6ec1afe9e64f1668caba5bfdb103c28d7f537ba3cdb8a patch-2.5.9.ta
|
||||||
9fa29beb2fc4a3c373829fc051830796de301f32a719d0b52a400d1719bbd7b1 perl-5.003.tar.gz
|
9fa29beb2fc4a3c373829fc051830796de301f32a719d0b52a400d1719bbd7b1 perl-5.003.tar.gz
|
||||||
1184478b298978b164a383ed5661e3a117c48ab97d6d0ab7ef614cdbe918b9eb perl5.004_05.tar.gz
|
1184478b298978b164a383ed5661e3a117c48ab97d6d0ab7ef614cdbe918b9eb perl5.004_05.tar.gz
|
||||||
c6c37e888b136ccefab903c51149f4b7bd659d69d4aea21245f61053a57aa60a tar-1.12.tar.gz
|
c6c37e888b136ccefab903c51149f4b7bd659d69d4aea21245f61053a57aa60a tar-1.12.tar.gz
|
||||||
|
404a8d72427a559c074e581bf8f7d5a73283faf249cd3faf6dc1c6faf97d07c7 sha-2-61555d.tar.gz
|
||||||
|
|
|
@ -148,6 +148,9 @@ get_file https://ftp.gnu.org/gnu/gzip/gzip-1.2.4.tar 1
|
||||||
# patch 2.5.9
|
# patch 2.5.9
|
||||||
get_file https://ftp.gnu.org/pub/gnu/patch/patch-2.5.9.tar.gz 1
|
get_file https://ftp.gnu.org/pub/gnu/patch/patch-2.5.9.tar.gz 1
|
||||||
|
|
||||||
|
# sha-2 61555d
|
||||||
|
get_file https://github.com/amosnier/sha-2/archive/61555d.tar.gz 1 sha-2-61555d.tar.gz
|
||||||
|
|
||||||
# make 3.80
|
# make 3.80
|
||||||
get_file https://ftp.gnu.org/gnu/make/make-3.80.tar.gz 1
|
get_file https://ftp.gnu.org/gnu/make/make-3.80.tar.gz 1
|
||||||
|
|
||||||
|
|
|
@ -86,41 +86,47 @@ cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 12: mes-libc-patched
|
# Part 12: sha-2
|
||||||
|
pkg="sha-2-61555d"
|
||||||
|
cd ${pkg}
|
||||||
|
kaem --file ${pkg}.kaem
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Part 13: mes-libc-patched
|
||||||
cd tcc-0.9.27
|
cd tcc-0.9.27
|
||||||
kaem --file mes-libc-patched.kaem
|
kaem --file mes-libc-patched.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 13: tcc-patched
|
# Part 14: tcc-patched
|
||||||
cd tcc-0.9.27
|
cd tcc-0.9.27
|
||||||
kaem --file tcc-patched.kaem
|
kaem --file tcc-patched.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 14: make
|
# Part 15: make
|
||||||
pkg="make-3.80"
|
pkg="make-3.80"
|
||||||
cd ${pkg}
|
cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 15: bzip2
|
# Part 16: bzip2
|
||||||
pkg="bzip2-1.0.8"
|
pkg="bzip2-1.0.8"
|
||||||
cd ${pkg}
|
cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 16: coreutils
|
# Part 17: coreutils
|
||||||
pkg="coreutils-5.0"
|
pkg="coreutils-5.0"
|
||||||
cd ${pkg}
|
cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 17: heirloom-devtools
|
# Part 18: heirloom-devtools
|
||||||
pkg="heirloom-devtools-070527"
|
pkg="heirloom-devtools-070527"
|
||||||
cd ${pkg}
|
cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 18: bash
|
# Part 19: bash
|
||||||
pkg="bash-2.05b"
|
pkg="bash-2.05b"
|
||||||
cd ${pkg}
|
cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
|
|
22
sysa/run.sh
22
sysa/run.sh
|
@ -9,36 +9,36 @@ set -e
|
||||||
|
|
||||||
export PREFIX=/after
|
export PREFIX=/after
|
||||||
|
|
||||||
# Part 19
|
# Part 20
|
||||||
build flex-2.5.11
|
build flex-2.5.11
|
||||||
|
|
||||||
# Part 20
|
# Part 21
|
||||||
build musl-1.1.24
|
build musl-1.1.24
|
||||||
|
|
||||||
# Part 21
|
|
||||||
build tcc-0.9.27 tcc-musl.sh
|
|
||||||
|
|
||||||
# Part 22
|
# Part 22
|
||||||
build m4-1.4.7
|
build tcc-0.9.27 tcc-musl.sh checksums/tcc-musl
|
||||||
|
|
||||||
# Part 23
|
# Part 23
|
||||||
build flex-2.6.4
|
build m4-1.4.7
|
||||||
|
|
||||||
# Part 24
|
# Part 24
|
||||||
|
build flex-2.6.4
|
||||||
|
|
||||||
|
# Part 25
|
||||||
build bison-3.4.1 stage1.sh
|
build bison-3.4.1 stage1.sh
|
||||||
build bison-3.4.1 stage2.sh
|
build bison-3.4.1 stage2.sh
|
||||||
build bison-3.4.1 stage3.sh
|
build bison-3.4.1 stage3.sh
|
||||||
|
|
||||||
# Part 25
|
# Part 26
|
||||||
build grep-2.4
|
build grep-2.4
|
||||||
|
|
||||||
# Part 26
|
# Part 27
|
||||||
build diffutils-2.7
|
build diffutils-2.7
|
||||||
|
|
||||||
# Part 27
|
# Part 28
|
||||||
build coreutils-5.0
|
build coreutils-5.0
|
||||||
|
|
||||||
# Part 28
|
# Part 29
|
||||||
build gawk-3.0.4
|
build gawk-3.0.4
|
||||||
|
|
||||||
# Part 29
|
# Part 29
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
53384 /after/bin/sha256sum
|
|
@ -0,0 +1,151 @@
|
||||||
|
SPDX-FileCopyrightText: 2021 Bastian Bittorf <bb@npl.de>
|
||||||
|
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
This adds a main() function to this tool, giving a frontend so we can call
|
||||||
|
it from the command line.
|
||||||
|
|
||||||
|
--- sha-256.c 2019-08-04 22:20:53.000000000 +1000
|
||||||
|
+++ sha-256.c 2021-02-15 17:21:27.478945543 +1100
|
||||||
|
@@ -1,10 +1,16 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
-
|
||||||
|
-#include "sha-256.h"
|
||||||
|
+#include <stdio.h>
|
||||||
|
|
||||||
|
#define CHUNK_SIZE 64
|
||||||
|
#define TOTAL_LEN_LEN 8
|
||||||
|
+#define MAX_FILE_SIZE 2*1024*1024
|
||||||
|
+
|
||||||
|
+void show_usage(void)
|
||||||
|
+{
|
||||||
|
+ printf("Usage: sha256sum <file>\n");
|
||||||
|
+ printf(" sha256sum <file> -c <known_SHA256_hash>\n");
|
||||||
|
+}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ABOUT bool: this file does not use bool in order to be as pre-C99 compatible as possible.
|
||||||
|
@@ -217,3 +223,121 @@
|
||||||
|
hash[j++] = (uint8_t) h[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+static void hash_to_string(char hash_string[66], uint8_t hash[32])
|
||||||
|
+{
|
||||||
|
+ for (size_t i = 0; i < 32; i++) {
|
||||||
|
+ hash_string += sprintf(hash_string, "%02x", hash[i]);
|
||||||
|
+ }
|
||||||
|
+ hash_string[65] = '\0';
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void hash_as_string(char filename[128], char hash_string[66])
|
||||||
|
+{
|
||||||
|
+ char buffer[MAX_FILE_SIZE];
|
||||||
|
+
|
||||||
|
+ FILE* fp = fopen(filename, "r");
|
||||||
|
+ if (fp == NULL)
|
||||||
|
+ {
|
||||||
|
+ printf("Opening file %s failed!", filename);
|
||||||
|
+ hash_string = NULL;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ size_t i;
|
||||||
|
+ for (i = 0; i < MAX_FILE_SIZE; i++) {
|
||||||
|
+ int c = fgetc(fp);
|
||||||
|
+ if (c == EOF) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ buffer[i] = c;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ uint8_t hash[32];
|
||||||
|
+
|
||||||
|
+ calc_sha_256(hash, buffer, i);
|
||||||
|
+ hash_to_string(hash_string, hash);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int main(int argc, char **argv)
|
||||||
|
+{
|
||||||
|
+ char buffer[MAX_FILE_SIZE];
|
||||||
|
+ size_t i;
|
||||||
|
+ FILE *fp;
|
||||||
|
+ FILE *csum_fp;
|
||||||
|
+
|
||||||
|
+ if (argc == 1) {
|
||||||
|
+ show_usage();
|
||||||
|
+ return 2;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if ((strcmp(argv[1], "-c") == 0) || (strcmp(argv[1], "--check") == 0)) {
|
||||||
|
+ /* Operate in check mode */
|
||||||
|
+ int failed = 0;
|
||||||
|
+
|
||||||
|
+ /* Get and open checksum file */
|
||||||
|
+ char *csum_filename = argv[2];
|
||||||
|
+ csum_fp = fopen(csum_filename, "r");
|
||||||
|
+ if (csum_fp == NULL) {
|
||||||
|
+ printf("Opening file %s failed!", csum_filename);
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ /* We break out of this loop at EOF */
|
||||||
|
+ while (1) {
|
||||||
|
+ /* Get the hash we need to check against */
|
||||||
|
+ char hash_true[256];
|
||||||
|
+ char filename[512];
|
||||||
|
+ int c = fgetc(csum_fp);
|
||||||
|
+ i = 0;
|
||||||
|
+ while (c != ' ' && c != EOF) {
|
||||||
|
+ hash_true[i] = c;
|
||||||
|
+ c = fgetc(csum_fp);
|
||||||
|
+ i++;
|
||||||
|
+ }
|
||||||
|
+ if(c == EOF) break;
|
||||||
|
+ /* Skip the next space(s) */
|
||||||
|
+ while (c == ' ') {
|
||||||
|
+ c = fgetc(csum_fp);
|
||||||
|
+ }
|
||||||
|
+ if(c == EOF) break;
|
||||||
|
+ /* Get the filename */
|
||||||
|
+ i = 0;
|
||||||
|
+ while (c != '\n' && c != EOF) {
|
||||||
|
+ filename[i] = c;
|
||||||
|
+ c = fgetc(csum_fp);
|
||||||
|
+ i++;
|
||||||
|
+ }
|
||||||
|
+ filename[i] = '\0';
|
||||||
|
+
|
||||||
|
+ /* Break out @ EOF */
|
||||||
|
+ if (c == EOF) break;
|
||||||
|
+
|
||||||
|
+ /* Get the hash */
|
||||||
|
+ char hash_string[66];
|
||||||
|
+ hash_as_string(filename, hash_string);
|
||||||
|
+ if (hash_string == NULL) return 127;
|
||||||
|
+
|
||||||
|
+ /* Output results */
|
||||||
|
+ printf("%s: ", filename);
|
||||||
|
+ if (strcmp(hash_true, hash_string)) {
|
||||||
|
+ printf("FAILED\n");
|
||||||
|
+ failed = 1;
|
||||||
|
+ } else {
|
||||||
|
+ printf("OK\n");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (failed) return 1;
|
||||||
|
+ } else {
|
||||||
|
+ /* All the arguments are files to generate checksums for */
|
||||||
|
+
|
||||||
|
+ for (i = 1; i < argc; i++) {
|
||||||
|
+ char hash[66];
|
||||||
|
+ hash_as_string(argv[i], hash);
|
||||||
|
+ if (hash == NULL) return 127;
|
||||||
|
+ printf("%s %s\n", hash, argv[i]);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cd build
|
||||||
|
|
||||||
|
# Extract
|
||||||
|
gunzip ../src/${pkg}.tar.gz
|
||||||
|
tar xf ../src/${pkg}.tar
|
||||||
|
cd sha-2-61555d45676473e77c11f8da97301e2d2b865871
|
||||||
|
|
||||||
|
# Patch
|
||||||
|
patch -Np0 -i ../../patches/frontend.patch
|
||||||
|
|
||||||
|
# Compile
|
||||||
|
tcc -c -o sha-256.o sha-256.c
|
||||||
|
|
||||||
|
# Link
|
||||||
|
tcc -static -o ${bindir}/sha256sum sha-256.o
|
||||||
|
|
||||||
|
# No test avaliable
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Checksums
|
||||||
|
fletcher16 checksums
|
Loading…
Reference in New Issue