Skip to content

Commit

Permalink
Merge pull request #214 from cyb3r4nt/fix-golangci-lint-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun authored Aug 31, 2024
2 parents 34ded9b + 551c128 commit fa44af5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
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

0 comments on commit fa44af5

Please sign in to comment.