Skip to content
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

Merged
merged 1 commit into from
Nov 21, 2016
Merged

Switch Fortuna with stream cipher. #1

merged 1 commit into from
Nov 21, 2016

Conversation

Bren2010
Copy link
Contributor

No description provided.

g.cipher.Encrypt(r[i*16:], g.counter[:])
g.increment()
}
type devNull struct{}
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this never err?

Copy link
Contributor Author

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++ {
Copy link
Contributor

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))
Copy link
Contributor

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.

@ignatk ignatk merged commit 53d0627 into cloudflare:master Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants