mirror of https://github.com/docker/docs.git
update to only use slots 0-3
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
parent
b7c38f0287
commit
beca50909d
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
USER_PIN = "123456"
|
USER_PIN = "123456"
|
||||||
SO_USER_PIN = "010203040506070801020304050607080102030405060708"
|
SO_USER_PIN = "010203040506070801020304050607080102030405060708"
|
||||||
numSlots = 50 // number of slots in the yubikey
|
numSlots = 4 // number of slots in the yubikey
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hardcoded yubikey PKCS11 ID
|
// Hardcoded yubikey PKCS11 ID
|
||||||
|
|
@ -421,27 +421,27 @@ func getNextEmptySlot(ctx *pkcs11.Ctx, session pkcs11.SessionHandle) ([]byte, er
|
||||||
}
|
}
|
||||||
objs = append(objs, o...)
|
objs = append(objs, o...)
|
||||||
}
|
}
|
||||||
taken := make([]bool, numSlots)
|
taken := make(map[int]bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Failed to find: %s %v\n", err.Error(), b)
|
logrus.Debugf("Failed to find: %s %v\n", err.Error(), b)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, obj := range objs {
|
for _, obj := range objs {
|
||||||
// Retrieve the public-key material to be able to create a new HSMRSAKey
|
// Retrieve the slot ID
|
||||||
attr, err := ctx.GetAttributeValue(session, obj, attrTemplate)
|
attr, err := ctx.GetAttributeValue(session, obj, attrTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Failed to get Attribute for: %v\n", obj)
|
logrus.Debugf("Failed to get Attribute for: %v\n", obj)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through all the attributes of this key and saves CKA_PUBLIC_EXPONENT and CKA_MODULUS. Removes ordering specific issues.
|
// Iterate through attributes. If an ID attr was found, mark it as taken
|
||||||
for _, a := range attr {
|
for _, a := range attr {
|
||||||
if a.Type == pkcs11.CKA_ID {
|
if a.Type == pkcs11.CKA_ID {
|
||||||
if len(a.Value) < 1 {
|
if len(a.Value) < 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// max 50 slots so a single byte will always represent
|
// a byte will always be capable of representing all slot IDs
|
||||||
// all possible slots positions
|
// for the Yubikeys
|
||||||
slotNum := int(a.Value[0])
|
slotNum := int(a.Value[0])
|
||||||
if slotNum >= len(taken) {
|
if slotNum >= len(taken) {
|
||||||
// defensive
|
// defensive
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue