//NewKey returns the Key created by c.KeyParser.Parse(k).
510748
func (c *Config) NewKey(k string) Key {
	return c.KeyParser.Parse(k)
}
550163
func (c *Client) CreateKey(opts CreateKeyOpts) (*Key, error) {
	var resp Key
	req := request{
		method:         client.POST,
		url:            apiKeys,
		reqValue:       opts,
		resp:           &resp,
		expectedStatus: http.StatusCreated,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to create key with name: %s", opts.Name)
	}
	return &resp, nil
}
504380
func NewCipher(key []byte) (cipher.AEAD, error) {
	return newCipher(key, chacha.NonceSize)
}
1144123
func newKey(s *Section, name, val string) *Key {
	return &Key{
		s:     s,
		name:  name,
		value: val,
	}
}
972575
func (oms *OnlyMapperStruct) NewKey() sophie.Sophier {
	if oms.NewKeyF != nil {
		return oms.NewKeyF()
	}
	// sophie.RawByteSlice is a Sophier that can read any Sophie data.
	return new(sophie.RawByteSlice)
}
1297791
func NewCipher(key []byte) (cipher.Block, error) {
	k := len(key)
	if k == 16 {
		c := new(blockCipher128)
		c.keySchedule(key)
		return c, nil
	}
	if k == 24 || k == 32 {
		c := new(blockCipher256)
		c.keySchedule(key)
		return c, nil
	}
	return nil, crypto.KeySizeError(k)
}
1040893
func NewPGPKeyGen(g *libkb.GlobalContext, arg keybase1.PGPKeyGenDefaultArg) *PGPKeyGen {
	return &PGPKeyGen{
		Contextified: libkb.NewContextified(g),
		arg:          arg,
	}
}
228199
func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func(*Gui, *View) error) (kb *keybinding) {
	kb = &keybinding{
		viewName: viewname,
		key:      key,
		ch:       ch,
		mod:      mod,
		handler:  handler,
	}
	return kb
}
39202
func NewKeyFinder(g *globals.Context) types.KeyFinder {
	return &KeyFinderImpl{
		Contextified: globals.NewContextified(g),
		DebugLabeler: utils.NewDebugLabeler(g.GetLog(), "KeyFinder", false),
		keys:         make(map[string]*types.NameInfo),
		decKeys:      make(map[string]types.CryptKey),
		encKeys:      make(map[string]encItem),
	}
}
318877
func NewKeyPair() (keyPair *KeyPair, err error) {
	priv, err := rsa.GenerateKey(rand.Reader, 2048)
	if err != nil {
		return nil, ErrKeyGeneration
	}

	if err := priv.Validate(); err != nil {
		return nil, ErrValidation
	}

	privDer := x509.MarshalPKCS1PrivateKey(priv)
	privateKey := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Headers: nil, Bytes: privDer})
	pubSSH, err := gossh.NewPublicKey(&priv.PublicKey)
	if err != nil {
		return nil, ErrPublicKey
	}

	return &KeyPair{
		PrivateKey: privateKey,
		PublicKey:  gossh.MarshalAuthorizedKey(pubSSH),
	}, nil
}
1276752
func (b *BoltCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
	return NewKeyValue(b.db, id)
}
921887
func (p *Parser) parseKey() (string, error) {
	tok, literal := p.consume()
	if tok != IdentifierToken {
		err := fmt.Errorf("found '%s', expected: identifier", literal)
		return "", err
	}
	if err := validateLabelKey(literal); err != nil {
		return "", err
	}
	return literal, nil
}
31991
func New(params *stripe.EphemeralKeyParams) (*stripe.EphemeralKey, error) {
	return getC().New(params)
}
412785
func NewKeyring() *Keyring {
	return &Keyring{
		encKeys: make(map[PublicKey]SecretKey),
		sigKeys: make(map[SigningPublicKey]SigningSecretKey),
	}
}
1016202
func NewNotFoundErrorWithKey(entity string, key, value string) NotFoundError {
	return NotFoundError{entity: entity, key: key, value: value}
}
491994
func newKeyInfo(subscriptionPublicKey, serverPublicKey []byte) []byte {
	info := make([]byte, len(keyInfoPrefix)+len(subscriptionPublicKey)+len(serverPublicKey))
	n := copy(info, keyInfoPrefix)
	n += copy(info[n:], subscriptionPublicKey)
	copy(info[n:], serverPublicKey)
	return info
}
201117
func NewKeyFromURL(orig string) (*Key, error) {
	s := strings.TrimSpace(orig)

	u, err := url.Parse(s)

	if err != nil {
		return nil, err
	}

	return &Key{
		orig: s,
		url:  u,
	}, nil
}