示例#1
0
func (s *StubCtx) CreateObject(sh pkcs11.SessionHandle, temp []*pkcs11.Attribute) (
	pkcs11.ObjectHandle, error) {
	err := s.checkErr("CreateObject")
	if err != nil {
		return pkcs11.ObjectHandle(0), err
	}
	return s.ctx.CreateObject(sh, temp)
}
示例#2
0
	"crypto/ecdsa"
	"crypto/rand"
	"crypto/rsa"
	"encoding/asn1"
	"github.com/miekg/pkcs11"
	"reflect"
	"strings"
	"testing"
)

type mockCtx struct {
	currentSearch []*pkcs11.Attribute
}

const sessionHandle = pkcs11.SessionHandle(17)
const rsaPrivateKeyHandle = pkcs11.ObjectHandle(23)

// Correct EC private key
const ecPrivateKeyHandle = pkcs11.ObjectHandle(32)
const ecPublicKeyHandle = pkcs11.ObjectHandle(33)
const ecCorrectKeyID = byte(0x03)

// EC private key with no matching public key
const ecPrivNoPubHandle = pkcs11.ObjectHandle(34)
const ecPrivNoPubID = byte(0x4)

// EC private and public key with invalid EC point
const ecInvEcPointPrivHandle = pkcs11.ObjectHandle(35)
const ecInvEcPointPubHandle = pkcs11.ObjectHandle(36)
const ecInvEcPointID = byte(0x5)
示例#3
0
文件: key_test.go 项目: 40a/cfssl
// +build !nopkcs11

package pkcs11key

import (
	"bytes"
	"crypto"
	"crypto/rand"
	"testing"

	"github.com/miekg/pkcs11"
)

type mockCtx struct{}

const privateKeyHandle = pkcs11.ObjectHandle(23)
const sessionHandle = pkcs11.SessionHandle(17)

var slots = []uint{7, 8, 9}
var tokenInfo = pkcs11.TokenInfo{
	Label: "token label",
}

func (c mockCtx) CloseSession(sh pkcs11.SessionHandle) error {
	return nil
}

func (c mockCtx) FindObjectsFinal(sh pkcs11.SessionHandle) error {
	return nil
}