Skip to content

Commit

Permalink
chore: update kerberos key derivation to reduce allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfendale committed Jul 5, 2024
1 parent abfca9a commit ad488be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,14 @@ func NewKerberosTicketInternalData(server *PRUDPServer) *KerberosTicketInternalD

// DeriveKerberosKey derives a users kerberos encryption key based on their PID and password
func DeriveKerberosKey(pid *types.PID, password []byte) []byte {
key := password
iterationCount := 65000 + pid.Value()%1024
key := make([]byte, md5.Size)
copy(key, password)

for i := 0; i < 65000+int(pid.Value())%1024; i++ {
var i uint64 = 0
for ; i < iterationCount; i++ {
hash := md5.Sum(key)
key = hash[:]
copy(key, hash[:])
}

return key
Expand Down

0 comments on commit ad488be

Please sign in to comment.