make key type deterministic with seed
This commit is contained in:
parent
da712abbb2
commit
bc7e9740d8
|
@ -41,13 +41,18 @@ func getOpts(r *http.Request) (*options, error) {
|
|||
seed, _ = binary.ReadVarint(bytes.NewReader(b[0:8]))
|
||||
}
|
||||
|
||||
var n int
|
||||
if 0 != seed {
|
||||
rndReader = rand.New(rand.NewSource(seed))
|
||||
rnd := rand.New(rand.NewSource(seed))
|
||||
rndReader = rnd
|
||||
n = rnd.Intn(2)
|
||||
} else {
|
||||
n = rand.Intn(2)
|
||||
}
|
||||
|
||||
kty, _ := tok["kty"].(string)
|
||||
if "" == kty {
|
||||
if 0 == rand.Intn(2) {
|
||||
if 0 == n {
|
||||
kty = "RSA"
|
||||
} else {
|
||||
kty = "EC"
|
||||
|
|
|
@ -121,7 +121,7 @@ func TestGenWithSeed(t *testing.T) {
|
|||
res, err := client.Do(&http.Request{
|
||||
Method: "POST",
|
||||
URL: urlstr,
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"seed":"test"}`))),
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"seed":"c"}`))),
|
||||
})
|
||||
if nil != err {
|
||||
//t.Fatal(err)
|
||||
|
@ -141,7 +141,7 @@ func TestGenWithSeed(t *testing.T) {
|
|||
res, err = client.Do(&http.Request{
|
||||
Method: "POST",
|
||||
URL: urlstr,
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"seed":"test"}`))),
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"seed":"c"}`))),
|
||||
})
|
||||
if nil != err {
|
||||
//t.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue