Skip to content

Instantly share code, notes, and snippets.

View ph4r05's full-sized avatar
🎯
Focusing

Dušan Klinec ph4r05

🎯
Focusing
View GitHub Profile
@ph4r05
ph4r05 / tpm-gen.c
Created December 21, 2016 18:32
Generate random numbers with TPM (Trusted Platform Module)
/* gcc -Wall -O2 -ltspi -o tpm-getrand tpm-getrand.c
*
* Usage:
* ./tpm-getrand | dd of=/tmp/random.data count=10 bs=1k
*
* Get random bytes from TPM pRNG
*
* Copyright (C) 2009 Kees Cook <kees@outflux.net>
* http://outflux.net/tpm/tpm-getrand.c
* License: GPLv3
@ph4r05
ph4r05 / sks-dump-script.sh
Created February 14, 2017 12:34 — forked from mattrude/sks-dump-script.sh
A simple script to export the full database of a sks server to a chosen location.
#!/bin/bash
# This script will stop the sks server, dump it's contents to
# the $PREDIR, then restart the sks server.
#
# Matt Rude <matt@mattrude.com> PGP: 0xDD23BF73
# URL: https://gist.github.com/mattrude/b0ac735d07b0031bb002
SKSDATE=`date +%Y-%m-%d`
USER="debian-sks"
@ph4r05
ph4r05 / pyx509_parse.py
Created March 25, 2017 08:04
Parsing X509 certificate, domain extraction
from cryptography.hazmat.backends import default_backend
from cryptography.x509.base import load_pem_x509_certificate
from cryptography.hazmat.primitives.serialization import load_ssh_public_key
from cryptography.hazmat.primitives import hashes
from cryptography.x509.oid import NameOID
from cryptography.x509.oid import ExtensionOID
from cryptography import x509
def get_backend(backend=None):
@ph4r05
ph4r05 / zim-wiki-mac-osx-app.md
Created May 17, 2017 11:02 — forked from akurani/zim-wiki-mac-osx-app.md
Create a Mac app for Zim Wiki.
--
-- Column DB encryption with indexing using pgcrypto
--
-- Demo encrypt/decrypt identity with pgcrypto
select convert_from(
decrypt_iv(
encrypt_iv(
'test',
digest('superkey', 'sha256'),
@ph4r05
ph4r05 / ct_array_compare.java
Last active November 11, 2021 09:13
Constant time array equality check in java
package ct;
public class CT {
/**
* Constant time array equals check.
* If the lengths do not match the function returns false immediately.
* @param a array A
* @param b array B
* @return true if arrays are equal on defined intervals
# task 1: implement logical formula evaluation
# T, F ~ true, false
# !, A, V, > ~ NOT, AND, OR, IMPLICATION
# Hint: translate atoms to integers (store integers on stack)
# Hint: the infix form: (!(F)) A (!((T) > (F)))
def eval_formula(inp):
stack = []
for token in inp:
pass
@ph4r05
ph4r05 / demo.java
Last active November 13, 2018 09:35
Simple java intro test
import javax.crypto.IllegalBlockSizeException;
class Main {
// Normally each class should be in a separate file.
static class Student {
private String name;
public Student(String name){
this.name = name;
class mt19937(object):
# https://github.com/james727/MTP/
def __init__(self, seed = 0):
self.state = [0]*624
self.f = 1812433253
self.m = 397
self.u = 11
self.s = 7
self.b = 0x9D2C5680
self.t = 15
@ph4r05
ph4r05 / payment_id_fix.py
Last active September 13, 2021 02:15
Fixes payment ID problem
# pip install monero_agent>=1.7.6
import binascii
import json
import requests
from monero_glue.xmr import crypto
from monero_serialize.xmrserialize import load_uvarint_b, uvarint_size