mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Replace crypto/rand with internal rand package
PiperOrigin-RevId: 200784607 Change-Id: I39aa6ee632936dcbb00fc298adccffa606e9f4c0
This commit is contained in:
@@ -11,6 +11,7 @@ go_library(
|
||||
],
|
||||
importpath = "gvisor.googlesource.com/gvisor/pkg/dhcp",
|
||||
deps = [
|
||||
"//pkg/rand",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/network/ipv4",
|
||||
"//pkg/tcpip/stack",
|
||||
|
||||
+1
-1
@@ -7,12 +7,12 @@ package dhcp
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/network/ipv4"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/stack"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package(licenses = ["notice"]) # Apache 2.0
|
||||
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "rand",
|
||||
srcs = ["rand.go"],
|
||||
importpath = "gvisor.googlesource.com/gvisor/pkg/rand",
|
||||
visibility = ["//:sandbox"],
|
||||
deps = ["@org_golang_x_sys//unix:go_default_library"],
|
||||
)
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2018 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package rand implements a cryptographically secure pseudorandom number
|
||||
// generator.
|
||||
package rand
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// reader implements an io.Reader that returns pseudorandom bytes.
|
||||
type reader struct{}
|
||||
|
||||
// Read implements io.Reader.Read.
|
||||
func (reader) Read(p []byte) (int, error) {
|
||||
return unix.Getrandom(p, 0)
|
||||
}
|
||||
|
||||
// Reader is the default reader.
|
||||
var Reader io.Reader = reader{}
|
||||
|
||||
// Read reads from the default reader.
|
||||
func Read(b []byte) (int, error) {
|
||||
return io.ReadFull(Reader, b)
|
||||
}
|
||||
@@ -33,6 +33,7 @@ go_library(
|
||||
"//pkg/abi/linux",
|
||||
"//pkg/amutex",
|
||||
"//pkg/log",
|
||||
"//pkg/rand",
|
||||
"//pkg/sentry/context",
|
||||
"//pkg/sentry/device",
|
||||
"//pkg/sentry/fs",
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
package dev
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/fs/ramfs"
|
||||
|
||||
@@ -39,6 +39,7 @@ go_library(
|
||||
"//pkg/binary",
|
||||
"//pkg/cpuid",
|
||||
"//pkg/log",
|
||||
"//pkg/rand",
|
||||
"//pkg/refs",
|
||||
"//pkg/sentry/arch",
|
||||
"//pkg/sentry/context",
|
||||
|
||||
@@ -17,13 +17,13 @@ package loader
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"path"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/abi"
|
||||
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
|
||||
"gvisor.googlesource.com/gvisor/pkg/cpuid"
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
|
||||
|
||||
@@ -70,6 +70,7 @@ go_library(
|
||||
"//pkg/eventchannel",
|
||||
"//pkg/log",
|
||||
"//pkg/metric",
|
||||
"//pkg/rand",
|
||||
"//pkg/sentry/arch",
|
||||
"//pkg/sentry/context",
|
||||
"//pkg/sentry/fs",
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"math"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/kernel"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sentry/safemem"
|
||||
|
||||
@@ -7,5 +7,8 @@ go_library(
|
||||
srcs = ["hash.go"],
|
||||
importpath = "gvisor.googlesource.com/gvisor/pkg/tcpip/network/hash",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//pkg/tcpip/header"],
|
||||
deps = [
|
||||
"//pkg/rand",
|
||||
"//pkg/tcpip/header",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package hash
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
|
||||
)
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ go_library(
|
||||
importpath = "gvisor.googlesource.com/gvisor/pkg/tcpip/transport/tcp",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/rand",
|
||||
"//pkg/sleep",
|
||||
"//pkg/state",
|
||||
"//pkg/tcpip",
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"encoding/binary"
|
||||
"hash"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/rand"
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
|
||||
|
||||
Reference in New Issue
Block a user