DockerCLI/vendor/github.com/miekg/pkcs11
Sebastiaan van Stijn b53ffd6c1f
vendor: bump miekg/pkcs11 v1.0.3
full diff: https://github.com/miekg/pkcs11/compare/v1.0.2...v1.0.3

- miekg/pkcs11#100 Add typed convenience `Find...` methods to `Session`
- miekg/pkcs11#115 Add CK_EFFECTIVELY_INFINITE and CK_UNAVAILABLE_INFORMATION

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-16 17:30:06 +01:00
..
LICENSE Add vendor 2017-04-17 18:12:58 -04:00
README.md vendor: bump miekg/pkcs11 v1.0.3 2020-01-16 17:30:06 +01:00
const.go vendor: bump miekg/pkcs11 v1.0.3 2020-01-16 17:30:06 +01:00
error.go Add vendor 2017-04-17 18:12:58 -04:00
go.mod bump miekg/pkcs11 v1.0.2 2019-08-16 11:29:02 +02:00
params.go bump miekg/pkcs11 v1.0.2 2019-08-16 11:29:02 +02:00
pkcs11.go bump miekg/pkcs11 v1.0.2 2019-08-16 11:29:02 +02:00
pkcs11.h Update Notary vendor to 0.6.0 release 2018-03-02 14:56:12 +00:00
pkcs11f.h Update Notary vendor to 0.6.0 release 2018-03-02 14:56:12 +00:00
pkcs11go.h Update PKCS11 library 2019-02-26 11:45:19 +00:00
pkcs11t.h Update PKCS11 library 2019-02-26 11:45:19 +00:00
release.go vendor: bump miekg/pkcs11 v1.0.3 2020-01-16 17:30:06 +01:00
types.go Update PKCS11 library 2019-02-26 11:45:19 +00:00
vendor.go Update PKCS11 library 2019-02-26 11:45:19 +00:00

README.md

PKCS#11 Build Status GoDoc

This is a Go implementation of the PKCS#11 API. It wraps the library closely, but uses Go idiom were 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 libsofthsm.so as the pkcs11 module:

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

Examples

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

p := pkcs11.New("/usr/lib/softhsm/libsofthsm.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.