コード例 #1
0
int main(int argc, char **args) {
    (void) argc; (void) args;

    test_s();
    test_S();
    test1();

    return 0;
}
コード例 #2
0
ファイル: kuzn.c プロジェクト: dzruyk/kuznyechik_cipher
int
test_kuzn()
{
	struct kuzn_ctx ctx;

	kuzn_context_init(&ctx);

	if (test_S() != 0) {
		printf("[-] S function test failed\n");
		return 1;
	} else {
		printf("[+] S test OK!\n");
	}
	
	if (test_R(&ctx) != 0) {
		printf("[-] R function test failed\n");
		return 1;
	} else {
		printf("[+] R test OK!\n");
	}

	if (test_L(&ctx) != 0) {
		printf("[-] L function test failed\n");
		return 1;
	} else {
		printf("[+] L test OK!\n");
	}

	if (test_keygen(&ctx) != 0) {
		printf("[-] expand key test failed\n");
		return 1;
	} else {
		printf("[+] expand key test OK!\n");
	}

	if (test_encryption(&ctx) != 0) {
		printf("[-] Encrypt/decrypt test failed\n");
		return 1;
	} else {
		printf("[+] Encrypt/decrypt test OK!\n");
	}

	return 0;
}
コード例 #3
0
ファイル: vmtest.c プロジェクト: raph38130/rplgm
main()
{
SetHandler(VBR+36*4,msg_S);//trap 4
SetHandler(VBR+37*4,msg_U);//trap 5

asm ("
    /* Transparent Translation Register
     * doc Motorola 3.1.3
     *
     * FFxxxxxx transparent
     * Enable
     * FC2 ignored (ok pour accès S ou U)
     * CM non cachable, serialized
     * R/W
     */
    move.l #0xff00c040,%d0
    movec.l %d0,%itt1
    movec.l %d0,%dtt1
    
    /* 
     * bloc 00xxxxxxxx transparent pour le mode S uniquement
     */
    move.l #0x0000a040,%d0
    movec.l %d0,%dtt0
    movec.l %d0,%itt0
    ");
    
    /*
     * table des descripteurs en 0x200000
     * 		- pour une seule page de 4 k à partir de 0x10000 : code + pile
     * 		(c'est la page n° 0,0,16)
     *		- pour la pile : une page avant 0x300000
     *		(c'est la page n° 0,11,63)
     */
InstallDescr(0,0,16);  
//InstallDescr(0,0,17);  
InstallDescr(0,11,63);  
//n m p
//p = (n°page % 8192) % 64 (si page de 4k)	0...63
//m = (n°page % 8192) / 64			0...127
//n = n°page / 8192				0...127
    asm("
    |instr. cache on, data cache on
    move.l #0x80008000,%a0
    movec.l %a0,%cacr
    move.l #0x200000,%a0
    movec.l %a0,%urp
    |vm Enable, page de 4k
    move.w #0x8000,%d0
    movec.l %d0,%tcr
    pflusha"
    );

test_S();
//passer en mode U
asm("
   move.l #0x300000,%a0
   |exemple avec une seule page
   |move.l #0x10000+4096,%a0
   move.l %a0,%usp
   move.w #0,%sr
   ");
   
test_U();
//il faudrait restorer le mode S pour terminer correctement
}
コード例 #4
0
void data_initialization(long int* t)
{
	*t = 0;
	for (int i = 0; i < def.locNx; i++)
		for (int j = 0; j < def.locNy; j++)
			for (int k = 0; k < def.locNz; k++)
			{
				int local = i + j * (def.locNx) + k * (def.locNx) * (def.locNy);

				HostArraysPtr.m[local]=def.porosity[0];
				S_local_initialization(local);

				/*if ((j == 0) && ((def.source) > 0))
				{
					HostArraysPtr.S_w[local] = def.S_w_gr;
					HostArraysPtr.S_n[local] = def.S_n_gr;
				}
				else
				{
					HostArraysPtr.S_w[local] = def.S_w_init;
					HostArraysPtr.S_n[local] = def.S_n_init;
				}*/

				/*double ro_g_dy = ((def.ro0_g * (1. - HostArraysPtr.S_w[local] - HostArraysPtr.S_n[local])
				+ def.ro0_w * HostArraysPtr.S_w[local]
				+ def.ro0_n * HostArraysPtr.S_n[local]) * (HostArraysPtr.m[local]) + (1. - HostArraysPtr.m[local]) * 2000.) * (def.g_const) * (def.hy);*/

				// Если отдельно задаем значения на границах через градиент
				//if (j == 0)
				{
					HostArraysPtr.P_w[local] = def.P_atm;
					HostArraysPtr.P_n[local] = def.P_atm;
					HostArraysPtr.P_g[local] = def.P_atm;
				}
				/*else
				{
					HostArraysPtr.P_w[local] = HostArraysPtr.P_w[local - (def.locNx)] + ro_g_dy;
					HostArraysPtr.P_n[local] = HostArraysPtr.P_n[local - (def.locNx)] + ro_g_dy;
					HostArraysPtr.P_g[local] = HostArraysPtr.P_g[local - (def.locNx)] + ro_g_dy;
				}*/

				HostArraysPtr.ro_w[local] = def.ro0_w * (1. + (def.beta_w) * (HostArraysPtr.P_w[local] - def.P_atm));
				HostArraysPtr.ro_n[local] = def.ro0_n * (1. + (def.beta_n) * (HostArraysPtr.P_n[local] - def.P_atm));
				HostArraysPtr.ro_g[local] = def.ro0_g * HostArraysPtr.P_g[local] / def.P_atm;

#ifdef ENERGY
				// !!!! Нужно задать начальные распределения температуры, энтальпии, энергии!
				HostArraysPtr.T[local] = 285;

				test_positive(HostArraysPtr.T[local], __FILE__, __LINE__);
#endif
				test_S(HostArraysPtr.S_n[local], __FILE__, __LINE__);
				test_S(HostArraysPtr.S_w[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.P_w[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.P_n[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.P_g[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.ro_w[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.ro_n[local], __FILE__, __LINE__);
				test_positive(HostArraysPtr.ro_g[local], __FILE__, __LINE__);
			}
}