Skip to content

Instantly share code, notes, and snippets.

View maxfindel's full-sized avatar

Max F. Findel maxfindel

View GitHub Profile
@maxfindel
maxfindel / dss_data_creator.rb
Created June 23, 2023 18:52
Adding LTV data to document signed with HexaPDF ruby gem
# This gist assumes you have a signed document, the certificate chain used to sign it and the certificate chain of a TSA (if you used one)
# signed_doc = HexaPDF::Document.open(File.join(base_path, 'signed-document.pdf'))
# sig_cert_chain = [end_user_cert, intermediate_cert, root_cert]
# tsa_cert_chain = [tsa_cert, tsa_intermediate_cert, tsa_root_cert]
# optional: output_path = File.join(base_path, 'signed-document-with-ltv.pdf')
# STEP 1: The base structure is added as indirect references all
signed_doc.catalog[:DSS] = signed_doc.add({})
signed_doc.catalog[:DSS][:CRLs] = signed_doc.add([])
signed_doc.catalog[:DSS][:Certs] = signed_doc.add([])
@maxfindel
maxfindel / triplesec.js
Created April 25, 2017 15:17
Importable implementation of Keybase's Triplesec (symetric encryption) to be run comfortably from ruby and other languages. Raw
var module;
module = (function() {
return {
enc: function(key_str, pt1_str) {
var encrypt, key, pt1;
key = new Buffer(key_str);
pt1 = new Buffer(pt1_str);
encrypt = require('triplesec').encrypt;
return encrypt({
@maxfindel
maxfindel / triplesec.coffee
Last active April 25, 2017 11:11
Importable implementation of Keybase's Triplesec (symetric encryption) to be run comfortably from ruby and other languages.
module = do ->
enc: (key_str, pt1_str) ->
key = new Buffer key_str
pt1 = new Buffer pt1_str
{encrypt} = require 'triplesec'
encrypt { key, data : pt1 }, (err, ciphertext) ->
console.log ciphertext.toString('base64')
dec: (key_str, ciphertext_str) ->
key = new Buffer key_str