Yay things work
Juniper Beatitudes [email protected]
Thu, 01 Jan 2026 14:53:01 -0600
4 files changed,
24 insertions(+),
12 deletions(-)
M
Makefile
→
Makefile
@@ -1,13 +1,14 @@
-CC ?= clang +CC ?= gcc AR ?= ar INCLUDE_PATH := . SOURCE_FILES := $(wildcard tinycrypt/*.c) SOURCE_OBJECTS := $(SOURCE_FILES:tinycrypt/%.c=lib/%.o) TEST_SOURCE_FILES := tinycrypt/tests/*.c -COMPILER_OPTS := -O3 -ffreestanding -std=c99 +COMPILER_OPTS := -ffreestanding -std=c99 +OPTIMIZE_LEVEL := -O3 test-main: $(SOURCE_OBJECTS) $(TEST_SOURCE_FILES) - @ $(CC) -o test-main -O3 -I$(INCLUDE_PATH) $(SOURCE_FILES) $(TEST_SOURCE_FILES) + @ $(CC) -o test-main -O3 -I$(INCLUDE_PATH) $(SOURCE_OBJECTS) $(TEST_SOURCE_FILES) tests: test-main @ ./test-main@@ -16,10 +17,10 @@ memcheck: test-main
@ valgrind ./test-main lib/%.o: tinycrypt/%.c - @ $(CC) -c $(COMPILER_OPTS) -I$(INCLUDE_PATH) $< -o $@ + @ $(CC) -c $(COMPILER_OPTS) $(OPTIMIZE_LEVEL) -I$(INCLUDE_PATH) $< -o $@ lib: $(SOURCE_OBJECTS) @ $(AR) rcs lib/libtinycrypt.a lib/*.o clean: - rm lib/*.o test-main+ @- rm lib/*.o test-main
M
flake.lock
→
flake.lock
@@ -2,16 +2,16 @@ {
"nodes": { "nixpkgs": { "locked": { - "lastModified": 1766902085, - "narHash": "sha256-coBu0ONtFzlwwVBzmjacUQwj3G+lybcZ1oeNSQkgC0M=", + "lastModified": 1767047869, + "narHash": "sha256-tzYsEzXEVa7op1LTnrLSiPGrcCY6948iD0EcNLWcmzo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c0b0e0fddf73fd517c3471e546c0df87a42d53f4", + "rev": "89dbf01df72eb5ebe3b24a86334b12c27d68016a", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" }
M
flake.nix
→
flake.nix
@@ -2,7 +2,7 @@ {
description = "TinyCrypT Build Environment"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11"; }; outputs =@@ -18,7 +18,7 @@ shl = pkgs.mkShell {
name = "tct-tooling-env"; packages = with pkgs; [ cmake - clang + gcc clang-tools gnumake valgrind
M
tinycrypt/tests/main.c
→
tinycrypt/tests/main.c
@@ -1,6 +1,9 @@
#include <stdbool.h> +#include <stddef.h> #include <stdio.h> +#include <string.h> +#include "tinycrypt/sha2.h" #include "tinycrypt/tests/harness.h" int@@ -11,7 +14,15 @@ tct_testing_init_ctx (&ctx);
printf ("Beginning tests\n"); tct_testing_start (&ctx); - // Tests go here + uint8_t buf[32]; + tct_sha256 (NULL, 0, buf); + uint8_t reference[] = { + 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, + 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, + 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55, + }; + tct_testing_assert (&ctx, !memcmp (buf, reference, sizeof (buf)), + "Empty SHA-256"); tct_testing_end (&ctx); printf ("%lu tests passed, %lu tests failed, %lu microseconds elapsed\n",