This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Find involutory exponents for a modulus like a Mersenne prime: 2^31-1 | |
Uses brute force | |
Very fast for small numbers, very slow for anything more than 16-bits. | |
gcc -O2 find_exp.c -ofind_exp -lcrypto | |
*/ | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Affine Permutation File Encoder/Decoder | |
This script allows you to encode and decode files using an Affine Permutation. | |
It uses command-line arguments to specify the operation mode (encode or decode), input file, and output file. | |
Additionally, it stores a SHA256 hash of the original data to verify successful decoding. | |
Usage: | |
To encode a file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
LCG output... | |
lcg(1) : 40B2947B | |
lcg(2) : 73718F14 | |
lcg(3) : 6203F04B | |
lcg(4) : 1BB91A70 | |
lcg(5) : 0CFC23E0 | |
ICG output... | |
icg(5) : 0CFC23E0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FEAL-8 Block Cipher | |
// | |
#include <stdio.h> | |
#include <stdint.h> | |
// Define the Sd function as per equation (7.6) | |
uint8_t Sd(uint8_t x, uint8_t y, uint8_t d) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ARADI and LLAMA: Low-Latency Cryptography for Memory Encryption | |
Published in August 2024 | |
Only tested on little-endian CPU. | |
For more details, see https://eprint.iacr.org/2024/1240 | |
*/ | |
#include <stdint.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ElGamal encryption | |
import random | |
from sympy import isprime, mod_inverse | |
# Generate a large prime number for the modulus (p) | |
def generate_large_prime(bits=256): | |
while True: | |
p = random.getrandbits(bits) | |
if isprime(p): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import secrets | |
# Elliptic Curve Parameters (placeholders for educational purposes) | |
p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F # Field prime | |
a = 0 | |
b = 7 | |
n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 # Order of G | |
# Base point G (using Bitcoin's secp256k1 parameters for illustration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Schnorr Digital Signature Scheme based on paper: | |
Efficient Signature Generation by Smart Cards, published in March 1991 by Claus-Peter Schnorr | |
''' | |
from random import randint | |
import sympy | |
import hashlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Running test...key : 803D8AB2E5B6E6FCA715737C3A82F7CE3C783124F6D51CD0 | |
Session keys match... | |
OK. | |
Generating random keys...OK | |
Private Key for Alice : 31FA1084 | |
Private Key for Bob : 2D748885 | |
Generating public keys... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ECC-32 implementation | |
Private Key for Alice : 775bd026 | |
Private Key for Bob : 5133580e | |
Public Key for Alice : (32f20f84, 63852a02) | |
Public Key for Bob : (6d4444c2, 1563edf9) | |
Session Key for Alice : (2f3a9fa3, 6a9fa1ce) |
NewerOlder