Skip to content

Commit b6f2f01

Browse files
linter
1 parent 784e4eb commit b6f2f01

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

include/jwt-cpp/jwt.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,15 +1144,11 @@ namespace jwt {
11441144
*/
11451145
hmacsha(std::string key, const EVP_MD* (*md)(), std::string name)
11461146
: secret(helper::raw2bn(key).release()), md(md), alg_name(std::move(name)) {}
1147-
hmacsha(const hmacsha& other)
1148-
: secret(BN_dup(other.secret)), md(other.md), alg_name(other.alg_name) {}
1149-
hmacsha(hmacsha&& other)
1150-
: secret(nullptr), md(std::move(other.md)), alg_name(std::move(other.alg_name)) {
1151-
if(BN_copy(other.secret, secret) == nullptr) throw std::runtime_error("failed to copy BN");
1152-
}
1153-
~hmacsha(){
1154-
BN_free(secret);
1147+
hmacsha(const hmacsha& other) : secret(BN_dup(other.secret)), md(other.md), alg_name(other.alg_name) {}
1148+
hmacsha(hmacsha&& other) : secret(nullptr), md(std::move(other.md)), alg_name(std::move(other.alg_name)) {
1149+
if(BN_copy(other.secret, secret) == nullptr) throw std::runtime_error("failed to copy BN");
11551150
}
1151+
~hmacsha(){ BN_free(secret); }
11561152
hmacsha& operator=(const hmacsha& other) = delete;
11571153
hmacsha& operator=(hmacsha&& other) = delete;
11581154

@@ -1172,8 +1168,8 @@ namespace jwt {
11721168
const auto buffer_size = BN_bn2bin(secret, buffer.data());
11731169
buffer.resize(buffer_size);
11741170

1175-
if (HMAC(md(), buffer.data(), buffer_size,
1176-
reinterpret_cast<const unsigned char*>(data.data()), static_cast<int>(data.size()),
1171+
if (HMAC(md(), buffer.data(), buffer_size, reinterpret_cast<const unsigned char*>(data.data()),
1172+
static_cast<int>(data.size()),
11771173
(unsigned char*)res.data(), // NOLINT(google-readability-casting) requires `const_cast`
11781174
&len) == nullptr) {
11791175
ec = error::signature_generation_error::hmac_failed;

0 commit comments

Comments
 (0)