Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix golangci-lint warnings #214

Merged
merged 4 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion provider/apple_pubkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type appleKeySet struct {

// get return Apple public key with specific KeyID (kid)
func (aks *appleKeySet) get(kid string) (keys *applePublicKey, err error) {
if aks.keys == nil || len(aks.keys) == 0 {
if len(aks.keys) == 0 {
return nil, fmt.Errorf("failed to get key in appleKeySet, key set is nil or empty")
}

Expand Down
8 changes: 4 additions & 4 deletions provider/apple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"crypto/rsa"
"crypto/sha1"
"encoding/base64"
"encoding/binary"
"encoding/json"
"fmt"
"io"
"log"
"math/big"
"net/http"
"net/http/cookiejar"
"net/url"
Expand Down Expand Up @@ -659,8 +659,8 @@ ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy
n := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(publicKey.N.Bytes())

// convert exponent
eBuff := make([]byte, 4)
binary.LittleEndian.PutUint32(eBuff, uint32(publicKey.E))
require.Positive(t, publicKey.E, "RSA exponent must be positive")
eBuff := big.NewInt(int64(publicKey.E)).Bytes()
e := base64.StdEncoding.WithPadding(base64.NoPadding).EncodeToString(eBuff)

JWK := struct {
Expand All @@ -670,7 +670,7 @@ ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy
Kid string `json:"kid"`
E string `json:"e"`
N string `json:"n"`
}{Alg: "RS256", Kty: "RSA", Use: "sig", Kid: "112233", N: n, E: e[:4]}
}{Alg: "RS256", Kty: "RSA", Use: "sig", Kid: "112233", N: n, E: e}

var buffJwk []byte
buffJwk, err = json.Marshal(JWK)
Expand Down
2 changes: 1 addition & 1 deletion v2/provider/apple_pubkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type appleKeySet struct {

// get return Apple public key with specific KeyID (kid)
func (aks *appleKeySet) get(kid string) (keys *applePublicKey, err error) {
if aks.keys == nil || len(aks.keys) == 0 {
if len(aks.keys) == 0 {
return nil, fmt.Errorf("failed to get key in appleKeySet, key set is nil or empty")
}

Expand Down
8 changes: 4 additions & 4 deletions v2/provider/apple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"crypto/rsa"
"crypto/sha1"
"encoding/base64"
"encoding/binary"
"encoding/json"
"fmt"
"io"
"log"
"math/big"
"net/http"
"net/http/cookiejar"
"net/url"
Expand Down Expand Up @@ -659,8 +659,8 @@ ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy
n := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(publicKey.N.Bytes())

// convert exponent
eBuff := make([]byte, 4)
binary.LittleEndian.PutUint32(eBuff, uint32(publicKey.E))
require.Positive(t, publicKey.E, "RSA exponent must be positive")
eBuff := big.NewInt(int64(publicKey.E)).Bytes()
e := base64.StdEncoding.WithPadding(base64.NoPadding).EncodeToString(eBuff)

JWK := struct {
Expand All @@ -670,7 +670,7 @@ ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy
Kid string `json:"kid"`
E string `json:"e"`
N string `json:"n"`
}{Alg: "RS256", Kty: "RSA", Use: "sig", Kid: "112233", N: n, E: e[:4]}
}{Alg: "RS256", Kty: "RSA", Use: "sig", Kid: "112233", N: n, E: e}

var buffJwk []byte
buffJwk, err = json.Marshal(JWK)
Expand Down
Loading