Browse Source

VID Hash method

V2Ray 10 years ago
parent
commit
2566fc3d14
3 changed files with 14 additions and 1 deletions
  1. 1 1
      spec/vmess.md
  2. 8 0
      vid.go
  3. 5 0
      vuserset.go

+ 1 - 1
spec/vmess.md

@@ -35,7 +35,7 @@
 数据部分
 数据部分
 * N 字节:请求数据
 * N 字节:请求数据
 
 
-其中指令部分经过 AES-128 加密,Key 为用户 VID;数据部分使用 AES-128-CBC 加密
+其中指令部分经过 AES-128 加密,Key 为 md5(用户 VID + 'PWD');数据部分使用 AES-128-CBC 加密
 
 
 ## 数据应答
 ## 数据应答
 认证部分:
 认证部分:

+ 8 - 0
vid.go

@@ -1,6 +1,7 @@
 package core
 package core
 
 
 import (
 import (
+  "crypto/md5"
 	"encoding/hex"
 	"encoding/hex"
 	"fmt"
 	"fmt"
 )
 )
@@ -8,6 +9,13 @@ import (
 // The ID of en entity, in the form of an UUID.
 // The ID of en entity, in the form of an UUID.
 type VID [16]byte
 type VID [16]byte
 
 
+func (v VID) Hash(suffix []byte) []byte {
+  md5 := md5.New()
+  md5.Write(v[:])
+  md5.Write(suffix)
+  return md5.Sum(nil)
+}
+
 var byteGroups = []int{8, 4, 4, 4, 12}
 var byteGroups = []int{8, 4, 4, 4, 12}
 
 
 // TODO: leverage a full functional UUID library
 // TODO: leverage a full functional UUID library

+ 5 - 0
vuserset.go

@@ -0,0 +1,5 @@
+package core
+
+type VUserSet struct {
+  validUserIds [][]byte
+}