Debian Codegraph @

sources/ippcp/hash/md5/pcpmd5stuff.h

raw symbols SCIP
1 /*************************************************************************
2 * Copyright (C) 2002 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *************************************************************************/
16
17 /*
18 //
19 // Purpose:
20 // Cryptography Primitive.
21 // Digesting message according to MD5
22 // (derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm)
23 //
24 // Equivalent code is available from RFC 1321.
25 //
26 // Contents:
27 // MD5 methods and constants
28 //
29 */
30
31 #include "owndefs.h"
32 #include "owncp.h"
33 #include "hash/pcphash.h"
34 #include "hash/pcphash_rmf.h"
35 #include "pcptool.h"
36
37 #include <assert.h>
38
39 #if !defined(_PCP_MD5_STUFF_H)
40 #define _PCP_MD5_STUFF_H
41
42 /* MD5 constants */
43 static const Ipp32u md5_iv[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476 };
44
45 static __ALIGN16 const Ipp32u md5_cnt[] = {
46 0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
47 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821,
48
49 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8,
50 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A,
51
52 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70,
53 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665,
54
55 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1,
56 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391
57 };
58
59 IPP_OWN_DEFN(static void, md5_hashInit, (void* pHash))
60 {
61 /* setup initial digest */
62 ((Ipp32u*)pHash)[0] = md5_iv[0];
63 ((Ipp32u*)pHash)[1] = md5_iv[1];
64 ((Ipp32u*)pHash)[2] = md5_iv[2];
65 ((Ipp32u*)pHash)[3] = md5_iv[3];
66 }
67
68 IPP_OWN_DEFN(static void, md5_hashUpdate, (void* pHash, const Ipp8u* pMsg, int msgLen))
69 {
70 UpdateMD5(pHash, pMsg, msgLen, md5_cnt);
71 }
72
73 IPP_OWN_DEFN(static void, md5_hashOctString, (Ipp8u * pMD, void* pHashVal, const int hashByteSize))
74 {
75 /* Handle the case when the requested hashByteSize is bigger than supported */
76 const int hashMaxByteSize = IPP_MD5_DIGEST_BITSIZE / 8; /* 16 */
77 const int outByteSize = IPP_MIN(hashByteSize, hashMaxByteSize);
78
79 /* The assertion is needed to indicate the case of incorrect usage of
80 the function during the development stage. */
81 assert(hashByteSize <= hashMaxByteSize);
82
83 /* md5 does not need conversion into big endian */
84 CopyBlock(pHashVal, pMD, outByteSize);
85 }
86
87 IPP_OWN_DEFN(static void, md5_msgRep, (Ipp8u * pDst, Ipp64u lenLo, Ipp64u lenHi))
88 {
89 IPP_UNREFERENCED_PARAMETER(lenHi);
90 lenLo <<= 3;
91 ((Ipp64u*)(pDst))[0] = lenLo;
92 }
93
94 #define cpFinalizeMD5 OWNAPI(cpFinalizeMD5)
95 /* clang-format off */
96 IPP_OWN_DECL(void, cpFinalizeMD5, (DigestMD5 pHash,
97 const Ipp8u* inpBuffer,
98 int inpLen,
99 Ipp64u processedMsgLen))
100 /* clang-format on */
101 #endif /* #if !defined(_PCP_MD5_STUFF_H) */