MCPcopy Create free account
hub / github.com/arun11299/cpp-jwt / sign

Method sign

include/jwt/algorithm.hpp:481–500  ·  view source on GitHub ↗

* Signs the input data using PEM encryption algorithm. * * Arguments: * @key : The key/secret to be used for signing. * Cannot be an empty string. * @data: The data to be signed. * * Exceptions: * Any allocation failure would be thrown out as * jwt::MemoryAllocationException. */

Source from the content-addressed store, hash-verified

479 * jwt::MemoryAllocationException.
480 */
481 static sign_result_t sign(const jwt::string_view key, const jwt::string_view data)
482 {
483 std::error_code ec{};
484
485 std::string ii{data.data(), data.length()};
486
487 EC_PKEY_uptr pkey{load_key(key, ec), ev_pkey_deletor};
488 if (ec) return { std::string{}, ec };
489
490 //TODO: Use stack string here ?
491 std::string sign = evp_digest(pkey.get(), data, ec);
492
493 if (ec) return { std::string{}, ec };
494
495 if (Hasher::type == EVP_PKEY_EC) {
496 sign = public_key_ser(pkey.get(), sign, ec);
497 }
498
499 return { std::move(sign), ec };
500 }
501
502 /**
503 */

Callers

nothing calls this directly

Calls 3

dataMethod · 0.80
lengthMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected