mirror of
https://github.com/go-gitea/gitea
synced 2024-09-12 09:26:56 +02:00
Replace deprecated elliptic.Marshal
(#26800)
In PR #26786, the Go version for golangci-lint is bumped to 1.21. This causes the following error: ``` models/migrations/v1_16/v210.go:132:23: SA1019: elliptic.Marshal has been deprecated since Go 1.21: for ECDH, use the crypto/ecdh package. This function returns an encoding equivalent to that of PublicKey.Bytes in crypto/ecdh. (staticcheck) PublicKey: elliptic.Marshal(elliptic.P256(), parsed.PubKey.X, parsed.PubKey.Y), ``` The change now uses [func (*PublicKey) ECDH](https://pkg.go.dev/crypto/ecdsa#PublicKey.ECDH), which is added in Go 1.20.
This commit is contained in:
parent
438c7642c7
commit
2d9249b6d9
@ -4,7 +4,6 @@
|
|||||||
package v1_16 //nolint
|
package v1_16 //nolint
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/elliptic"
|
|
||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
@ -123,13 +122,17 @@ func RemigrateU2FCredentials(x *xorm.Engine) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
pubKey, err := parsed.PubKey.ECDH()
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
remigrated := &webauthnCredential{
|
remigrated := &webauthnCredential{
|
||||||
ID: reg.ID,
|
ID: reg.ID,
|
||||||
Name: reg.Name,
|
Name: reg.Name,
|
||||||
LowerName: strings.ToLower(reg.Name),
|
LowerName: strings.ToLower(reg.Name),
|
||||||
UserID: reg.UserID,
|
UserID: reg.UserID,
|
||||||
CredentialID: base32.HexEncoding.EncodeToString(parsed.KeyHandle),
|
CredentialID: base32.HexEncoding.EncodeToString(parsed.KeyHandle),
|
||||||
PublicKey: elliptic.Marshal(elliptic.P256(), parsed.PubKey.X, parsed.PubKey.Y),
|
PublicKey: pubKey.Bytes(),
|
||||||
AttestationType: "fido-u2f",
|
AttestationType: "fido-u2f",
|
||||||
AAGUID: []byte{},
|
AAGUID: []byte{},
|
||||||
SignCount: reg.Counter,
|
SignCount: reg.Counter,
|
||||||
|
Loading…
Reference in New Issue
Block a user