| package data |
| |
| import ( |
| "encoding/json" |
| |
| . "gopkg.in/check.v1" |
| ) |
| |
| type TypesSuite struct{} |
| |
| var _ = Suite(&TypesSuite{}) |
| |
| func (TypesSuite) TestKeyIDs(c *C) { |
| // This public key is from the TUF specs: |
| // |
| // https://github.com/theupdateframework/specification |
| // |
| // Unfortunately there was a bug in the 1.0 spec, which reused the 0.9 |
| // key ids. This patch fixes it: |
| // |
| // https://github.com/theupdateframework/specification/pull/43 |
| public := `"72378e5bc588793e58f81c8533da64a2e8f1565c1fcc7f253496394ffc52542c"` |
| keyid09 := "1a2b4110927d4cba257262f614896179ff85ca1f1353a41b5224ac474ca71cb4" |
| keyid10 := "1bf1c6e3cdd3d3a8420b19199e27511999850f4b376c4547b2f32fba7e80fca3" |
| keyid10algos := "8e1824bd4e2de736e1388208c41e439fa1cfa19f4852f9ca80015e1da981cad5" |
| |
| var hexbytes HexBytes |
| err := json.Unmarshal([]byte(public), &hexbytes) |
| c.Assert(err, IsNil) |
| |
| key := Key{ |
| Type: KeyTypeEd25519, |
| Value: KeyValue{Public: hexbytes}, |
| } |
| c.Assert(key.IDs(), DeepEquals, []string{keyid09}) |
| |
| key = Key{ |
| Type: KeyTypeEd25519, |
| Scheme: KeySchemeEd25519, |
| Value: KeyValue{Public: hexbytes}, |
| } |
| c.Assert(key.IDs(), DeepEquals, []string{keyid10, keyid09}) |
| |
| key = Key{ |
| Type: KeyTypeEd25519, |
| Scheme: KeySchemeEd25519, |
| Algorithms: KeyAlgorithms, |
| Value: KeyValue{Public: hexbytes}, |
| } |
| c.Assert(key.IDs(), DeepEquals, []string{keyid10algos, keyid09}) |
| } |