Ideally, a hash function interface should have only three or four functions: an initializer; a function that takes a single byte and hashes it as though it was part of a continuous message; a function that takes a void * and a size_t and does the same as the previous one, but for every byte in the array; and a function to get the digest.
Since you're using C++, it makes no sense to keep the digest outside of the object. Leave it as a member of the class.
Your testo array seems unnecessarily complex. Unless I'm mistaken, you're encoding the size of the array at the end of the array. How, may I ask, do you know
where to look for the size. You're not passing any other parameters to the function, so I can't imagine what it does.
Your class definition should look something like this:
1 2 3 4 5 6 7 8
|
class RIPEMD160{
word32 digest[5];
public:
RIPEMD160();
void hash(char byte);
void hash(void *array,size_t size);
void result(word32 array[5]);
};
|
Note: if RIPEMD160 needs padding if the length of a block isn't a multiple of something, you should take care of it yourself inside hash(), rather than leave it up to the user.