mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 12:41:53 +08:00
refactor: mylib 重命名为 libs
更清晰的目录命名,libs/ 存放内嵌的独立协议实现库。
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package sec
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/shadow1ng/fscan/libs/grdp/glog"
|
||||
"github.com/shadow1ng/fscan/libs/grdp/protocol/t125/gcc"
|
||||
)
|
||||
|
||||
func TestGenerateKeysRejectsShortRandoms(t *testing.T) {
|
||||
glog.SetLevel(glog.NONE)
|
||||
|
||||
clientRandom := make([]byte, 32)
|
||||
serverRandom := make([]byte, 32)
|
||||
|
||||
if _, _, _, err := generateKeys(clientRandom, nil, gcc.ENCRYPTION_FLAG_128BIT); err == nil {
|
||||
t.Fatal("expected error for empty server random")
|
||||
}
|
||||
|
||||
if _, _, _, err := generateKeys(nil, serverRandom, gcc.ENCRYPTION_FLAG_128BIT); err == nil {
|
||||
t.Fatal("expected error for empty client random")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateKeysAcceptsValidRandoms(t *testing.T) {
|
||||
glog.SetLevel(glog.NONE)
|
||||
|
||||
clientRandom := make([]byte, 32)
|
||||
serverRandom := make([]byte, 32)
|
||||
|
||||
macKey, decryptKey, encryptKey, err := generateKeys(clientRandom, serverRandom, gcc.ENCRYPTION_FLAG_128BIT)
|
||||
if err != nil {
|
||||
t.Fatalf("generateKeys returned error for valid randoms: %v", err)
|
||||
}
|
||||
if len(macKey) != 16 || len(decryptKey) != 16 || len(encryptKey) != 16 {
|
||||
t.Fatalf("unexpected key lengths: mac=%d decrypt=%d encrypt=%d", len(macKey), len(decryptKey), len(encryptKey))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user