Skip to content

Instantly share code, notes, and snippets.

Avatar

Robin Percy rbnpercy

View GitHub Profile
View async_tasks.cljs
(defn task-queue
"Creates `core.async` channel which will process 0 arg functions put there in serial fashon.
Takes the same argument/s as `core.async/chan`, those arguments will be delegated to the
channel constructor.
Returns task-queue where tasks represented by 0 arg task functions can be put for processing."
[& args]
(let [task-queue (apply async/chan args)]
(async/go-loop [task-fn (async/<! task-queue)]
(run-task task-fn)
(recur (async/<! task-queue)))
View keycard-cash-sign.sh
./keycard shell <<END
cash-select
cash-sign 0000000000000000000000000000000000000000000000000000000000000000
END
View keycard-remove-master-key.sh
./keycard shell <<END
keycard-select
keycard-set-secrets 123456 123456789012 KeycardTest
keycard-pair
keycard-open-secure-channel
keycard-verify-pin {{ session_pin }}
keycard-remove-key
View keycard-derive-key-sign.sh
./keycard shell <<END
keycard-select
keycard-set-secrets 123456 123456789012 KeycardTest
keycard-pair
keycard-open-secure-channel
keycard-verify-pin {{ session_pin }}
keycard-derive-key m/44'/60'/0'/0/0
keycard-sign 0000000000000000000000000000000000000000000000000000000000000000
View generate-keycard-master-key.sh
./keycard shell <<END
keycard-select
keycard-set-secrets 123456 123456789012 KeycardTest
keycard-pair
keycard-open-secure-channel
keycard-verify-pin {{ session_pin }}
keycard-generate-key
View check_keycard_status.sh
./keycard shell <<END
keycard-select
keycard-set-secrets 123456 123456789012 KeycardTest
keycard-pair
keycard-open-secure-channel
keycard-get-status
keycard-verify-pin {{ session_pin }}
keycard-unpair {{ session_pairing_index }}
View sign-message-with-keycard.sh
./keycard shell <<END
# select the keycard applet
keycard-select
# set the secrets we had from the initialisation
keycard-set-secrets 123456 123456789012 KeycardTest
# pairing is usually done once per device
keycard-pair
keycard-open-secure-channel
keycard-verify-pin {{ session_pin }}
# derive the key we want to use
View generate-keycard-master-key.sh
./keycard shell <<END
# select the keycard applet
keycard-select
# set the secrets we had from the initialisation
keycard-set-secrets 123456 123456789012 KeycardTest
# pairing is usually done once per device
keycard-pair
keycard-open-secure-channel
# required for the key generation
keycard-verify-pin {{ session_pin }}
View install_keycard.sh
# @rbin
# Install keycard applet
gp-select
gp-open-secure-channel
gp-delete D2760000850101
gp-delete A00000080400010101
gp-delete A00000080400010301
gp-delete A0000008040001
gp-load keycard.cap A0000008040001
View base64_test.cr
require "base64"
STR_SIZE = 131072
TRIES = 8192
str = "a" * STR_SIZE
str2 = Base64.strict_encode(str)
print "encode #{str[0..3]}... to #{str2[0..3]}...: "