Skip to content

Instantly share code, notes, and snippets.

View 46bit's full-sized avatar
🏳️‍🌈

Miki Mokrysz 46bit

🏳️‍🌈
View GitHub Profile
@46bit
46bit / gist:5db76cde9c48bfa31039
Last active August 29, 2015 14:05
Things to remind myself about the Highway Code
break for 15+ minutes every 2 hours
limit on towing weight
do not use horn when stationary or 11:30pm-7am in built-up area
sidelights and rear registration must be lit half an hour either side of sunset/sunrise
headlights must be lit at night unless there are streetlights
when stationary, apply the parking brake and release the foot brake to reduce dazzle
use dipped headlights in daytime, built-up areas, overtaking until level
hazard warning lights should be used at night in built-up areas, or dull daytime
start/stop braking lightly, for safety
try to avoid wheellock in emergency brake
#include <stdio.h>
#include <stdlib.h>
#include <openssl/ec.h>
//#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
int main()
{
BN_CTX *bn_ctx = BN_CTX_new();
@46bit
46bit / bn_lib.c
Created November 17, 2014 22:47
An extract from OpenSSL crypto/bn/bn_lib.c. BN_bn2bin is used to extract binary data from bignums. I think?
int BN_bn2bin(const BIGNUM *a, unsigned char *to)
{
int n,i;
BN_ULONG l;
bn_check_top(a);
n=i=BN_num_bytes(a);
while (i--)
{
l=a->d[i/BN_BYTES];
@46bit
46bit / fips_drbg_ec.c
Created November 17, 2014 22:58
An internal routine for the deprecated OpenSSL implementation of Dual_EC_DRBG.
static int drbg_ec_generate(DRBG_CTX *dctx,
unsigned char *out, size_t outlen,
const unsigned char *adin, size_t adin_len)
{
DRBG_EC_CTX *ectx = &dctx->d.ec;
BIGNUM *t, *r;
BIGNUM *s = ectx->s;
/* special case: check reseed interval */
if (out == NULL)
{
@46bit
46bit / maze.rs
Created December 12, 2014 15:00
What pointers do I need to add to make this work? Edges should store references to nodes; nodes store references to edges.
struct Node<D> {
edges: Vec<Edge<D>>,
pub data: D
}
impl<D> Node<D> {
pub fn new(data: D) -> Node<D> {
Node{data: data, edges: Vec::new()}
}
}
@46bit
46bit / maize-len0-unreduced.rs
Created December 29, 2014 02:42
Bizarre difference in Vec<Node<NodeInfo>> lengths in subsequent areas of code. Need to reduce out a testcase for debugging/getting help.
use std::collections::HashMap;
use std::num::Int;
use std::num::Float;
use std::io;
use std::uint;
use std::io::File;
#[deriving(Show)]
pub struct Graph<D,E> {
pub nodes: Vec<Node<D>>,
U.S. First Strike
USSR First Strike
NATO/Warsaw Pact
Far East Strategy
US USSR Escalation
Middle East War
USSR China Attack
India Pakistan War
Mediterranean War
HongKong Variant
@46bit
46bit / alphac.js
Created January 11, 2015 04:54
Alphac text `encrypter' I'm trying to reverse for fun, original JavaScript. http://www.myersdaily.org/joseph/javascript/alphac.html
c64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''), l64 = {};
for (i=0; i<64; i++)
l64[c64[i]] = i;
function alphar(s) {
// I only pray--let me be ready.
var i;
// s must contain only base-64 characters!
s = s.replace(/[^0-9A-Za-z+\/]+/g, '');
s = s.split('');
@46bit
46bit / alphac.py
Last active August 29, 2015 14:13
ALPHAC text encrypter that I'm attacking for fun, reimplemented cleanly in Python. Source: http://www.myersdaily.org/joseph/javascript/alphac.html.
from random import randint
# ALPHAC encryption method
# From http://www.myersdaily.org/joseph/javascript/alphac.html
# This a much cleaner Python reimplementation for Cryptanalysis.
class Alphac:
c64 = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
# s = input string (only characters in c64)
# k = key string (only characters in c64)
import random, heapq
def ax2_bx_c(x, (a, b, c)):
return a * x**2 + b * x + c
def ax2_bx_c_fitness(x_range, ideal_params, test_params):
fitness = 0.0
for x in x_range:
x = float(x)
fitness += ax2_bx_c(x, test_params) - ax2_bx_c(x, ideal_params)