SSL and TLS

SSL – Secure socket layer
TLS – Transport layer security

The original Secure Sockets Layer (SSL) implementation was developed in the early 1990s by the Netscape Communications Corporation to secure HTTP, which sends its data as plain text over the Inter- net. The first official release was version 2.0, which gained widespread acceptance despite some design
problems with the protocol.

In the late 1990s it became apparent that SSL 2.0 was not secure. Netscape began working on SSL 3.0. In conjunction with Netscape, the Internet Engineering Task Force (IETF, the Internet standards governing body) began work on standardizing SSL, a project that became known as TLS (Transport Layer Security).

SSL 3.0 was not developed as rigorously as TLS, so it became available sooner and quickly overtook SSL 2.0 as the industry standard. TLS was finalized in 2000, providing the first standardized protocol for SSL. Although SSL 3.0 is still in widespread use, it is mostly obsolete for new development since almost all modern browsers support TLS.

The differences between TLS protocol and SSL 3.0 are not dramatic, but they are significant enough that TLS 1.0 and SSL 3.0 do not interoperate (although TLS 1.0 does incorporate a mechanism by which a TLS implementation can back down to SSL 3.0).

SSL is simple in theory (keys are exchanged using public-key cryptography, communication is done using symmetric-key cryptography), the actual implementation is quite complex. This section briefly covers the details of establishing an SSL connection and communicating using that connection.

SSL hand shake diagram http://en.wikipedia.org/wiki/Secure_Sockets_Layer

Permutation or combination

I had this confusion about permutation and combination. I got it clarified.

  • permutation, if the order of objects is important. Means we consider all possible orders.
  • combination, if the selection of objects is important. Means we consider this object with that object.

Ex:- I have a plate of 4 cups with different dishes (D1,D2,D3,D4), I want to taste only two dishes and see how the over all taste effect my impression on dishes.

  • Combination,. (D1,D2), (D1,D3), (D1,D4), (D2,D3),(D2,D4),(D3,D4) => 6 combinations. 4C2 is the representation.
  • Permutation, for each combination, I can taste in two ways. For example,  (D1,D2) can be tasted in order (D1,D2) or (D2,D1). so total there are => 6 combination * 2 permutation for each combination =  12 permutations. 4P2 is the representation

Formulas:

NCr = N!/ ((N-r)! * r!)

NPr = N!/(N-r)!

 Which one is the permutation or combination problem?

1. Doctor suggested to eat daily two verity of fruits and I have 4 apples, 3 oranges , 12 bananas and 6 chikku in my fridge. How many ways I can select two verity of fruits?

Ans: There are 6 combinations possible for two verity of fruits from 4 verities. But there are multiple objects in each verity. So we need to consider all those objects when we select. For combination of 4 apples (A1, A2,A3,A4) and 3 oranges (O1,O2,O3), we can have combinations => (A1,O1), (A1,O2),(A1,O3)  (A2,O1), (A2,O2),(A2,O3) (A3,O1), (A3,O2),(A3,O3)(A4,O1), (A4,O2),(A4,O3) (12 combinations). This is represented ad 4C1 * 3C1

Total number of ways: 4C1 * 3C1 + 4C1 * 12C1 +  4C1 * 6C1 +  3C1 *  12C1 + 3C1 * 6C1 + 12C1 *  6C1

If the problem says any two fruits ( Can be same fruit) then the number of ways will be =>  Add 4C2 + 3c2 + 12C2 + 6C2 to the above total.

2. IPL series has 8 teams and how many games will they play given two teams participate in a game?

Ans: This is a combination problem.

Choose 2 teams from 8 teams = 8C2 = 28 Games.

2a. Each team has their home ground, so total 8 grounds. If we put a constraint that each team has to play in other team’s ground.

Ans: For each combination, we have to play two games,  For example, IND ground (IND vs SA), SA ground (SA vs IND). So total = 28 combinations * 2 = 56 Games. You can also treat this as permutation problem. 8P2 =56. Because the order of team comes in to picture.

3. I have 4 math books but my book shelf has space for only three books. How many ways I can arrange these books?

Ans: When we say arrange, the includes the order.

B1,B2,B3,B4 books in (B1,B2,B3), (B1,B2,B4), (B2,B3,B4) and (B1,B3,B4)  => So 4C3 combinations =>  4 combinations.

For combination (B1,B2,B3), we can arrange (B1,B2,B3),(B1,B3,B2),(B2,B1,B3),(B2,B3,B1),(B3,B2,B1)(B3,B1,B2) => orders. 3P3 = 6 orders

so total  4 * 6 = 24 arrangements.

 This is a permutation problem, where we want to arrange 4 math books in 3 slots. Here we want all possible order of arrangements of books. The above explanation is represented as 4P3 = 24 arrangements.

Difference b/t memmove and memcpy

Difference between memmove and memcpy ?

void *memcpy(void *restrict s1, const void *restrict s2, size_t n);

The  memcpy() function copies n bytes from memory area s2 to s1. It returns s1. If copying takes  place  between  objects that overlap, the behavior is undefined.

void *memmove(void *s1, const void *s2, size_t n);

The memmove() function copies n bytes from memory area s2 to memory area s1. Copying between objects  that  overlap  will take place correctly. It returns s1.

What is this overlapping of objects?

#include <stdio.h>
#include <string.h>

main()

{

char string1[30]=”Gangadhar Mylapuram”;
char string2[30]=”Gangadhar Mylapuram”;
char *s1;
s1= string1 + 1;

memcpy(s1,string1,5);
printf(“memcpy: %s string %s\n”,s1,string1);

s1= string2 + 1;
memmove(s1,string2,5);
printf(“memmove: %s string %s\n”,s1,string2);

}

}

memcpy: Gangghar Mylapuram string GGangghar Mylapuram
memmove: Gangahar Mylapuram string GGangahar Mylapuram