Пример #1
0
func ParseDevice(jw *jsonw.Wrapper, t time.Time) (ret *Device, err error) {
	var obj Device
	if err = jw.UnmarshalAgain(&obj); err == nil {
		ret = &obj
		ret.CTime = keybase1.ToTime(t)
		ret.MTime = keybase1.ToTime(t)
	}
	return
}
Пример #2
0
func (cr CheckResult) Export() *keybase1.CheckResult {
	return &keybase1.CheckResult{
		ProofResult: ExportProofError(cr.Status),
		Time:        keybase1.ToTime(cr.Time),
		Freshness:   cr.Freshness(),
	}
}
Пример #3
0
func (cr CheckResult) Export() *keybase1.CheckResult {
	return &keybase1.CheckResult{
		ProofResult:   ExportProofError(cr.Status),
		Time:          keybase1.ToTime(cr.Time),
		DisplayMarkup: cr.ToDisplayString(),
	}
}
Пример #4
0
func (l LinkCheckResult) Export() keybase1.LinkCheckResult {
	ret := keybase1.LinkCheckResult{
		ProofId:       l.position,
		ProofResult:   ExportProofError(l.err),
		SnoozedResult: ExportProofError(l.snoozedErr),
		TorWarning:    l.torWarning,
	}
	if l.cached != nil {
		ret.Cached = l.cached.Export()
	}
	bt := false
	if l.diff != nil {
		ret.Diff = ExportTrackDiff(l.diff)
		if l.diff.BreaksTracking() {
			bt = true
		}
	}
	if l.remoteDiff != nil {
		ret.RemoteDiff = ExportTrackDiff(l.remoteDiff)
		if l.remoteDiff.BreaksTracking() {
			bt = true
		}
	}
	if l.hint != nil {
		ret.Hint = l.hint.Export()
	}
	ret.TmpTrackExpireTime = keybase1.ToTime(l.tmpTrackExpireTime)
	ret.BreaksTracking = bt
	return ret
}
Пример #5
0
func (i *Identify2WithUIDTester) Insert(up *keybase1.UserPlusKeys) error {
	tmp := *up
	copy := &tmp
	copy.Uvv.CachedAt = keybase1.ToTime(i.now)
	i.cache[up.Uid] = copy
	return nil
}
Пример #6
0
func (ir IdentifyOutcome) ExportToUncheckedIdentity() *keybase1.Identity {
	tmp := keybase1.Identity{
		Status: ExportErrorAsStatus(ir.Error),
	}
	if ir.TrackUsed != nil {
		tmp.WhenLastTracked = keybase1.ToTime(ir.TrackUsed.GetCTime())
	}

	pc := ir.ProofChecksSorted()
	tmp.Proofs = make([]keybase1.IdentifyRow, len(pc))
	for j, p := range pc {
		tmp.Proofs[j] = p.ExportToIdentifyRow(j)
	}

	tmp.Revoked = make([]keybase1.TrackDiff, len(ir.Revoked))
	for j, d := range ir.Revoked {
		// Should have all non-nil elements...
		tmp.Revoked[j] = *ExportTrackDiff(d)
		if d.BreaksTracking() {
			tmp.BreaksTracking = true
		}
	}
	tmp.RevokedDetails = ir.RevokedDetails
	return &tmp
}
Пример #7
0
func ExportRemoteProof(p RemoteProofChainLink) keybase1.RemoteProof {
	k, v := p.ToKeyValuePair()
	return keybase1.RemoteProof{
		ProofType:     p.GetProofType(),
		Key:           k,
		Value:         v,
		DisplayMarkup: v,
		SigID:         p.GetSigID(),
		MTime:         keybase1.ToTime(p.GetCTime()),
	}
}
Пример #8
0
func (k *KeybaseDaemonLocal) revokeDeviceForTesting(clock Clock,
	uid keybase1.UID, index int) error {
	k.lock.Lock()
	defer k.lock.Unlock()

	user, err := k.localUsers.getLocalUser(uid)
	if err != nil {
		return fmt.Errorf("No such user %s: %v", uid, err)
	}

	if index >= len(user.VerifyingKeys) ||
		(k.currentUID == uid && index == user.CurrentCryptPublicKeyIndex) {
		return fmt.Errorf("Can't revoke index %d", index)
	}

	if user.RevokedVerifyingKeys == nil {
		user.RevokedVerifyingKeys = make(map[VerifyingKey]keybase1.KeybaseTime)
	}
	if user.RevokedCryptPublicKeys == nil {
		user.RevokedCryptPublicKeys =
			make(map[CryptPublicKey]keybase1.KeybaseTime)
	}

	kbtime := keybase1.KeybaseTime{
		Unix:  keybase1.ToTime(clock.Now()),
		Chain: 100,
	}
	user.RevokedVerifyingKeys[user.VerifyingKeys[index]] = kbtime
	user.RevokedCryptPublicKeys[user.CryptPublicKeys[index]] = kbtime

	user.VerifyingKeys = append(user.VerifyingKeys[:index],
		user.VerifyingKeys[index+1:]...)
	user.CryptPublicKeys = append(user.CryptPublicKeys[:index],
		user.CryptPublicKeys[index+1:]...)

	if k.currentUID == uid && index < user.CurrentCryptPublicKeyIndex {
		user.CurrentCryptPublicKeyIndex--
	}
	if k.currentUID == uid && index < user.CurrentVerifyingKeyIndex {
		user.CurrentVerifyingKeyIndex--
	}

	k.localUsers[uid] = user
	return nil
}
Пример #9
0
func (e *ListTrackingEngine) runTable(trackList TrackList) error {
	for _, link := range trackList {
		uid, err := link.GetTrackedUID()
		if err != nil {
			return err
		}
		entry := keybase1.UserSummary{
			Username:     link.ToDisplayString(),
			SigIDDisplay: link.GetSigID().ToDisplayString(true),
			TrackTime:    keybase1.ToTime(link.GetCTime()),
			Uid:          keybase1.UID(uid),
		}
		entry.Proofs.PublicKeys = e.linkPGPKeys(link)
		entry.Proofs.Social = e.linkSocialProofs(link)
		entry.Proofs.Web = e.linkWebProofs(link)
		e.tableResult = append(e.tableResult, entry)
	}
	return nil
}
Пример #10
0
// Check checks for an update. If not requested (by user) and not forced it will
// exit early if check has already been applied within checkDuration().
func (u *UpdateChecker) Check(force bool, requested bool) error {
	if !requested && !force {
		if lastCheckedPTime := u.updater.config.GetUpdateLastChecked(); lastCheckedPTime > 0 {
			lastChecked := keybase1.FromTime(lastCheckedPTime)
			if time.Now().Before(lastChecked.Add(checkDuration())) {
				u.log.Debug("Already checked: %s", lastChecked)
				return nil
			}
		}
	}

	checkTime := time.Now()
	_, err := u.updater.Update(u.ui, force, requested)
	if err != nil {
		return err
	}

	u.log.Debug("Saving updater last checked: %s", checkTime)
	u.updater.config.SetUpdateLastChecked(keybase1.ToTime(checkTime))
	return nil
}
Пример #11
0
// Sigs returns the sig list, after processing.
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:        int(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
}
Пример #12
0
func makeTestKBPKIClientWithRevokedKey(t *testing.T, revokeTime time.Time) (
	client *KBPKIClient, currentUID keybase1.UID, users []LocalUser) {
	currentUID = keybase1.MakeTestUID(1)
	names := []libkb.NormalizedUsername{"test_name1", "test_name2"}
	users = MakeLocalUsers(names)
	// Give each user a revoked key
	for i, user := range users {
		index := 99
		keySalt := keySaltForUserDevice(user.Name, index)
		newVerifyingKey := MakeLocalUserVerifyingKeyOrBust(keySalt)
		user.RevokedVerifyingKeys = map[VerifyingKey]keybase1.KeybaseTime{
			newVerifyingKey: {Unix: keybase1.ToTime(revokeTime), Chain: 100},
		}
		users[i] = user
	}
	codec := NewCodecMsgpack()
	daemon := NewKeybaseDaemonMemory(currentUID, users, codec)
	config := &ConfigLocal{codec: codec, daemon: daemon}
	setTestLogger(config, t)
	return NewKBPKIClient(config), currentUID, users
}
Пример #13
0
func (t *Tracker2Syncer) syncFromServer(uid keybase1.UID, sr SessionReader) (err error) {

	defer t.G().Trace(fmt.Sprintf("syncFromServer(%s)", uid), func() error { return err })()

	hargs := HTTPArgs{
		"uid":       UIDArg(uid),
		"reverse":   B{t.reverse},
		"autoCamel": B{true},
	}
	lv := t.getLoadedVersion()
	if lv >= 0 {
		hargs.Add("version", I{lv})
	}
	var res *APIRes
	res, err = t.G().API.Get(APIArg{
		Endpoint:    "user/list_followers_for_display",
		Args:        hargs,
		NeedSession: false,
	})
	t.G().Log.Debug("| syncFromServer() -> %s", ErrToOk(err))
	if err != nil {
		return err
	}
	var tmp keybase1.UserSummary2Set
	if err = res.Body.UnmarshalAgain(&tmp); err != nil {
		return
	}
	tmp.Time = keybase1.ToTime(time.Now())
	if lv < 0 || tmp.Version > lv {
		t.G().Log.Debug("| syncFromServer(): got update %d > %d (%d records)", tmp.Version, lv,
			len(tmp.Users))
		t.res = &tmp
		t.dirty = true
	} else {
		t.G().Log.Debug("| syncFromServer(): no change needed @ %d", lv)
	}
	return nil
}
Пример #14
0
func (u *UpdateChecker) Check(force bool, requested bool) error {
	ui, _ := u.ui.GetUpdateUI()
	if ui == nil && !force {
		return fmt.Errorf("No UI for update check")
	}

	if !requested && !force {
		if lastCheckedPTime := u.updater.config.GetUpdateLastChecked(); lastCheckedPTime > 0 {
			lastChecked := keybase1.FromTime(lastCheckedPTime)
			if time.Now().Before(lastChecked.Add(checkDuration())) {
				u.log.Debug("Already checked: %s", lastChecked)
				return nil
			}
		}
	}

	_, err := u.updater.Update(ui, force, requested)
	if err != nil {
		return err
	}
	u.log.Debug("Updater checked")
	u.updater.config.SetUpdateLastChecked(keybase1.ToTime(time.Now()))
	return nil
}
Пример #15
0
func (e *Identify2WithUID) toUserPlusKeys() keybase1.UserPlusKeys {
	return e.them.ExportToUserPlusKeys(keybase1.ToTime(e.getNow()))
}
Пример #16
0
func (s TrackSummary) Export(username string) (ret keybase1.TrackSummary) {
	ret.Time = keybase1.ToTime(s.time)
	ret.IsRemote = s.isRemote
	ret.Username = username
	return
}
Пример #17
0
// Insert adds a user to the cache, keyed on UID.
func (c *Identify2Cache) Insert(up *keybase1.UserPlusKeys) error {
	tmp := *up
	copy := &tmp
	copy.Uvv.CachedAt = keybase1.ToTime(time.Now())
	return c.cache.Set(string(up.Uid), copy)
}