Related Informations Sites

Websites may Interest You

RSS Subscription

Subscribe via RSS reader:
Subscribe via Email Address:
 
Showing posts with label Algorithm. Show all posts
Showing posts with label Algorithm. Show all posts

An implementation of RSA Algorithm

Posted By HinD On 10:52 AM 3 comments
RSA, named after its three creators - Rivest, Shamir and Adleman, was the first effective public-key algorithm, and for years has withstood intense scrutiny by cryptanalysts all over the world.
Unlike symmetric key algorithms, where, as long as one presumes that an algorithm is not flawed, the security relies on having to try all possible keys, public-key algorithms rely on it being computationally unfeasible to recover the private key from the public key.

RSA relies on the fact that it is easy to multiply two large prime numbers together, but extremely hard (i.e. time consuming) to factor them back from the result (Ref. 6).

Factoring a number means finding its prime factors, which are the prime numbers that need to be multiplied together in order to produce that number. For example:

10 = 2 * 5
60 = 2 * 2 * 3 * 5
2^113 - 1 = 3391 * 23279 * 65993 * 1868569 * 1066818132868207
The algorithm:

Two very large prime numbers, normally of equal length, are randomly chosen then multiplied together.
N = A*B

T = (A-1) * (B-1)

A third number is then also chosen randomly as the public key (E) such that it has no common factors (i.e. is relatively prime) with T. The private key (D) is then:

D = E^-1 mod T

To encrypt a block of plaintext (M) into ciphertext (C):

C = M^E mod N

To decrypt:

M = C^D mod N

As an example:

1st prime (A) = 37

2nd prime (B) = 23

So,

N= 37*23 = 851

T = (37 - 1)*(23 - 1) = 36 * 23 = 792

E must have no factors other than 1 in common with 792.

E (public key) could be 5.

D (private key) = 5^-1 mod 792 = 317

To encrypt a message (M) of the character ‘G’:

If G is represented as 7 (7th letter in alphabet), then M= 7.

C (ciphertext) = 7^5 mod 851 = 638

To decrypt:

M = 638^317 mod 851 = 7
==================================================================================
#include< stdio.h>
#include< conio.h>

int phi,M,n,e,d,C,FLAG;

int check()
{
int i;
for(i=3;e%i==0 && phi%i==0;i+2)
{
FLAG = 1;
return;
}
FLAG = 0;
}

void encrypt()
{
int i;
C = 1;
for(i=0;i< e;i++)
C=C*M%n;
C = C%n;
printf("\n\tEncrypted keyword : %d",C);
}

void decrypt()
{
int i;
M = 1;
for(i=0;i< d;i++)
M=M*C%n;
M = M%n;
printf("\n\tDecrypted keyword : %d",M);
}

void main()
{
int p,q,s;
clrscr();
printf("Enter Two Relatively Prime Numbers\t: ");
scanf("%d%d",&p,&q);
n = p*q;
phi=(p-1)*(q-1);
printf("\n\tF(n)\t= %d",phi);
do
{
printf("\n\nEnter e\t: ");
scanf("%d",&e);
check();
}while(FLAG==1);
d = 1;
do
{
s = (d*e)%phi;
d++;
}while(s!=1);
d = d-1;
printf("\n\tPublic Key\t: {%d,%d}",e,n);
printf("\n\tPrivate Key\t: {%d,%d}",d,n);
printf("\n\nEnter The Plain Text\t: ");
scanf("%d",&M);
encrypt();
printf("\n\nEnter the Cipher text\t: ");
scanf("%d",&C);
decrypt();
getch();
}

/*************** OUTPUT *****************

Enter Two Relatively Prime Numbers : 7 17

F(n) = 96

Enter e : 5

Public Key : {5,119}
Private Key : {77,119}

Enter The Plain Text : 19

Encrypted keyword : 66

Enter the Cipher text : 66

Decrypted keyword : 19 */

aNti-VirRuS mimicing Real World ANT

Posted By HinD On 1:34 AM 2 comments


ARTICLE TAKEN FORM BSSINESS-STANDARD.COM

Swarms of digital ants may soon crawl all over the internet, scouting not for food, but computer worms and self-replicating programs designed to steal information or facilitate unauthorised use of machines. Security experts have successfully deployed a new type of network security software which mimics the habits of real-world ants.

Ants on earth, for instance, wander randomly but return to their colonies when they find food. But on the way back, they leave behind pheromone trails. If other ants find the trail, they follow it and reinforce it. The idea of the ant colony algorithm follows this pattern. The digital ants wander through computer networks. When an ant detects a threat, other ants converge on the scene, drawing the attention of human operators who step in to investigate.

"In nature, we know that ants defend themselves against threats very successfully," Wake Forest Professor of Computer Science Errin Fulp, an expert in security and computer networks, said in a press statement, adding: "They can ramp up their defence rapidly, and then resume routine behaviour quickly after an intruder has been stopped. We were trying to achieve that same framework in a computer system.”

Digital ants are an application of Swarm Intelligence or SI. Examples of this concept abound in nature, and include ant colonies, bird flocking, animal herding, bacterial growth, and fish schooling. SI, which refers to a general set of algorithms, was made popular in works of fiction like 'Prey' from Michael Crichton, where a swarm of nano-robots attacks humans as experiments go wrong, and robotic sentinels in movies like The Matrix.

Using SI, these digital ants adapt to the variations of viruses that hackers routinely introduce. This is critical since security programs gobble up more resources, and antivirus scans take longer and machines run slower when anti-virus packages discover new threats and issue updates.

Glenn Fink, a research scientist at Pacific Northwest National Laboratory (PNNL) in Richland, Washington, came up with the idea of copying ant behaviour. PNNL, one of ten Department of Energy laboratories, conducts cutting-edge research in cyber security. Fink was familiar with Fulp's expertise developing faster scans using parallel processing – dividing computer data into batches like lines of shoppers going through grocery store checkouts, where each lane is focused on certain threats.

He invited Fulp and Wake Forest graduate students Wes Featherstun and Brian Williams to join a project there this summer that tested digital ants on a network of 64 computers. SI, the approach developed by PNNL and Wake Forest, divides the process of searching for specific threats.

“Our idea is to deploy 3,000 different types of digital ants, each looking for evidence of a threat,” Fulp said. “As they move about the network, they leave digital trails modelled after the scent trails ants in nature use to guide other ants. Each time a digital ant identifies some evidence, it is programmed to leave behind a stronger scent. Stronger scent trails attract more ants, producing the swarm that marks a potential computer infection.”

Fulp says the new security approach is best suited for large networks that share many identical machines, such as those found in governments, large corporations and universities.

And computer users need not worry that a swarm of digital ants will decide to take up residence in their machine by mistake. Digital ants cannot survive without software “sentinels” located at each machine, which in turn report to network “sergeants” monitored by humans, who supervise the colony and maintain ultimate control.