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

Баг в лекции про безопасность #15

Open
MrDjeb opened this issue Oct 31, 2023 · 0 comments
Open

Баг в лекции про безопасность #15

MrDjeb opened this issue Oct 31, 2023 · 0 comments

Comments

@MrDjeb
Copy link

MrDjeb commented Oct 31, 2023

func checkPass(passHash []byte, plainPassword string) bool {
salt := passHash[0:8]
userPassHash := hashPass(salt, plainPassword)
return bytes.Equal(userPassHash, passHash)
}

Слайс passHash меняется внутри функции hashPass(), т.к. salt получили через срез слайса passHash и он указывает на ту же память. Функция считает любые пароли равными :D

17 строчку можно заменить на:
salt := make([]byte, 8) copy(salt, passHash[:8])

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

No branches or pull requests

1 participant