Example #1
0
/* Called when seahorse-actions has a response to send back */
gboolean
gkd_gpg_agent_send_reply (GkdGpgAgentCall *call, gboolean ok, const gchar *response)
{
	int fd = g_io_channel_unix_get_fd (call->channel);
	if (!write_all (fd, ok ? GPG_AGENT_OK : GPG_AGENT_ERR, ok ? KL (GPG_AGENT_OK) : KL (GPG_AGENT_ERR)) ||
	    (response && !write_all (fd, response, -1)) ||
	    !write_all (fd, "\n", 1))
		return FALSE;

	return TRUE;
}
Example #2
0
void GEMENI_charsent() {
	unsigned long r = s->log[s->lc];
	if (UCA0IFG & UCTXIFG) {
		s->nch++;
		switch (s->nch) {
			case 1:
				UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r);
			break;
			case 2:
				UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3;
			break;
			case 3:
				UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r);
			break;
			case 4:
				UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r);
			break;
			case 5:
				UCA0TXBUF = POUND(r)<<1 | ZRS(r);
			break;
			default:
				s->lc++;
				if (s->lc != s->nc-1) {

  					s->nch = 0;
  					UCA0TXBUF = 1 << 7; // first packet, no fn or '#'
				} else {
					s->flags &= ~CSEND;
				}

		}
	}
}
Example #3
0
gboolean
gkd_gpg_agent_send_data (GkdGpgAgentCall *call, const gchar *data)
{
	int fd = g_io_channel_unix_get_fd (call->channel);
	if (!write_all (fd, GPG_AGENT_DATA, KL (GPG_AGENT_DATA)) ||
	    !write_all (fd, data, -1) ||
	    !write_all (fd, "\n", 1))
		return FALSE;

	return TRUE;
}
Example #4
0
HBufC* PkiUtil::AttributeTypeToNameL(const TDesC &aType)
{
    HBufC* name;

    if (aType.Compare(KX520CountryName) == 0)
    {
        name = KC().AllocL();
    }
    else if (aType.Compare(KX520OrganizationName) == 0)
    {
        name = KO().AllocL();
    }
    else if (aType.Compare(KX520OrganizationalUnitName) == 0)
    {
        name = KOU().AllocL();
    }
    else if (aType.Compare(KX520LocalityName) == 0)
    {
        name = KL().AllocL();
    }
    else if (aType.Compare(KX520StateOrProvinceName) == 0)
    {
        name = KST().AllocL();
    }
    else if (aType.Compare(KX520CommonName) == 0)
    {
        name = KCN().AllocL();
    }
    else
    {
        // Use the dotted-decimal encoding
        // of the OID as the attribute name
        name = aType.AllocL();
    }

    return name;
}
Example #5
0
void _stdcall serpent256_decrypt(const unsigned char *in, unsigned char *out, serpent256_key *key)
{
	u32 *k = key->expkey;
	u32	 r0, r1, r2, r3, r4;

	r0 = p32(in)[0]; r1 = p32(in)[1];
	r2 = p32(in)[2]; r3 = p32(in)[3];

	K(r0,r1,r2,r3,32);
	SI7(r0,r1,r2,r3,r4); KL(r1,r3,r0,r4,r2,31);
	SI6(r1,r3,r0,r4,r2); KL(r0,r2,r4,r1,r3,30);
	SI5(r0,r2,r4,r1,r3); KL(r2,r3,r0,r4,r1,29);
	SI4(r2,r3,r0,r4,r1); KL(r2,r0,r1,r4,r3,28);
	SI3(r2,r0,r1,r4,r3); KL(r1,r2,r3,r4,r0,27);
	SI2(r1,r2,r3,r4,r0); KL(r2,r0,r4,r3,r1,26);
	SI1(r2,r0,r4,r3,r1); KL(r1,r0,r4,r3,r2,25);
	SI0(r1,r0,r4,r3,r2); KL(r4,r2,r0,r1,r3,24);
	SI7(r4,r2,r0,r1,r3); KL(r2,r1,r4,r3,r0,23);
	SI6(r2,r1,r4,r3,r0); KL(r4,r0,r3,r2,r1,22);
	SI5(r4,r0,r3,r2,r1); KL(r0,r1,r4,r3,r2,21);
	SI4(r0,r1,r4,r3,r2); KL(r0,r4,r2,r3,r1,20);
	SI3(r0,r4,r2,r3,r1); KL(r2,r0,r1,r3,r4,19);
	SI2(r2,r0,r1,r3,r4); KL(r0,r4,r3,r1,r2,18);
	SI1(r0,r4,r3,r1,r2); KL(r2,r4,r3,r1,r0,17);
	SI0(r2,r4,r3,r1,r0); KL(r3,r0,r4,r2,r1,16);
	SI7(r3,r0,r4,r2,r1); KL(r0,r2,r3,r1,r4,15);
	SI6(r0,r2,r3,r1,r4); KL(r3,r4,r1,r0,r2,14);
	SI5(r3,r4,r1,r0,r2); KL(r4,r2,r3,r1,r0,13);
	SI4(r4,r2,r3,r1,r0); KL(r4,r3,r0,r1,r2,12);
	SI3(r4,r3,r0,r1,r2); KL(r0,r4,r2,r1,r3,11);
	SI2(r0,r4,r2,r1,r3); KL(r4,r3,r1,r2,r0,10);
	SI1(r4,r3,r1,r2,r0); KL(r0,r3,r1,r2,r4,9);
	SI0(r0,r3,r1,r2,r4); KL(r1,r4,r3,r0,r2,8);
	SI7(r1,r4,r3,r0,r2); KL(r4,r0,r1,r2,r3,7);
	SI6(r4,r0,r1,r2,r3); KL(r1,r3,r2,r4,r0,6);
	SI5(r1,r3,r2,r4,r0); KL(r3,r0,r1,r2,r4,5);
	SI4(r3,r0,r1,r2,r4); KL(r3,r1,r4,r2,r0,4);
	SI3(r3,r1,r4,r2,r0); KL(r4,r3,r0,r2,r1,3);
	SI2(r4,r3,r0,r2,r1); KL(r3,r1,r2,r0,r4,2);
	SI1(r3,r1,r2,r0,r4); KL(r4,r1,r2,r0,r3,1);
	SI0(r4,r1,r2,r0,r3); K(r2,r3,r1,r4,0);

	p32(out)[0] = r2; p32(out)[1] = r3;
	p32(out)[2] = r1; p32(out)[3] = r4;
}
Example #6
0
void __serpent_decrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src)
{
	const u32 *k = ctx->expkey;
	const __le32 *s = (const __le32 *)src;
	__le32	*d = (__le32 *)dst;
	u32	r0, r1, r2, r3, r4;

	r0 = le32_to_cpu(s[0]);
	r1 = le32_to_cpu(s[1]);
	r2 = le32_to_cpu(s[2]);
	r3 = le32_to_cpu(s[3]);

					K(r0, r1, r2, r3, 32);
	SI7(r0, r1, r2, r3, r4);	KL(r1, r3, r0, r4, r2, 31);
	SI6(r1, r3, r0, r4, r2);	KL(r0, r2, r4, r1, r3, 30);
	SI5(r0, r2, r4, r1, r3);	KL(r2, r3, r0, r4, r1, 29);
	SI4(r2, r3, r0, r4, r1);	KL(r2, r0, r1, r4, r3, 28);
	SI3(r2, r0, r1, r4, r3);	KL(r1, r2, r3, r4, r0, 27);
	SI2(r1, r2, r3, r4, r0);	KL(r2, r0, r4, r3, r1, 26);
	SI1(r2, r0, r4, r3, r1);	KL(r1, r0, r4, r3, r2, 25);
	SI0(r1, r0, r4, r3, r2);	KL(r4, r2, r0, r1, r3, 24);
	SI7(r4, r2, r0, r1, r3);	KL(r2, r1, r4, r3, r0, 23);
	SI6(r2, r1, r4, r3, r0);	KL(r4, r0, r3, r2, r1, 22);
	SI5(r4, r0, r3, r2, r1);	KL(r0, r1, r4, r3, r2, 21);
	SI4(r0, r1, r4, r3, r2);	KL(r0, r4, r2, r3, r1, 20);
	SI3(r0, r4, r2, r3, r1);	KL(r2, r0, r1, r3, r4, 19);
	SI2(r2, r0, r1, r3, r4);	KL(r0, r4, r3, r1, r2, 18);
	SI1(r0, r4, r3, r1, r2);	KL(r2, r4, r3, r1, r0, 17);
	SI0(r2, r4, r3, r1, r0);	KL(r3, r0, r4, r2, r1, 16);
	SI7(r3, r0, r4, r2, r1);	KL(r0, r2, r3, r1, r4, 15);
	SI6(r0, r2, r3, r1, r4);	KL(r3, r4, r1, r0, r2, 14);
	SI5(r3, r4, r1, r0, r2);	KL(r4, r2, r3, r1, r0, 13);
	SI4(r4, r2, r3, r1, r0);	KL(r4, r3, r0, r1, r2, 12);
	SI3(r4, r3, r0, r1, r2);	KL(r0, r4, r2, r1, r3, 11);
	SI2(r0, r4, r2, r1, r3);	KL(r4, r3, r1, r2, r0, 10);
	SI1(r4, r3, r1, r2, r0);	KL(r0, r3, r1, r2, r4, 9);
	SI0(r0, r3, r1, r2, r4);	KL(r1, r4, r3, r0, r2, 8);
	SI7(r1, r4, r3, r0, r2);	KL(r4, r0, r1, r2, r3, 7);
	SI6(r4, r0, r1, r2, r3);	KL(r1, r3, r2, r4, r0, 6);
	SI5(r1, r3, r2, r4, r0);	KL(r3, r0, r1, r2, r4, 5);
	SI4(r3, r0, r1, r2, r4);	KL(r3, r1, r4, r2, r0, 4);
	SI3(r3, r1, r4, r2, r0);	KL(r4, r3, r0, r2, r1, 3);
	SI2(r4, r3, r0, r2, r1);	KL(r3, r1, r2, r0, r4, 2);
	SI1(r3, r1, r2, r0, r4);	KL(r4, r1, r2, r0, r3, 1);
	SI0(r4, r1, r2, r0, r3);	K(r2, r3, r1, r4, 0);

	d[0] = cpu_to_le32(r2);
	d[1] = cpu_to_le32(r3);
	d[2] = cpu_to_le32(r1);
	d[3] = cpu_to_le32(r4);
}
Example #7
0
	return input == NULL ? false : true;
}
bool Use_LCG(_RNG_Parameters_){
	LC_RNG rng(seed);
	rng.GenerateBlock(input,size);
	return input == NULL ? false : true;
}

/************************库信息说明*****************************/
//其他数值分别是BLOCK,STREAM,HASH,MAC,RNG
extern const int DLL_ALGORITHM_TYPE = 0;
/************************算法信息*****************************/
//数组AMOUNT中第一个数为分组密码算法的数量,以后依次为流密码,HASH,MAC,RNG的数量
extern const int AMOUNTS[] = {21,6,18,6,2};
extern const Cipher CIPHERS[] = {
	BlockInfo("AES",KL(AES),BS(AES)),BlockInfo("Blowfish",KL(Blowfish),BS(Blowfish)),
	BlockInfo("Camellia",KL(Camellia),BS(Camellia)),BlockInfo("CAST256",KL(CAST256),BS(CAST256)),
	BlockInfo("DES",KL(DES),BS(DES)),BlockInfo("MARS",KL(MARS),BS(MARS)),
	BlockInfo("IDEA",KL(IDEA),BS(IDEA)),BlockInfo("RC5",KL(RC5),BS(RC5)),
	BlockInfo("RC6",KL(RC6),BS(RC6)),BlockInfo("SEED",KL(SEED),BS(SEED)),
	BlockInfo("Serpent",KL(Serpent),BS(Serpent)),BlockInfo("SHACAL2",KL(SHACAL2),BS(SHACAL2)),
	BlockInfo("SKIPJACK",KL(SKIPJACK),BS(SKIPJACK)),BlockInfo("TEA",KL(TEA),BS(TEA)),
	BlockInfo("Twofish",KL(Twofish),BS(Twofish)),BlockInfo("XTEA",KL(XTEA),BS(XTEA)),
	BlockInfo("DES_EDE3",KL(DES_EDE3),BS(DES_EDE3)),BlockInfo("GOST",KL(GOST),BS(GOST)),
	BlockInfo("SHARK",KL(SHARK),BS(SHARK)),BlockInfo("Square",KL(Square),BS(Square)),
	BlockInfo("ThreeWay",KL(ThreeWay),BS(ThreeWay)),

	StreamInfo("Sosemanuk",KL(Sosemanuk),IL(Sosemanuk)),
	StreamInfo("Salsa20",KL(Salsa20),IL(Salsa20)),
	StreamInfo("XSalsa20",KL(XSalsa20),IL(XSalsa20)),
	StreamInfo("SEAL",KL(SEAL<>),IL(SEAL<>)),
void SpriteCharacterGame::SpawnSystem(vector<Node*>* a_waypoint, int a_x, int a_y, int a_unit, int a_star, int a_planet,int a_moons, 
	int a_satellite, int a_asteroid)
{
	float Rot = 0.00025;
	//float Rot() { return HELP_Random(); };
	int k = 0;
	enum NodeType
	{
		EMPTY, STAR, PLANET, MOON, SATELLITE, ASTEROID
	};
	for (int i = 0; i <  a_star; i++)
	{
		(*a_waypoint).push_back(new Node(a_x , a_y,STAR));
		(*a_waypoint)[k]->ChangeSprite(TM_SUN);
		(*a_waypoint)[k]->SetNodeReq(0,Fuel);
		(*a_waypoint)[k]->SetSprite(110, 110, 0, 0, 110, 110, 0, Rot);
		m_stars++;
		k++;
		cout << "Star " << k << endl;
	}
	for (int i = 0; i < a_planet; i++)
	{
		int j = 0;
		while(j == 0){j = HELP_Random(-1, 1);}
		(*a_waypoint).push_back(new Node(KL() * i *(110) + (a_unit), KL() * i * (110) + (a_unit), PLANET));
		(*a_waypoint)[k]->ChangeSprite(TM_PLANETONE);
		for (int i = 0; i < a_waypoint->size(); i++) { if ((*a_waypoint)[k]->m_x == (*a_waypoint)[i]->m_x && (*a_waypoint)[k]->m_y == (*a_waypoint)[i]->m_y) { (*a_waypoint)[k]->m_x += HELP_Random(100,200); (*a_waypoint)[k]->m_y += HELP_Random(100, 200);} }
		(*a_waypoint)[k]->SetSprite(110, 110, 0, 0, 110/2, 110/2, 0, Rot + 0.00025 * KL());
		(*a_waypoint)[k]->SetParent(0);
		(*a_waypoint)[k]->SetNodeReq(0, Metal);
		if ((*a_waypoint)[k - 1]->m_x == (*a_waypoint)[k]->m_x) { (*a_waypoint)[k]->m_x *= -1; }
		if ((*a_waypoint)[k - 1]->m_y == (*a_waypoint)[k]->m_y) { (*a_waypoint)[k]->m_y *= -1; }
		m_planets++;
		k++;
		cout << "Planet " << k << endl;
	}
	for (int i = 0; i < a_moons; i++)
	{
		int j = 0;
		while (j == 0) { j = HELP_Random(-1, 1); }
		(*a_waypoint).push_back(new Node(KL() * i *(110) + (a_unit), KL() * i * (110) + (a_unit), MOON));
		(*a_waypoint)[k]->ChangeSprite(TM_MOONONE);
		(*a_waypoint)[k]->SetNodeReq(0, Fuel);
		for (int i = 0; i < a_waypoint->size(); i++) { if ((*a_waypoint)[k]->m_x == (*a_waypoint)[i]->m_x && (*a_waypoint)[k]->m_y == (*a_waypoint)[i]->m_y) { (*a_waypoint)[k]->m_x += HELP_Random(100, 200); (*a_waypoint)[k]->m_y += HELP_Random(100, 200); } }
		(*a_waypoint)[k]->SetSprite(110, 110, 0, 0, 110/3, 110/3, 0, Rot + 0.0025 * KL());
		(*a_waypoint)[k]->SetParent(HELP_Random(a_star + 1, a_planet));
		if ((*a_waypoint)[k - 1]->m_x == (*a_waypoint)[k]->m_x) { (*a_waypoint)[k]->m_x *= -1; }
		if ((*a_waypoint)[k - 1]->m_y == (*a_waypoint)[k]->m_y) { (*a_waypoint)[k]->m_y *= -1; }
		m_moons++;
		k++;
		cout << "Moon " << k << endl;
	}
	for (int i = 0; i < a_asteroid; i++)
	{
		int j = 0;
		while (j == 0) { j = HELP_Random(-1, 1); }
		(*a_waypoint).push_back(new Node(KL() * i *(110) + (a_unit), KL() * i * (110) + (a_unit), PLANET));
		(*a_waypoint)[k]->ChangeSprite(TM_PLANETONE);
		(*a_waypoint)[k]->SetNodeReq(0, Metal);
		for (int i = 0; i < a_waypoint->size(); i++) { if ((*a_waypoint)[k]->m_x == (*a_waypoint)[i]->m_x && (*a_waypoint)[k]->m_y == (*a_waypoint)[i]->m_y) { (*a_waypoint)[k]->m_x += HELP_Random(100, 200); (*a_waypoint)[k]->m_y += HELP_Random(100, 200); } }
		(*a_waypoint)[k]->SetSprite(110, 110, 0, 0, 110/4, 110/4, 0, Rot + 0.025 * KL());
		(*a_waypoint)[k]->SetParent(HELP_Random(a_star + 1, a_moons));
		if ((*a_waypoint)[k - 1]->m_x == (*a_waypoint)[k]->m_x) { (*a_waypoint)[k]->m_x *= -1; }
		if ((*a_waypoint)[k - 1]->m_y == (*a_waypoint)[k]->m_y) { (*a_waypoint)[k]->m_y *= -1; }
		m_asteroids++;
		k++;
		cout << "Asteroid " << k << endl;
	}

	(*a_waypoint).push_back(new Node(a_unit + 100, a_unit + 100, SATELLITE));
	(*a_waypoint)[k]->ChangeSprite(TM_BASESTATION);  
	(*a_waypoint)[k]->SetNodeReq(0, Home);
	for (int i = 0; i < a_waypoint->size(); i++) { if ((*a_waypoint)[k]->m_x == (*a_waypoint)[i]->m_x && (*a_waypoint)[k]->m_y == (*a_waypoint)[i]->m_y) { (*a_waypoint)[k]->m_x += HELP_Random(100, 200); (*a_waypoint)[k]->m_y += HELP_Random(100, 200); } }
	(*a_waypoint)[k]->SetSprite(150, 100, 0, 0, 150/2.5, 100/2.5, 0, Rot + 0.000050 * KL());
	(*a_waypoint)[k]->SetParent(a_star);
	if ((*a_waypoint)[k - 1]->m_x == (*a_waypoint)[k]->m_x) { (*a_waypoint)[k]->m_x *= -1; }
	if ((*a_waypoint)[k - 1]->m_y == (*a_waypoint)[k]->m_y) { (*a_waypoint)[k]->m_y *= -1; }
	m_satellites++;
	cout << "Satellite " << k << endl;

	bool DistanceCheck = false;
	while (DistanceCheck == false)
	{
		DistanceCheck = true;
		for (int i = 0; i < (*a_waypoint).size(); i++)
		{
			if ((*a_waypoint)[i]->m_x > 1250) { (*a_waypoint)[i]->m_x -= 500; DistanceCheck = false; }
			if ((*a_waypoint)[i]->m_y > 1250) { (*a_waypoint)[i]->m_y -= 500; DistanceCheck = false; }
			cout << "Distance Checking " << i <<  endl;
		};
	}
	cout << "Distance Checked " << endl;
	bool BB = false;
	bool AA = false;
	int j = 0;
	int i = 0;
	int L = 0;
	int M = 0;
	int H = a_waypoint->size();

	int Rotations = 0;

	while (BB == false)
	{
		BB = true;
		AA = false;
		while (AA == false)
		{
			AA = true;
			if (j == 0 && i == 0) { i++; AA == false;}
			else if (j == i) { j++; AA == false;}

			if (j >= a_waypoint->size()) { j = 0; }
			if (i >= a_waypoint->size()) { i = 0; }
			
			if ((*a_waypoint)[i]->m_x == (*a_waypoint)[j]->m_x && (*a_waypoint)[i]->m_y == (*a_waypoint)[j]->m_y)
			{
				(*a_waypoint)[i]->SetXY(HELP_Random(150,500),HELP_Random(150,500));
				AA == false;
				BB == false;
			}
			else { L++; BB = false; AA = false;}

			if (L >= a_waypoint->size()) {AA = true; }

			j++;
			Rotations++;
			if (Rotations > 5000)
			{ return; }
			cout << "Iteration "<< Rotations << endl;
		}
		M++;
		j = 0;
		L = 0;
		if (M == a_waypoint->size()) { BB = true; }
		i++;
		if (i > a_waypoint->size()) { i = 0; }
		Rotations++;
		if (Rotations > 5000)
		{ return; }
		cout << "Iteration " << Rotations << endl;
	}
	cout << "Iterated " << Rotations << " times" << endl;
	i = 0;
	j = 0;
	cout << "System created" << endl;
}
Example #9
0
unsigned short keypad_keysym_redirect(unsigned short keysym)
{
	if (applic_keypad || KTYP(keysym) != KT_PAD || KVAL(keysym) >= NR_PAD) return keysym;

	#define KL(val) K(KT_LATIN, val)
	static const unsigned short num_map[] = {
		KL('0'), KL('1'), KL('2'), KL('3'), KL('4'),
		KL('5'), KL('6'), KL('7'), KL('8'), KL('9'),
		KL('+'), KL('-'), KL('*'), KL('/'), K_ENTER,
		KL(','), KL('.'), KL('?'), KL('('), KL(')'),
		KL('#')
	};

	static const unsigned short fn_map[] = {
		K_INSERT, K_SELECT, K_DOWN, K_PGDN, K_LEFT,
		K_P5, K_RIGHT, K_FIND, K_UP, K_PGUP,
		KL('+'), KL('-'), KL('*'), KL('/'), K_ENTER,
		K_REMOVE, K_REMOVE, KL('?'), KL('('), KL(')'),
		KL('#')
	};

	if (lock_state & K_NUMLOCK) return num_map[keysym - K_P0];
	return fn_map[keysym - K_P0];
}