Validate rand key length before 3des operations

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-04-28 11:44:56 +08:00
parent 666388a5ed
commit ae847f5e29
6 changed files with 41 additions and 11 deletions
+9
View File
@@ -1,6 +1,7 @@
package session
import (
"errors"
ghomemodel "honoka-chan/internal/model/ghome"
)
@@ -37,3 +38,11 @@ func (ss *Session) SetRandKey(key string) {
return
}
}
func (ss *Session) Get3DESRandKey() ([]byte, error) {
randKey := ss.GetRandKey()
if len(randKey) < 24 {
return nil, errors.New("invalid rand key")
}
return randKey[:24], nil
}