Public Key Cryptogrophy – The Puzzle of Private and Public Keys

Whenever we disclose any of our private information (or any type of info that might hamper our lives if it gets into the wrong hands) to an authority online, we always have second thoughts about how communication networks work and if they'll be able to keep our information secure.

So to end this uncertainty to some extent, you’ll get to know how public-key cryptography (asymmetric cryptography) helps carry out the exchange of our information over the internet securely in this article.

How Secure Is 256-bit Encryption?

SSL security is all about encryption of data over two nodes. The safe transfer over an internet connection is attained due to encryption performed by the SSL system.

Why Is it Necessary?

Now, I can list n-numbers of examples that could prove its necessity for our daily transmission or transactions process.

EC Private and Public Key Pair

An EC (Elliptic Curve) key-pair is a pair of a private and public key constructed from a given subgroup generator in a given elliptic curve group.

Here are the steps to generate an EC private and public key pair:

Encryption, Part 2: Public Key/Private Key Encryption

In my previous article, I presented the concept of symmetric encryption, where the same key is used to encrypt and decrypt data. The biggest limitation of symmetric encryption is the key itself. The key used for encryption and decryption has to be kept a secret. If the key is compromised, the encrypted data is no longer secure. While you may feel that it will be easy to keep the key safe, consider the fact that the same key cannot be used to encrypt data between multiple parties. For example, if Alice and Bob agree to use a secret key X for exchanging their messages, the same key X cannot be used to exchange messages between Alice and Jane. This is because such messages can be decrypted by Bob as well. Hence, in addition to keeping the key a secret, each pair that wishes to communicate secretly will have to maintain a key for their conversation.

This problem is overcome by the concept of public key/private key encryption (also known as Public Key Encryption or PKE for short).

Encryption and Signing

Symmetric Encryption

Symmetric encryption means that the same key is used to encrypt and decrypt:

Public Key Infrastructure (PKI)

Asymmetric Encryption

To solve the problem of negotiating 100 keys, if you want to send something privately to 100 individuals/system, a public/private key is used. If a message is encrypted using public key then it can be decrypted only with private key, and on the same line, if a message is encrypted using a private key, then it can decrypted using only a public key (not even with a private key)

Extracting a Private Key From the Java Keystore (JKS)

I’ve been working with the AS2 Protocol and the AdroitLogic AS2Gateway for quite some time now, and hence, playing with JKS has been a must. One of the tricks that were required from time to time was extracting the private key and public key (certificate) from Java KeyStores. In this blog post, we’ll go through a couple of simple commands on how to do that.

What Is a Java KeyStore (JKS)? 

A JKS is an encrypted security file used to store a set of cryptographic keys or certificates in the binary format, and it requires a password to be opened. JKS files are used for a variety of security purposes. They can be used to identify the author of an Android app during a build and when publishing to Android Market in Google Play or in SSL encryption.