public final class

RSAPadding

extends Object
java.lang.Object
   ↳ sun.security.rsa.RSAPadding

Class Overview

RSA padding and unpadding. Format of PKCS#1 v1.5 padding is: 0x00 | BT | PS...PS | 0x00 | data...data where BT is the blocktype (1 or 2). The length of the entire string must be the same as the size of the modulus (i.e. 128 byte for a 1024 bit key). Per spec, the padding string must be at least 8 bytes long. That leaves up to (length of key in bytes) - 11 bytes for the data. OAEP padding is a bit more complicated and has a number of options. We support: . arbitrary hash functions ('Hash' in the specification), MessageDigest implementation must be available . MGF1 as the mask generation function . the empty string as the default value for label L and whatever specified in javax.crypto.spec.OAEPParameterSpec Note: RSA keys should be at least 512 bits long

Summary

Constants
int PAD_BLOCKTYPE_1
int PAD_BLOCKTYPE_2
int PAD_NONE
int PAD_OAEP_MGF1
Public Methods
static RSAPadding getInstance(int type, int paddedSize, SecureRandom random)
Get a RSAPadding instance of the specified type.
static RSAPadding getInstance(int type, int paddedSize, SecureRandom random, OAEPParameterSpec spec)
Get a RSAPadding instance of the specified type, which must be OAEP.
static RSAPadding getInstance(int type, int paddedSize)
Get a RSAPadding instance of the specified type.
int getMaxDataSize()
Return the maximum size of the plaintext data that can be processed using this object.
byte[] pad(byte[] data)
Pad the data and return the padded block.
byte[] pad(byte[] data, int ofs, int len)
Pad the data and return the padded block.
byte[] unpad(byte[] padded)
Unpad the padded block and return the data.
byte[] unpad(byte[] padded, int ofs, int len)
Unpad the padded block and return the data.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int PAD_BLOCKTYPE_1

Constant Value: 1 (0x00000001)

public static final int PAD_BLOCKTYPE_2

Constant Value: 2 (0x00000002)

public static final int PAD_NONE

Constant Value: 3 (0x00000003)

public static final int PAD_OAEP_MGF1

Constant Value: 4 (0x00000004)

Public Methods

public static RSAPadding getInstance (int type, int paddedSize, SecureRandom random)

Get a RSAPadding instance of the specified type. Keys used with this padding must be paddedSize bytes long.

public static RSAPadding getInstance (int type, int paddedSize, SecureRandom random, OAEPParameterSpec spec)

Get a RSAPadding instance of the specified type, which must be OAEP. Keys used with this padding must be paddedSize bytes long.

public static RSAPadding getInstance (int type, int paddedSize)

Get a RSAPadding instance of the specified type. Keys used with this padding must be paddedSize bytes long.

public int getMaxDataSize ()

Return the maximum size of the plaintext data that can be processed using this object.

public byte[] pad (byte[] data)

Pad the data and return the padded block.

public byte[] pad (byte[] data, int ofs, int len)

Pad the data and return the padded block.

public byte[] unpad (byte[] padded)

Unpad the padded block and return the data.

public byte[] unpad (byte[] padded, int ofs, int len)

Unpad the padded block and return the data.