예제 #1
0
func VerifySecret(secret uint64, req *ReuseConnReq) bool {
	content := []byte(fmt.Sprintf("%d\n%d\n%d\n", req.id, req.index, req.received))
	x := C.hash((*C.uint8_t)(&content[0]), C.int(len(content)))
	token := uint64(C.hmac(x, C.uint64_t(secret)))
	Debug("content:%s, hashkey:%x, secret:%x, token:%x, req.token:%x", string(content), uint64(x), secret, token, req.token)
	return token == req.token
}
예제 #2
0
파일: protocol.go 프로젝트: tzngit/goscon
func GenRC4Key(v1 uint64, v2 uint64, key []byte) {
	h := C.hmac(C.uint64_t(v1), C.uint64_t(v2))
	binary.LittleEndian.PutUint64(key, uint64(h))
}