// New returns a hash.Hash computing the CMac checksum.
// If the block cipher is not supported by CMac
// (see package doc), a non-nil error is returned.
323661
func New(c cipher.Block) (hash.Hash, error) {
	if c == nil {
		return nil, errors.New("the cipher.Block must not be nil")
	}
	bs := c.BlockSize()

	var p int
	switch bs {
	default:
		return nil, errors.New("cipher block size not supported")
	case 8:
		p = p64
	case 16:
		p = p128
	case 32:
		p = p256
	case 64:
		p = p512
	case 128:
		p = p1024
	}

	m := &macFunc{
		cipher: c,
		k0:     make([]byte, bs),
		k1:     make([]byte, bs),
		buf:    make([]byte, bs),
	}
	c.Encrypt(m.k0, m.k0)

	v := shift(m.k0, m.k0)
	m.k0[bs-1] ^= byte(subtle.ConstantTimeSelect(v, p, 0))

	v = shift(m.k1, m.k0)
	m.k1[bs-1] ^= byte(subtle.ConstantTimeSelect(v, p, 0))

	return m, nil
}
102724
func New(chainConn *chain.BitcoindConn, chainParams *chaincfg.Params,
	spendHintCache chainntnfs.SpendHintCache,
	confirmHintCache chainntnfs.ConfirmHintCache) *BitcoindNotifier {

	notifier := &BitcoindNotifier{
		chainParams: chainParams,

		notificationCancels:  make(chan interface{}),
		notificationRegistry: make(chan interface{}),

		blockEpochClients: make(map[uint64]*blockEpochRegistration),

		spendHintCache:   spendHintCache,
		confirmHintCache: confirmHintCache,

		quit: make(chan struct{}),
	}

	notifier.chainConn = chainConn.NewBitcoindClient()

	return notifier
}
1044177
func New384() hash.Hash {
	d := &digest{function: crypto.SHA384}
	d.Reset()
	return d
}
1054059
func NewHashFromHex(hex string) (hash *Hash, _ error) {
	h := new(Hash)
	if err := h.SetHex(hex); err != nil {
		return nil, err
	}
	return h, nil
}
595502
func New() hash.Hash {
	d := &digest{function: crypto.SHA512}
	d.Reset()
	return d
}
934067
func New(cryptoProvider core.CryptoSuite) (*SigningManager, error) {
	return &SigningManager{cryptoProvider: cryptoProvider, hashOpts: cryptosuite.GetSHAOpts()}, nil
}
656106
func New(key []byte, t1 int) (cipher.Block, error) {
	// TODO(dgryski): error checking for key length
	return &rc2Cipher{
		k: expandKey(key, t1),
	}, nil
}
1360491
func New(key *[16]byte) hash.Hash64 {
	h := new(hashFunc)
	h.key[0] = uint64(key[0]) | uint64(key[1])<<8 | uint64(key[2])<<16 | uint64(key[3])<<24 |
		uint64(key[4])<<32 | uint64(key[5])<<40 | uint64(key[6])<<48 | uint64(key[7])<<56
	h.key[1] = uint64(key[8]) | uint64(key[9])<<8 | uint64(key[10])<<16 | uint64(key[11])<<24 |
		uint64(key[12])<<32 | uint64(key[13])<<40 | uint64(key[14])<<48 | uint64(key[15])<<56
	h.Reset()
	return h
}
843398
func New(hashfunc func([]byte) uint32, replicaPoints int) *HashRing {
	r := &HashRing{
		replicaPoints: replicaPoints,
		hashfunc: func(str string) int {
			return int(hashfunc([]byte(str)))
		},
		logger: logging.Logger("ring"),

		checksummers: map[string]Checksummer{
			"replica": &replicaPointChecksummer{},
		},
	}

	r.serverSet = make(map[string]struct{})
	r.tree = &redBlackTree{}
	return r
}
570407
func New(key, secret string) (api *API) {
	api = &API{
		APIKey:    key,
		APISecret: secret,
	}
	return api
}
761855
func (l loader) New(ctx context.Context) (backend.Crypto, error) {
	out.Debug(ctx, "Using Crypto Backend: %s", name)
	return New(ctx, Config{
		Umask: fsutil.Umask(),
		Args:  GPGOpts(),
	})
}
370435
func New(options ...Options) *Secure {
	var o Options
	if len(options) == 0 {
		o = Options{}
	} else {
		o = options[0]
	}

	o.ContentSecurityPolicy = strings.Replace(o.ContentSecurityPolicy, "$NONCE", "'nonce-%[1]s'", -1)

	o.nonceEnabled = strings.Contains(o.ContentSecurityPolicy, "%[1]s")

	s := &Secure{
		opt:            o,
		badHostHandler: http.HandlerFunc(defaultBadHostHandler),
	}

	if s.opt.AllowedHostsAreRegex {
		// Test for invalid regular expressions in AllowedHosts
		for _, allowedHost := range o.AllowedHosts {
			regex, err := regexp.Compile(fmt.Sprintf("^%s$", allowedHost))
			if err != nil {
				panic(fmt.Sprintf("Error parsing AllowedHost: %s", err))
			}
			s.cRegexAllowedHosts = append(s.cRegexAllowedHosts, regex)
		}
	}

	return s
}
696920
func New(certFile, keyFile string, d time.Duration) *TLSHealthChecker {
	c, err := tls.LoadX509KeyPair(certFile, keyFile)
	if err != nil {
		return &TLSHealthChecker{cert: nil}
	}
	if len(c.Certificate) > 0 {
		c1, _ := x509.ParseCertificate(c.Certificate[0])
		return &TLSHealthChecker{cert: c1, dur: d}
	}
	return &TLSHealthChecker{cert: nil}
}
255645
func New(rowPins, colPins []int) (*Matrix4x3, error) {
	m := &Matrix4x3{
		rowPins: make([]embd.DigitalPin, rows),
		colPins: make([]embd.DigitalPin, cols),
		poll:    pollDelay,
	}

	var err error
	for i := 0; i < rows; i++ {
		m.rowPins[i], err = embd.NewDigitalPin(rowPins[i])
		if err != nil {
			return nil, err
		}
	}
	for i := 0; i < cols; i++ {
		m.colPins[i], err = embd.NewDigitalPin(colPins[i])
		if err != nil {
			return nil, err
		}
	}

	return m, nil
}
429016
func New(params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) {
	return getC().New(params)
}
473405
func New256() hash.Hash {
	d := new(digest)
	d.initialize(config256)
	return d
}
1225556
func New(h crypto.Hash) *Isolated {
	a := ""
	switch h {
	case crypto.SHA1:
		a = "sha-1"
	case crypto.SHA256:
		a = "sha-256"
	case crypto.SHA512:
		a = "sha-512"
	}
	return &Isolated{
		Algo:    a,
		Version: IsolatedFormatVersion,
		Files:   map[string]File{},
	}
}