diff options
author | Yawning Angel <yawning@torproject.org> | 2014-08-23 05:33:23 +0000 |
---|---|---|
committer | Yawning Angel <yawning@torproject.org> | 2014-08-23 05:33:23 +0000 |
commit | 1e574942d586bb26f659f9ebee9ec90d778ecb97 (patch) | |
tree | 57fc5d280550da67d710c1dd0a3740a6274f73d0 /common/drbg | |
parent | 596cc8507340a1233defe5bf88e6e2a400cc7f9f (diff) |
Change all the arguments to use base16 from base64.
WARNING: THIS BREAKS BACKWARD COMPATIBILITY.
This is primarily to work around bug #12930. Base16 was chosen over
unpadded Base64 because the go runtime Base64 decoder does not handle
omitting the padding.
May $deity have mercy on anyone who needs to hand-enter an obfs4 bridge
line because I will not.
Diffstat (limited to 'common/drbg')
-rw-r--r-- | common/drbg/hash_drbg.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/common/drbg/hash_drbg.go b/common/drbg/hash_drbg.go index 5329828..2cd1ec7 100644 --- a/common/drbg/hash_drbg.go +++ b/common/drbg/hash_drbg.go @@ -30,7 +30,7 @@ package drbg import ( - "encoding/base64" + "encoding/hex" "encoding/binary" "fmt" "hash" @@ -55,9 +55,9 @@ func (seed *Seed) Bytes() *[SeedLength]byte { return (*[SeedLength]byte)(seed) } -// Base64 returns the Base64 representation of the seed. -func (seed *Seed) Base64() string { - return base64.StdEncoding.EncodeToString(seed.Bytes()[:]) +// Hex returns the hexdecimal representation of the seed. +func (seed *Seed) Hex() string { + return hex.EncodeToString(seed.Bytes()[:]) } // NewSeed returns a Seed initialized with the runtime CSPRNG. @@ -83,11 +83,11 @@ func SeedFromBytes(src []byte) (seed *Seed, err error) { return } -// SeedFromBase64 creates a Seed from the Base64 representation, truncating to +// SeedFromHex creates a Seed from the hexdecimal representation, truncating to // SeedLength as appropriate. -func SeedFromBase64(encoded string) (seed *Seed, err error) { +func SeedFromHex(encoded string) (seed *Seed, err error) { var raw []byte - if raw, err = base64.StdEncoding.DecodeString(encoded); err != nil { + if raw, err = hex.DecodeString(encoded); err != nil { return nil, err } |