Add support for ShangMi SM2 Public Key
osvalban opened this issue · comments
Hello,
Abstract
https://github.com/emmansun/gmsm provides Golang implementations for Chinese crypto standards. In particular, it would be great to accept ShangMi SM2 Public Key (based on ecdsa) for generation of JWKs by this library.
Describe the proposed solution/change
package main
import (
"crypto/rand"
"fmt"
"github.com/emmansun/gmsm/sm2"
"github.com/lestrrat-go/jwx/jwk"
)
func main() {
shangmi2pk, _ := sm2.GenerateKey(rand.Reader)
_, err := jwk.New(shangmi2pk.Public())
fmt.Println(err)
}
failed to initialize *jwk.ecdsaPublicKey from *ecdsa.PublicKey: invalid elliptic curve &{%!s(func() *sm2ec.SM2P256Point=0x4c9a80) %!s(*elliptic.CurveParams=&{0xc0000c8060 0xc0000c80a0 0xc0000c80e0 0xc0000c8120 0xc0000c8160 256 sm2p256v1})}
Analysis
ecutil.go mentions algorithms may be compiled in/out. If you could advise how to add on a compatible elliptic curve, that could also help.
Thank you.
That's actually something I'm trying to smooth out in #969 (related: #912)
You can actually register keys as it is, but EC keys are turning out to be a pain because of the conversion between strings and elliptic.Curve or similar (there's also the confusing reality of having to represent ed25519 curves in a sane manner). As of now I don't have a good answer. If you are curious, you could take a look at the internals and let me know if you have ideas.
I'm currently distracted by other things in life, so while I do intend to work on it, I can't give you a timeline if it's just me working on it.
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Removing stale label. We'll probably allow this to happen when v3 comes out