Blake implementation in C

On Mon, Jun 23, 2014 at 08:01:07AM -0700, Sarthak Jain wrote:
> > +typedef uint32_t word;
> > +#define HASH_SIZE 8
> > +#define BLOCK_SIZE 16
> > +#define SALT_SIZE 4
> > +#define counte_SIZE 2
> > +#define ROTATEL(x,n) ((x << n) | (x >> (32-n)))
> > +#define ROTATER(x,n) ((x >> n) | (x << (32-n)))
> > +typedef word Hash[HASH_SIZE];
> > +typedef word Block[BLOCK_SIZE];
> > +typedef word Salt[SALT_SIZE];
> > +word coun[counte_SIZE];
> > +
> > +int index1, index2;
> > +word mblock[BLOCK_SIZE];
> > +word constant[16];
> > +word v[4][4];
> 
> Yes sir, that is true for multiple threads 


Global variables are a no-no unless they are constants (in which case
they have to be declared static const). The function *will definitely*
be used in the threaded environment.


> but in a case where we are not using threads and if we are calling
> the "raazcompress" function many times, then that will result in
> redeclaration of those variables which are now defined in this
> function. Will it create any overhead or it is okay?

The "redeclaration" does not cost any thing the stuff is usually
allocated on the stack which means a stack pointer increment. Besides
that point you should always remember that pre-mature optimisation is
the root of all evil. Particularly in the case when the code is
obviously incorrect.

Please try to follow the coding style of the SHA hashes. They are
written taking all these into consideration.