1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
21 #include <cppunit/TestAssert.h>
22 #include <cppunit/TestFixture.h>
23 #include <cppunit/extensions/HelperMacros.h>
24 #include <cppunit/plugin/TestPlugIn.h>
27 #include <string_view>
29 #include <rtl/digest.h>
30 #include <rtl/string.h>
31 #include <rtl/ustring.hxx>
32 #include <rtl/ustrbuf.hxx>
33 #include <rtl/strbuf.hxx>
42 constexpr OStringLiteral
sSampleString ("This is a sample sentence, which we use to check some crypto functions in sal.");
43 constexpr OStringLiteral
sSampleString_only_one_diff ("This is a sample sentence. which we use to check some crypto functions in sal.");
45 const rtlDigestAlgorithm constDigestAlgorithms
[] =
47 rtl_Digest_AlgorithmMD2
,
48 rtl_Digest_AlgorithmMD5
,
49 rtl_Digest_AlgorithmSHA
,
50 rtl_Digest_AlgorithmSHA1
,
51 rtl_Digest_AlgorithmHMAC_MD5
,
52 rtl_Digest_AlgorithmHMAC_SHA1
,
55 const sal_uInt32 constDigestAlgorithmLengths
[] =
57 RTL_DIGEST_LENGTH_MD2
,
58 RTL_DIGEST_LENGTH_MD5
,
59 RTL_DIGEST_LENGTH_SHA
,
60 RTL_DIGEST_LENGTH_SHA1
,
61 RTL_DIGEST_LENGTH_HMAC_MD5
,
62 RTL_DIGEST_LENGTH_HMAC_SHA1
,
65 const std::string_view constSampleStringSums
[] =
67 std::string_view("647ee6c9d4aa5fdd374ed9d7a156acbf"),
68 std::string_view("b16b903e6fc0b62ae389013ed93fe531"),
69 std::string_view("eab2814429b2613301c8a077b806af3680548914"),
70 std::string_view("2bc5bdb7506a2cdc2fd27fc8b9889343012d5008"),
71 std::string_view("0b1b0e1a6f2e4420326354b031063605"),
72 std::string_view("1998c6a556915be76451bfb587fa7c34d849936e")
75 // Create hex-value string from the digest value to keep the string size minimal
76 OString
createHex(const sal_uInt8
* pKeyBuffer
, sal_uInt32 nKeyLen
)
78 OStringBuffer
aBuffer(nKeyLen
* 2 + 1);
79 for (sal_uInt32 i
= 0; i
< nKeyLen
; ++i
)
81 sal_Int32 nValue
= static_cast<sal_Int32
>(pKeyBuffer
[i
]);
84 aBuffer
.append(nValue
, 16);
86 return aBuffer
.makeStringAndClear();
89 OString
getDigest(const OString
& aMessage
, rtlDigestAlgorithm aAlgorithm
)
91 rtlDigest handle
= rtl_digest_create(aAlgorithm
);
93 const sal_uInt8
* pData
= reinterpret_cast<const sal_uInt8
*>(aMessage
.getStr());
94 sal_uInt32 nSize
= aMessage
.getLength();
96 rtl_digest_init(handle
, pData
, nSize
);
97 rtl_digest_update(handle
, pData
, nSize
);
99 sal_uInt32 nKeyLen
= rtl_digest_queryLength(handle
);
100 std::unique_ptr
<sal_uInt8
[]> pKeyBuffer(new sal_uInt8
[nKeyLen
]);
102 rtl_digest_get(handle
, pKeyBuffer
.get(), nKeyLen
);
103 OString aSum
= createHex(pKeyBuffer
.get(), nKeyLen
);
105 rtl_digest_destroy( handle
);
109 class DigestTest
: public CppUnit::TestFixture
114 for (size_t i
= 0; i
< SAL_N_ELEMENTS(constDigestAlgorithms
); i
++)
116 rtlDigest handle
= rtl_digest_create( constDigestAlgorithms
[i
] );
117 CPPUNIT_ASSERT_MESSAGE("create digest", handle
!= nullptr);
118 rtl_digest_destroy( handle
);
121 rtlDigest handle
= rtl_digest_create( rtl_Digest_AlgorithmInvalid
);
122 CPPUNIT_ASSERT_EQUAL_MESSAGE("create invalid digest", static_cast<rtlDigest
>(nullptr), handle
);
123 rtl_digest_destroy( handle
);
128 for (size_t i
= 0; i
< SAL_N_ELEMENTS(constDigestAlgorithms
); i
++)
130 rtlDigest handle
= rtl_digest_create(constDigestAlgorithms
[i
]);
131 rtlDigestAlgorithm aAlgo
= rtl_digest_queryAlgorithm(handle
);
132 CPPUNIT_ASSERT_EQUAL_MESSAGE("query handle", aAlgo
, constDigestAlgorithms
[i
]);
133 rtl_digest_destroy( handle
);
138 void testQueryLength()
141 sal_uInt32 nAlgoLength
;
143 for (size_t i
= 0; i
< SAL_N_ELEMENTS(constDigestAlgorithms
); i
++)
145 handle
= rtl_digest_create(constDigestAlgorithms
[i
]);
146 nAlgoLength
= rtl_digest_queryLength(handle
);
147 CPPUNIT_ASSERT_EQUAL_MESSAGE("query Length", nAlgoLength
, constDigestAlgorithmLengths
[i
]);
148 rtl_digest_destroy( handle
);
151 handle
= rtl_digest_create( rtl_Digest_AlgorithmInvalid
);
152 nAlgoLength
= rtl_digest_queryLength(handle
);
153 CPPUNIT_ASSERT_EQUAL_MESSAGE("query length", static_cast<sal_uInt32
>(0), nAlgoLength
);
154 rtl_digest_destroy( handle
);
159 rtlDigestError aError
;
163 aError
= rtl_digest_init(handle
, nullptr, 0);
164 CPPUNIT_ASSERT_EQUAL_MESSAGE("init(NULL, 0, 0)", rtl_Digest_E_Argument
, aError
);
166 handle
= rtl_digest_create( rtl_Digest_AlgorithmMD5
);
167 aError
= rtl_digest_init(handle
, nullptr, 0);
168 CPPUNIT_ASSERT_EQUAL_MESSAGE("init(handle, 0, 0)", rtl_Digest_E_None
, aError
);
169 rtl_digest_destroy( handle
);
171 for (size_t i
= 0; i
< SAL_N_ELEMENTS(constDigestAlgorithms
); i
++)
173 handle
= rtl_digest_create(constDigestAlgorithms
[i
]);
175 OString aMessage
= sSampleString
;
176 const sal_uInt8
* pData
= reinterpret_cast<const sal_uInt8
*>(aMessage
.getStr());
177 sal_uInt32 nSize
= aMessage
.getLength();
179 aError
= rtl_digest_init(handle
, pData
, nSize
);
180 CPPUNIT_ASSERT_EQUAL_MESSAGE("init(handle, pData, nSize)", rtl_Digest_E_None
, aError
);
182 rtl_digest_update(handle
, pData
, nSize
);
184 sal_uInt32 nKeyLen
= rtl_digest_queryLength( handle
);
185 std::unique_ptr
<sal_uInt8
[]> pKeyBuffer(new sal_uInt8
[nKeyLen
]);
187 rtl_digest_get( handle
, pKeyBuffer
.get(), nKeyLen
);
188 createHex(pKeyBuffer
.get(), nKeyLen
);
190 rtl_digest_destroy( handle
);
197 OString aSum1
= getDigest(sSampleString
, rtl_Digest_AlgorithmMD5
);
198 OString aSum2
= getDigest(sSampleString
, rtl_Digest_AlgorithmMD5
);
200 CPPUNIT_ASSERT_EQUAL_MESSAGE(
201 "md5sum must have a length", sal_Int32(32), aSum1
.getLength() );
202 CPPUNIT_ASSERT_EQUAL_MESSAGE(
203 "md5sum must have a length", sal_Int32(32), aSum2
.getLength() );
204 CPPUNIT_ASSERT_EQUAL_MESSAGE("source is the same, dest must be also the same", aSum1
, aSum2
);
208 OString aSum1
= getDigest(sSampleString
, rtl_Digest_AlgorithmMD5
);
209 OString aSum2
= getDigest(sSampleString_only_one_diff
, rtl_Digest_AlgorithmMD5
);
211 CPPUNIT_ASSERT_EQUAL_MESSAGE(
212 "md5sum must have a length", sal_Int32(32), aSum1
.getLength() );
213 CPPUNIT_ASSERT_EQUAL_MESSAGE(
214 "md5sum must have a length", sal_Int32(32), aSum2
.getLength() );
215 CPPUNIT_ASSERT_MESSAGE("differ only in one char", aSum1
!= aSum2
);
221 for (size_t i
= 0; i
< SAL_N_ELEMENTS(constDigestAlgorithms
); i
++)
223 OString aSum
= getDigest(sSampleString
, constDigestAlgorithms
[i
]);
224 CPPUNIT_ASSERT_EQUAL_MESSAGE("Checksum of sample string is wrong.", OString(constSampleStringSums
[i
]), aSum
);
228 OString
runCheckPBKDF2(OString
& sPassword
, bool bClearSalt
, sal_uInt32 nCount
)
230 sal_uInt32 nKeyLen
= RTL_DIGEST_LENGTH_HMAC_SHA1
;
231 std::unique_ptr
<sal_uInt8
[]> pKeyBuffer(new sal_uInt8
[nKeyLen
]);
233 memset(pKeyBuffer
.get(), 0, nKeyLen
);
235 sal_uInt8
const * pPassword
= reinterpret_cast<sal_uInt8
const *>(sPassword
.getStr());
236 sal_Int32 nPasswordLen
= sPassword
.getLength();
238 sal_uInt32 nSaltDataLen
= RTL_DIGEST_LENGTH_HMAC_SHA1
;
239 std::unique_ptr
<sal_uInt8
[]> pSaltData(new sal_uInt8
[nSaltDataLen
]);
240 memset(pSaltData
.get(), 0, nSaltDataLen
);
244 // wilful contamination
248 rtlDigestError aError
= rtl_digest_PBKDF2(pKeyBuffer
.get(), nKeyLen
, pPassword
, nPasswordLen
, pSaltData
.get(), nSaltDataLen
, nCount
);
250 CPPUNIT_ASSERT_EQUAL(rtl_Digest_E_None
, aError
);
252 OString aKey
= createHex(pKeyBuffer
.get(), nKeyLen
);
254 // OString sSalt = createHex(pSaltData, nSaltDataLen);
255 // printf("Salt: %s\n", sSalt.getStr());
257 // CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_PBKDF2) );
263 OString aPassword
= "Password";
266 runCheckPBKDF2(aPassword
, false, 1);
267 runCheckPBKDF2(aPassword
, false, 2);
268 runCheckPBKDF2(aPassword
, true, 1);
269 runCheckPBKDF2(aPassword
, true, 2);
270 runCheckPBKDF2(aPassword
, false, 3);
271 runCheckPBKDF2(aPassword
, false, 4);
272 runCheckPBKDF2(aPassword
, true, 3);
273 runCheckPBKDF2(aPassword
, true, 4);
278 rtlDigestError aError
;
282 aError
= rtl_digest_update(aHandle
, nullptr, 0);
283 CPPUNIT_ASSERT_EQUAL_MESSAGE("does not handle wrong parameter", rtl_Digest_E_Argument
, aError
);
286 aError
= rtl_digest_updateMD2(aHandle
, nullptr, 0);
287 CPPUNIT_ASSERT_EQUAL_MESSAGE("does not handle wrong parameter", rtl_Digest_E_Argument
, aError
);
289 aError
= rtl_digest_updateMD5(aHandle
, nullptr, 0);
290 CPPUNIT_ASSERT_EQUAL_MESSAGE("does not handle wrong parameter", rtl_Digest_E_Argument
, aError
);
292 aHandle
= rtl_digest_create( rtl_Digest_AlgorithmMD2
);
293 CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle
!= nullptr);
295 const sal_uInt8
* pData
= reinterpret_cast<const sal_uInt8
*>(sSampleString
.getStr());
296 sal_uInt32 nSize
= sSampleString
.getLength();
298 aError
= rtl_digest_updateMD2(aHandle
, nullptr, 0);
299 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'pData' wrong", rtl_Digest_E_Argument
, aError
);
301 aError
= rtl_digest_updateMD2(aHandle
, pData
, 0);
302 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'nSize' wrong", rtl_Digest_E_None
, aError
);
304 rtl_digest_destroyMD2(aHandle
);
306 // use wrong Algorithm!!! This is volitional!
307 aHandle
= rtl_digest_create(rtl_Digest_AlgorithmMD2
);
308 CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle
!= nullptr);
310 aError
= rtl_digest_updateMD5(aHandle
, pData
, nSize
);
311 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'handle' wrong", rtl_Digest_E_Algorithm
, aError
);
313 rtl_digest_destroyMD5(aHandle
);
315 aHandle
= rtl_digest_create( rtl_Digest_AlgorithmMD5
);
316 CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle
!= nullptr);
318 aError
= rtl_digest_updateMD5(aHandle
, nullptr, 0);
319 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'pData' wrong", rtl_Digest_E_Argument
, aError
);
321 aError
= rtl_digest_updateMD5(aHandle
, pData
, 0);
322 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'nSize' wrong", rtl_Digest_E_None
, aError
);
324 rtl_digest_destroyMD5(aHandle
);
330 rtlDigestError aError
;
333 aError
= rtl_digest_get(aHandle
, nullptr, 0);
334 CPPUNIT_ASSERT_EQUAL_MESSAGE("does not handle wrong parameter", rtl_Digest_E_Argument
, aError
);
337 aError
= rtl_digest_getMD5(aHandle
, nullptr, 0);
338 CPPUNIT_ASSERT_EQUAL_MESSAGE("does not handle wrong parameter", rtl_Digest_E_Argument
, aError
);
340 // test with wrong algorithm
341 aHandle
= rtl_digest_create(rtl_Digest_AlgorithmMD2
);
342 CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle
!= nullptr);
344 sal_uInt32 nKeyLen
= rtl_digest_queryLength(aHandle
);
345 std::unique_ptr
<sal_uInt8
[]> pKeyBuffer(new sal_uInt8
[nKeyLen
]);
347 aError
= rtl_digest_getMD5(aHandle
, nullptr, 0);
348 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle 2. parameter wrong", rtl_Digest_E_Argument
, aError
);
350 aError
= rtl_digest_getMD5(aHandle
, pKeyBuffer
.get(), 0);
351 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'handle' wrong", rtl_Digest_E_Algorithm
, aError
);
353 rtl_digest_destroyMD2(aHandle
);
355 aHandle
= rtl_digest_create(rtl_Digest_AlgorithmMD5
);
356 CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle
!= nullptr);
358 aError
= rtl_digest_getMD5(aHandle
, nullptr, nKeyLen
);
359 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'pData' wrong", rtl_Digest_E_Argument
, aError
);
361 aError
= rtl_digest_getMD5(aHandle
, pKeyBuffer
.get(), 0);
362 CPPUNIT_ASSERT_EQUAL_MESSAGE("handle parameter 'nSize' wrong", rtl_Digest_E_BufferSize
, aError
);
364 rtl_digest_destroyMD5(aHandle
);
367 void testSHA1SumForBiggerInputData()
369 // The test data was extracted from oox encrypted document (salt + password).
370 // First case: 16 bytes salt + 34 bytes password (12345678901234567)
371 // Second case: 16 bytes salt + 36 bytes password (123456789012345678)
373 const unsigned char aData
[] = {
374 0x37, 0x5f, 0x47, 0x7a, 0xd2, 0x13, 0xbe, 0xd2, 0x3c, 0x23, 0x33, 0x39,
375 0x68, 0x21, 0x03, 0x6d, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
376 0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0x38, 0x00, 0x39, 0x00, 0x30, 0x00,
377 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00,
381 std::unique_ptr
<sal_uInt8
[]> pResult(new sal_uInt8
[RTL_DIGEST_LENGTH_SHA1
]);
383 rtl_digest_SHA1(aData
, sizeof(aData
), pResult
.get(), RTL_DIGEST_LENGTH_SHA1
);
385 OString sKey
= createHex(pResult
.get(), RTL_DIGEST_LENGTH_SHA1
);
387 CPPUNIT_ASSERT_EQUAL(OString("06f460d693aecdd3b5cbe8365408eccfc570f32a"), sKey
);
390 // tdf#114939, verify that rtl_digest_SHA1 computes broken results for certain input (which
391 // is not fixed for compatibility reasons):
393 sal_uInt8 result
[RTL_DIGEST_LENGTH_SHA1
];
395 RTL_CONSTASCII_STRINGPARAM("1012345678901234567890123456789012345678901234567890"),
396 result
, RTL_DIGEST_LENGTH_SHA1
);
397 // Rather than correct "9cb1dab34448c1ea460da1f8736869c8852f212f":
398 CPPUNIT_ASSERT_EQUAL(
399 OString("90a461ee9cc69cedaeb25c2dc5cc62544ebd5241"),
400 createHex(result
, RTL_DIGEST_LENGTH_SHA1
));
406 unsigned char const data
[] = {
407 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
408 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
409 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
410 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
411 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
412 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
413 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
414 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
416 OString
const expected
[] = {
417 "d41d8cd98f00b204e9800998ecf8427e",
418 "cfcd208495d565ef66e7dff9f98764da",
419 "b4b147bc522828731f1a016bfa72c073",
420 "c6f057b86584942e415435ffb1fa93d4",
421 "4a7d1ed414474e4033ac29ccb8653d9b",
422 "dcddb75469b4b4875094e14561e573d8",
423 "670b14728ad9902aecba32e22fa4f6bd",
424 "29c3eea3f305d6b823f562ac4be35217",
425 "dd4b21e9ef71e1291183a46b913ae6f2",
426 "4c93008615c2d041e33ebac605d14b5b",
427 "f1b708bba17f1ce948dc979f4d7092bc",
428 "645a8aca5a5b84527c57ee2f153f1946",
429 "35b9ab5a36f3234dd26db357fd4a0dc1",
430 "4aad0d9ff11812ebdd5e376fdbef6222",
431 "c47532bbb1e2883c902071591ae1ec9b",
432 "5284047f4ffb4e04824a2fd1d1f0cd62",
433 "1e4a1b03d1b6cd8a174a826f76e009f4",
434 "0e7b9f29a828b6f953b482fc299e536b",
435 "3ea032bf79e8c116b05f4698d5a8e044",
436 "15f47c8a3e5e9685307dd65a653b8dc0",
437 "cc545187d0745132de1e9941db0ef6ce",
438 "0585e303e79acd837c3a3e2a2bec8b18",
439 "b28ccfdee4b9f39ba18b58a4f61a03d1",
440 "d018229b1183c926c10ea688350afec8",
441 "660719b4a7591769583a7c8d20c6dfa4",
442 "1e2432adacf481836265fcc62ee8f3e3",
443 "6e88e2af74c1d9d7d7d652b90d03751e",
444 "780ca685003cec1d617beaa6f346e1be",
445 "7f2e1dcfd6e2a3f5c38f31e640136ff6",
446 "1a3dee46117aeb8010cf365b8653faa8",
447 "1d0064395af3c745f6c3194e92373d7a",
448 "b52582043219f2deb2d3c9cb05d6448a",
449 "cd9e459ea708a948d5c2f5a6ca8838cf",
450 "00de800ecd7a4fb2813986c987e46d51",
451 "15336d4b38561a82bd24c9398b781aed",
452 "5fe699d3c461ab5a795505f59d5adf15",
453 "c5e0eb03cbb4bea95ce3f8f48fca77d5",
454 "355c1410373ef02fff2b03844d72c7d4",
455 "02df97da8207de2b3afa69c151ca8958",
456 "82c66dbf3e73f87ffc9564b2098d6a4f",
457 "b373e3ddc3438d7c10c76f3ad9d4c401",
458 "fac901a4a3dbc4461541731a33a31d15",
459 "f573e011b414bf3f9dd284f7dad29592",
460 "11694570cc5dda099669f2ba3660a70d",
461 "60997cc8aef7fedd9995e6b3ca89ce26",
462 "63c5fcf83c2275fe64e880dd8dfc5cd6",
463 "c7a0a100057ebbfc63ee169562026aea",
464 "42c2dec247919384edece38033458627",
465 "b505acf9fc996902b0c547a2abfc62b2",
466 "2fa7a1321d6b5fa0e04ad46785f574f3",
467 "86d2bfc0bab44eecf21e1432be7b3efc",
468 "7ca318f12a0955a3e637dc5645a2f96e",
469 "3eda02765b8fb8bb9b20c735f4537827",
470 "26dead12262c9a5c115b01e0a3c805b6",
471 "978b0444e93c5f7d714575f28a77dca1",
472 "d7fe636bd28e2ee2ba4d6c5898318699",
473 "ce992c2ad906967c63c3f9ab0c2294a9",
474 "1f3b814e9d417e9fd8750299982feb1f",
475 "1a2f42174eaa78ce6a67d75e98a59cb6",
476 "17c772c45c9a09f6e56b7228ddd161a7",
477 "5b19445b70b493c78f3bc06eb7962315",
478 "e590c24cc612bdedd522dfe23bb29b42",
479 "4d78c699a0167bc0cfce8a5c5a715c0e",
480 "5703db92acb9d45e3975822c9206453f",
481 "10eab6008d5642cf42abd2aa41f847cb",
483 rtlDigest digest
= rtl_digest_createMD5();
484 for (size_t i
= 0; i
< sizeof(data
); ++i
)
486 rtl_digest_updateMD5(digest
, &data
, i
);
487 sal_uInt8 buf
[RTL_DIGEST_LENGTH_MD5
];
488 rtl_digest_getMD5(digest
, &buf
[0], sizeof(buf
));
489 OString
const sResult
= createHex(&buf
[0], sizeof(buf
));
490 CPPUNIT_ASSERT_EQUAL(expected
[i
], sResult
);
492 rtl_digest_destroyMD5(digest
);
495 CPPUNIT_TEST_SUITE(DigestTest
);
496 CPPUNIT_TEST(testCreate
);
497 CPPUNIT_TEST(testQuery
);
498 CPPUNIT_TEST(testQueryLength
);
499 CPPUNIT_TEST(testInit
);
500 CPPUNIT_TEST(testEqual
);
501 CPPUNIT_TEST(testCheckSum
);
502 CPPUNIT_TEST(testPBKDF2
);
503 CPPUNIT_TEST(testUpdate
);
504 CPPUNIT_TEST(testGet
);
505 CPPUNIT_TEST(testSHA1SumForBiggerInputData
);
506 CPPUNIT_TEST(testMD5
);
508 CPPUNIT_TEST_SUITE_END();
511 CPPUNIT_TEST_SUITE_REGISTRATION(DigestTest
);
513 } // namespace rtl_digest
515 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */