Beispiel #1
0
int aes_encode(image_desc i_img, image_desc *p_img)
{
uint16_t planeSize;
planeSize = mallocImageContent(p_img, i_img.width, i_img.height);
/* Exit the function if allocation fails */
if (planeSize == 0) return FUNERR;
int nb=(i_img.width) * (i_img.height); 

// nombre de blocs de 16
  int nb_bloc=nb/16;
 
  printf("Nombre de blocs = %d \n",nb_bloc);
  test_encrypt_ecb_verbose(p_img->pBlue,i_img.pBlue, nb_bloc);
  test_encrypt_ecb_verbose(p_img->pGreen,i_img.pGreen, nb_bloc);
  test_encrypt_ecb_verbose(p_img->pRed,i_img.pRed, nb_bloc);
  

  // dernier bloc
  int rest=nb%16;
  printf("Reste = %d \n",rest);
  if (rest!=0) 
	{
           uint8_t * dernier_bloc=malloc(16*sizeof(uint8_t));
           memset(dernier_bloc, 0,16);
           test_encrypt_ecb_verbose(dernier_bloc,i_img.pBlue+nb_bloc*16,1);
	
  	   int i;
  	    for(i=0;i<rest;i++) {
			p_img->pBlue[i+nb_bloc*16]=*(dernier_bloc+i);
		      		}
	}
 return FUNOK;
}
Beispiel #2
0
int main(void)
{
    test_encrypt_cbc();
    test_decrypt_cbc();
    test_decrypt_ecb();
    test_encrypt_ecb();
    test_encrypt_ecb_verbose();
    
    encrypt_cbc_ts();
	//decrypt_cbc_ts();
	
    return 0;
}