C++ 如何将两个字节*(secblock)与运算符';secblock<;T、 A>;::操作员+=';

C++ 如何将两个字节*(secblock)与运算符';secblock<;T、 A>;::操作员+=';,c++,crypto++,allocator,C++,Crypto++,Allocator,请举个小例子。我试着在文档中使用它,但我不明白如何使用它 信息: main.cpp|97|error: no matching function for call to 'CryptoPP::SecBlock<unsigned char>::operator+=(CryptoPP::SecBlock<unsigned char>*)' secblock.h|568|note: candidate: CryptoPP::SecBlock<T, A

请举个小例子。我试着在文档中使用它,但我不明白如何使用它

信息:

main.cpp|97|error: no matching function for call to 
   'CryptoPP::SecBlock<unsigned char>::operator+=(CryptoPP::SecBlock<unsigned char>*)'
   secblock.h|568|note: candidate: 
   CryptoPP::SecBlock<T, A>& CryptoPP::SecBlock<T, A>::operator+=(const CryptoPP::SecBlock<T, A>&)
   [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>]
   secblock.h|568|note:   
   no known conversion for argument 1 from 'CryptoPP::SecBlock<unsigned char>*' 
   to 'const CryptoPP::SecBlock<unsigned char>&'
main.cpp | 97 |错误:没有用于调用的匹配函数
'CryptoPP::SecBlock::operator+=(CryptoPP::SecBlock*)'
secblock.h | 568 |注:候选人:
CryptoPP::SecBlock&CryptoPP::SecBlock::operator+=(常量CryptoPP::SecBlock&)
[with T=unsigned char;A=CryptoPP::AllocatorWithCleanup]
secblock.h | 568 |注:
“CryptoPP::SecBlock*”中的参数1没有已知转换
到“const CryptoPP::SecBlock&”
我的代码:

SecBlock<byte, AllocatorWithCleanup<byte> > hash_ripemd160_temp;
  RIPEMD160().CalculateDigest(hash_ripemd160_temp, hash_sha256, 32);

  SecBlock<byte, AllocatorWithCleanup<byte> > hash_ripemd160 = L0_byte;

   hash_ripemd160 = SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (&hash_ripemd160_temp);
SecBlock hash\u ripemd160\u temp;
RIPEMD160().CalculateDigest(哈希值为RIPEMD160,哈希值为256,32);
SecBlock hash_ripemd160=L0_字节;
hash_ripemd160=SecBlock::operator+=(&hash_ripemd160_temp);
在文档中,如下所示:

SecBlock<byte , AllocatorWithCleanup<byte > >& SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (const SecBlock< byte , AllocatorWithCleanup<byte > > &t)     
Append contents from another SecBlock.

Parameters

t   the other SecBlock

Internally, this SecBlock calls Grow and then copies the new content.

If the memory block is reduced in size, then the unused area is set to 0.
SecBlock&SecBlock::运算符+=(const SecBlock&t)
附加来自另一个SecBlock的内容。
参数
在另一个街区
在内部,此SecBlock调用Grow,然后复制新内容。
如果内存块的大小减小,则未使用的区域设置为0。

文件secblock.h.第568行的定义调用运算符函数的最简单方法是只使用运算符:

  hash_ripemd160 += hash_ripemd160_temp;
如果您想直接调用它(我不建议这样),您必须这样调用它,因为它是一个成员函数:

hash_ripemd160.operator += (hash_ripemd160_temp);
如何将两个字节*(secblock)与
operator'secblock::operator+='连接起来

拉动后尝试以下操作。(或使用
git clone执行新签出。)https://github.com/weidai11/cryptopp.git

在修复/提交之前,它看起来应该在大多数情况下触发
InvalidArgument
异常。然而,在窗口上有一些角落的情况,我们不太确定这可能会导致无声截断


静默截断是个问题,我们正在讨论Crypto++5.6.4版本。

散列之前删除
&

hash_ripemd160 = SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (hash_ripemd160_temp);
hash\u ripemd160=SecBlock::operator+=(hash\u ripemd160\u temp);

操作员接受的是对象,而不是指针。

BааааМ和Alan。。。再次感谢您在这个问题上的帮助。我真的很恼火,我们没有早点赶上。我将在死后重新评估我们的工程流程,寻找差距。结果:分别为EEE46B312007181E9B2E48C9361A58CC26EF1EBD和EEE46B3120071E9B2E48C9361A58CC26EF1EBD。再次感谢。
SecBlock<T, A>& operator+=(const SecBlock<T, A> &t)
{
    assert((!t.m_ptr && !t.m_size) || (t.m_ptr && t.m_size));

    if(t.m_size)
    {
        if(this != &t)  // s += t
        {
            const size_type oldSize = m_size;
            Grow(m_size+t.m_size);
            memcpy_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), t.m_ptr, t.m_size*sizeof(T));
        }
        else            // t += t
        {
            SecBlock result(m_size+t.m_size);
            if(m_size) {memcpy_s(result.m_ptr, result.m_size*sizeof(T), m_ptr, m_size*sizeof(T));}
            memcpy_s(result.m_ptr+m_size, (result.m_size-m_size)*sizeof(T), t.m_ptr, t.m_size*sizeof(T));
            swap(result);
        }
    }
    return *this;
}
hash_ripemd160 = SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (hash_ripemd160_temp);