• Stars
    star
    355
  • Rank 115,839 (Top 3 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 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

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
7,768
star
2

gobook

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

learninggo

Learning Go Book in mmark
Go
533
star
4

exdns

Go DNS example programs
Go
289
star
5

lean

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

rdup

The only backup program that doesn't make backups!
C
107
star
7

unbound

A Go wrapper for libunbound
Go
98
star
8

pandoc2rfc

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

dinit

An init for use inside Docker containers
Go
67
star
10

skydns2

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

dnsv2

Go
44
star
12

bgp

BGP implementation in Go
Go
41
star
13

gitopper

Gitops for non-Kubernetes folks
Go
38
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
20
star
18

redis

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

dnsrouter

Route DNS packets
Go
14
star
20

bitradix

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

dreck

Bot to help with GitHub chores
Go
12
star
22

pgo

container gitops in a simple way
Go
10
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

ssd

Go
7
star
27

nxdomain

CoreDNS plugin: return NXDOMAIN for configured domains
Go
7
star
28

dump

dump all incoming request in coredns
Go
5
star
29

lboverlay

Go
5
star
30

local

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

caddy-debian

Create debian package for Caddy
Makefile
5
star
32

cf

CFEngine formatter
Go
4
star
33

nsec4

authenticated denial of existence
Shell
4
star
34

denialid

Authenticated Denial of Existence in the DNS
XSLT
4
star
35

access

why - explain why a user can or cannot access a file
Go
4
star
36

debian

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

nlgids

caddy middleware for nlgids.london
Go
2
star
38

a

2
star
39

rota

generate oncall rotations
Go
2
star
40

mmark.nl

mmark.miek.nl website
HTML
2
star
41

dname

HTML
2
star
42

coderemarks

Annotate source code with remarks in LaTeX
2
star
43

kubeadam

TeX
1
star
44

xdoc

Go
1
star
45

corecheck

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

signalds

1
star
47

caddy-user

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