Wei Dai

27 papers A 1B 2C 9Misc 4Journal 3Unranked 8
YearRankTypeTitle / Venue / Authors
2019 conf
ICCV Workshops
Dawei Du, Yue Zhang, Zexin Wang, Zhikang Wang, Zichen Song, Ziming Liu, Liefeng Bo, Hailin Shi, Rui Zhu, Aashish Kumar, Aijin Li, Almaz Zinollayev, Anuar Askergaliyev, Arne Schumann, Binjie Mao, Pengfei Zhu, Byeongwon Lee, Chang Liu, Changrui Chen, Chunhong Pan, Chunlei Huo, Da Yu, Dechun Cong, Dening Zeng, Dheeraj Reddy Pailla, Di Li, Longyin Wen, Dong Wang, Donghyeon Cho, Dongyu Zhang, Furui Bai, George Jose, Guangyu Gao, Guizhong Liu, Haitao Xiong, Hao Qi, Haoran Wang, Xiao Bian, Heqian Qiu, Hongliang Li, Huchuan Lu, Ildoo Kim, Jaekyum Kim, Jane Shen, Jihoon Lee, Jing Ge, Jingjing Xu, Jingkai Zhou, Haibin Ling, Jonas Meier, Jun Won Choi, Junhao Hu, Junyi Zhang, JunYing Huang, Kaiqi Huang, Keyang Wang, Lars Sommer, Lei Jin, Lei Zhang, Qinghua Hu, Lianghua Huang, Lin Sun, Lucas Steinmann, Meixia Jia, Nuo Xu, Pengyi Zhang, Qiang Chen, Qingxuan Lv, Qiong Liu, Qishang Cheng, Tao Peng, Sai Saketh Chennamsetty, Shuhao Chen, Shuo Wei, Srinivas S. S. Kruthiventi, Sungeun Hong, Sungil Kang, Tong Wu, Tuo Feng, Varghese Alex Kollerathu, Wanqi Li, Jiayu Zheng, Wei Dai, Weida Qin, Weiyang Wang, Xiaorui Wang, Xiaoyu Chen, Xin Chen, Xin Sun, Xin Zhang, Xin Zhao, Xindi Zhang, Xinyao Wang, Xinyu Zhang, Xuankun Chen, Xudong Wei, Xuzhang Zhang, Yanchao Li, Yifu Chen, Yu Heng Toh, Yu Zhang, Yu Zhu, Yunxin Zhong
2016 J jnl
IEEE Trans. Image Process.
Wei Dai, Gene Cheung, Ngai-Man Cheung, Antonio Ortega, Oscar C. Au
2015 J jnl
CoRR
Wei Dai, Gene Cheung, Ngai-Man Cheung, Antonio Ortega, Oscar C. Au
2014 C conf
MMSP
Luheng Jia, Oscar C. Au, Chi-Ying Tsui, Wei Dai, Pengfei Wan
2014 conf
APSIPA
Ting Sun, Pengfei Wan, Oscar C. Au, Wei Dai, Luheng Jia, Yuan Yuan, Amin Zheng, Rui Ma
2014 Misc conf
ICASSP
Wenjing Zhu, Oscar C. Au, Wei Dai, Haitao Yang, Rui Ma, Luheng Jia, Jin Zeng, Pengfei Wan
2014 Misc conf
ICASSP
Wei Dai, Oscar C. Au, Wenjing Zhu, Pengfei Wan, Wei Hu, Jiantao Zhou
2013 B conf
ICIP
Wei Dai, Oscar C. Au, Wenjing Zhu, Wei Hu, Pengfei Wan, Jiali Li
2013 conf
APSIPA
Jin Zeng, Oscar C. Au, Wei Dai, Yue Kong, Luheng Jia, Wenjing Zhu
2013 conf
ICME Workshops
Xingyu Zhang, Oscar C. Au, Chao Pang, Wei Dai, Yuanfang Guo, Lu Fang
2013 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Chao Pang, Oscar C. Au, Feng Zou, Jingjing Dai, Xingyu Zhang, Wei Dai
2013 A conf
ICME
Wei Dai, Oscar C. Au, Wenjing Zhu, Xingyu Zhang, Feng Zou, Chao Pang
2013 conf
GlobalSIP
Wenjing Zhu, Oscar C. Au, Wei Dai, Xingyu Zhang, Jiali Li, Hong Zhang
2013 C conf
MMSP
Yongfang Shi, Oscar C. Au, Hong Zhang, Xingyu Zhang, Luheng Jia, Wei Dai, Wenjing Zhu
2013 C conf
ISCAS
Ruobing Zou, Oscar C. Au, Guyue Zhou, Wei Dai, Wei Hu, Pengfei Wan
2013 B conf
ICIP
Wei Dai, Gene Cheung, Ngai-Man Cheung, Antonio Ortega, Oscar C. Au
2013 C conf
MMSP
Wei Dai, Oscar C. Au, Xing Wen, Wenjing Zhu, Feng Zou, Xingyu Zhang, Vinit Jakhetiya
2013 C conf
VCIP
Wenjing Zhu, Oscar C. Au, Haitao Yang, Wei Dai, Hong Zhang, Xingyu Zhang
2012 Misc conf
ICASSP
Wei Dai, Oscar C. Au, Chao Pang, Lin Sun, Ruobing Zou, Sijin Li
2012 C conf
VCIP
Wei Dai, Oscar C. Au, Sijin Li, Lin Sun, Ruobing Zou
2012 conf
APSIPA
Lin Sun, Oscar C. Au, Wei Dai, Yuanfang Guo, Ruobing Zou
2012 C conf
ISCAS
Wei Dai, Oscar C. Au, Sijin Li, Lin Sun, Ruobing Zou
2012 conf
APSIPA
Lin Sun, Oscar C. Au, Jiali Li, Ruobing Zou, Wei Dai
2012 C conf
MMSP
Lin Sun, Oscar C. Au, Wei Dai, Ruobing Zou, Sijin Li
2012 C conf
MMSP
Sijin Li, Oscar C. Au, Ruobing Zou, Lin Sun, Wei Dai
2011 Misc conf
ICIG
Lin Sun, Oscar C. Au, Ruobing Zou, Wei Dai, Xing Wen, Sijin Li, Jiali Li
2011 conf
PSIVT (2)
Ruobing Zou, Oscar C. Au, Lin Sun, Sijin Li, Wei Dai
tests/unit/test_decompile_utils.py
← Index tests/unit/test_decompile_utils.py python
"""Unit tests for decompiler utility modules:
- bninja/utils/hashes.py
- bninja/utils/json_encoder.py
- bninja/analysis/low_level_normalization.py
"""
import hashlib
import json
import pytest


# ============================================================================
# 1a. hashes.py
# ============================================================================

from redb.extractors.decompiler.bninja.utils.hashes import (
    calculate_md5,
    calculate_sha256,
    calculate_tlsh,
)


class TestCalculateMD5:
    def test_calculate_md5_known_value(self):
        expected = hashlib.md5(b"test").hexdigest()
        assert calculate_md5("test") == expected

    def test_calculate_md5_empty(self):
        expected = hashlib.md5(b"").hexdigest()
        assert calculate_md5("") == expected


class TestCalculateSHA256:
    def test_calculate_sha256_known_value(self):
        expected = hashlib.sha256(b"hello world").hexdigest()
        assert calculate_sha256("hello world") == expected

    def test_calculate_sha256_empty_string(self):
        result = calculate_sha256("")
        assert len(result) == 64
        assert all(c in "0123456789abcdef" for c in result)


class TestCalculateTLSH:
    def test_calculate_tlsh_long_data(self):
        # TLSH requires >= 50 bytes
        data = "A" * 100
        result = calculate_tlsh(data)
        assert result is not None
        assert isinstance(result, str)

    def test_calculate_tlsh_short_data(self):
        data = "A" * 10
        result = calculate_tlsh(data)
        assert result is None

    def test_calculate_tlsh_deterministic(self):
        data = "x" * 200
        assert calculate_tlsh(data) == calculate_tlsh(data)



# ============================================================================
# 1b. json_encoder.py
# ============================================================================

from redb.extractors.decompiler.bninja.utils.json_encoder import BinaryNinjaEncoder


class TestBinaryNinjaEncoder:
    def test_encode_value_confidence_object(self):
        obj = type("VC", (), {"value": 42, "confidence": 255})()
        result = json.dumps(obj, cls=BinaryNinjaEncoder)
        assert json.loads(result) == 42

    def test_encode_str_fallback(self):
        obj = type("Obj", (), {"__str__": lambda self: "custom_repr"})()
        result = json.dumps(obj, cls=BinaryNinjaEncoder)
        assert json.loads(result) == "custom_repr"

    def test_encode_normal_types(self):
        data = {"a": 1, "b": [2, 3], "c": "hello"}
        result = json.dumps(data, cls=BinaryNinjaEncoder)
        assert json.loads(result) == data

    def test_encode_set_via_str(self):
        # Python sets have __str__, so BinaryNinjaEncoder converts them
        # to their string repr instead of raising TypeError.
        result = json.dumps(set([1, 2, 3]), cls=BinaryNinjaEncoder)
        parsed = json.loads(result)
        assert isinstance(parsed, str)
        assert "1" in parsed


# ============================================================================
# 1c. low_level_normalization.py
# ============================================================================

from redb.extractors.decompiler.bninja.analysis.low_level_normalization import (
    LowLevelNormalization,
)


class MockIL:
    """Mock IL node for normalization tests."""
    def __init__(self, operation, operands=None):
        self.operation = operation
        self.operands = operands or []


class TestLowLevelNormalization:
    def setup_method(self):
        self.normalizer = LowLevelNormalization()

    def test_normalize_single_instruction(self):
        node = MockIL(operation=5)
        result = self.normalizer.normalize_instruction_all_levels(node)
        assert result == [5]

    def test_normalize_nested_operands(self):
        child1 = MockIL(operation=10)
        child2 = MockIL(operation=20)
        root = MockIL(operation=1, operands=[child1, child2])
        result = self.normalizer.normalize_instruction_all_levels(root)
        assert result == [1, 10, 20]

    def test_normalize_empty_operands(self):
        node = MockIL(operation=42, operands=[])
        result = self.normalizer.normalize_instruction_all_levels(node)
        assert result == [42]

    def test_normalize_list_operands(self):
        # Simulates phi-node style list operands
        inner = MockIL(operation=99)
        node = MockIL(operation=7, operands=[[inner]])
        result = self.normalizer.normalize_instruction_all_levels(node)
        assert result == [7, 99]

    def test_normalize_none_input(self):
        result = self.normalizer.normalize_instruction_all_levels(None)
        assert result == []