Wednesday, July 30, 2008

Cryptographic with Asymmetric Keys: Public Key and Private Key

Asymmetric cryptography uses one key to encrypt a message and another key to decrypt the encrypted message. One of the two keys is called a public key. Another is called a private key. As implied by their names, a public key is usually broadcast as general information, while a private key is kept confidential. A private key has no relation to a public key. There is no way (or with little possibility) of inferring a private key from the knowledge of public key.

A -->|Message|-->B

Suppose we would like to protect a message from A to B from being eavesdropped (e.g., in a website with https:://).

The process proceeds as follows:

1. B broadcasts its public key.
2. A recognizes the public key of B.
3. A encrypts the message using the pubic key of B, and sends the encrypted message to B.
4. B decrypts the encrypted message using its private key.

Since there is no way of inferring the private key from the public key, no one benefits from knowing B's public key and the messaged remains gibberish to everybody who does not know the private key of B.

Clearly, the public key is a powerful concept which allows end-to-end encryption without having to share the key apriori.

Saturday, July 19, 2008

Linux initialization files: .bash_profile and .bashrc

As a Linux or Cygwin (Linux emulation for Windows) new, would you wonder what really happen when you execute the shell (e.g., double click on the Cygwin icon)? In the old day, Windows always invokes a file called "autoexec.bat". This file contains a bunch of thing the the window will do at the boot-up such as setting path or invoke other programs (e.g., anti-virus).

In your home directory, there are two files, ".bash_profile" and ".bashrc", which are the initialization file in the Linux. When you open a shell, they are automatically executed as a shell initialization.The path setting is contained in these files.

The difference? According to [Josh Staiger],

- ".bash_profile" is invoked for a log-in session. Log-in? Yeah, log-in. It means anything that you usually need to provide user name and password such as log-in physically at the boot-up or using ssh

- ".bashrc" is invoked for a non-log-in session. For example, when you have already log-in to a graphical environment such as KDE. All you have to do is to click on a terminal icon and you don't have to provide username/password to open a shell.

In fact, you can see in the file ".bash_profile" the following

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi


which basically invokes ".bashrc" if it exists.

For the Cygwin environment, you can add your own initialization in either ".bashrc" or ".bash_profile". Wanna try? Add the following lines into the files and restart the shell.

- Add to ".bashrc"


echo Add2.bashrc


- Add to ".bash_profile"

echo Add2.bash_profile

PATH=${PATH}:
export =


ENJOY...