func matchSlots()

in aws_signing_helper/pkcs11_signer.go [173:205]


func matchSlots(slots []SlotIdInfo, uri *pkcs11uri.Pkcs11URI) (matches []SlotIdInfo) {
	var (
		uriSlotNr uint64
		uriSlot   string
		ok        bool
	)

	if uri == nil {
		return slots
	}

	uriSlot, ok = uri.GetPathAttribute("slot-id", false)
	if ok {
		uriSlotNr, _ = strconv.ParseUint(uriSlot, 0, 32)
	}

	for _, slot := range slots {
		if uriSlotNr != 0 && uriSlotNr != uint64(slot.id) {
			continue
		}
		if mismatchAttr(uri, "token", slot.tokInfo.Label) ||
			mismatchAttr(uri, "model", slot.tokInfo.Model) ||
			mismatchAttr(uri, "manufacturer", slot.tokInfo.ManufacturerID) ||
			mismatchAttr(uri, "serial", slot.tokInfo.SerialNumber) ||
			mismatchAttr(uri, "slot-description", slot.info.SlotDescription) ||
			mismatchAttr(uri, "slot-manufacturer", slot.info.ManufacturerID) {
			continue
		}
		matches = append(matches, slot)
	}

	return matches
}