Exemplo n.º 1
0
static int do_connecting(void)
{
  struct key csession_secret;
  struct key csession_public;
  struct key tmpkey;
  unsigned backoff = 1;

  saw_seq_gap = 0;
  buffer->rewind();
  key_generate(&csession_secret, &csession_public, keyex);
  make_ini(&csession_public, buffer->peek());
  keylist_exchange_list_key(&tmpkey, &server_publics, &csession_secret);
  auth_start(&cid_authenticator, &tmpkey);

  while (!exitasap) {
    send_packet("INI1", cid_timeout * backoff);
    while (!exitasap) {
      if (poll_both() == 0)
	return STATE_DISCONNECTED;
      if (stdin_ready)
	read_lines();
      if (sock_ready) {
	if (receive_cid(&csession_secret))
	  return STATE_SENDING;
	backoff = 0;
      }
    }
    if (backoff < retransmits)
      ++backoff;
  }
  return STATE_EXITING;
}
Exemplo n.º 2
0
/*
 * Signal handler for the key regeneration alarm.  Note that this
 * alarm only occurs in the daemon waiting for connections, and it does not
 * do anything with the private key or random state before forking.
 * Thus there should be no concurrency control/asynchronous execution
 * problems.
 */
static void
generate_ephemeral_server_key(void)
{
	u_int32_t rnd = 0;
	int i;

	verbose("Generating %s%d bit RSA key.",
	    sensitive_data.server_key ? "new " : "", options.server_key_bits);
	if (sensitive_data.server_key != NULL)
		key_free(sensitive_data.server_key);
	sensitive_data.server_key = key_generate(KEY_RSA1,
	    options.server_key_bits);
	verbose("RSA key generation complete.");

	for (i = 0; i < SSH_SESSION_KEY_LENGTH; i++) {
		if (i % 4 == 0)
			rnd = arc4random();
		sensitive_data.ssh1_cookie[i] = rnd & 0xff;
		rnd >>= 8;
	}
	arc4random_stir();
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: manals/Aes
int main ()
{

	 int i,j;

	unsigned char state[4][4] = {{0x32,0x88,0x31,0xE0},{0x43,0x5A,0x31,0x37},{0xF6,0x30,0x98,0x07},{0xa8,0x8D,0xA2,0x34}};
	unsigned char key[4][4]={{0x2B,0x28,0xAB,0x09},{0x7E,0xAE,0xF7,0xCF},{0x15,0xD2,0x15,0x4F},{0x16,0xA6,0x88,0x3C}};
	 unsigned char expan_key[4][44];
	 unsigned char temp[4][4];
//============1. Read user text into matrix=================
//===

	 print(state);
printf("\n KEY IN HEX \n");




print(key);

printf("\n");
printf("\n");
key_generate(key,expan_key);

printf("\n");
printf("\n");
//=================2. Add round key Correct ================



Add_key(state,key);

printf("\n AFTER ADDING ROUND KEY \n");

print(state);

int start=4;
int loop;
	unsigned char temp_key[4][4];
//=================3. n round ================

for(loop=1;loop<11;loop++)
{
	printf("\n State %d \n",loop);

	print(state);




	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			temp_key[j][i]=expan_key[j][loop*start+i];
		}

	}


	printf("\n key %d \n",loop);


	print(temp_key);
//=================3.a. SubByte ================


     subByte(state);

printf("\n AFTER SubByte\n");

print(state);

printf("\n");


//=================3.b. Shift raw Correct ================

shiftRaw(state);


printf("\n AFTER shift raw \n");

print(state);

printf("\n");


//=================3.c. mix Column Correct ================
if(loop!=10)
{
mixcolumn(state,temp);

printf("\n AFTER MIX COLUMN \n");

for(j=0;j<4;j++)
		{
		for (i=0;i<4;i++)
			{
			state[j][i]=temp[j][i];

		}
}
}

print(state);

//=================3.d. Add round key ================


Add_key(state,temp_key);

printf("\n AFTER ADDING ROUND KEY %d\n",loop);

print(state);

printf("\n");




}

	return 0;



}