1- package keymanagement
1+ package kas
22
33import (
44 "context"
@@ -21,7 +21,7 @@ import (
2121var ErrNoActiveKeyForAlgorithm = errors .New ("no active key found for specified algorithm" )
2222
2323// Used for reaching out to platform to get keys
24- type PlatformKeyIndexer struct {
24+ type KeyIndexer struct {
2525 // SDK is the SDK instance used to interact with the platform
2626 sdk * sdk.SDK
2727 // KasURI
@@ -31,13 +31,13 @@ type PlatformKeyIndexer struct {
3131}
3232
3333// platformKeyAdapter is an adapter for KeyDetails, where keys come from the platform
34- type KasKeyAdapter struct {
34+ type KeyAdapter struct {
3535 key * policy.KasKey
3636 log * logger.Logger
3737}
3838
39- func NewPlatformKeyIndexer (sdk * sdk.SDK , kasURI string , l * logger.Logger ) * PlatformKeyIndexer {
40- return & PlatformKeyIndexer {
39+ func NewPlatformKeyIndexer (sdk * sdk.SDK , kasURI string , l * logger.Logger ) * KeyIndexer {
40+ return & KeyIndexer {
4141 sdk : sdk ,
4242 kasURI : kasURI ,
4343 log : l ,
@@ -61,7 +61,7 @@ func convertAlgToEnum(alg string) (policy.Algorithm, error) {
6161 }
6262}
6363
64- func (p * PlatformKeyIndexer ) FindKeyByAlgorithm (ctx context.Context , algorithm string , _ bool ) (trust.KeyDetails , error ) {
64+ func (p * KeyIndexer ) FindKeyByAlgorithm (ctx context.Context , algorithm string , _ bool ) (trust.KeyDetails , error ) {
6565 alg , err := convertAlgToEnum (algorithm )
6666 if err != nil {
6767 return nil , err
@@ -90,13 +90,13 @@ func (p *PlatformKeyIndexer) FindKeyByAlgorithm(ctx context.Context, algorithm s
9090 return nil , ErrNoActiveKeyForAlgorithm
9191 }
9292
93- return & KasKeyAdapter {
93+ return & KeyAdapter {
9494 key : activeKey ,
9595 log : p .log ,
9696 }, nil
9797}
9898
99- func (p * PlatformKeyIndexer ) FindKeyByID (ctx context.Context , id trust.KeyIdentifier ) (trust.KeyDetails , error ) {
99+ func (p * KeyIndexer ) FindKeyByID (ctx context.Context , id trust.KeyIdentifier ) (trust.KeyDetails , error ) {
100100 req := & kasregistry.GetKeyRequest {
101101 Identifier : & kasregistry.GetKeyRequest_Key {
102102 Key : & kasregistry.KasKeyIdentifier {
@@ -113,13 +113,13 @@ func (p *PlatformKeyIndexer) FindKeyByID(ctx context.Context, id trust.KeyIdenti
113113 return nil , err
114114 }
115115
116- return & KasKeyAdapter {
116+ return & KeyAdapter {
117117 key : resp .GetKasKey (),
118118 log : p .log ,
119119 }, nil
120120}
121121
122- func (p * PlatformKeyIndexer ) ListKeys (ctx context.Context ) ([]trust.KeyDetails , error ) {
122+ func (p * KeyIndexer ) ListKeys (ctx context.Context ) ([]trust.KeyDetails , error ) {
123123 req := & kasregistry.ListKeysRequest {
124124 KasFilter : & kasregistry.ListKeysRequest_KasUri {
125125 KasUri : p .kasURI ,
@@ -132,7 +132,7 @@ func (p *PlatformKeyIndexer) ListKeys(ctx context.Context) ([]trust.KeyDetails,
132132
133133 keys := make ([]trust.KeyDetails , len (resp .GetKasKeys ()))
134134 for i , key := range resp .GetKasKeys () {
135- keys [i ] = & KasKeyAdapter {
135+ keys [i ] = & KeyAdapter {
136136 key : key ,
137137 log : p .log ,
138138 }
@@ -141,21 +141,21 @@ func (p *PlatformKeyIndexer) ListKeys(ctx context.Context) ([]trust.KeyDetails,
141141 return keys , nil
142142}
143143
144- func (p * KasKeyAdapter ) ID () trust.KeyIdentifier {
144+ func (p * KeyAdapter ) ID () trust.KeyIdentifier {
145145 return trust .KeyIdentifier (p .key .GetKey ().GetKeyId ())
146146}
147147
148148// Might need to convert this to a standard format
149- func (p * KasKeyAdapter ) Algorithm () string {
149+ func (p * KeyAdapter ) Algorithm () string {
150150 return p .key .GetKey ().GetKeyAlgorithm ().String ()
151151}
152152
153- func (p * KasKeyAdapter ) IsLegacy () bool {
153+ func (p * KeyAdapter ) IsLegacy () bool {
154154 return false
155155}
156156
157157// This will point to the correct "manager"
158- func (p * KasKeyAdapter ) System () string {
158+ func (p * KeyAdapter ) System () string {
159159 var mode string
160160 if p .key .GetKey ().GetProviderConfig () != nil {
161161 mode = p .key .GetKey ().GetProviderConfig ().GetName ()
@@ -211,7 +211,7 @@ func convertPEMToJWK(_ string) (string, error) {
211211 return "" , errors .New ("convertPEMToJWK function is not implemented" )
212212}
213213
214- func (p * KasKeyAdapter ) ExportPublicKey (ctx context.Context , format trust.KeyType ) (string , error ) {
214+ func (p * KeyAdapter ) ExportPublicKey (ctx context.Context , format trust.KeyType ) (string , error ) {
215215 publicKeyCtx := p .key .GetKey ().GetPublicKeyCtx ()
216216
217217 // Decode the base64-encoded public key
@@ -241,6 +241,6 @@ func (p *KasKeyAdapter) ExportPublicKey(ctx context.Context, format trust.KeyTyp
241241 }
242242}
243243
244- func (p * KasKeyAdapter ) ExportCertificate (_ context.Context ) (string , error ) {
244+ func (p * KeyAdapter ) ExportCertificate (_ context.Context ) (string , error ) {
245245 return "" , errors .New ("not implemented" )
246246}
0 commit comments