0% found this document useful (0 votes)
11 views

Encryption

How to solve encryption

Uploaded by

SRINIBAS PRUSTY
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Encryption

How to solve encryption

Uploaded by

SRINIBAS PRUSTY
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Encryption:-

 Encryption is the process of encoding a message or information in a way that only


authorized parties can access it and those who are not authorized cannot.
 T
h
e
r
e

is two types of encryption :-

Asymmetric Encryption:-
In public-key encryption schemes, the encryption key is published for anyone to use and for
encrypting messages. Only the receiving party has access to the decryption key that enables
messages to be read

Symmetric Encryption:-
In symmetric-key schemes, the encryption and decryption keys are the same.
Communicating parties must have the same key in order to achieve secure communication.

Key:-

 A key is a string of characters used within an encryption algorithm for altering data so that it
appears random. Like a physical key, it locks (encrypts) data so that only someone with the
right key can unlock (decrypt) it.
 In other words key is a group of random characters in a particular order. Encryption
protocols use a key to alter data so that it's scrambled, and so that anyone without the key
can't decode the information.
 The original data is known as the plaintext, and the data after the key encrypts it is known as
the ciphertext.

The formula: plaintext + key = ciphertext


 There are two kinds of encryption: symmetric encryption and asymmetric encryption, also
known as public key encryption.

This document Prepared by :- Maheswar and Khageswar


 In symmetric encryption, both sides of a conversation use the same key for turning plaintext
into ciphertext and vice versa.
 In asymmetric or public key encryption, the two sides of the conversation each use a
different key. One key is called the public key, and one key is called the private key – thusly
named because one of the parties keeps it secret and never shares it with anyone. When
plaintext is encrypted with the public key, only the private key can decrypt it, not the public
key.

Encryption Algorithms:-
Triple DES Encryption:-
 Triple DES was designed to replace the original Data Encryption Standard (DES) algorithm,
which hackers learned to defeat with ease. At one time, Triple DES was the recommended
standard and the most widely used symmetric algorithm in the industry.
 Triple DES uses three individual keys with 56 bits each. The total key length adds up to 168
bits, but experts say that 112-bits in key strength is more like it.
 Though it is slowly being phased out, Triple DES is still a dependable hardware encryption
solution for financial services and other industries.

RSA Encryption:-
 RSA is a public-key encryption algorithm and the standard for encrypting data sent over the
internet. It also happens to be one of the methods used in PGP and GPG programs.
 Unlike Triple DES, RSA is considered an asymmetric encryption algorithm because it uses a
pair of keys. The public key is used to encrypt a message and a private key to decrypt it. It
takes attackers quite a bit of time and processing power to break this encryption code.

Advanced Encryption Standards (AES):-


 The Advanced Encryption Standard (AES) is the algorithm trusted as the standard by the
U.S. government and many other organizations.
 Although it is extremely efficient in 128-bit form, AES encryption also uses keys of 192 and
256 bits for heavy-duty encryption.
 AES is considered resistant to all attacks, with the exception of brute-force attacks, which
attempt to decipher messages using all possible combinations in the 128-, 192- or 256-bit
cipher. Still, security experts believe that AES will eventually become the standard for
encrypting data in the private sector.

Class IvParameterSpec:-
 It is present in javax.crypto.spec.IvParameterSpec package.
 It inherits from Object class and AlgorithmParameterSpec interface.

This document Prepared by :- Maheswar and Khageswar


 This class specifies an initialization vector (IV). Examples which use IVs are ciphers in
feedback mode, e.g., DES in CBC mode and RSA ciphers with OAEP encoding operation.
 This class having two constructer:-
IvParameterSpec(byte[] iv):-
Creates an IvParameterSpec object using the bytes in iv as the IV
It throws NullPointerException(if iv is null).
IvParameterSpec((byte[] iv, int offset, int len):-
Creates an IvParameterSpec object using the first len bytes in iv, beginning at offset
inclusive, as the IV.
It throws IllegalArgumentException - if iv is null or iv.length - offset < len).
It throws ArrayIndexOutOfBoundsException- is thrown if offset or len index bytes
outside the iv.

 it have also one method byte[] getIV()(Returns the initialization vector (IV))
 it Returns a new array each time this method is called.
Class SecretKeySpec:-
 It is present in javax.crypto.spec.SecretKeySpec package.
 It inherits from Object class and KeySpec, SecretKey interface.
 This class specifies a secret key in a provider-independent fashion.

 It can be used to construct a SecretKey from a byte array, without having to go through a
(provider-based) SecretKeyFactory.

 This class is only useful for raw secret keys that can be represented as a byte array and have
no key parameters associated with them, e.g., DES or Triple DES keys.

 This class having two constructer:-


SecretKeySpec(byte[] key,int offset,int len,String algorithm)
Constructs a secret key from the given byte array, using the first len bytes of key, starting at
offset inclusive.
It throws IllegalArgumentException- if algorithm is null or key is null, empty, or too
short, i.e. key.length-offset<len

This document Prepared by :- Maheswar and Khageswar


it throws ArrayIndexOutOfBoundsException- is thrown if offset or len index bytes outside
the key.

SecretKeySpec(byte[] key,String algorithm)

Constructs a secret key from the given byte array.

It throws IllegalArgumentException- if algorithm is null or

key is null or empty.

 This class also some method:-

boolean equals(Object obj)

Tests for equality between the specified object and this object.
String getAlgorithm()

Returns the name of the algorithm associated with this secret key.

byte[] getEncoded()

Returns the key material of this secret key.

String getFormat()

Returns the name of the encoding format for this secret key.

Int hashCode()

Calculates a hash code value for the object.

Cipher:-
 It is present in javax.crypto.Cipher package.
 It inherits from Object class.
 This class provides the functionality of a cryptographic cipher for encryption and
decryption. It forms the core of the Java Cryptographic Extension (JCE) framework.
 In order to create a Cipher object, the application calls the Cipher's getInstance method, and
passes the name of the requested transformation to it.

 Every implementation of the Java platform is required to support the following standard
Cipher transformations with the keysizes in parentheses:

AES/CBC/NoPadding (128)

AES/CBC/PKCS5Padding (128)

This document Prepared by :- Maheswar and Khageswar


AES/ECB/NoPadding (128)

AES/ECB/PKCS5Padding (128)

DES/CBC/NoPadding (56)

DES/CBC/PKCS5Padding (56)

DES/ECB/NoPadding (56)

DES/ECB/PKCS5Padding (56)

DESede/CBC/NoPadding (168)

DESede/CBC/PKCS5Padding (168)

DESede/ECB/NoPadding (168)

DESede/ECB/PKCS5Padding (168)

RSA/ECB/PKCS1Padding (1024, 2048)

RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)

RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)


 This class having a constructer:-
protected Cipher(CipherSpi cipherSpi,Provider provider,String ransformation)

It Creates a Cipher object.

 This class also some method:-

byte[] doFinal()

Finishes a multiple-part encryption or decryption operation, depending on how this


cipher was initialized.

byte[] doFinal(byte[] input)

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part


operation.

int doFinal(byte[] output, int outputOffset)

This document Prepared by :- Maheswar and Khageswar


Finishes a multiple-part encryption or decryption operation, depending on how this
cipher was initialized.

byte[] doFinal(byte[] input, int inputOffset, int inputLen)

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part


operation.

Int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output)

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part


operation.

Int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int
outputOffset)

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part


operation.

Int doFinal(ByteBuffer input, ByteBuffer output)

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part


operation.

String getAlgorithm()

Returns the algorithm name of this Cipher object.

Int getBlockSize()

Returns the block size (in bytes).

ExemptionMechanism getExemptionMechanism()

Returns the exemption mechanism object used with this cipher.

static Cipher getInstance(String transformation)

Returns a Cipher object that implements the specified transformation.

static Cipher getInstance(String transformation, Provider provider)

Returns a Cipher object that implements the specified transformation.

static Cipher getInstance(String transformation, String provider)

Returns a Cipher object that implements the specified transformation.

byte[] getIV()

Returns the initialization vector (IV) in a new buffer.

This document Prepared by :- Maheswar and Khageswar


static int getMaxAllowedKeyLength(String transformation)

Returns the maximum key length for the specified transformation according to the
installed JCE jurisdiction policy files.

static AlgorithmParameterSpec getMaxAllowedParameterSpec(String


transformation)

Returns an AlgorithmParameterSpec object which contains the maximum cipher


parameter value according to the jurisdiction policy file.

Int getOutputSize(int inputLen)

Returns the length in bytes that an output buffer would need to be in order to hold the
result of the next update or doFinal operation, given the input length inputLen (in
bytes).

AlgorithmParameters getParameters()

Returns the parameters used with this cipher.

Provider getProvider()

Returns the provider of this Cipher object.

Void init(int opmode, Certificate certificate)

Initializes this cipher with the public key from the given certificate.

Void init(int opmode, Certificate certificate, SecureRandom random)

Initializes this cipher with the public key from the given certificate and a source of
randomness.

Void init(int opmode, Key key)

Initializes this cipher with a key.

Void init(int opmode, Key key, AlgorithmParameters params)

Initializes this cipher with a key and a set of algorithm parameters.

Void init(int opmode, Key key, AlgorithmParameterSpec params)

Initializes this cipher with a key and a set of algorithm parameters.

Void init(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom


random)

Initializes this cipher with a key, a set of algorithm parameters, and a source of
randomness.

This document Prepared by :- Maheswar and Khageswar


Void init(int opmode, Key key, AlgorithmParameters params, SecureRandom
random)

Initializes this cipher with a key, a set of algorithm parameters, and a source of
randomness.

Void init(int opmode, Key key, SecureRandom random)

Initializes this cipher with a key and a source of randomness.

Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int


wrappedKeyType)

Unwrap a previously wrapped key.

byte[] update(byte[] input)

Continues a multiple-part encryption or decryption operation (depending on how this


cipher was initialized), processing another data part.

byte[] update(byte[] input, int inputOffset, int inputLen)

Continues a multiple-part encryption or decryption operation (depending on how this


cipher was initialized), processing another data part.

Int update(byte[] input, int inputOffset, int inputLen, byte[] output)

Continues a multiple-part encryption or decryption operation (depending on how this


cipher was initialized), processing another data part.

Int update(byte[] input, int inputOffset, int inputLen, byte[] output, int
outputOffset)

Continues a multiple-part encryption or decryption operation (depending on how this


cipher was initialized), processing another data part.

Int update(ByteBuffer input, ByteBuffer output)

Continues a multiple-part encryption or decryption operation (depending on how this


cipher was initialized), processing another data part.

Void updateAAD(byte[] src)

Continues a multi-part update of the Additional Authentication Data (AAD).

Void updateAAD(byte[] src, int offset, int len)

Continues a multi-part update of the Additional Authentication Data (AAD), using a


subset of the provided buffer.

Void updateAAD(ByteBuffer src)

This document Prepared by :- Maheswar and Khageswar


Continues a multi-part update of the Additional Authentication Data (AAD).

byte[] wrap(Key key)

Wrap a key.

--------End--------

This document Prepared by :- Maheswar and Khageswar

You might also like