mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 17:48:20 +00:00
fix lint
This commit is contained in:
parent
0538e86ddd
commit
28e2ccf7e4
2 changed files with 9 additions and 22 deletions
|
@ -146,10 +146,7 @@ func (c *Client) Login(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that this Publickey that the Server gave us actually Matches our Privatekey
|
// Validate that this Publickey that the Server gave us actually Matches our Privatekey
|
||||||
randomString, err := randStringBytesRmndr(50)
|
randomString := randStringBytesRmndr(50)
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Generating Random String as PublicKey Validation Message: %w", err)
|
|
||||||
}
|
|
||||||
armor, err := helper.EncryptMessageArmored(user.GPGKey.ArmoredKey, randomString)
|
armor, err := helper.EncryptMessageArmored(user.GPGKey.ArmoredKey, randomString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Encryping PublicKey Validation Message: %w", err)
|
return fmt.Errorf("Encryping PublicKey Validation Message: %w", err)
|
||||||
|
|
26
api/misc.go
26
api/misc.go
|
@ -1,25 +1,15 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"math/rand"
|
||||||
"math/big"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func randStringBytesRmndr(length int) (string, error) {
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
result := ""
|
|
||||||
for {
|
func randStringBytesRmndr(length int) string {
|
||||||
if len(result) >= length {
|
b := make([]byte, length)
|
||||||
return result, nil
|
for i := range b {
|
||||||
}
|
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
||||||
num, err := rand.Int(rand.Reader, big.NewInt(int64(127)))
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
n := num.Int64()
|
|
||||||
// Make sure that the number/byte/letter is inside
|
|
||||||
// the range of printable ASCII characters (excluding space and DEL)
|
|
||||||
if n > 32 && n < 127 {
|
|
||||||
result += string(n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue