Skip to content

Instantly share code, notes, and snippets.

View randombit's full-sized avatar

Jack Lloyd randombit

View GitHub Profile
@randombit
randombit / gen_wordpress_secrets.py
Created November 27, 2018 15:51
Generate secrets for wordpress
#!/usr/bin/python
import os
import binascii
keys = [
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
@randombit
randombit / rsa_sign.py
Created November 21, 2018 16:24
Threshold 2-of-2 RSA signatures
#!/usr/bin/python
from fractions import gcd
import random
def lcm(a,b):
return (a*b)//gcd(a,b)
def egcd(a, b):
if a == 0:
@randombit
randombit / packages
Last active May 23, 2022 13:45
Arch package list
After installing, add:
Useful
--------
vim
emacs-nox
net-tools
tmux
tcpdump
nmap
@randombit
randombit / dsa_groups.txt
Created August 2, 2018 16:34
DSA groups generated by lexicographical first working seed
P=1024 Q=160
Seed=000000000000000000000000000000000000021
-----BEGIN X9.42 DH PARAMETERS-----
MIIBHwKBgQCEoKuNbWMqbPuFOqSWKMGJyQ8VMSWLMtQ80wj0Is3RxrGpz0Bpshd7
Q9EL7BVjwTi+bZe68bXwU8GsHNLq6qplevvfsmpeHaJn0vt/gHRjmWWB68phAuPe
+CcU9X4ESl8e869AkSq3rnCnpTHauBDMkOWvXiMRUNEE5QbPdNHlhQKBgQCBrdzE
HRHk662S9/WZnuZpAeZjQCZZug1DToG97W4Z9xOycttPZ50N5mC4+NOhmfV4t3a+
1wTe7vuYdL8zHt/dcIx9ow/uriqlaFX2Hh/jTYeC8r0m1JDcBxKV21aE5QLqpCfu
Jr8h/76s55aY1m2OWaR1K//y54GWZ4sxoxgS8gIVANnk4S2TxAhgZKmIVOksz0sn
dNlL
@randombit
randombit / format_ecdsa.py
Created May 31, 2018 21:15
Format Wycheproof ECDSA test data
!/usr/bin/python
import json
import hashlib
import binascii
from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.type.univ import Sequence
from pyasn1.type.univ import Integer
from pyasn1.type.namedtype import NamedTypes
from pyasn1.type.namedtype import NamedType
@randombit
randombit / mr_iterations.py
Created April 10, 2018 15:41
Miller-Rabin error probabilities
#!/usr/bin/python
from math import log, pow, sqrt
import sys
# Estimate Miller-Rabin error probability based on bitsize (k)
# and number of MR tests (t)
# https://www.math.dartmouth.edu//~carlp/PDF/paper88.pdf
#include <botan/fpe_fe1.h>
#include <assert.h>
#include <iostream>
using namespace Botan;
BigInt power(size_t g, size_t x)
{
BigInt r = 1;
for(size_t i = 0; i != x; ++i)
@randombit
randombit / gist:d1c9ec22e0b5d31dba460d791e24e05d
Last active December 28, 2021 19:45
Advanced Cryptography Topics
Pallier Cryptosystem
Voting protocols, systems, mixnets
Homomorphic encryption (ElGamal, mixnets, voting)
Sigma protocols
Zero Knowledge Proofs, Fiat-Shamir Transform
ID based signatures and encryption
SNARKs
Ring signatures, group signatures
Signcryption
Pairings, uses thereof
/*
Compile time string switch
Requires C++14 constexpr
*/
#include <cstdint>
#include <cstdio>
#if 0
// C++14 version
*** This is just my personal todo file for botan. It is not supposed
to make any sense to you. Some of these things may happen some day.
If something in here excites you feel free to take it on though.
The easy way to do a FIPS 140 validation is to not need to do a FIPS 140 validation.
FIPS just cares about the crypto impl, if we're just an 'application calling OpenSSL FIPS object'
that happens to implement TLS, all is well. This requires a special mode that enables
only OpenSSL's AES, SHA, RSA, ECDSA, RNG, etc and disable the builtins including our
HMAC_DRBG (instead AutoSeeded_RNG calls OpenSSL's FIPS RNG), plus probably 2-3
exposed API functions for the application to control the OpenSSL self tests and etc.