CBC encode process in C++

CBC ブロック暗号モードで暗号化する時は以下のような処理を行う。
ちなみにテストしていないので使用する場合は注意されたし・・・ デバッグ歓迎(^^;;;;


/**
@parma T : block object
@parma FUNCTION_T : encryption functor type
@param target[in] encryption data block object (POD ok)
@param src[in] initial vector
@param count[in] number of target
@param encode_functor[in] encryption functor
@note
ex: functor interface
@code
template
struct encode{
EncryptionLogic *pLogic;
encode(EncryptionLogic *a){
pLogic = a;
}
T &operator()(const T &a){
return pLogic->Encode(a);
}
}
@endcode
*/

template<typename T,class FUNCTION_T>
inline T *cbc_encode_process(T *target,const T &src,size_t count,
FUNCTION_T encode_func)
{
size_t i;
T ref_t = src;
for(i=0;i<count;i++)
{
ref_t ^= target[i];
ref_t = encode_func(ref_t);
target[i] = ref_t;
}
return target;
}

追記:アップデートされないようにプログラムされていたのでFIX.
さらに追記:やっぱりバグっているっぽいです。