Skip to content

Instantly share code, notes, and snippets.

@tsenger
tsenger / PACEPinpadTester.java
Created March 9, 2016 13:30
Test for PACE per PCSC reader with pinpad
package de.tsenger.sandbox;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
@tsenger
tsenger / jc_HmacSha256.java
Created October 23, 2017 14:43
JavaCard implementation of HMAC SHA256
private short computeHmacSha256(byte[] key, short key_offset, short key_length,
byte[] message, short message_offset, short message_length,
byte[] mac, short mac_offset){
short BLOCKSIZE=64;
short HASHSIZE=32;
// compute inner hash
for (short i=0; i<key_length; i++){
hmacBuffer[i]= (byte) (key[(short)(key_offset+i)] ^ (0x36));
@tsenger
tsenger / letsencrypt_notes.sh
Created March 23, 2018 15:16 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
@tsenger
tsenger / CardDav2GrandstreamXML.py
Created December 20, 2018 08:25
Converter for CardDav phonebook to Grandstream DP720 / DP750 XML phonebook
#Convert CardDav contacts to GrandStream DP720 / DP750 XML phonebook
import vobject
vcf_path = "./contacts.vcf"
xml_path = './xml_contacts.xml'
# phone number: CardDav to Grandstream
map_number_types = {
"work": "Work",
package de.tsenger.kasper.decoder;
import org.spongycastle.asn1.ASN1GeneralizedTime;
import org.spongycastle.asn1.ASN1Integer;
import org.spongycastle.asn1.ASN1ObjectIdentifier;
import org.spongycastle.asn1.ASN1UTCTime;
import org.spongycastle.asn1.DEROctetString;
import org.spongycastle.asn1.DERPrintableString;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.DERTaggedObject;
@tsenger
tsenger / expanse_aes_key.py
Created August 27, 2024 12:00
Expanse an AES-128 key to 16 round keys
# Expanse an AES-128 key to 16 round keys
import sys
# AES S-Box
s_box = [
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,