Skip to content

Commit

Permalink
Use crypto.GenerateRandomBytes instead of doing it by hand
Browse files Browse the repository at this point in the history
This makes the code a bit shorter, and properly handle
cryptographic error conditions.
  • Loading branch information
jvoisin authored and fguillot committed Mar 11, 2024
1 parent 9c8a7df commit 5bcb379
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
package config // import "miniflux.app/v2/internal/config"

import (
"crypto/rand"
"fmt"
"sort"
"strings"
"time"

"miniflux.app/v2/internal/crypto"
"miniflux.app/v2/internal/version"
)

Expand Down Expand Up @@ -171,9 +171,6 @@ type Options struct {

// NewOptions returns Options with default values.
func NewOptions() *Options {
randomKey := make([]byte, 16)
rand.Read(randomKey)

return &Options{
HTTPS: defaultHTTPS,
logFile: defaultLogFile,
Expand Down Expand Up @@ -242,7 +239,7 @@ func NewOptions() *Options {
metricsPassword: defaultMetricsPassword,
watchdog: defaultWatchdog,
invidiousInstance: defaultInvidiousInstance,
proxyPrivateKey: randomKey,
proxyPrivateKey: crypto.GenerateRandomBytes(16),
webAuthn: defaultWebAuthn,
}
}
Expand Down

0 comments on commit 5bcb379

Please sign in to comment.