TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptXkcp.c
Go to the documentation of this file.
1
19#include "CryptParallelHash.h"
20
34EFIAPI
36 OUT UINT8 *EncBuf,
37 IN UINTN Value
38 )
39{
40 UINT32 BlockNum;
41 UINT32 EncLen;
42 UINT32 Index;
43 UINTN ValueCopy;
44
45 for ( ValueCopy = Value, BlockNum = 0; ValueCopy && (BlockNum < sizeof (UINTN)); ++BlockNum, ValueCopy >>= 8 ) {
46 //
47 // Empty
48 //
49 }
50
51 if (BlockNum == 0) {
52 BlockNum = 1;
53 }
54
55 for (Index = 1; Index <= BlockNum; ++Index) {
56 EncBuf[Index] = (UINT8)(Value >> (8 * (BlockNum - Index)));
57 }
58
59 EncBuf[0] = (UINT8)BlockNum;
60 EncLen = BlockNum + 1;
61
62 return EncLen;
63}
64
78EFIAPI
80 OUT UINT8 *EncBuf,
81 IN UINTN Value
82 )
83{
84 UINT32 BlockNum;
85 UINT32 EncLen;
86 UINT32 Index;
87 UINTN ValueCopy;
88
89 for (ValueCopy = Value, BlockNum = 0; ValueCopy && (BlockNum < sizeof (UINTN)); ++BlockNum, ValueCopy >>= 8) {
90 //
91 // Empty
92 //
93 }
94
95 if (BlockNum == 0) {
96 BlockNum = 1;
97 }
98
99 for (Index = 1; Index <= BlockNum; ++Index) {
100 EncBuf[Index-1] = (UINT8)(Value >> (8 * (BlockNum-Index)));
101 }
102
103 EncBuf[BlockNum] = (UINT8)BlockNum;
104 EncLen = BlockNum + 1;
105
106 return EncLen;
107}
UINT64 UINTN
UINTN EFIAPI RightEncode(OUT UINT8 *EncBuf, IN UINTN Value)
Definition: CryptXkcp.c:79
UINTN EFIAPI LeftEncode(OUT UINT8 *EncBuf, IN UINTN Value)
Definition: CryptXkcp.c:35
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284