/* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2 . 0 . If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This file tests the md4.c implementation.
#include "gtest/gtest.h"
#include "md4.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Casting.h"
struct RFC1320TestParams {
const char * data;
const uint8_t expectedHash[
16 ];
};
static const RFC1320TestParams RFC1320_TEST_PARAMS[] = {
{
"" ,
{
0 x31,
0 xd6,
0 xcf,
0 xe0,
0 xd1,
0 x6a,
0 xe9,
0 x31,
0 xb7,
0 x3c,
0 x59,
0 xd7,
0 xe0,
0 xc0,
0 x89,
0 xc0}},
{
"a" ,
{
0 xbd,
0 xe5,
0 x2c,
0 xb3,
0 x1d,
0 xe3,
0 x3e,
0 x46,
0 x24,
0 x5e,
0 x05,
0 xfb,
0 xdb,
0 xd6,
0 xfb,
0 x24}},
{
"abc" ,
{
0 xa4,
0 x48,
0 x01,
0 x7a,
0 xaf,
0 x21,
0 xd8,
0 x52,
0 x5f,
0 xc1,
0 x0a,
0 xe8,
0 x7a,
0 xa6,
0 x72,
0 x9d}},
{
"message digest" ,
{
0 xd9,
0 x13,
0 x0a,
0 x81,
0 x64,
0 x54,
0 x9f,
0 xe8,
0 x18,
0 x87,
0 x48,
0 x06,
0 xe1,
0 xc7,
0 x01,
0 x4b}},
{
"abcdefghijklmnopqrstuvwxyz" ,
{
0 xd7,
0 x9e,
0 x1c,
0 x30,
0 x8a,
0 xa5,
0 xbb,
0 xcd,
0 xee,
0 xa8,
0 xed,
0 x63,
0 xdf,
0 x41,
0 x2d,
0 xa9},
},
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ,
{
0 x04,
0 x3f,
0 x85,
0 x82,
0 xf2,
0 x41,
0 xdb,
0 x35,
0 x1c,
0 xe6,
0 x27,
0 xe1,
0 x53,
0 xe7,
0 xf0,
0 xe4},
},
{
"1234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890" ,
{
0 xe3,
0 x3b,
0 x4d,
0 xdc,
0 x9c,
0 x38,
0 xf2,
0 x19,
0 x9c,
0 x3e,
0 x7b,
0 x16,
0 x4f,
0 xcc,
0 x05,
0 x36},
}};
class psm_MD4 : public ::testing::Test,
public ::testing::WithParamInterface<RFC1320TestParams> {};
TEST_P(psm_MD4, RFC1320TestValues) {
const RFC1320TestParams& params(GetParam());
uint8_t actualHash[
16 ];
md4sum(mozilla::BitwiseCast<
const uint8_t*,
const char *>(params.data),
strlen(params.data), actualHash);
EXPECT_TRUE(mozilla::ArrayEqual(actualHash, params.expectedHash))
<<
"MD4 hashes aren't equal for input: '" << params.data <<
"'" ;
}
INSTANTIATE_TEST_SUITE_P(psm_MD4, psm_MD4,
testing::ValuesIn(RFC1320_TEST_PARAMS));
Messung V0.5 in Prozent C=93 H=93 G=92
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-08-25)
¤
*© Formatika GbR, Deutschland