当前位置: 首页>>代码示例>>Golang>>正文


Golang PGPKeyBundle.GetKID方法代码示例

本文整理汇总了Golang中github.com/keybase/client/go/libkb.PGPKeyBundle.GetKID方法的典型用法代码示例。如果您正苦于以下问题:Golang PGPKeyBundle.GetKID方法的具体用法?Golang PGPKeyBundle.GetKID怎么用?Golang PGPKeyBundle.GetKID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/keybase/client/go/libkb.PGPKeyBundle的用法示例。


在下文中一共展示了PGPKeyBundle.GetKID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Add

// Add adds bundle to the keyset.  If a key already exists, it
// will be ignored.
func (k *keyset) Add(bundle *libkb.PGPKeyBundle) {
	kid := bundle.GetKID()
	if _, ok := k.keys[kid]; ok {
		return
	}
	k.keys[kid] = bundle
	k.index = append(k.index, kid)
}
开发者ID:mattcurrycom,项目名称:client,代码行数:10,代码来源:pgp_encrypt.go

示例2: deviceSignPGP

func (d *Locksmith) deviceSignPGP(ctx *Context) (err error) {
	d.G().Log.Debug("+ deviceSignPGP")
	defer func() {
		d.G().Log.Debug("- deviceSignPGP -> %s", libkb.ErrToOk(err))
	}()
	pgpKeys := d.arg.User.GetActivePGPKeys(false)
	if len(pgpKeys) == 0 {
		err = errors.New("no active PGP keys unexpectedly")
		return err
	}
	var selected *libkb.PGPKeyBundle
	if len(pgpKeys) > 1 {
		// show a list of pgp keys and let them select which one to use
		selected, err = d.selectPGPKey(ctx, pgpKeys)
		if err != nil {
			return err
		}
		if selected == nil {
			err = fmt.Errorf("no key selected")
			return err
		}
	} else {
		selected = pgpKeys[0]
	}

	ctx.LogUI.Debug("selected pgp key: %s", selected.VerboseDescription())
	ctx.LogUI.Debug("selected pgp key kid: %s", selected.GetKID())

	var pk libkb.ServerPrivateKey
	var ok bool
	if ctx.LoginContext != nil {
		pk, ok = ctx.LoginContext.SecretSyncer().FindPrivateKey(selected.GetKID().String())
	} else {
		err = d.G().LoginState().SecretSyncer(func(ss *libkb.SecretSyncer) {
			pk, ok = ss.FindPrivateKey(selected.GetKID().String())
		}, "Locksmith - deviceSignPGP - FindPrivateKey")
		if err != nil {
			return err
		}
	}
	if ok {
		d.G().Log.Debug("| found synced secret key, unlocking it")
		skb, serr := pk.ToSKB(d.G())
		if serr != nil {
			err = serr
			return err
		}

		pgpk, perr := skb.PromptAndUnlock(ctx.LoginContext, "sign new device", "keybase", nil, ctx.SecretUI, nil, d.arg.User)
		if perr != nil {
			err = perr
			return err
		}
		return d.deviceSignPGPNext(ctx, pgpk)
	}

	// use gpg to unlock it
	gpg := d.G().GetGpgClient()
	if err = gpg.Configure(); err != nil {
		return err
	}

	bundle, ierr := gpg.ImportKey(true, selected.GetFingerprint())
	if ierr != nil {
		err = ierr
		return err
	}

	if err = bundle.Unlock("adding this device to your account", ctx.SecretUI); err != nil {
		err = fmt.Errorf("bundle Unlock error: %s", err)
		return err
	}

	return d.deviceSignPGPNext(ctx, bundle)
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:75,代码来源:locksmith.go


注:本文中的github.com/keybase/client/go/libkb.PGPKeyBundle.GetKID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。