@@ -1140,15 +1140,11 @@ namespace jwt {
11401140 */
11411141 hmacsha (std::string key, const EVP_MD* (*md)(), std::string name)
11421142 : secret(helper::raw2bn(key).release()), md(md), alg_name(std::move(name)) {}
1143- hmacsha (const hmacsha& other)
1144- : secret(BN_dup(other.secret)), md(other.md), alg_name(other.alg_name) {}
1145- hmacsha (hmacsha&& other)
1146- : secret(nullptr ), md(std::move(other.md)), alg_name(std::move(other.alg_name)) {
1147- if (BN_copy (other.secret , secret) == nullptr ) throw std::runtime_error (" failed to copy BN" );
1148- }
1149- ~hmacsha (){
1150- BN_free (secret);
1143+ hmacsha (const hmacsha& other) : secret(BN_dup(other.secret)), md(other.md), alg_name(other.alg_name) {}
1144+ hmacsha (hmacsha&& other) : secret(nullptr ), md(std::move(other.md)), alg_name(std::move(other.alg_name)) {
1145+ if (BN_copy (other.secret , secret) == nullptr ) throw std::runtime_error (" failed to copy BN" );
11511146 }
1147+ ~hmacsha (){ BN_free (secret); }
11521148 hmacsha& operator =(const hmacsha& other) = delete ;
11531149 hmacsha& operator =(hmacsha&& other) = delete ;
11541150
@@ -1168,8 +1164,8 @@ namespace jwt {
11681164 const auto buffer_size = BN_bn2bin (secret, buffer.data ());
11691165 buffer.resize (buffer_size);
11701166
1171- if (HMAC (md (), buffer.data (), buffer_size,
1172- reinterpret_cast < const unsigned char *>(data. data ()), static_cast <int >(data.size ()),
1167+ if (HMAC (md (), buffer.data (), buffer_size, reinterpret_cast < const unsigned char *>(data. data ()),
1168+ static_cast <int >(data.size ()),
11731169 (unsigned char *)res.data (), // NOLINT(google-readability-casting) requires `const_cast`
11741170 &len) == nullptr ) {
11751171 ec = error::signature_generation_error::hmac_failed;
0 commit comments