Skip to content

Commit eeaa6c6

Browse files
Update jwt.h
1 parent 6400858 commit eeaa6c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/jwt-cpp/jwt.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,11 +1152,12 @@ namespace jwt {
11521152
std::string res(static_cast<size_t>(EVP_MAX_MD_SIZE), '\0');
11531153
auto len = static_cast<unsigned int>(res.size());
11541154

1155-
const int secret_size = BN_num_bytes(secret.get());
1156-
std::vector<unsigned char> buffer(size, '\0');
1157-
BN_bn2bin(secret.get(), buffer.data());
1155+
const BIGNUM* secret_bn = secret.get();
1156+
std::vector<unsigned char> buffer(BN_num_bytes(secret_bn), '\0');
1157+
const auto buffer_size = BN_bn2bin(secret_bn, buffer.data());
1158+
buffer.resize(buffer_size);
11581159

1159-
if (HMAC(md(), secret.data(), secret_size,
1160+
if (HMAC(md(), buffer.data(), buffer_size,
11601161
reinterpret_cast<const unsigned char*>(data.data()), static_cast<int>(data.size()),
11611162
(unsigned char*)res.data(), // NOLINT(google-readability-casting) requires `const_cast`
11621163
&len) == nullptr) {

0 commit comments

Comments
 (0)