Skip to content

Commit bb531b5

Browse files
committed
fix sigh util
1 parent c96683e commit bb531b5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/common/sign_util.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ int sha1_verify(const utility::string_t& context, const utility::string_t& sign,
8383
unsigned char sigbuf[8196 * 16] = {};
8484
unsigned int siglen = 0;
8585

86-
auto decoded = str16to8(TIGER_API::base64_decode(sign));
87-
memcpy(sigbuf, decoded.data(), decoded.size());
88-
siglen = decoded.size();
86+
auto vec_base64_decode = utility::conversions::from_base64(sign);
8987

9088
unsigned char hash[SHA_DIGEST_LENGTH] = { 0 };
9189

9290
SHA1((const unsigned char*)context_s.c_str(), context_s.size(), hash);
9391

9492
RSA *rsa = create_rsa((utility::char_t *)key.c_str(), false);
95-
96-
int ret = RSA_verify(NID_sha1, hash, SHA_DIGEST_LENGTH,
97-
sigbuf, siglen, rsa);
93+
int ret = -1;
94+
if (vec_base64_decode.size() > 0)
95+
{
96+
ret = RSA_verify(NID_sha1, hash, SHA_DIGEST_LENGTH,
97+
&vec_base64_decode[0], vec_base64_decode.size(), rsa);
98+
}
9899
return ret;
99-
100100
}
101101

102102
#endif //TIGERAPI_SIGN_UTIL_H

0 commit comments

Comments
 (0)