• Stars
    star
    375
  • Rank 114,096 (Top 3 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created about 12 years ago
  • Updated 7 months ago

Reviews

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

Repository Details

pkcs11 wrapper for Go

PKCS#11

This is a Go implementation of the PKCS#11 API. It wraps the library closely, but uses Go idiom where it makes sense. It has been tested with SoftHSM.

SoftHSM

  • Make it use a custom configuration file export SOFTHSM_CONF=$PWD/softhsm.conf

  • Then use softhsm to init it

    softhsm --init-token --slot 0 --label test --pin 1234
    
  • Then use libsofthsm2.so as the pkcs11 module:

    p := pkcs11.New("/usr/lib/softhsm/libsofthsm2.so")

Examples

A skeleton program would look somewhat like this (yes, pkcs#11 is verbose):

p := pkcs11.New("/usr/lib/softhsm/libsofthsm2.so")
err := p.Initialize()
if err != nil {
    panic(err)
}

defer p.Destroy()
defer p.Finalize()

slots, err := p.GetSlotList(true)
if err != nil {
    panic(err)
}

session, err := p.OpenSession(slots[0], pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
if err != nil {
    panic(err)
}
defer p.CloseSession(session)

err = p.Login(session, pkcs11.CKU_USER, "1234")
if err != nil {
    panic(err)
}
defer p.Logout(session)

p.DigestInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_SHA_1, nil)})
hash, err := p.Digest(session, []byte("this is a string"))
if err != nil {
    panic(err)
}

for _, d := range hash {
        fmt.Printf("%x", d)
}
fmt.Println()

Further examples are included in the tests.

To expose PKCS#11 keys using the crypto.Signer interface, please see github.com/thalesignite/crypto11.

More Repositories

1

dns

DNS library in Go
Go
8,024
star
2

gobook

A complete introduction into Go, superseded by https://github.com/miekg/learninggo
TeX
874
star
3

learninggo

Learning Go Book in mmark
Go
541
star
4

gitopper

Gitops for non-Kubernetes folks
Go
380
star
5

exdns

Go DNS example programs
Go
299
star
6

lean

Pretty, minimal, one-line, fast ZSH prompt
Shell
154
star
7

rdup

The only backup program that doesn't make backups!
C
106
star
8

unbound

A Go wrapper for libunbound
Go
101
star
9

pandoc2rfc

Use pandoc to create XML suitable for xml2rfc
Python
81
star
10

dinit

An init for use inside Docker containers
Go
67
star
11

skydns2

Development is taking place: https://github.com/skynetservices/skydns2
Go
63
star
12

dnsv2

Go
44
star
13

bgp

BGP implementation in Go
Go
41
star
14

xds

command line interface for Envoy xDS endpoint
Go
35
star
15

block

Proof of concept CoreDNS plugin that implements a block list
Go
23
star
16

yamlfmt

Format YAML
Go
21
star
17

dnsfs

A DNS filesystem
Go
21
star
18

redis

CoreDNS plugin implementing a shared cache using Redis
Go
14
star
19

bitradix

A radix tree that branches on the bits in a key
Go
14
star
20

dnsrouter

Route DNS packets
Go
14
star
21

dreck

Bot to help with GitHub chores
Go
12
star
22

pgo

container gitops in a simple way
Go
11
star
23

rip

RIP protocol implementation in Go
Go
10
star
24

lg-dns

DNS Looking Glass
Go
9
star
25

mutfs

A filesystem where you can create, but not alter files, imMUTable FS.
Go
8
star
26

dnsfmt

Auto format DNS zone files
Go
7
star
27

ssd

Go
6
star
28

nxdomain

CoreDNS plugin: return NXDOMAIN for configured domains
Go
6
star
29

dump

dump all incoming request in coredns
Go
5
star
30

lboverlay

Go
5
star
31

local

CoreDNS plugin that answers "local" queries
Go
5
star
32

caddy-debian

Create debian package for Caddy
Makefile
5
star
33

access

why - explain why a user can or cannot access a file
Go
5
star
34

cf

CFEngine formatter
Go
4
star
35

nsec4

authenticated denial of existence
Shell
4
star
36

denialid

Authenticated Denial of Existence in the DNS
XSLT
4
star
37

ebpf

ebpf compiler in Go; Write Go, get ebpf
Go
4
star
38

debian

Small CI to create debian packages for various (Go) binaries
Shell
3
star
39

nlgids

caddy middleware for nlgids.london
Go
2
star
40

a

2
star
41

ssh2prom

Prometheus metrics from openssh
Go
2
star
42

mmark.nl

mmark.miek.nl website
HTML
2
star
43

dname

HTML
2
star
44

coderemarks

Annotate source code with remarks in LaTeX
2
star
45

rota

generate oncall rotations
Go
2
star
46

gompletely

completions generation
Go
1
star
47

kubeadam

TeX
1
star
48

xdoc

Go
1
star
49

corecheck

Utility to check Markdown files for valid Corefile snippets.
Go
1
star
50

signalds

1
star
51

caddy-user

Caddy module that changes to a different user before serving the request
Go
1
star