-
-
-
-void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s){
- /* we migth return if the key is valid and if setup was successful */
- uint32_t x[4], z[4];
- #define BPX ((uint8_t*)&(x[0]))
- #define BPZ ((uint8_t*)&(z[0]))
- s->shortkey = (keylength_b<=80);
- /* littel endian only! */
- memset(&(x[0]), 0 ,16); /* set x to zero */
- if(keylength_b > 128)
- keylength_b=128;
- memcpy(&(x[0]), key, (keylength_b+7)/8);
-
-
- /* todo: merge a and b and compress the whole stuff */
- /***** A *****/
- cast5_init_A((uint8_t*)(&z[0]), (uint8_t*)(&x[0]), false);
- /***** M *****/
- cast5_init_M((uint8_t*)(&(s->mask[0])), (uint8_t*)(&z[0]), false, false);
- /***** B *****/
- cast5_init_A((uint8_t*)(&x[0]), (uint8_t*)(&z[0]), true);
- /***** N *****/
- cast5_init_M((uint8_t*)(&(s->mask[4])), (uint8_t*)(&x[0]), true, false);
- /***** A *****/
- cast5_init_A((uint8_t*)(&z[0]), (uint8_t*)(&x[0]), false);
- /***** N' *****/
- cast5_init_M((uint8_t*)(&(s->mask[8])), (uint8_t*)(&z[0]), true, true);
- /***** B *****/
- cast5_init_A((uint8_t*)(&x[0]), (uint8_t*)(&z[0]), true);
- /***** M' *****/
- cast5_init_M((uint8_t*)(&(s->mask[12])), (uint8_t*)(&x[0]), false, true);
-
- /* that were the masking keys, now the rotation keys */
- /* set the keys to zero */
- memset(&(s->rotl[0]),0,8);
- s->roth[0]=s->roth[1]=0;
- /***** A *****/
- cast5_init_A((uint8_t*)(&z[0]), (uint8_t*)(&x[0]), false);
- /***** M *****/
- cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 0, (uint8_t*)(&z[0]), false, false);
- /***** B *****/
- cast5_init_A((uint8_t*)(&x[0]), (uint8_t*)(&z[0]), true);
- /***** N *****/
- cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 1, (uint8_t*)(&x[0]), true, false);
- /***** A *****/
- cast5_init_A((uint8_t*)(&z[0]), (uint8_t*)(&x[0]), false);
- /***** N' *****/
- cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 2, (uint8_t*)(&z[0]), true, true);
- /***** B *****/
- cast5_init_A((uint8_t*)(&x[0]), (uint8_t*)(&z[0]), true);
- /***** M' *****/
- cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 3, (uint8_t*)(&x[0]), false, true);
- /* done ;-) */
+void cast5_init(const void *key, uint16_t keylength_b, cast5_ctx_t *s)
+{
+ /* we migth return if the key is valid and if setup was successful */
+ uint32_t x[4], z[4];
+#define BPX ((uint8_t*)&(x[0]))
+#define BPZ ((uint8_t*)&(z[0]))
+ s->shortkey = (keylength_b <= 80);
+ /* littel endian only! */
+ memset(&(x[0]), 0, 16); /* set x to zero */
+ if (keylength_b > 128)
+ keylength_b = 128;
+ memcpy(&(x[0]), key, (keylength_b + 7) / 8);
+
+ /* todo: merge a and b and compress the whole stuff */
+ /***** A *****/
+ cast5_init_A((uint8_t*) (&z[0]), (uint8_t*) (&x[0]), false);
+ /***** M *****/
+ cast5_init_M((uint8_t*) (&(s->mask[0])), (uint8_t*) (&z[0]), false, false);
+ /***** B *****/
+ cast5_init_A((uint8_t*) (&x[0]), (uint8_t*) (&z[0]), true);
+ /***** N *****/
+ cast5_init_M((uint8_t*) (&(s->mask[4])), (uint8_t*) (&x[0]), true, false);
+ /***** A *****/
+ cast5_init_A((uint8_t*) (&z[0]), (uint8_t*) (&x[0]), false);
+ /***** N' *****/
+ cast5_init_M((uint8_t*) (&(s->mask[8])), (uint8_t*) (&z[0]), true, true);
+ /***** B *****/
+ cast5_init_A((uint8_t*) (&x[0]), (uint8_t*) (&z[0]), true);
+ /***** M' *****/
+ cast5_init_M((uint8_t*) (&(s->mask[12])), (uint8_t*) (&x[0]), false, true);
+
+ /* that were the masking keys, now the rotation keys */
+ /* set the keys to zero */
+ memset(&(s->rotl[0]), 0, 8);
+ s->roth[0] = s->roth[1] = 0;
+ /***** A *****/
+ cast5_init_A((uint8_t*) (&z[0]), (uint8_t*) (&x[0]), false);
+ /***** M *****/
+ cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 0, (uint8_t*) (&z[0]), false, false);
+ /***** B *****/
+ cast5_init_A((uint8_t*) (&x[0]), (uint8_t*) (&z[0]), true);
+ /***** N *****/
+ cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 1, (uint8_t*) (&x[0]), true, false);
+ /***** A *****/
+ cast5_init_A((uint8_t*) (&z[0]), (uint8_t*) (&x[0]), false);
+ /***** N' *****/
+ cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 2, (uint8_t*) (&z[0]), true, true);
+ /***** B *****/
+ cast5_init_A((uint8_t*) (&x[0]), (uint8_t*) (&z[0]), true);
+ /***** M' *****/
+ cast5_init_rM(&(s->rotl[0]), &(s->roth[0]), 3, (uint8_t*) (&x[0]), false, true);
+ /* done ;-) */