Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oncilla committed Dec 18, 2019
1 parent 401aa10 commit 09ef8d2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go/beacon_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type periodicTasks struct {
intfs *ifstate.Interfaces
conn *snet.SCIONPacketConn
genMac func() hash.Hash
trustStore *trust.Store
trustStore trust.Store
store beaconstorage.Store
msgr infra.Messenger
topoProvider topology.Provider
Expand Down
2 changes: 2 additions & 0 deletions go/lib/ctrl/cert_mgmt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ go_library(
"//go/lib/common:go_default_library",
"//go/lib/scrypto:go_default_library",
"//go/lib/scrypto/cert:go_default_library",
"//go/lib/scrypto/cert/v2:go_default_library",
"//go/lib/scrypto/trc:go_default_library",
"//go/lib/scrypto/trc/v2:go_default_library",
"//go/proto:go_default_library",
],
)
15 changes: 10 additions & 5 deletions go/lib/ctrl/cert_mgmt/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"fmt"

"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/scrypto/cert"
legacy "github.com/scionproto/scion/go/lib/scrypto/cert"
"github.com/scionproto/scion/go/lib/scrypto/cert/v2"
"github.com/scionproto/scion/go/proto"
)

Expand All @@ -29,21 +30,25 @@ type Chain struct {
RawChain common.RawBytes `capnp:"chain"`
}

func (c *Chain) Chain() (*cert.Chain, error) {
func (c *Chain) Chain() (*legacy.Chain, error) {
if c.RawChain == nil {
return nil, nil
}
return cert.ChainFromRaw(c.RawChain, true)
return legacy.ChainFromRaw(c.RawChain, true)
}

func (c *Chain) ProtoId() proto.ProtoIdType {
return proto.CertChain_TypeID
}

func (c *Chain) String() string {
chain, err := c.Chain()
raw, err := cert.ParseChain(c.RawChain)
if err != nil {
return fmt.Sprintf("Invalid CertificateChain: %v", err)
}
return chain.String()
as, err := raw.AS.Encoded.Decode()
if err != nil {
return fmt.Sprintf("Invalid AS certificate: %v", err)
}
return fmt.Sprintf("ISD%d-AS%s-V%d", as.Subject.I, as.Subject.A, as.Version)
}
17 changes: 11 additions & 6 deletions go/lib/ctrl/cert_mgmt/trc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"fmt"

"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/scrypto/trc"
legacy "github.com/scionproto/scion/go/lib/scrypto/trc"
"github.com/scionproto/scion/go/lib/scrypto/trc/v2"
"github.com/scionproto/scion/go/proto"
)

Expand All @@ -29,21 +30,25 @@ type TRC struct {
RawTRC common.RawBytes `capnp:"trc"`
}

func (t *TRC) TRC() (*trc.TRC, error) {
func (t *TRC) TRC() (*legacy.TRC, error) {
if t.RawTRC == nil {
return nil, nil
}
return trc.TRCFromRaw(t.RawTRC, true)
return legacy.TRCFromRaw(t.RawTRC, true)
}

func (t *TRC) ProtoId() proto.ProtoIdType {
return proto.TRC_TypeID
}

func (t *TRC) String() string {
u, err := t.TRC()
signed, err := trc.ParseSigned(t.RawTRC)
if err != nil {
return fmt.Sprintf("Invalid TRC: %v", err)
return fmt.Sprintf("Invalid signed TRC: %v", err)
}
return u.String()
pld, err := signed.EncodedTRC.Decode()
if err != nil {
return fmt.Sprintf("Invalid TRC payload: %v", err)
}
return fmt.Sprintf("ISD%d-V%d", pld.ISD, pld.Version)
}

0 comments on commit 09ef8d2

Please sign in to comment.