mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Move crypto/random to rng
This commit is contained in:
parent
7c9065b8fa
commit
099a597be9
15 changed files with 22 additions and 20 deletions
|
@ -1,7 +0,0 @@
|
||||||
// Package random provides a feedable CSPRNG.
|
|
||||||
//
|
|
||||||
// CSPRNG used is fortuna: github.com/seehuhn/fortuna
|
|
||||||
// By default the CSPRNG is fed by two sources:
|
|
||||||
// - OS RNG
|
|
||||||
// - Entropy gathered by context switching
|
|
||||||
package random
|
|
9
rng/doc.go
Normal file
9
rng/doc.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// Package rng provides a feedable CSPRNG.
|
||||||
|
//
|
||||||
|
// CSPRNG used is fortuna: github.com/seehuhn/fortuna
|
||||||
|
// By default the CSPRNG is fed by two sources:
|
||||||
|
// - It starts with a seed from `crypto/rand` and periodically reseeds from there
|
||||||
|
// - A really simple tickfeeder which extracts entropy from the internal go scheduler using goroutines and is meant to be used under load.
|
||||||
|
//
|
||||||
|
// The RNG can also be easily fed with additional sources.
|
||||||
|
package rng
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/safing/portbase/crypto/random"
|
"github.com/safing/portbase/rng"
|
||||||
)
|
)
|
||||||
|
|
||||||
func noise() {
|
func noise() {
|
||||||
|
@ -55,13 +55,13 @@ func main() {
|
||||||
switch os.Args[1] {
|
switch os.Args[1] {
|
||||||
case "fortuna":
|
case "fortuna":
|
||||||
|
|
||||||
err := random.Start()
|
err := rng.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
b, err := random.Bytes(64)
|
b, err := rng.Bytes(64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package random
|
package rng
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
Loading…
Add table
Reference in a new issue