You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920
  1. package migrations
  2. import (
  3. "golang.org/x/crypto/bcrypt"
  4. )
  5. // See the v12-to-v13 schema change. The format of this hash is:
  6. // 30 bytes of global salt, 30 bytes of per-passphrase salt, then the bcrypt hash
  7. func CheckOragonoPassphraseV0(hash, passphrase []byte) error {
  8. globalSalt := hash[:30]
  9. passphraseSalt := hash[30:60]
  10. bcryptHash := hash[60:]
  11. assembledPasswordBytes := make([]byte, 0, 60+len(passphrase)+2)
  12. assembledPasswordBytes = append(assembledPasswordBytes, globalSalt...)
  13. assembledPasswordBytes = append(assembledPasswordBytes, '-')
  14. assembledPasswordBytes = append(assembledPasswordBytes, passphraseSalt...)
  15. assembledPasswordBytes = append(assembledPasswordBytes, '-')
  16. assembledPasswordBytes = append(assembledPasswordBytes, passphrase...)
  17. return bcrypt.CompareHashAndPassword(bcryptHash, assembledPasswordBytes)
  18. }