-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54cb51e
commit 31e4b4b
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pearl | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGenerateCircID2(t *testing.T) { | ||
f := CircID2Format{} | ||
assert.Equal(t, CircID(0), GenerateCircID(f, 0)>>15) | ||
assert.Equal(t, CircID(1), GenerateCircID(f, 1)>>15) | ||
} | ||
|
||
func TestGenerateCircID4(t *testing.T) { | ||
f := CircID4Format{} | ||
assert.Equal(t, CircID(0), GenerateCircID(f, 0)>>31) | ||
assert.Equal(t, CircID(1), GenerateCircID(f, 1)>>31) | ||
} | ||
|
||
func TestGenerateCircID4Rand(t *testing.T) { | ||
f := CircID4Format{} | ||
assert.NotEqual(t, GenerateCircID(f, 0), GenerateCircID(f, 0)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Package torcrypto provides cryptographic functions useful in tor. | ||
package torcrypto | ||
|
||
import "crypto/rand" | ||
|
||
// Rand generates n bytes of cryptographic random. Panics if the read fails. | ||
func Rand(n int) []byte { | ||
x := make([]byte, n) | ||
_, err := rand.Read(x) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return x | ||
} |
This file was deleted.
Oops, something went wrong.