Skip to content

Commit cde975d

Browse files
committed
C++: Add even more test cases.
1 parent 2f0be40 commit cde975d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-1240/tests_not_crypto.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,26 @@ void broadcastNodes(int *v) {
113113
// This function has "cast" and "des" in the name.
114114
COMPUTE(v)
115115
}
116+
117+
#define ROTATE(val, amount) ( (val << amount) | (val >> (32 - amount)) )
118+
119+
static inline void hashMix(const int *data, int &state) {
120+
// This function looks like part of a hashing function. It's not necessarily intended to
121+
// be a cryptographic hash, so should not be flagged.
122+
state ^= data[0];
123+
ROTATE(state, 1);
124+
state ^= data[1];
125+
ROTATE(state, 7);
126+
state ^= data[2];
127+
ROTATE(state, 11);
128+
state ^= data[3];
129+
ROTATE(state, 3);
130+
state ^= data[4];
131+
ROTATE(state, 13);
132+
state ^= data[5];
133+
ROTATE(state, 5);
134+
state ^= data[6];
135+
ROTATE(state, 2);
136+
state ^= data[7];
137+
ROTATE(state, 17);
138+
}

0 commit comments

Comments
 (0)