From a023987aae7dbf01b012cf0abc83d1398dd2eddb Mon Sep 17 00:00:00 2001 From: Val Date: Mon, 9 Jan 2023 01:39:54 -0600 Subject: [PATCH] Make changes for Halifax --- .clang-format | 30 +++++++++++++++--------------- 23-Baku/baku.py | 1 - common/io.c | 19 ++++++++++++++++++- common/lib.c | 19 ++++++++++++++----- readme.md | 3 +++ 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/.clang-format b/.clang-format index fde4470..e7216fb 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -# +-------------+---------+-----------------------+ +# +-----------------------------------------------+ # | Created 2022-04-23 | # +-----------------------------------------------+ @@ -27,7 +27,7 @@ IncludeBlocks: Regroup # Allow short blocks on single line AllowShortBlocksOnASingleLine: Always -AllowShortEnumsOnASingleLine: false +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: AllIfsAndElse AllowShortLambdasOnASingleLine: Inline @@ -47,22 +47,22 @@ BitFieldColonSpacing: After BreakBeforeBraces: Custom # Disable that BraceWrapping: - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + AfterControlStatement: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false - IndentBraces: false + IndentBraces: false - SplitEmptyFunction: false + SplitEmptyFunction: false # Don't break before ?:, it looks ugly BreakBeforeTernaryOperators: false diff --git a/23-Baku/baku.py b/23-Baku/baku.py index 63e56c1..f64e3c8 100644 --- a/23-Baku/baku.py +++ b/23-Baku/baku.py @@ -37,7 +37,6 @@ inv_sbox = [ for key in keys: key = bytes.fromhex(key) - cipher = Cipher(algorithms.AES128(key), modes.ECB()); enc = cipher.encryptor() diff --git a/common/io.c b/common/io.c index addd8eb..bfb8dd9 100644 --- a/common/io.c +++ b/common/io.c @@ -5,7 +5,24 @@ #include #include "mem.h" // 512 600 0011 -void INT (int arg, ...); + +int flag_enable_0x7f = 1; + +void INT (int arg, ...) { + switch (arg) { + case 0x40: + flag_enable_0x7f = 0; + break; + case 0x7f: + if(flag_enable_0x7f) { + printf("The lock is now open.\n"); + exit(0); + } + break; + default: + printf("INT(0x%02x, ...) unimplemented", arg); + } +} char hascii(int i) { if (i > '9') diff --git a/common/lib.c b/common/lib.c index 23d3da3..9974cd7 100644 --- a/common/lib.c +++ b/common/lib.c @@ -4,14 +4,23 @@ #include #include "mem.h" -int verify_ed25519 (char * ed25519_pubkey, void * buf, int size, char * signature) {return 1;}; +//* functions that rely on hardware components of the Lockitall lock +int verify_ed25519 (char * ed25519_pubkey, void * buf, int size, char * signature) { + //FIXME: This is not correct (see ../22-Churchill/churchill.asm) + INT(0x33, ed25519_pubkey, buf, size, signature); + return 1; +} +int sha256_internal (size_t sram_in_buf, size_t size, char * out_buf) { + INT(0x41, sram_in_buf, size, out_buf); + return 0; +} +//* functions that are explicitly implemented in the standard library //void *memcpy(void *__restrict__ __dest, const void *__restrict__ __src, size_t __n); //int memcmp(const void *__s1, const void *__s2, size_t __n); - -void sha1 (void *buf,size_t size, char * out_buf) {} -void sha256 (void *buf,size_t size, char * out_buf) {} -void sha512 (void *buf,size_t size, char * out_buf) {} +void sha1 (void *buf,size_t size, char * out_buf) {/* implementation goes here */} +void sha256 (void *buf,size_t size, char * out_buf) {/* implementation goes here */} +void sha512 (void *buf,size_t size, char * out_buf) {/* implementation goes here */} #endif // __uC_LIB_C__ diff --git a/readme.md b/readme.md index e3f4409..9054a84 100644 --- a/readme.md +++ b/readme.md @@ -44,3 +44,6 @@ Hopefully in the coming weeks I'll learn enough about malloc and free to get som ### 2022 Dec 11 PM: St. John's Baku + +### 2022 Dec 12 PM - Ongoing + Halifax