func (c *CmdPGPDecrypt) Run() error { cli, err := GetPGPClient() if err != nil { return err } protocols := []rpc.Protocol{ NewStreamUIProtocol(), NewSecretUIProtocol(G), NewIdentifyTrackUIProtocol(), } if err := RegisterProtocols(protocols); err != nil { return err } snk, src, err := c.ClientFilterOpen() if err != nil { return err } opts := keybase1.PGPDecryptOptions{ AssertSigned: c.signed, SignedBy: c.signedBy, TrackOptions: c.trackOptions, } arg := keybase1.PGPDecryptArg{Source: src, Sink: snk, Opts: opts} _, err = cli.PGPDecrypt(context.TODO(), arg) cerr := c.Close(err) return libkb.PickFirstError(err, cerr) }
func (s *CmdSign) Run() (err error) { protocols := []rpc.Protocol{ NewStreamUIProtocol(s.G()), NewSecretUIProtocol(s.G()), } cli, err := GetSaltpackClient(s.G()) if err != nil { return err } if err = RegisterProtocolsWithContext(protocols, s.G()); err != nil { return err } snk, src, err := s.ClientFilterOpen() if err == nil { arg := keybase1.SaltpackSignArg{ Source: src, Sink: snk, Opts: keybase1.SaltpackSignOptions{ Detached: s.detached, Binary: s.binary, }, } err = cli.SaltpackSign(context.TODO(), arg) } cerr := s.Close(err) return libkb.PickFirstError(err, cerr) }
func (c *CmdPGPEncrypt) Run() error { cli, err := GetPGPClient() if err != nil { return err } protocols := []rpc.Protocol{ NewStreamUIProtocol(c.G()), NewSecretUIProtocol(c.G()), NewIdentifyTrackUIProtocol(c.G()), } if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil { return err } snk, src, err := c.ClientFilterOpen() if err != nil { return err } opts := keybase1.PGPEncryptOptions{ Recipients: c.recipients, NoSign: !c.sign, NoSelf: c.noSelf, BinaryOut: c.binaryOut, KeyQuery: c.keyQuery, SkipTrack: c.skipTrack, TrackOptions: c.trackOptions, } arg := keybase1.PGPEncryptArg{Source: src, Sink: snk, Opts: opts} err = cli.PGPEncrypt(context.TODO(), arg) cerr := c.Close(err) return libkb.PickFirstError(err, cerr) }
func (c *CmdEncrypt) Run() error { cli, err := GetSaltpackClient(c.G()) if err != nil { return err } protocols := []rpc.Protocol{ NewStreamUIProtocol(c.G()), NewSecretUIProtocol(c.G()), NewIdentifyUIProtocol(c.G()), } if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil { return err } snk, src, err := c.filter.ClientFilterOpen() if err != nil { return err } opts := keybase1.SaltpackEncryptOptions{ Recipients: c.recipients, NoSelfEncrypt: c.noSelfEncrypt, Binary: c.binary, HideRecipients: c.hideRecipients, } arg := keybase1.SaltpackEncryptArg{Source: src, Sink: snk, Opts: opts} err = cli.SaltpackEncrypt(context.TODO(), arg) cerr := c.filter.Close(err) return libkb.PickFirstError(err, cerr) }
func (c *CmdPGPVerify) Run() error { cli, err := GetPGPClient() if err != nil { return err } protocols := []rpc.Protocol{ NewStreamUIProtocol(), NewSecretUIProtocol(G), NewIdentifyTrackUIProtocol(), } if err := RegisterProtocols(protocols); err != nil { return err } _, src, err := c.ClientFilterOpen() if err != nil { return err } arg := keybase1.PGPVerifyArg{ Source: src, Opts: keybase1.PGPVerifyOptions{ TrackOptions: c.trackOptions, Signature: c.detachedData, SignedBy: c.signedBy, }, } _, err = cli.PGPVerify(context.TODO(), arg) cerr := c.Close(err) return libkb.PickFirstError(err, cerr) }
func (c *CmdDecrypt) Run() error { cli, err := GetSaltpackClient(c.G()) if err != nil { return err } // Can't do this in ParseArgv, need to wait until later // in the initialization c.spui.terminal = c.G().UI.GetTerminalUI() protocols := []rpc.Protocol{ NewStreamUIProtocol(c.G()), NewSecretUIProtocol(c.G()), NewIdentifyUIProtocol(c.G()), keybase1.SaltpackUiProtocol(c.spui), } if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil { return err } snk, src, err := c.filter.ClientFilterOpen() if err != nil { return err } var info keybase1.SaltpackEncryptedMessageInfo arg := keybase1.SaltpackDecryptArg{ Source: src, Sink: snk, Opts: c.opts, } info, err = cli.SaltpackDecrypt(context.TODO(), arg) if _, ok := err.(libkb.NoDecryptionKeyError); ok { c.explainDecryptionFailure(&info) } else if c.senderfile != nil { if info.Sender.Username != "" { if _, err := c.senderfile.Write([]byte(info.Sender.Username)); err != nil { c.G().Log.Errorf("failure writing sender file: %s", err) } } c.senderfile.Close() } cerr := c.filter.Close(err) return libkb.PickFirstError(err, cerr) }
func (s *CmdPGPSign) Run() (err error) { protocols := []rpc.Protocol{ NewStreamUIProtocol(), NewSecretUIProtocol(G), } cli, err := GetPGPClient() if err != nil { return err } if err = RegisterProtocols(protocols); err != nil { return err } snk, src, err := s.ClientFilterOpen() if err == nil { arg := keybase1.PGPSignArg{Source: src, Sink: snk, Opts: s.opts} err = cli.PGPSign(context.TODO(), arg) } cerr := s.Close(err) return libkb.PickFirstError(err, cerr) }
func (c *CmdVerify) Run() (err error) { cli, err := GetSaltpackClient(c.G()) if err != nil { return err } c.spui = &SaltpackUI{ Contextified: libkb.NewContextified(c.G()), terminal: c.G().UI.GetTerminalUI(), } protocols := []rpc.Protocol{ NewStreamUIProtocol(c.G()), NewSecretUIProtocol(c.G()), NewIdentifyUIProtocol(c.G()), keybase1.SaltpackUiProtocol(c.spui), } if err = RegisterProtocolsWithContext(protocols, c.G()); err != nil { return err } snk, src, err := c.ClientFilterOpen() if err == nil { arg := keybase1.SaltpackVerifyArg{ Source: src, Sink: snk, Opts: keybase1.SaltpackVerifyOptions{ Signature: c.detachedData, SignedBy: c.signedBy, }, } err = cli.SaltpackVerify(context.TODO(), arg) } cerr := c.Close(err) return libkb.PickFirstError(err, cerr) }
func (u *UnixFilter) Close(inerr error) error { e1 := u.source.Close() e2 := u.sink.Close() e3 := u.sink.HitError(inerr) return libkb.PickFirstError(e1, e2, e3) }