Skip to content

Commit

Permalink
Added comments for CKA_EC_PARAMS and CKR_USER_ALREADY_LOGGED_IN
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrossard committed Oct 27, 2015
1 parent c814d7d commit 4129895
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crypto/pkcs11key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@ func getRSAPublicKey(module ctx, session pkcs11.SessionHandle, privateKeyHandle
func getECPublicKey(module ctx, session pkcs11.SessionHandle, privateKeyHandle pkcs11.ObjectHandle) (interface{}, error) {
var noKey interface{}

// http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/os/pkcs11-curr-v2.40-os.html#_Toc416960012
template := []*pkcs11.Attribute{
// CKA_EC_PARAMS contains the OID of the curve (part of the
// public key
pkcs11.NewAttribute(pkcs11.CKA_EC_PARAMS, nil),
// CKA_ID will allow use to find the corresponding public key
pkcs11.NewAttribute(pkcs11.CKA_ID, nil),
}

Expand Down Expand Up @@ -486,6 +490,7 @@ func (ps *Key) openSession() (pkcs11.SessionHandle, error) {
// credentials.
if err = ps.module.Login(session, pkcs11.CKU_USER, ps.pin); err != nil {
if err == pkcs11.Error(pkcs11.CKR_USER_ALREADY_LOGGED_IN) {
// But if the token says we're already logged in, it's ok.
err = nil
} else {
ps.module.CloseSession(session)
Expand Down

0 comments on commit 4129895

Please sign in to comment.