| 1 |
package set_ecdsa |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
|
| 6 |
"github.com/theupdateframework/go-tuf/data" |
| 7 |
"github.com/theupdateframework/go-tuf/pkg/keys" |
| 8 |
) |
| 9 |
|
| 10 |
/* |
| 11 |
Importing this package will allow support for both hex-encoded ECDSA |
| 12 |
verifiers and PEM-encoded ECDSA verifiers. |
| 13 |
Note that this package imports "github.com/theupdateframework/go-tuf/pkg/keys" |
| 14 |
and overrides the ECDSA verifier loaded at init time in that package. |
| 15 |
*/ |
| 16 |
|
| 17 |
func init() { |
| 18 |
_, ok := keys.VerifierMap.Load(data.KeyTypeECDSA_SHA2_P256) |
| 19 |
if !ok { |
| 20 |
panic(errors.New("expected to override previously loaded PEM-only ECDSA verifier")) |
| 21 |
} |
| 22 |
// store a mapping for both data.KeyTypeECDSA_SHA2_P256_OLD_FMT and data.KeyTypeECDSA_SHA2_P256 |
| 23 |
// in case a client is verifying using both the old non-compliant format and a newly generated root |
| 24 |
keys.VerifierMap.Store(data.KeyTypeECDSA_SHA2_P256, keys.NewDeprecatedEcdsaVerifier) // compliant format |
| 25 |
keys.VerifierMap.Store(data.KeyTypeECDSA_SHA2_P256_OLD_FMT, keys.NewDeprecatedEcdsaVerifier) // deprecated format |
| 26 |
} |