MCPcopy Create free account
hub / github.com/SmingHub/Sming / checkHash

Method checkHash

tests/HostTests/modules/Network/Crypto.cpp:83–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 * Check standard hashes which have getState / setState implementations
82 */
83 template <class Context> void checkHash(const FlashString& expectedHash, const FlashString& expectedState)
84 {
85 Context ctx;
86 ctx.update(FS_plainText);
87 auto state = ctx.getState();
88 auto hash = ctx.getHash();
89
90 auto stateText = Crypto::toString(state.value);
91 auto hashText = Crypto::toString(hash);
92
93 Serial.println(Context::Engine::name);
94 Serial.print(_F(" state: "));
95 Serial.println(stateText);
96 Serial.print(_F(" count: "));
97 Serial.println(state.count);
98 Serial.print(_F(" final: "));
99 Serial.println(hashText);
100 Serial.print(_F(" context size: "));
101 Serial.println(sizeof(Context));
102
103 REQUIRE(state.count == FS_plainText.length());
104 REQUIRE(Crypto::toString(state.value) == expectedState);
105 REQUIRE(hashText == expectedHash);
106 }
107
108 /*
109 * Check supplementary hashes which do not implement getState / setState and may have optional engine arguments

Callers

nothing calls this directly

Calls 7

printlnMethod · 0.80
toStringFunction · 0.50
updateMethod · 0.45
getStateMethod · 0.45
getHashMethod · 0.45
printMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected