Skip to content

Commit

Permalink
Add zbar-tools package to read QRs using webcam and `create-key-sha…
Browse files Browse the repository at this point in the history
…re-card` script
  • Loading branch information
aitorpazos committed Mar 27, 2021
1 parent 21fc410 commit 41a111c
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0] - 2021-03-27

### Added

- `zbarcam` tool to be able to scan QR codes using the webcam
- `create-key-share-card` script to generate printable cards in xfce ISO

## [0.7.0] - 2021-03-14

### Added
Expand Down
2 changes: 2 additions & 0 deletions files-min/config/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ echo "My passphrase" | scrypt-rs -l<generated key length> -s <salt string>
echo "My text" | qrencode -o <qr file.png>
- Display QR image:
display <qr file.png>
- Scan QR code using webcam:
zbarcam --raw

If you are dealing with BIP39 word lists or seeds you can use the `hal` command:
hal bip39 get-seed "your BIP words" | jq -r .entropy | ssss-split -t <x> -n <n>
Expand Down
1 change: 1 addition & 0 deletions files-min/config/packages
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ xbitmaps
xdg-user-dirs
xinit
xterm
zbar-tools
Binary file modified files-min/config/shamir-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions files-xfce/config/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ echo "My passphrase" | scrypt-rs -l<generated key length> -s <salt string>
echo "My text" | qrencode -o <qr file.png>
- Display QR image:
display <qr file.png>
- Scan QR code using webcam:
zbarcam --raw

If you are dealing with BIP39 word lists or seeds you can use the `hal` command:
hal bip39 get-seed "your BIP words" | jq -r .entropy | ssss-split -t <x> -n <n>
Expand All @@ -30,6 +32,12 @@ If you don't select the correct number of words, the generation will fail. Howev

## Experimental USB printer support:

- You can generate a card that you can print using your browser with the following command:
create-key-share-card SHARE_NAME SHARE_KEY_VALUE

This command will generate a SHARE_NAME.htm file that you can open in the browser and print it from it after you
configure a printer.

- Add a printer (user: user , password: user) using CUPS admin page in the browser:
http://127.0.0.1:631/admin
- Display detected printers:
Expand Down
3 changes: 2 additions & 1 deletion files-xfce/config/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ chmod a+r /usr/share/pixmaps/shamir-background.png

cp /root/hal /usr/bin/
cp /root/scrypt-rs /usr/bin/
chmod a+rx /usr/bin/hal /usr/bin/scrypt-rs
cp /root/create-key-share-card /usr/bin/
chmod a+rx /usr/bin/hal /usr/bin/scrypt-rs /usr/bin/create-key-share-card

cat > /etc/skel/.config/epiphany/web-extension-settings.ini << EOF
[org/gnome/epiphany]
Expand Down
100 changes: 100 additions & 0 deletions files-xfce/config/create-key-share-card
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env bash

function usage() {
cat << EOF
Incorrect parameters used.
Usage: $0 SHARE_NAME SHARE_KEY_VALUE
SHARE_NAME An arbitrary short name for the share
SHARE_KEY_VALUE Value string of the key share (use - to read string from standard input)
This script will generate SHARE_NAME.htm and SHARE_NAME.png files that can be used to print the share as card.
EOF
}

if [ "$#" -ne 2 ]; then
usage;
exit 1
fi

NAME=$1
INPUT_KEY=$2

QR_IMG="./${NAME}.png"

if [ "${INPUT_KEY}" = "-" ]; then
read
INPUT_KEY="${REPLY}"
fi

echo "${INPUT_KEY}" | qrencode -o ${QR_IMG}

cat > ${NAME}.htm << EOHTML
<html>
<head>
<title>Shamir key part card - ${NAME}</title>
<style>
body { background-color: white; font-family: sans-serif}
.card { border: solid black 1mm; padding: 2mm; margin: 1mm; width: 10cm; height: 6cm; }
.header { font-weight: bolder; font-size: 16pt; text-align: center; height: 10mm; }
.content { display: flex; height: 47mm; }
.footer { font-size: 8pt; text-align: center; }
.cell { display: block; }
#key_text { height: 40mm; width: 60mm; }
#key_text h1 { font-size: 12pt; font-weight: bold; margin: 1mm; }
#key_text p { margin: 1mm; }
#key_value { word-break: break-all }
#key_qr { height: 40mm; width: 40mm; text-align: right; }
#key_qr img { height: 100%; width: 100%; }
#instructions { font-size: 8pt; display: block; margin: 0; }
#instructions p { margin: 0; }
</style>
</head>
<body>
<div class="card" id="front">
<div class="header">
Shamir key share part
</div>
<div class="content">
<div class="cell" id="key_text">
<h1>Name:</h1>
<p id="key_name">${NAME}</p>
<h1>Shamir key share value:</h1>
<p id="key_value">${INPUT_KEY}</p>
</div>
<div class="cell" id="key_qr">
<img src="${QR_IMG}" />
</div>
</div>
<div class="footer">
Generated by Shamir-iso ( https://aitorpazos.es/shamir-iso )
</div>
</div>
<hr />
<div class="card" id="back">
<div class="header">
Shamir key share instructions
</div>
<div class="content" id="instructions">
<p>
The key written on the front of this card is one of the shares of a key divided using Shamir's secret sharing
scheme.
</p>
<p>
Important notes:
</p>
<ul>
<li>You can only recover the original key having access to the number of shares defined by the threshold
selected when this part was generated.</li>
<li>Any combination of the shares that count up to the threshold is able to recover the original key.</li>
<li>This is a high value key.</li>
<li>It is important that you keep this key in a safe place and protected from unauthorized access.</li>
</ul>
</div>
<div class="footer">
Generated by Shamir-iso ( https://aitorpazos.es/shamir-iso )
</div>
</div>
</body>
</html>
EOHTML
1 change: 1 addition & 0 deletions files-xfce/config/packages
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ xbitmaps
xdg-user-dirs
xinit
xterm
zbar-tools
Binary file modified files-xfce/config/shamir-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shamir-background.kra
Binary file not shown.

0 comments on commit 41a111c

Please sign in to comment.