// NewSecretKey returns a SecretKey structure based on the passed parameters.
169764
func NewSecretKey(password *[]byte, N, r, p int) (*SecretKey, error) {
	sk := SecretKey{
		Key: (*CryptoKey)(&[KeySize]byte{}),
	}
	// setup parameters
	sk.Parameters.N = N
	sk.Parameters.R = r
	sk.Parameters.P = p
	_, err := io.ReadFull(prng, sk.Parameters.Salt[:])
	if err != nil {
		return nil, err
	}

	// derive key
	err = sk.deriveKey(password)
	if err != nil {
		return nil, err
	}

	// store digest
	sk.Parameters.Digest = sha256.Sum256(sk.Key[:])

	return &sk, nil
}
459370
func (c *Cluster) CreateSecret(s types.SecretSpec) (string, error) {
	var resp *swarmapi.CreateSecretResponse
	if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
		secretSpec := convert.SecretSpecToGRPC(s)

		r, err := state.controlClient.CreateSecret(ctx,
			&swarmapi.CreateSecretRequest{Spec: &secretSpec})
		if err != nil {
			return err
		}
		resp = r
		return nil
	}); err != nil {
		return "", err
	}
	return resp.Secret.ID, nil
}
901394
func NewSecretStore(g *GlobalContext, username NormalizedUsername) SecretStore {
	store := g.SecretStore()
	if store != nil {
		return &SecretStoreImp{
			username: username,
			store:    store,
		}
	}
	return nil
}
1200763
func NewSecretsProxy() *SecretsProxy {

	return &SecretsProxy{
		socketPath:      constants.DefaultSecretsPath,
		drivers:         cache.NewCache("secrets driver cache"),
		apiCacheMapping: cache.NewCache("secrets api cache"),
		cgroupCache:     cache.NewCache("secrets pu cache"),
		policyCache:     cache.NewCache("policy cache"),
	}
}
43901
func (c *ClusterManager) SecretSetDefaultSecretKey(secretKey string, override bool) error {
	return c.secretsManager.SecretSetDefaultSecretKey(secretKey, override)
}
56437
func newSecrets(c *Client, ns string) *secrets {
	return &secrets{
		client:    c,
		namespace: ns,
	}
}
90995
func (k *Keyrings) GetSecretKeyWithPrompt(m MetaContext, arg SecretKeyPromptArg) (key GenericKey, err error) {
	defer m.Trace(fmt.Sprintf("Keyrings#GetSecretKeyWithPrompt(%s)", arg.Reason), func() error { return err })()

	key = k.cachedSecretKey(m, arg.Ska)
	if key != nil {
		return key, err
	}

	key, _, err = k.GetSecretKeyAndSKBWithPrompt(m, arg)

	if key != nil && err == nil {
		setCachedSecretKey(m, arg.Ska, key, nil)
	}

	return key, err
}
139482
func NewSecretService() *SecretService {
	return &SecretService{
		LoadSecretFn: func(ctx context.Context, orgID platform.ID, k string) (string, error) {
			return "", fmt.Errorf("not implmemented")
		},
		GetSecretKeysFn: func(ctx context.Context, orgID platform.ID) ([]string, error) {
			return nil, fmt.Errorf("not implmemented")
		},
		PutSecretFn: func(ctx context.Context, orgID platform.ID, k string, v string) error {
			return fmt.Errorf("not implmemented")
		},
		PutSecretsFn: func(ctx context.Context, orgID platform.ID, m map[string]string) error {
			return fmt.Errorf("not implmemented")
		},
		PatchSecretsFn: func(ctx context.Context, orgID platform.ID, m map[string]string) error {
			return fmt.Errorf("not implmemented")
		},
		DeleteSecretFn: func(ctx context.Context, orgID platform.ID, ks ...string) error {
			return fmt.Errorf("not implmemented")
		},
	}
}
602473
func (s *Service) GetSecretKeys(ctx context.Context, orgID influxdb.ID) ([]string, error) {
	var vs []string
	err := s.kv.View(ctx, func(tx Tx) error {
		vals, err := s.getSecretKeys(ctx, tx, orgID)
		if err != nil {
			return err
		}

		vs = vals
		return nil
	})

	if err != nil {
		return nil, err
	}

	return vs, nil
}
850699
func (m *MockCluster) SecretGetDefaultSecretKey() (interface{}, error) {
	ret := m.ctrl.Call(m, "SecretGetDefaultSecretKey")
	ret0, _ := ret[0].(interface{})
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
704116
func newSecrets(c *CoreV1Client, namespace string) *secrets {
	return &secrets{
		client: c.RESTClient(),
		ns:     namespace,
	}
}
899824
func (s *BaiduChannelRequest) SetSecretKey(v string) *BaiduChannelRequest {
	s.SecretKey = &v
	return s
}
463938
func IsSecretKey(value string) bool {
	return len(value) <= validation.DNS1123SubdomainMaxLength && secretKeyRegexp.MatchString(value)
}
330963
func NewSecrets(s PublicSecrets) (Secrets, error) {
	switch s.SecretsType() {
	case PKICompactType:
		t := s.(*CompactPKIPublicSecrets)
		return NewCompactPKIWithTokenCA(t.Key, t.Certificate, t.CA, t.TokenCAs, t.Token, t.Compressed)
	default:
		return nil, fmt.Errorf("Unsupported type")
	}
}
59231
func (s *SecretService) GetSecretKeys(ctx context.Context, orgID platform.ID) ([]string, error) {
	data, _, err := s.loadSecrets(ctx, orgID)
	if err != nil {
		return nil, err
	}

	keys := make([]string, 0, len(data))
	for k := range data {
		keys = append(keys, k)
	}

	return keys, nil
}
1145768
func (soc *Socket) SetCurveSecretkey(key string) error {
	return soc.setString(C.ZMQ_CURVE_SECRETKEY, key)
}
911608
func NewSecrets(impl corev1.SecretInterface) *Secrets {
	return &Secrets{
		impl: impl,
		Log:  func(_ string, _ ...interface{}) {},
	}
}