@@ -3,7 +3,6 @@ package client
33import (
44 "bytes"
55 "encoding/json"
6- "errors"
76 "io"
87 "io/ioutil"
98 "log"
@@ -560,56 +559,6 @@ func (c *Client) downloadMetaUnsafe(name string, maxMetaSize int64) ([]byte, err
560559 return ioutil .ReadAll (io .LimitReader (r , maxMetaSize ))
561560}
562561
563- // getRootAndLocalVersionsUnsafe decodes the versions stored in the local
564- // metadata without verifying signatures to protect against downgrade attacks
565- // when the root is replaced and contains new keys. It also sets the local meta
566- // cache to only contain the local root metadata.
567- func (c * Client ) getRootAndLocalVersionsUnsafe () error {
568- type versionData struct {
569- Signed struct {
570- Version int
571- }
572- }
573-
574- meta , err := c .local .GetMeta ()
575- if err != nil {
576- return err
577- }
578-
579- getVersion := func (name string ) (int , error ) {
580- m , ok := meta [name ]
581- if ! ok {
582- return 0 , nil
583- }
584- var data versionData
585- if err := json .Unmarshal (m , & data ); err != nil {
586- return 0 , err
587- }
588- return data .Signed .Version , nil
589- }
590-
591- c .timestampVer , err = getVersion ("timestamp.json" )
592- if err != nil {
593- return err
594- }
595- c .snapshotVer , err = getVersion ("snapshot.json" )
596- if err != nil {
597- return err
598- }
599- c .targetsVer , err = getVersion ("targets.json" )
600- if err != nil {
601- return err
602- }
603-
604- root , ok := meta ["root.json" ]
605- if ! ok {
606- return errors .New ("tuf: missing local root after downloading, this should not be possible" )
607- }
608- c .localMeta = map [string ]json.RawMessage {"root.json" : root }
609-
610- return nil
611- }
612-
613562// remoteGetFunc is the type of function the download method uses to download
614563// remote files
615564type remoteGetFunc func (string ) (io.ReadCloser , int64 , error )
@@ -790,6 +739,7 @@ func (c *Client) localMetaFromSnapshot(name string, m data.SnapshotFileMeta) (js
790739}
791740
792741// hasTargetsMeta checks whether local metadata has the given snapshot meta
742+ //lint:ignore U1000 unused
793743func (c * Client ) hasTargetsMeta (m data.SnapshotFileMeta ) bool {
794744 b , ok := c .localMeta ["targets.json" ]
795745 if ! ok {
@@ -804,6 +754,7 @@ func (c *Client) hasTargetsMeta(m data.SnapshotFileMeta) bool {
804754}
805755
806756// hasSnapshotMeta checks whether local metadata has the given meta
757+ //lint:ignore U1000 unused
807758func (c * Client ) hasMetaFromTimestamp (name string , m data.TimestampFileMeta ) bool {
808759 b , ok := c .localMeta [name ]
809760 if ! ok {
0 commit comments