File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ func base64BEtoBigInt(in string) (*big.Int, error) {
105
105
}
106
106
107
107
// PublicKey returns the public key for this instance of CoseSignerKeyVault
108
+ //
109
+ // NOTE: Only valid for ECDSA
108
110
func (kv * KeyVaultCoseSigner ) PublicKey () (* ecdsa.PublicKey , error ) {
109
111
if kv .key .Key .X == nil || kv .key .Key .Y == nil {
110
112
return nil , fmt .Errorf ("public key is nil" )
@@ -120,12 +122,23 @@ func (kv *KeyVaultCoseSigner) PublicKey() (*ecdsa.PublicKey, error) {
120
122
return nil , fmt .Errorf ("unable to convert Y %s: %w" , * kv .key .Key .Y , err )
121
123
}
122
124
125
+ var curve elliptic.Curve
126
+
127
+ switch kv .key .Key .Crv {
128
+ case keyvault .P256 :
129
+ curve = elliptic .P256 ()
130
+ case keyvault .P384 :
131
+ curve = elliptic .P384 ()
132
+ case keyvault .P521 :
133
+ curve = elliptic .P521 ()
134
+ default :
135
+ return nil , fmt .Errorf ("failed to find ecdsa curve for public key" )
136
+ }
137
+
123
138
return & ecdsa.PublicKey {
124
- Curve : & elliptic.CurveParams {
125
- Name : "P-384" ,
126
- },
127
- X : X ,
128
- Y : Y ,
139
+ Curve : curve ,
140
+ X : X ,
141
+ Y : Y ,
129
142
}, nil
130
143
}
131
144
You can’t perform that action at this time.
0 commit comments