• Stars
    star
    251
  • Rank 161,862 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created almost 11 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple PKCS11 provider for TPM chips

Simple TPM PK11

A simple library for using the TPM chip to secure SSH keys.

Copyright 2013-2016 Google Inc. All Rights Reserved. Apache 2.0 license.

This is NOT a Google product.

Contact: [email protected] / [email protected] https://github.com/ThomasHabets/

Install dependencies

Debian

apt install tpm-tools libtspi-dev libopencryptoki-dev libssl-dev

Fedora

tpm-tools
opencryptoki-devel
trousers-devel
openssl-devel

FreeBSD

pkg install tpm-tools trousers-tddl opencryptoki openssl

Build simple-tpm-pk11

If there is no configure script (e.g. because the release comes directly from the git repo where generated files are not committed), then run:

apt install autotools libtool   # Or equivalent for your OS.
./bootstrap.sh

When configure does exist, configure and build:

./configure && make && sudo make install

Init TPM chip

  1. If you have not taken ownership, do so.
tpm_takeownership -z
Enter owner password: [enter something secret here]
Confirm password: [enter something secret here]
  1. SRK password is usually the Well Known Secret (all nulls). You can specify a password but it's easier it you don't. The SRK password is only used to allow crypto operations. You still need blobs and key passwords to use other peoples keys.

    The "SRK password" is needed to be able to do operations with the "SRK", which is the actual cryptographic key. The user has no access to the SRK directly. The same goes for other keys protected by the TPM chip.

tpm_changeownerauth -s -r

If you get any error messages, see read TPM-TROUBLESHOOTING.

User setup

1. Create key

mkdir ~/.simple-tpm-pk11/
stpm-keygen -o ~/.simple-tpm-pk11/my.key

(use -p if you want to set a password on the key)

Try out the key:

dd if=/dev/urandom of=to-sign bs=1 count=35
stpm-sign -k ~/.simple-tpm-pk11/my.key -f to-sign
stpm-sign -k ~/.simple-tpm-pk11/my.key -f to-sign -r > to-sign.sig
stpm-verify -f to-sign -k ~/.simple-tpm-pk11/my.key -s to-sign.sig

2. Create config

echo "key my.key" > ~/.simple-tpm-pk11/config

Optional config options

log foo.log
key_pin my-pin-here
srk_pin my-pin-here
debug

3. Extract the public key in SSH format

ssh-keygen -D libsimple-tpm-pk11.so

Install it where you want to log in, in the usual authorized_keys way.

Try logging in using your new fancy key:

ssh -I libsimple-tpm-pk11.so shell.example.com

4. Configure SSH to always use this module

Add this to ~/.ssh/config:

Host *
      PKCS11Provider libsimple-tpm-pk11.so

then try:

ssh shell.example.com

4a. Alternatively, add the TPM to your ssh-agent

This has to be the OpenSSH ssh-agent, since gnome-keyring doesn't support PKCS#11. A sign that you run gnome-keyring (or your OpenSSH is compiled without PKCS#11 support) is that you see this error message when you try:

$ ssh-add -s /โ€ฆ/libsimple-tpm-pk11.so
Enter passphrase for PKCS#11:
Could not add card "/โ€ฆ/libsimple-tpm-pk11.so": agent refused operation

Tested with

Hardware

  • Dell Precision T3500 / WEC TPM 1.2.2.81
  • HP Z440 / IFX TPM 1.2.4.40
  • Lenovo T410 / STM TPM 1.2.8.16
  • Lenovo T440s / STM TPM 1.2.13.12
  • Lenovo T500 / INTC STM 1.2.4.1
  • Lenono X200s / INTC TPM 1.2.4.1
  • Lenovo X230 / STM TPM 1.2.13.8
  • Lenovo X240 / STM TPM 1.2.13.12
  • Lenovo T460s /IFX TPM 1.2.6.40

Software

  • OpenSSH 5.9
  • OpenSSH 6.0p1 on Debian 7.2
  • OpenSSH 6.4p1 on CentOS 7.0
  • OpenSSH 6.6.1p1 on FreeBSD 11-CURRENT
  • OpenSSH 6.8p1 on Arch Linux
  • OpenSSH 7.1p2 on Debian
  • OpenSSH 7.2p2 Ubuntu 16.04.2 LTS (Xenial Xerus)
  • OpenSSH 7.9p1 on Debian 10.3

TODO

  • Clean up code.
  • config option: log to stdout and/or stderr in addition to logfile.
  • Install in the correct place.
  • Add PKCS11 support to ssh server.
  • Global config in /etc.
  • Script to automate setting up, including verifying TPM state and fixing it.
  • Auto-generate keys on demand? Or should this only be part of script to set up?
  • Make it work with gpg, and document.
  • Make it work with SSH certs, and document.
  • Make it work with openssl, and document.
  • Make it work with Firefox, and document.
  • Make it work with Chrome, and document.
  • Make it work with encrypted home directories, and document.

Reference links

Make new release

  • Update configure.ac with new version, commit.
  • git tag -a -s 0.0x
  • git push --tags

Some random notes, not instructions

openssl genrsa -out rsa-key 2048
openssl rsa -in rsa-key -modulus
exponent is always 65537.
ssh-keygen -f rsa-key -y > rsa-key.pub

More Repositories

1

arping

ARP Ping
C
398
star
2

cmdg

Command line Gmail client
Go
195
star
3

injcode

Inject code into a running process
C++
114
star
4

ssh-scripts

Some SSH-related scripts
Python
105
star
5

monotonic_clock

Portable C library for getting monotonic time
C
70
star
6

xor-analyze

Program for cryptanalyzing xor "encryption" with variable key length
C
42
star
7

ax25ms

This project is a set of AX.25 microservices, to be pluggable for any implementation.
C++
30
star
8

tlssh

TLS Shell
C++
25
star
9

bthelper

Bluetooth helper tools for setting up serial ports for e.g. SSH
C++
25
star
10

eggpd

Erlang BGP daemon
Erlang
25
star
11

sshproxy

SSH Proxy / Load balancer
Go
22
star
12

radiostuff

My collection of gnuradio stuff
Python
21
star
13

openssl-tpm-engine

TPM engine module for OpenSSL (this is not upstream)
Shell
20
star
14

rslurp

slurp down a whole HTTP directory, with parallel goodness
Go
19
star
15

gtping

GTP Ping
C
16
star
16

sim

Multi Party Authorization version of sudo/doas
C++
15
star
17

ind

Indent output from subprocess
C
12
star
18

weberl

Like web.py, but for Erlang
Erlang
11
star
19

clipsniff

Sniff the clipboard of a Unix X server.
C++
10
star
20

goircd

Minimalistic simple Internet Relay Chat (IRC) server
Go
10
star
21

pipebench

Measures the speed of stdin/stdout communication. I would actually recommend 'pv' over this program. I put it on github in order to collect everything in one place.
C
9
star
22

hamtransfer

Tool for transferring files over amateur radio using modern techniques
Rust
8
star
23

dejitun

De-jitter tunnel
C++
8
star
24

yhsmpam

YubiHSM PAM module backend
Python
8
star
25

goodpipe

Rust
7
star
26

qpov

Tool for converting Quake demo files to POV-Ray
Go
6
star
27

dotfiles

My dotfiles
C++
6
star
28

tlscheck

Quickly check TLS certificates of frontends and backends
Go
6
star
29

libopenpty

openpty() for platforms that don't have it
C
6
star
30

rustradio

Like GNURadio, but in Rust
Rust
6
star
31

diamond_linking_example

Example of a diamond linking thingy with version problems. See http://blog.habets.pp.se/2012/05/Shared-libraries-diamond-problem
C
6
star
32

multitraceroute

Fast traceroute that does TCP, UDP and ICMP traceroute in parallel and shows the results in one big table.
Python
5
star
33

tcpstats

Collect stats on TCP connections on close()
Python
5
star
34

wifispace

GNURadio program for measuring how busy wifi channels are
C++
5
star
35

lightwave

Like google wave, but much dumber and written in erlang
Erlang
5
star
36

zipbrute

Old project for brute forcing zip file passwords I found in an old backup from 2001.
C
4
star
37

tarweb

Serve a static website from a tar file
C++
4
star
38

hamwebby

Web interface for remote rig control of ham radios
JavaScript
4
star
39

opwgen

Generate passwords like OPIE generates OTPs: readably
C
4
star
40

fluxbox

Fluxbox window manager
4
star
41

netmap

Make and organize network maps from data directly out of your routers
Go
4
star
42

gopload

Self-contained simple HTTP upload handler using websockets to show progress
Go
4
star
43

openvpn

OpenVPN, with SSL Engine (TPM) support
C
3
star
44

cert-sig-pin

Extract a certificate signature suitable for Chrome public key pinning.
Go
3
star
45

pam_externalpass

Spawn external program from PAM to do authentication
Shell
3
star
46

yurate

Curate Youtube videos so that you don't miss any subscribed content.
JavaScript
3
star
47

temp-to-cloud

Upload temperature measurements to Stackdriver
Go
3
star
48

go-uuid

Local mirror of deleted codesite project
Python
2
star
49

firewalls-at-the-source

Go
2
star
50

x11type

Simulate keypresses in X
Shell
2
star
51

travelling-amateur

Tool for finding rules for operating amateur radio while visiting another country.
JavaScript
2
star
52

autoscan

Web and LCD/button UI for scanning from a USB scanner directly into Google Drive
Go
2
star
53

udportknock

UDP portknock script
Shell
2
star
54

pgsql

Postgresql useful commands, to be run with psql [databasename] -f <filename>
2
star
55

brain

My brain
POV-Ray SDL
2
star
56

ychares

Yubikey challenge-response script
Python
2
star
57

netcat

netcat-openbsd with fixed TCP_MD5SIG for Linux
C
2
star
58

yoracle

Yubikey oracle
Python
2
star
59

3ggraph

Graph live information from a 3G dongle
Python
2
star
60

irssi

irssi with TPM support
C
2
star
61

kybertest

CLI to encrypt files using quantum-resistant cryptography
C++
2
star
62

livecount

A widget for a web page (e.g. a blog post) that shows how many people (browsers) currently have the page open
Rust
2
star
63

airthingy

Tools for airthings API and bluetooth
Go
2
star
64

roodit

My reddit scripts
Python
2
star
65

sparslog

My implementation of an IKEA sparsnรคs SDR receiver
Rust
2
star
66

drive-du

Cmdline and cloud tool for listing folder sizes in Google Drive
Go
2
star
67

tlshake

Rust
2
star
68

mdsort

Maildir sorter
Python
1
star
69

smoog

My smugmug scripts
Python
1
star
70

openvpn-debian

OpenVPN, with SSL Engine (TPM) support
C
1
star
71

ndping

Like ARPing, but for IPv6
1
star
72

closite

Redirect user to the closest site using javascript
JavaScript
1
star
73

libdropprivs

Example code (will be library) for dropping privileges
C
1
star
74

profy

Always-on VPN client scripts intended for Raspberry Pi or other small computers
Shell
1
star
75

gr-habets38

My gnuradio components for gnuradio 3.8+
C++
1
star
76

doublecross-cpp

Experiments in making C++11 versions of things that exist in other languages. Such as the Maybe Monad from Haskell.
C++
1
star
77

tleservice

TLEService is a microservice for calculating satellite orbits.
Go
1
star
78

flight-radiation

Radiation data from a recent flight between LHR and SFO
Shell
1
star
79

keffos

Silly OS I wrote as a teenager
C
1
star