Skip to content

Commit e51671c

Browse files
committed
More partial SHA2 implementations
1 parent 31d8ae2 commit e51671c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Classes/FCryptoSHA2.uc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,36 @@ static final function Sha2SmallUpdate(
271271
}
272272
}
273273

274+
static final function Sha2SmallOut(
275+
const out FCryptoSHA224Context Cc,
276+
out array<byte> Dst,
277+
int Num
278+
)
279+
{
280+
local byte Buf[64];
281+
local int Val[8];
282+
local int Ptr;
283+
284+
Ptr = Cc.Count & 63;
285+
// class'FCryptoMemory'.static.MemCpy(Buf, Cf.Buf, Ptr);
286+
// class'FCryptoMemory'.static.MemCpy(Val, CC.Val, 32 /* sizeof Val */);
287+
Buf[Ptr++] = 0x80;
288+
if (Ptr > 56)
289+
{
290+
// class'FCryptoMemory'.static.MemSet(Buf, 0, 64 - Ptr, Ptr);
291+
// Sha2SmallRound(Buf, Val);
292+
// class'FCryptoMemory'.static.MemSet(Buf, 0, 56);
293+
}
294+
else
295+
{
296+
class'FCryptoMemory'.static.MemSet(Buf, 0, 56 - Ptr, Ptr);
297+
}
298+
299+
Enc64BE(Buf /* + 56 */, Cc.Count << 3); // TODO
300+
// Sha2SmallRound(Buf, Val); // TODO
301+
// RangeEnc32BE(Dst, Val, Num); // TODO
302+
}
303+
274304
// TODO: make this a macro for performance?
275305
static final function RangeDec32BE(
276306
out array<int> V,
@@ -303,6 +333,28 @@ static final function int Dec32BE(
303333
);
304334
}
305335

336+
// TODO: make this a macro for performance?
337+
static final function Enc64BE(
338+
out array<byte> Dst,
339+
int X // TODO: need to use a QWORD here?
340+
)
341+
{
342+
// br_enc32be(buf, (uint32_t)(x >> 32));
343+
// br_enc32be(buf + 4, (uint32_t)x);
344+
}
345+
346+
// TODO: make this a macro for performance?
347+
static final function Enc32BE(
348+
out array<byte> Dst,
349+
int X
350+
)
351+
{
352+
Dst[0] = X >>> 24;
353+
Dst[1] = X >>> 16;
354+
Dst[2] = X >>> 8;
355+
Dst[3] = X
356+
}
357+
306358
DefaultProperties
307359
{
308360
SHA224_IV={(

0 commit comments

Comments
 (0)