// ExportKeysByGUN exports all keys filtered to a GUN
327754
func ExportKeysByGUN(to io.Writer, s Exporter, gun string) error {
	keys := s.ListFiles()
	sort.Strings(keys) // ensure consistency. ListFiles has no order guarantee
	for _, loc := range keys {
		keyFile, err := s.Get(loc)
		if err != nil {
			logrus.Warn("Could not parse key file at ", loc)
			continue
		}
		block, _ := pem.Decode(keyFile)
		keyGun := block.Headers["gun"]
		if keyGun == gun { // must be full GUN match
			if err := ExportKeys(to, s, loc); err != nil {
				return err
			}
		}
	}
	return nil
}
816412
func (k *Key) ExportEncryptedPrivate(password []byte) ([]byte, error) {
	var privBytes []byte
	switch priv := k.Private.(type) {
	case *rsa.PrivateKey:
		privBytes = x509.MarshalPKCS1PrivateKey(priv)
	default:
		return nil, errors.New("only RSA private key is supported")
	}

	privPEMBlock, err := x509.EncryptPEMBlock(rand.Reader, rsaPrivateKeyPEMBlockType, privBytes, password, x509.PEMCipher3DES)
	if err != nil {
		return nil, err
	}

	buf := new(bytes.Buffer)
	if err := pem.Encode(buf, privPEMBlock); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
301253
func ConvertKeysToStrings(item interface{}) interface{} {
	switch typedDatas := item.(type) {
	case map[string]interface{}:
		for key, value := range typedDatas {
			typedDatas[key] = ConvertKeysToStrings(value)
		}
		return typedDatas
	case map[interface{}]interface{}:
		newMap := make(map[string]interface{})
		for key, value := range typedDatas {
			stringKey := key.(string)
			newMap[stringKey] = ConvertKeysToStrings(value)
		}
		return newMap
	case []interface{}:
		for i, value := range typedDatas {
			typedDatas[i] = ConvertKeysToStrings(value)
		}
		return typedDatas
	default:
		return item
	}
}
580915
func (g *Gauge) Export() (JSONMetric, error) {
	var buf bytes.Buffer

	err := binary.Write(&buf, binary.LittleEndian, g.value)
	if err != nil {
		return JSONMetric{}, err
	}

	return JSONMetric{
		MetricKey: MetricKey{
			Name:       g.Name,
			Type:       "gauge",
			JoinedTags: strings.Join(g.Tags, ","),
		},
		Tags:  g.Tags,
		Value: buf.Bytes(),
	}, nil
}
328364
func (b *BoltBackend) Export() ([]backend.Item, error) {
	var rootBuckets [][]string
	err := b.db.View(func(tx *bolt.Tx) error {
		tx.ForEach(func(name []byte, b *bolt.Bucket) error {
			rootBuckets = append(rootBuckets, []string{string(name)})
			return nil
		})
		return nil
	})
	if err != nil {
		return nil, trace.Wrap(err)
	}

	var items []backend.Item
	for _, bucket := range rootBuckets {
		f := &fetcher{
			bucket: bucket,
		}

		err := b.db.View(f.fetch)
		if err != nil {
			return nil, trace.Wrap(boltErr(err))
		}

		for _, p := range f.paths {
			item, err := b.getItem(p.bucket, p.key)
			if err != nil {
				continue
			}
			items = append(items, *item)
		}
	}
	return items, nil
}
1328625
func (e *SigsList) Sigs() []keybase1.Sig {
	res := make([]keybase1.Sig, len(e.sigs))
	for i, s := range e.sigs {
		var key string
		fp := s.GetPGPFingerprint()
		if fp != nil {
			key = fp.ToDisplayString(e.Verbose)
		}
		res[i] = keybase1.Sig{
			Seqno:        s.GetSeqno(),
			SigIDDisplay: s.GetSigID().ToDisplayString(e.Verbose),
			Type:         s.Type(),
			CTime:        keybase1.ToTime(s.GetCTime()),
			Revoked:      s.IsRevoked(),
			Active:       e.isActiveKey(s),
			Key:          key,
			Body:         s.ToDisplayString(),
		}
	}
	return res
}
786952
func (a *api) WriteDelegateKey(filename string, data []byte) error {
	return auth.WriteKeyToFile(filename, data)
}
428033
func (m *MockCryptoSuite) KeyGen(opts core.KeyGenOpts) (k core.Key, err error) {
	return nil, nil
}
591798
func ExportPreimages(db ethdb.Database, fn string) error {
	log.Info("Exporting preimages", "file", fn)

	// Open the file handle and potentially wrap with a gzip stream
	fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
	if err != nil {
		return err
	}
	defer fh.Close()

	var writer io.Writer = fh
	if strings.HasSuffix(fn, ".gz") {
		writer = gzip.NewWriter(writer)
		defer writer.(*gzip.Writer).Close()
	}
	// Iterate over the preimages and export them
	it := db.NewIteratorWithPrefix([]byte("secure-key-"))
	for it.Next() {
		if err := rlp.Encode(writer, it.Value()); err != nil {
			return err
		}
	}
	log.Info("Exported preimages", "file", fn)
	return nil
}
576350
func (ckf ComputedKeyFamily) ExportPerUserKeys() (ret []keybase1.PerUserKey) {

	for _, k := range ckf.cki.PerUserKeys {
		ret = append(ret, k)
	}
	sort.Sort(perUserKeyList(ret))
	return ret
}
344840
func (pub *PublicKey) ExportECDSA() *ecdsa.PublicKey {
	return &ecdsa.PublicKey{Curve: pub.Curve, X: pub.X, Y: pub.Y}
}
142769
func ExportTrackDiff(d TrackDiff) (res *keybase1.TrackDiff) {
	if d != nil {
		res = &keybase1.TrackDiff{
			Type:          keybase1.TrackDiffType(d.GetTrackDiffType()),
			DisplayMarkup: d.ToDisplayString(),
		}
	}
	return
}
625291
func (conn *Conn) export(methods map[string]reflect.Value, path ObjectPath, iface string, includeSubtree bool) error {
	h, ok := conn.handler.(*defaultHandler)
	if !ok {
		return fmt.Errorf(
			`dbus: export only allowed on the default hander handler have %T"`,
			conn.handler)
	}

	if !path.IsValid() {
		return fmt.Errorf(`dbus: Invalid path name: "%s"`, path)
	}

	// Remove a previous export if the interface is nil
	if methods == nil {
		return conn.unexport(h, path, iface)
	}

	// If this is the first handler for this path, make a new map to hold all
	// handlers for this path.
	if !h.PathExists(path) {
		h.AddObject(path, newExportedObject())
	}

	exportedMethods := make(map[string]Method)
	for name, method := range methods {
		exportedMethods[name] = exportedMethod{method}
	}

	// Finally, save this handler
	obj := h.objects[path]
	obj.AddInterface(iface, newExportedIntf(exportedMethods, includeSubtree))

	return nil
}
68576
func (v *NFSVolume) Export(label, parent string, writer io.Writer, excludes []string) error {
	return ErrNotSupported
}
1334186
func (s TrackSummary) Export(username string) (ret keybase1.TrackSummary) {
	ret.Time = keybase1.ToTime(s.time)
	ret.IsRemote = s.isRemote
	ret.Username = username
	return
}
910586
func (e *Store) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
	obj, err := e.Get(ctx, name, &metav1.GetOptions{})
	if err != nil {
		return nil, err
	}
	if accessor, err := meta.Accessor(obj); err == nil {
		exportObjectMeta(accessor, opts.Exact)
	} else {
		klog.V(4).Infof("Object of type %v does not have ObjectMeta: %v", reflect.TypeOf(obj), err)
	}

	if e.ExportStrategy != nil {
		if err = e.ExportStrategy.Export(ctx, obj, opts.Exact); err != nil {
			return nil, err
		}
	} else {
		e.CreateStrategy.PrepareForCreate(ctx, obj)
	}
	return obj, nil
}
1082136
func (devices *DeviceSet) exportDeviceMetadata(hash string) (*deviceMetadata, error) {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return nil, err
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	metadata := &deviceMetadata{info.DeviceID, info.Size, info.Name()}
	return metadata, nil
}