Skip to content

Commit

Permalink
TrustStore: Ensure referenced TRC is available
Browse files Browse the repository at this point in the history
When verifying a signature, the verifier now makes sure to have the
referenced TRC available locally.

This is one mechanism how TRC updates are disseminated.
  • Loading branch information
oncilla committed Jan 21, 2020
1 parent 6f99584 commit 066152f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions go/lib/infra/modules/trust/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,18 @@ func (v *verifier) Verify(ctx context.Context, msg []byte, sign *proto.SignS) er
"expected", v.BoundSrc, "actual", src)
}

id := ChainID{IA: src.IA, Version: src.ChainVer}
opts := infra.ChainOpts{
// Ensure that the TRC announced in source is available locally. Thus, not
// missing TRC updates.
tOpts := infra.TRCOpts{
TrustStoreOpts: infra.TrustStoreOpts{Server: v.Server},
AllowInactive: true,
}
if _, err := v.Store.GetTRC(ctx, TRCID{ISD: src.IA.I, Version: src.TRCVer}, tOpts); err != nil {
return err
}

key, err := v.Store.GetASKey(ctx, id, opts)
opts := infra.ChainOpts{TrustStoreOpts: infra.TrustStoreOpts{Server: v.Server}}
key, err := v.Store.GetASKey(ctx, ChainID{IA: src.IA, Version: src.ChainVer}, opts)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions go/lib/infra/modules/trust/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestVerify(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
p := mock_trust.NewMockCryptoProvider(ctrl)
p.EXPECT().GetTRC(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
p.EXPECT().GetASKey(gomock.Any(), gomock.Any(),
gomock.Any()).Return(scrypto.KeyMeta{Key: public, Algorithm: scrypto.Ed25519}, nil)

Expand Down

0 comments on commit 066152f

Please sign in to comment.