Skip to content

Instantly share code, notes, and snippets.

View josephlr's full-sized avatar

Joe Richey josephlr

View GitHub Profile
@josephlr
josephlr / tpm.proto
Created June 22, 2021 02:16
Notes on MachineState and AttestationPolicy
message Certificate {
bytes der = 1;
}
message Database {
repeated Certificate certs = 1;
repeated bytes hashes = 2;
}
use num::Rational;
use std::{collections::HashMap, iter::once};
struct Calc(HashMap<(isize, isize), Rational>);
impl Calc {
fn prob(&mut self, me: isize, you: isize) -> Rational {
assert!(me > 0);
assert!(you > 0);
// If we already have computed the solution, use that.
#!/usr/bin/env python3
singles = {
0: "", # This is wrong for "zero", but is right for everything else.
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
@josephlr
josephlr / main.rs
Created January 7, 2020 07:29
getrandom example program
use getrandom::getrandom;
fn main() {
let mut data = [0u8; 4];
getrandom(&mut data).unwrap();
println!("{}", u32::from_ne_bytes(data));
}
@josephlr
josephlr / objdump.asm
Created January 3, 2020 12:19
use_file::getrandom_inner
0000000000004740 <_ZN9getrandom8use_file15getrandom_inner17h89c10d768f32f0baE>:
4740: 55 push %rbp
4741: 41 57 push %r15
4743: 41 56 push %r14
4745: 41 55 push %r13
4747: 41 54 push %r12
4749: 53 push %rbx
474a: 50 push %rax
474b: 48 89 f3 mov %rsi,%rbx
474e: 49 89 fe mov %rdi,%r14
early console in extract_kernel
input_data: 0x000000000243b3b1
input_len: 0x0000000000497de4
output: 0x0000000001000000
output_len: 0x00000000018aa2c0
kernel_total_size: 0x000000000162c000
trampoline_32bit: 0x000000000009d000
booted via startup_64()
early console in extract_kernel
input_data: 0x000000000243b3b1
input_len: 0x0000000000497de4
output: 0x0000000001000000
output_len: 0x00000000018aa2c0
kernel_total_size: 0x000000000162c000
trampoline_32bit: 0x000000000009d000
booted via startup_64()
Physical KASLR using RDRAND RDTSC...
Virtual KASLR using RDRAND RDTSC...
@josephlr
josephlr / gist:39a723baa1f36346d1b904eaa8e98479
Created June 20, 2019 09:37
Output of "bazel test --test_output=all //ring:all"
INFO: Analyzed 34 targets (29 packages loaded, 871 targets configured).
INFO: Found 21 targets and 13 test targets...
INFO: From Testing //ring:ecdsa_tests:
==================== Test output for //ring:ecdsa_tests:
running 5 tests
test ecdsa_from_pkcs8_test ... ok
test ecdsa_generate_pkcs8_test ... ok
test ecdsa_test_public_key_coverage ... ok
test signature_ecdsa_verify_fixed_test ... ok
@josephlr
josephlr / perlasm.bzl
Created June 20, 2019 09:34
Bazel file to support OpenSSl-style perl -> asm generation
load("@bazel_skylib//lib:paths.bzl", "paths")
def perlasm(src, perlasm_utils, name=None):
""" Creates a genrule to process the src. Returns rule name."""
(filename, ext) = paths.split_extension(paths.basename(src))
if ext != ".pl":
fail("Provided perlasm file {} must be a Perl file".format(src))
if name == None:
name = filename
@josephlr
josephlr / BUILD
Last active June 20, 2019 09:48
BUILD file for Ring (x86_64 only, needs perlasm.bzl)
package(
default_visibility = ["//visibility:private"],
licenses = ["notice"], # ISC-style
)
## C Code
cc_library(
name = "base",
hdrs = ["include/GFp/base.h"],