Beispiel #1
0
static int cfb64_test(unsigned char *cfb_cipher)
	{
	des_key_schedule ks;
	int err=0,i,n;

	des_set_key_checked(&cfb_key,ks);
	memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
	n=0;
	des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
	des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
			  &cfb_tmp,&n,DES_ENCRYPT);
	if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
		{
		err=1;
		printf("cfb_encrypt encrypt error\n");
		for (i=0; i<24; i+=8)
			printf("%s\n",pt(&(cfb_buf1[i])));
		}
	memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
	n=0;
	des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
	des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
			  sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
	if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
		{
		err=1;
		printf("cfb_encrypt decrypt error\n");
		for (i=0; i<24; i+=8)
			printf("%s\n",pt(&(cfb_buf2[i])));
		}
	return(err);
	}
Beispiel #2
0
static int cfb64_test(unsigned char *cfb_cipher)
	{
	des_key_schedule ks;
	int err=0,i,n;

	DES_set_key_checked(&cfb_key,&ks);
	TINYCLR_SSL_MEMCPY(cfb_tmp,cfb_iv,sizeof(cfb_iv));
	n=0;
	des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
	des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
			  &cfb_tmp,&n,DES_ENCRYPT);
	if (TINYCLR_SSL_MEMCMP(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
		{
		err=1;
		TINYCLR_SSL_PRINTF("cfb_encrypt encrypt error\n");
		for (i=0; i<24; i+=8)
			TINYCLR_SSL_PRINTF("%s\n",pt(&(cfb_buf1[i])));
		}
	TINYCLR_SSL_MEMCPY(cfb_tmp,cfb_iv,sizeof(cfb_iv));
	n=0;
	des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
	des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
			  sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
	if (TINYCLR_SSL_MEMCMP(plain,cfb_buf2,sizeof(plain)) != 0)
		{
		err=1;
		TINYCLR_SSL_PRINTF("cfb_encrypt decrypt error\n");
		for (i=0; i<24; i+=8)
			TINYCLR_SSL_PRINTF("%s\n",pt(&(cfb_buf2[i])));
		}
	return(err);
	}
Beispiel #3
0
static void
cfb64_test(unsigned char *cfb_cipher)
{
	int n;
	des_key_schedule ks;

	des_set_key_checked(&cfb_key, ks);
	memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
	n = 0;
	des_cfb64_encrypt(plain, cfb_buf1, 12, ks, &cfb_tmp, &n, DES_ENCRYPT);
	des_cfb64_encrypt(&(plain[12]), &(cfb_buf1[12]), sizeof(plain) - 12, ks,
			  &cfb_tmp, &n, DES_ENCRYPT);
	if (memcmp(cfb_cipher, cfb_buf1, sizeof(plain)) != 0)
		fail_cfb_buf("cfb_encrypt encrypt error", cfb_buf1);
	memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
	n = 0;
	des_cfb64_encrypt(cfb_buf1, cfb_buf2, 17, ks, &cfb_tmp, &n, DES_DECRYPT);
	des_cfb64_encrypt(&(cfb_buf1[17]), &(cfb_buf2[17]),
			  sizeof(plain) - 17, ks, &cfb_tmp, &n, DES_DECRYPT);
	if (memcmp(plain, cfb_buf2, sizeof(plain)) != 0)
		fail_cfb_buf("cfb_encrypt decrypt error", cfb_buf2);
}