Skip to content

Instantly share code, notes, and snippets.

View colmmacc's full-sized avatar

Colm MacCárthaigh colmmacc

View GitHub Profile
@colmmacc
colmmacc / wordle-cribs.md
Created January 3, 2022 01:12
Wordle Letter Frequency Cribs

Wordle Letter Frequency Table

If you're used to solving cryptic puzzles, or deciphering texts using crypt-analytical cribs, it can be useful to know the relative frequency of letters in the distribution of words. Wordle has a built-in list of 5-letter words. That list isn't the same as all of the five letter words in the dictionary, or even only the common ones. Perfectly common words like 'tudor' are omitted. This gist contains a few useful tables that are worth familiarizing yourself with if you want to solve wordle puzzles logically.

The raw frequency of each letter

extern crate sha2;
extern crate nix;
extern crate libc;
use sha2::{Sha256, Digest};
use nix::request_code_write;
use std::os::unix::prelude::*;
use std::os::raw::c_int;
use std::fs::File;
use std::mem;

How many ways can we express "::"

Both IPv4 and IPv6 allow for some flexibility in how IP addresses are expressed as strings, but IPv6 really takes it to the max. How many ways can we express the all-zeroes IPv6 address, a.k.a. "::". Let's see.

The obvious

 ::

Running count: 1.

@colmmacc
colmmacc / shardcalc.py
Last active August 7, 2023 11:05
Calculate the blast radius of a shuffle shard
import sys
# choose() is the same as computing the number of combinations. Normally this is
# equal to:
#
# factorial(N) / (factorial(m) * factorial(N - m))
#
# but this is very slow to run and requires a deep stack (without tail
# recursion).
#
import sys
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
def choose(n, m):
return factorial(n) / (factorial(m) * factorial(n - m))
diff --git a/tls/s2n_connection.c b/tls/s2n_connection.c
index 27a9c04..8a3f42e 100644
--- a/tls/s2n_connection.c
+++ b/tls/s2n_connection.c
@@ -206,6 +206,7 @@ int s2n_connection_wipe(struct s2n_connection *conn)
conn->mode = mode;
conn->config = config;
conn->close_notify_queued = 0;
+ conn->current_user_data_consumed = 0;
conn->initial.cipher_suite = &s2n_null_cipher_suite;
@colmmacc
colmmacc / Ticket Key Rotation.md
Last active July 12, 2016 17:40
Proposal for Ticket Key Rotation in s2n

Ticket Key Rotation Proposal for s2n

What are session tickets and why do we need them?

In TLS, at a high level there are two phases: a handshake phase where asymmetric cryptography is used by two ends (server and client) to agree on a shared key, and a second phase for data transmission where that shared key is used to encrypt/decrypt data. The first phase is generally more expensive than the second; it's computationally intense to agree on a key, and it takes several network round trips to do.

@colmmacc
colmmacc / Factorial.md
Last active May 12, 2016 17:35
Factorial problem

Problem statement

x! = (7!)! / 7!  # solve for x

Solution

Let 7! be N. Re-express as

x! = N! / N
@colmmacc
colmmacc / openssl_rng.c
Last active January 13, 2016 18:38
An RNG API for OpenSSL
#include <openssl/rand.h>
void example() {
/* Initialize the random subsystem. generally called prior to chroot, may fail if /dev/urandom is not available. */
RNG_init();
/* alternatively, a more future-flexible OpenSSL init that calls RNG_init() internally. Similar to SSL_library_init, but more general. */
OPENSSL_init();
/* Instantiate an RNG */

Keybase proof

I hereby claim:

  • I am colmmacc on github.
  • I am colmmacc (https://keybase.io/colmmacc) on keybase.
  • I have a public key whose fingerprint is AD0A 9656 5D4A 027F CF43 AD31 843C 9675 D3C0 3962

To claim this, I am signing this object: