// Check performs a strict verification on the extension according to the standard(s)
18376
func Check(d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	if d.Cert.SerialNumber.Cmp(big.NewInt(0)) == -1 {
		e.Err("Certificate serial number MUST be a positive integer (%d)", d.Cert.SerialNumber)
	}

	// Remaining checks are not relevant for CA certificates
	if d.Cert.IsCA {
		return e
	}

	// https://cabforum.org/2016/07/08/ballot-164/
	if d.Cert.NotBefore.After(time.Date(2016, 9, 30, 0, 0, 0, 0, time.UTC)) {
		if d.Cert.SerialNumber.BitLen() < 64 {
			e.Err("Certificate serial number should be 64 bits but contains %d bits", d.Cert.SerialNumber.BitLen())
		}
	} else {
		// all new end-entity certificates must contain at least 20 bits of unpredictable random data (preferably in the serial number).
		if d.Cert.SerialNumber.BitLen() < 20 {
			e.Warning("Certificate serial number must contain at least 20 bits of unpredictable random data, found only %d bits", d.Cert.SerialNumber.BitLen())
		}
	}

	return nil
}
997865
func Check(c context.Context, tok string) error {
	_, err := xsrfToken.Validate(c, tok, state(c))
	return err
}
880949
func (f *Filter) Check(d *certdata.Data) bool {
	// Is certificate recognised as one of the given types
	if len(f.Type) > 0 {
		var inFilter bool
		for _, t := range f.Type {
			if d.Type == t {
				inFilter = true
			}
		}
		if !inFilter {
			return false
		}
	}

	// Issued before given date
	if f.IssuedBefore != nil && !d.Cert.NotBefore.Before(*f.IssuedBefore) {
		return false
	}
	// Issued after given date
	if f.IssuedAfter != nil && !d.Cert.NotBefore.After(*f.IssuedAfter) {
		return false
	}
	// Expires before given date
	if f.ExpiresBefore != nil && !d.Cert.NotBefore.Before(*f.ExpiresBefore) {
		return false
	}
	// Expires after given date
	if f.ExpiresAfter != nil && !d.Cert.NotAfter.After(*f.ExpiresAfter) {
		return false
	}

	return true
}
107968
func (ld *etcdLockDescriptor) Check(ctx context.Context) error {
	_, err := ld.s.cli.KeepAliveOnce(ctx, ld.leaseID)
	if err != nil {
		return convertError(err, "lease")
	}
	return nil
}
551848
func Check(d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	gkp := goodkey.NewKeyPolicy()
	err := gkp.GoodKey(d.Cert.PublicKey)
	if err != nil {
		e.Err("Certificate %s", strings.ToLower(err.Error()))
		return e
	}

	return e
}
1065806
func (b Bitmap) Check(idx uint) bool {
	bucket := idx >> 3
	mask := byte(1 << (idx & 7))
	return (b[bucket] & mask) != 0
}
1231250
func (b *permBiz) Check(user web.User, scope string, resType, resID string) (err error) {
	au := user.(*model.AuthUser)
	if au.Admin() {
		return
	}

	do(func(d dao.Interface) {
		var perm *model.Perm
		perm, err = d.PermGet(resType, resID)
		if err != nil {
			return
		}

		if perm == nil || perm.Scope == model.PermNone || (scope == "read" && perm.Scope == model.PermWrite) {
			return
		}

		for _, u := range perm.Users {
			if user.ID() == u {
				return
			}
		}

		for _, r := range perm.Roles {
			if au.IsInRole(r) {
				return
			}
		}
		err = ErrForbidden
	})
	return
}
509436
func (h *Handler) Check(err error) {
	// Check iff there were no errors
	if h.Err == nil {
		h.Err = err
	}
}
500775
func check(sl []string, s string) bool {
	var check bool
	for _, str := range sl {
		if str == s {
			check = true
			break
		}
	}
	return check
}
1362499
func (c *Constraint) Check(v *Version) bool {
	return c.f(v, c.check)
}
9608
func (f *JSONConfigFile) Check() error {
	return PickFirstError(
		// Feel free to add others here..
		func() error {
			_, err := f.GetRunMode()
			return err
		}(),
	)
}
1098425
func (sp *StandardProvider) Check() error {
	if sp.Paths.KeyFile == "" && sp.Paths.CertFile == "" {
		return nil
	}

	if sp.Paths.KeyFile == "" {
		return ErrMissingKeyPath
	}

	if sp.Paths.CertFile == "" {
		return ErrMissingCertPath
	}

	return nil
}
654980
func (val *Validation) Check() error {
	if val == nil || len(val.Errors) <= 0 {
		return nil
	}

	return val.constructErrorMessage()
}
46074
func (d *Checker) Check(values []interface{}) (bool, error) {
	bs, err := codec.EncodeValue([]byte{}, types.MakeDatums(values...)...)
	if err != nil {
		return false, errors.Trace(err)
	}
	key := string(bs)
	_, ok := d.existingKeys[key]
	if ok {
		return false, nil
	}
	d.existingKeys[key] = true
	return true, nil
}
160548
func Check(d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	switch d.Type {
	case "EV":
		if strings.LastIndex(d.Cert.Subject.CommonName, "*") > -1 {
			e.Err("Certificate should not contain a wildcard")
		}
		for _, n := range d.Cert.DNSNames {
			if strings.LastIndex(n, "*") > -1 {
				e.Err("Certificate subjectAltName '%s' should not contain a wildcard", n)
			}
		}
	case "DV", "OV":
		if strings.LastIndex(d.Cert.Subject.CommonName, "*") > 0 {
			e.Err("Certificate wildcard is only allowed as prefix")
		}
		for _, n := range d.Cert.DNSNames {
			if strings.LastIndex(n, "*") > 0 {
				e.Err("Certificate subjectAltName '%s' wildcard is only allowed as prefix", n)
			}
		}
	}

	return e
}
195532
func (c *BundlingChecker) check(items []checkerItem) {
	c.waitc <- struct{}{}
	c.wg.Add(1)
	go func() {
		c.doCheck(items)
		c.wg.Done()
		<-c.waitc
	}()

}
1275524
func (c *constraint) check(v *Version) bool {
	return c.function(v, c)
}