* @brief: Payload SHA 256 = Hex(SHA256Hash( ) (no new-line char at end) * * @todo support for signing of PUSH, POST content / payload * @param signPayload specifies whether the content / payload should be signed * @return signature of the content or "UNSIGNED-PAYLOAD" to mark that the payload is not signed */
| 264 | * @return signature of the content or "UNSIGNED-PAYLOAD" to mark that the payload is not signed |
| 265 | */ |
| 266 | String |
| 267 | getPayloadSha256(bool signPayload) |
| 268 | { |
| 269 | static const String UNSIGNED_PAYLOAD("UNSIGNED-PAYLOAD"); |
| 270 | |
| 271 | if (!signPayload) { |
| 272 | return UNSIGNED_PAYLOAD; |
| 273 | } |
| 274 | |
| 275 | unsigned char payloadHash[SHA256_DIGEST_LENGTH]; |
| 276 | SHA256(reinterpret_cast<const unsigned char *>(""), 0, payloadHash); /* empty content */ |
| 277 | |
| 278 | return base16Encode(reinterpret_cast<char *>(payloadHash), SHA256_DIGEST_LENGTH); |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * @brief Get Canonical Uri SHA256 Hash |
no test coverage detected