Skip to content

Instantly share code, notes, and snippets.

View itzmeanjan's full-sized avatar
😎
Working ...

Anjan Roy itzmeanjan

😎
Working ...
View GitHub Profile
@itzmeanjan
itzmeanjan / linux-machine-setup.sh
Last active November 4, 2024 10:35
Quickly setup AWS EC2 linux instance - ready for running tests and benchmarks
#!/bin/bash
# System update
sudo apt-get update
sudo apt-get upgrade -y
# Install system development tools
sudo apt-get install build-essential -y
sudo apt-get install cmake -y
@itzmeanjan
itzmeanjan / diff.patch
Created October 29, 2023 13:12
Steps to Generate Known Answer Tests for RC4OK Pseudo Random Number Generator
diff --git a/demo_rc4ok.c b/demo_rc4ok.c
index 72abbb1..968c191 100644
--- a/demo_rc4ok.c
+++ b/demo_rc4ok.c
@@ -3,7 +3,7 @@
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
-#include <rc4ok.h>
+#include "rc4ok.h"
@itzmeanjan
itzmeanjan / git.patch
Last active October 11, 2023 09:49
Known Answer Tests for Multimixer-128: Universal Keyed Hashing, based on Integer Multiplication
diff --git a/ReferenceCode/Multimixer-128.py b/ReferenceCode/Multimixer-128.py
index 2f9b11e..54cb0a6 100644
--- a/ReferenceCode/Multimixer-128.py
+++ b/ReferenceCode/Multimixer-128.py
@@ -96,9 +96,70 @@ def Int_multimix(M,K):
#256 = block size of Multimixer-128
-l = int(input("Enter message Length: "))
+def gen_rand_bytes(l: int) -> bytes:
@itzmeanjan
itzmeanjan / saber_kem_kat.patch
Last active October 20, 2023 16:31
Git Patch for Generating Known Answer Tests ( KATs ) from Saber Reference Implementation
diff --git a/Reference_Implementation_KEM/Makefile b/Reference_Implementation_KEM/Makefile
index 7608e07..adfda63 100644
--- a/Reference_Implementation_KEM/Makefile
+++ b/Reference_Implementation_KEM/Makefile
@@ -14,13 +14,13 @@ SOURCES = pack_unpack.c poly.c fips202.c verify.c cbd.c SABER_indcpa.c kem.c
HEADERS = SABER_params.h pack_unpack.h poly.h rng.h fips202.h verify.h cbd.h SABER_indcpa.h
test/test_kex: $(SOURCES) $(HEADERS) rng.o test/test_kex.c
- $(CC) $(CFLAGS) -o $@ $(SOURCES) rng.o test/test_kex.c -lcrypto
+ $(CC) $(CFLAGS) -o $@ -DSABER_L=$(SABER_L) $(SOURCES) rng.o test/test_kex.c -lcrypto
@itzmeanjan
itzmeanjan / google-benchmark-with-libpfm.md
Last active May 6, 2024 02:28
Using Performance Monitoring Unit(s), when benchmarking with google-benchmark.

Background

I'm demonstrating following on a machine, running Ubuntu 22.04 with GNU/Linux kernel 5.19.0.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
@itzmeanjan
itzmeanjan / gen_fips202_kat.py
Created July 6, 2023 15:32
Script for generating KATs for SHA3 Hash functions and Extendable output functions, defined in FIPS 202 Standard
#!/usr/bin/python
import random
import hashlib
MIN_MSG_LEN = 0 # minimum input message byte length
MAX_MSG_LEN = 1024 # maximum input message byte length
SQUEEZED_LEN = 256 # number of bytes squeezed from Xof
@itzmeanjan
itzmeanjan / frodokem_kat.patch
Last active September 12, 2023 18:47
Git Patch for generating Known Answer Tests ( KATs ) from FrodoKEM Reference Implementation
diff --git a/FrodoKEM/python3/frodokem.py b/FrodoKEM/python3/frodokem.py
index 731cb0e..c701108 100644
--- a/FrodoKEM/python3/frodokem.py
+++ b/FrodoKEM/python3/frodokem.py
@@ -4,6 +4,7 @@
import bitstring
import math
+import sys
import secrets
@itzmeanjan
itzmeanjan / REAME.md
Last active April 14, 2023 11:30
Generate Known Answer Tests for Xoofff - Deck function instantiated with Xoodoo permutation

This gist holds steps for generating Known Answer Tests from Xoofff's reference C++ implementation ( more @ https://github.com/KeccakTeam/Xoodoo.git ), by applying following git patch s.t. these KATs can be used for ensuring functional correctness of my Rust library implementation of Xoofff ( more @ https://github.com/itzmeanjan/xoofff ).

  • Clone repository holding reference implementation of Xoofff
git clone https://github.com/KeccakTeam/Xoodoo.git
  • Pin repository state to specific commit.
@itzmeanjan
itzmeanjan / sphincs_kat_generation.patch
Created November 28, 2022 11:41
Git Patch for generating Known Answer Tests ( KATs ) from SPHINCS+ Reference Implementation
diff --git a/ref/Makefile b/ref/Makefile
index a3aabad..24c34e1 100644
--- a/ref/Makefile
+++ b/ref/Makefile
@@ -43,7 +43,7 @@ benchmarks: $(BENCHMARK)
benchmark: $(BENCHMARK:=.exec)
PQCgenKAT_sign: PQCgenKAT_sign.c $(DET_SOURCES) $(DET_HEADERS)
- $(CC) $(CFLAGS) -o $@ $(DET_SOURCES) $< -lcrypto
+ $(CC) $(CFLAGS) -o $@ $(DET_SOURCES) -I/usr/local/opt/[email protected]/include -L/usr/local/opt/[email protected]/lib $< -lcrypto
@itzmeanjan
itzmeanjan / ml_dsa_kat_generation.patch
Last active June 30, 2024 13:53
Git Patch to Generate Known Answer Tests ( KATs ) from ML-DSA "Official" Reference Implementation
diff --git a/ref/hex_print.h b/ref/hex_print.h
new file mode 100644
index 0000000..7afd872
--- /dev/null
+++ b/ref/hex_print.h
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdint.h>
+
+inline void to_hex(const uint8_t *const bytes, const size_t blen) {