@@ -1143,18 +1143,18 @@ namespace jwt {
11431143 * \param name Name of the algorithm
11441144 */
11451145 hmacsha (std::string key, const EVP_MD* (*md)(), std::string name)
1146- : secret(helper::raw2bn(key)), 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- }
1150- hmacsha (hmacsha&& other) :
1151- secret (BN_copy(other.secret)), md(std::move(other.md)), alg_name( std::move(other.alg_name)) {
1146+ : 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 " );
11521152 }
11531153 ~hmacsha (){
1154- BN_free (secret)
1154+ BN_free (secret);
11551155 }
1156- hmacsha& operator =(const hmacsha& other) = default ;
1157- hmacsha& operator =(hmacsha&& other) = default ;
1156+ hmacsha& operator =(const hmacsha& other) = delete ;
1157+ hmacsha& operator =(hmacsha&& other) = delete ;
11581158
11591159 /* *
11601160 * Sign jwt data
@@ -1212,7 +1212,7 @@ namespace jwt {
12121212
12131213 private:
12141214 // / HMAC secret
1215- const BIGNUM* secret;
1215+ BIGNUM* secret;
12161216 // / HMAC hash generator
12171217 const EVP_MD* (*md)();
12181218 // / algorithm's name
0 commit comments