Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion p11mod/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ import (
// TODO: Upstream this to miekg.
type Backend interface {
Info() (pkcs11.Info, error)
Slots() ([]p11.Slot, error)
Slots() ([]Slot, error)
}

type Slot interface {
ID() uint
Info() (pkcs11.SlotInfo, error)
TokenInfo() (pkcs11.TokenInfo, error)
OpenSession() (p11.Session, error)
OpenWriteSession() (p11.Session, error)
}
6 changes: 3 additions & 3 deletions p11mod/p11mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func SetBackend(b Backend, err error) {

func init() {
b := &llBackend{
slots: []p11.Slot{},
slots: []Slot{},
sessions: map[pkcs11.SessionHandle]*llSession{},
}

Expand All @@ -35,7 +35,7 @@ type llSession struct {
}

type llBackend struct {
slots []p11.Slot
slots []Slot
slotsMutex sync.RWMutex
sessions map[pkcs11.SessionHandle]*llSession
sessionsMutex sync.RWMutex
Expand Down Expand Up @@ -91,7 +91,7 @@ func (ll *llBackend) GetSlotList(tokenPresent bool) ([]uint, error) {
return ids, nil
}

func (ll *llBackend) getSlotByID(slotID uint) (p11.Slot, error) {
func (ll *llBackend) getSlotByID(slotID uint) (Slot, error) {
// Fast path: if the ID is already known, we can use a read-only lock.

ll.slotsMutex.RLock()
Expand Down