| 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 |