-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch Fortuna with stream cipher. #1
Conversation
g.cipher.Encrypt(r[i*16:], g.counter[:]) | ||
g.increment() | ||
} | ||
type devNull struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name is cool, but in this context probably should be devZero
} | ||
|
||
func passKey(password, realm string) []byte { | ||
return pbkdf2.Key([]byte(password), []byte(realm), 4096, 32, sha256.New) | ||
} | ||
|
||
func NewDRNG(password, realm string) io.Reader { | ||
rng := &fortunaGenerator{} | ||
rng.Reseed(passKey(password, realm)) | ||
block, _ := aes.NewCipher(passKey(password, realm)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this never err?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will error if passKey returns a slice which isn't 16 or 32 bytes long.
|
||
g.buffer.Write(blocks) | ||
func (dn devNull) Read(p []byte) (n int, err error) { | ||
for i := 0; i < len(p); i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i := range p {
@@ -136,10 +53,10 @@ func NewDRNGwithSeed(password, realm string, seed []byte) (io.Reader, error) { | |||
return nil, err | |||
} | |||
|
|||
rng := &fortunaGenerator{} | |||
rng.Reseed(rngSeed) | |||
block, _ := aes.NewCipher(passKey(password, realm)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed this last time.
I guess here should be block, _ := aes.NewCipher(rngSeed)
, otherwise we are not using provided master seed.
No description provided.