Lines Matching full:hash
3 * Test cases for hash functions, including a benchmark. This is included by
99 * Test the hash function against a list of test vectors.
114 HASH(test_buf, data_len, actual_hash); in test_hash_test_vectors()
123 * Test that the hash function produces correct results for *every* length up to
124 * 4096 bytes. To do this, generate seeded random data, then calculate a hash
125 * value for each length 0..4096, then hash the hash values. Verify just the
126 * final hash value, which should match only when all hash values were correct.
131 u8 hash[HASH_SIZE]; in test_hash_all_lens_up_to_4096() local
137 HASH(test_buf, len, hash); in test_hash_all_lens_up_to_4096()
138 HASH_UPDATE(&ctx, hash, HASH_SIZE); in test_hash_all_lens_up_to_4096()
140 HASH_FINAL(&ctx, hash); in test_hash_all_lens_up_to_4096()
141 KUNIT_ASSERT_MEMEQ(test, hash, hash_testvec_consolidated, HASH_SIZE); in test_hash_all_lens_up_to_4096()
145 * Test that the hash function produces the same result with a one-shot
162 /* Compute the hash value in one shot. */ in test_hash_incremental_updates()
163 HASH(&test_buf[offset], total_len, hash1); in test_hash_incremental_updates()
166 * Compute the hash value incrementally, using a randomly in test_hash_incremental_updates()
186 /* Verify that the two hash values are the same. */ in test_hash_incremental_updates()
195 * Test that the hash function does not overrun any buffers. Uses a guard page
209 u8 hash[HASH_SIZE]; in test_hash_buffer_overruns() local
212 HASH(buf_end - len, len, hash); in test_hash_buffer_overruns()
215 HASH_FINAL(&ctx, hash); in test_hash_buffer_overruns()
217 /* Check for overruns of the hash value buffer. */ in test_hash_buffer_overruns()
218 HASH(test_buf, len, buf_end - HASH_SIZE); in test_hash_buffer_overruns()
223 /* Check for overuns of the hash context. */ in test_hash_buffer_overruns()
226 HASH_FINAL(guarded_ctx, hash); in test_hash_buffer_overruns()
238 u8 hash[HASH_SIZE]; in test_hash_overlaps() local
249 HASH(&test_buf[offset], len, hash); in test_hash_overlaps()
250 HASH(&test_buf[offset], len, ovl_hash); in test_hash_overlaps()
252 test, hash, ovl_hash, HASH_SIZE, in test_hash_overlaps()
257 HASH(&test_buf[offset], len, hash); in test_hash_overlaps()
262 test, hash, ovl_hash, HASH_SIZE, in test_hash_overlaps()
267 HASH(&test_buf[offset], len, hash); in test_hash_overlaps()
273 test, hash, ovl_hash, HASH_SIZE, in test_hash_overlaps()
296 HASH(&test_buf[data_offs1], len, &hash1[hash_offs1]); in test_hash_alignment_consistency()
298 HASH(&test_buf[data_offs2], len, &hash2[hash_offs2]); in test_hash_alignment_consistency()
317 "Hash context was not zeroized by finalization"); in test_hash_ctx_zeroization()
329 * Compute the hash of one of the test messages and verify that it matches the
330 * expected hash from @state->expected_hashes. To increase the chance of
339 HASH(&test_buf[i * IRQ_TEST_DATA_LEN], IRQ_TEST_DATA_LEN, actual_hash); in hash_irq_test1_func()
351 /* Prepare some test messages and compute the expected hash of each. */ in test_hash_interrupt_context_1()
354 HASH(&test_buf[i * IRQ_TEST_DATA_LEN], IRQ_TEST_DATA_LEN, in test_hash_interrupt_context_1()
424 * can detect, this test case can also detect bugs where hash function
436 HASH(test_buf, TEST_BUF_LEN, state->expected_hash); in test_hash_interrupt_context_2()
474 * the underlying unkeyed hash function, which is already well-tested by the
505 * up to 293, which is somewhat larger than the largest hash in test_hmac()
536 /* Benchmark the hash function on various data lengths. */
543 u8 hash[HASH_SIZE]; in benchmark_hash() local
550 HASH(test_buf, TEST_BUF_LEN, hash); in benchmark_hash()
562 HASH(test_buf, len, hash); in benchmark_hash()