MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / H

Function H

libi2pd/Gost.cpp:870–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

868 }
869
870 static void H (const uint8_t * iv, const uint8_t * buf, size_t len, uint8_t * digest)
871 {
872 // stage 1
873 GOST3411Block h, N, s, m;
874 memcpy (h.buf, iv, 64);
875 memset (N.buf, 0, 64);
876 memset (s.buf, 0, 64);
877 size_t l = len;
878 // stage 2
879 while (l >= 64)
880 {
881 memcpy (m.buf, buf + l - 64, 64); // TODO
882 h= gN (N, h, m);
883 N.Add (512);
884 s = m + s;
885 l -= 64;
886 }
887 // stage 3
888 size_t padding = 64 - l;
889 if (padding)
890 {
891 memset (m.buf, 0, padding - 1);
892 m.buf[padding - 1] = 1;
893 }
894 memcpy (m.buf + padding, buf, l);
895
896 h = gN (N, h, m);
897 N.Add (l*8);
898 s = m + s;
899
900 GOST3411Block N0;
901 memset (N0.buf, 0, 64);
902 h = gN (N0, h, N);
903 h = gN (N0, h, s);
904
905 memcpy (digest, h.buf, 64);
906 }
907
908 void GOSTR3411_2012_256 (const uint8_t * buf, size_t len, uint8_t * digest)
909 {

Callers 5

GetCredentialMethod · 0.85
GetSubcredentialMethod · 0.85
GenerateAlphaMethod · 0.85
GOSTR3411_2012_256Function · 0.85
GOSTR3411_2012_512Function · 0.85

Calls 2

gNFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected