Adding running tests on Alpine for coreclr build (#17038)
[platform/upstream/coreclr.git] / src / inc / marvin32.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 #ifndef MARVIN32_INCLUDED
6 #define MARVIN32_INCLUDED
7
8
9 #include "common.h"
10 #include "windows.h"
11
12 //
13 // Pointer-const typedefs:
14 //
15 // These definitions are missing from the standard Windows declarations.
16 // Should probably be moved to a central typedef file.
17 //
18 typedef const BYTE      * PCBYTE;
19 typedef const USHORT    * PCUSHORT;
20 typedef const ULONG     * PCULONG;
21 typedef const ULONGLONG * PCULONGLONG;
22 typedef const VOID      * PCVOID;
23
24
25
26 //
27 // MARVIN32
28 //
29
30 #define SYMCRYPT_MARVIN32_RESULT_SIZE       (8)
31 #define SYMCRYPT_MARVIN32_SEED_SIZE         (8)
32 #define SYMCRYPT_MARVIN32_INPUT_BLOCK_SIZE  (4)
33
34 // These macros only support little-endian machines with unaligned access
35 #define LOAD_LSBFIRST16( p ) ( *(USHORT    *)(p))
36 #define LOAD_LSBFIRST32( p ) ( *(ULONG     *)(p))
37 #define STORE_LSBFIRST32( p, x ) ( *(ULONG     *)(p) =        (x) )
38
39 // Disable the warning about padding the struct on amd64
40 #pragma warning(push)
41 #pragma warning(disable:4324)
42
43 typedef struct _SYMCRYPT_MARVIN32_EXPANDED_SEED
44 {
45     ULONG   s[2];
46 } SYMCRYPT_MARVIN32_EXPANDED_SEED, *PSYMCRYPT_MARVIN32_EXPANDED_SEED;
47
48 typedef SYMCRYPT_MARVIN32_EXPANDED_SEED SYMCRYPT_MARVIN32_CHAINING_STATE, *PSYMCRYPT_MARVIN32_CHAINING_STATE;
49 typedef const SYMCRYPT_MARVIN32_EXPANDED_SEED * PCSYMCRYPT_MARVIN32_EXPANDED_SEED;
50
51 typedef struct _SYMCRYPT_MARVIN32_STATE
52 {
53     BYTE                                buffer[8];  // 4 bytes of data, 4 more bytes for final padding
54     SYMCRYPT_MARVIN32_CHAINING_STATE    chain;      // chaining state 
55     PCSYMCRYPT_MARVIN32_EXPANDED_SEED   pSeed;      // 
56     ULONG                               dataLength; // length of the data processed so far, mod 2^32
57 } SYMCRYPT_MARVIN32_STATE, *PSYMCRYPT_MARVIN32_STATE;
58 typedef const SYMCRYPT_MARVIN32_STATE *PCSYMCRYPT_MARVIN32_STATE;
59 #pragma warning(pop)
60
61 //
62 // Function declarations
63 //
64 HRESULT SymCryptMarvin32ExpandSeed(
65         __out               PSYMCRYPT_MARVIN32_EXPANDED_SEED    pExpandedSeed,
66         __in_ecount(cbSeed) PCBYTE                              pbSeed,
67                             SIZE_T                              cbSeed);
68
69 VOID SymCryptMarvin32Init(_Out_   PSYMCRYPT_MARVIN32_STATE            pState,
70         _In_    PCSYMCRYPT_MARVIN32_EXPANDED_SEED   pExpandedSeed);
71
72 VOID SymCryptMarvin32Result(
73         _Inout_                                        PSYMCRYPT_MARVIN32_STATE    pState,
74         _Out_  PBYTE                       pbResult);
75
76 VOID SymCryptMarvin32Append(_Inout_                    SYMCRYPT_MARVIN32_STATE * state,
77         _In_reads_bytes_(cbData) PCBYTE                    pbData,
78         SIZE_T               cbData);
79
80 VOID SymCryptMarvin32(
81         __in                                            PCSYMCRYPT_MARVIN32_EXPANDED_SEED   pExpandedSeed,
82         __in_ecount(cbData)                             PCBYTE                              pbData,
83                                                         SIZE_T                              cbData,
84         __out_ecount(SYMCRYPT_MARVIN32_RESULT_SIZE)     PBYTE                               pbResult);
85 #endif // MARVIN32_INCLUDED