"x/ref": Add Dump method to BlessingRoots
This CL adds a 'Dump' method to BlessingRoots to obtain
the set of all roots. While I hope that this is useful
in general, it is necessary for addressing:
https://github.com/vanadium/issues/issues/228
MultiPart: 2/2
Change-Id: I705b312aabc0a4747f14728fba360fb9cec683db
diff --git a/services/agent/agentlib/client.go b/services/agent/agentlib/client.go
index bcda630..7dc2c3c 100644
--- a/services/agent/agentlib/client.go
+++ b/services/agent/agentlib/client.go
@@ -272,6 +272,26 @@
return b.caller.call("BlessingRootsRecognized", results(), marshalledKey, blessing)
}
+func (b *blessingRoots) Dump() map[security.BlessingPattern][]security.PublicKey {
+ var marshaledRoots map[security.BlessingPattern][][]byte
+ if err := b.caller.call("BlessingRootsDump", results(&marshaledRoots)); err != nil {
+ vlog.Errorf("error calling BlessingRootsDump: %v", err)
+ return nil
+ }
+ ret := make(map[security.BlessingPattern][]security.PublicKey)
+ for p, marshaledKeys := range marshaledRoots {
+ for _, marshaledKey := range marshaledKeys {
+ key, err := security.UnmarshalPublicKey(marshaledKey)
+ if err != nil {
+ vlog.Errorf("security.UnmarshalPublicKey(%v) returned error: %v", marshaledKey, err)
+ continue
+ }
+ ret[p] = append(ret[p], key)
+ }
+ }
+ return ret
+}
+
func (b *blessingRoots) DebugString() (s string) {
err := b.caller.call("BlessingRootsDebugString", results(&s))
if err != nil {