APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv final Class AES_Crypt

extends SymmetricCipher
Class Inheritance
Imports
java.security.InvalidKeyException, .MessageDigest, java.util.Arrays, jdk.internal.vm.annotation.IntrinsicCandidate

Implementation of the AES cipher, which is based on the following documents:
External Specification
https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf, https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197-upd1.pdf

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private byte[]
private static final int[]
private int
private static final byte[][]
private int[]
private int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
decryptBlock(byte[]
[in] the ciphertext to be decrypted.
cipher
,
int
[in] the ciphertext offset in the array of bytes.
cOff
,
byte[]
[out] the decrypted plaintext output.
plain
,
int
[in] the plaintext offset in the array of bytes.
pOff
)

Implements abstract com.sun.crypto.provider.SymmetricCipher.decryptBlock.

Method for one block of decryption.

pack-priv void
encryptBlock(byte[]
[in] the plaintext to be encrypted.
plain
,
int
[in] the plaintext offset in the array of bytes.
pOff
,
byte[]
[out] the encrypted ciphertext output.
cipher
,
int
[in] the ciphertext offset in the array of bytes.
cOff
)

Implements abstract com.sun.crypto.provider.SymmetricCipher.encryptBlock.

Method for one block of encryption.

private static int[]

Returns:

the inverse cipher round keys.
genInvRoundKeys
(int[]
[in] the targeted word for substitution.
w
,
int
[in] the number of rounds for generating the round keys.
rounds
)

Generate the inverse cipher round keys.

private static int[]

Returns:

the cipher round keys.
genRoundKeys
(byte[]
[in] the symmetric key byte array.
key
,
int
[in] the number of rounds for generating the round keys.
rounds
)

Generate the cipher's round keys as outlined in section 5.2 of the spec.

pack-priv int

Returns:

the AES block cipher size (in bytes).
getBlockSize
()

Implements abstract com.sun.crypto.provider.SymmetricCipher.getBlockSize.

Return the block cipher size.

private void
implDecryptBlock(byte[]
[in] the ciphertext to be decrypted.
c
,
int
[in] the ciphertext offset in the array of bytes.
co
,
byte[]
[out] the plaintext output.
p
,
int
[in] the plaintext offset in the array of bytes.
po
)

Method for one block of decryption.

private void
implEncryptBlock(byte[]
[in] the plaintext to be encrypted.
p
,
int
[in] the plaintext offset in the array of bytes.
po
,
byte[]
[out] the ciphertext output.
c
,
int
[in] the ciphertext offset in the array of bytes.
co
)

Method for one block of encryption.

pack-priv void
init(boolean
[in] indicates if encrypting (false) or decrypting (true).
decrypting
,
String
[in] the case insentive string name for the AES cipher.
algorithm
,
byte[]
[in] the symmetric key byte array for encryption/decryption.
key
)

Implements abstract com.sun.crypto.provider.SymmetricCipher.init.

Check algorithm and initalize round keys for decryption and encryption.

pack-priv static boolean

Returns:

true if the size of the key is valid else false.
isKeySizeValid
(int
the size of the key (in bytes) to be validated.
len
)

Verifies if the length argument is a valid key size or not.

private static int

Returns:

the substituted word.
subWord
(int
[in] the targeted word for substitution.
word
)

Substitute the word as a step of key expansion.

Field Detail

AES_128_ROUNDSback to summary
private static final int AES_128_ROUNDS
AES_192_ROUNDSback to summary
private static final int AES_192_ROUNDS
AES_256_ROUNDSback to summary
private static final int AES_256_ROUNDS
BWback to summary
private static final int BW
prevKeyback to summary
private byte[] prevKey
RCONback to summary
private static final int[] RCON
roundsback to summary
private int rounds
SBOXback to summary
private static final byte[][] SBOX
sessionKdback to summary
private int[] sessionKd
sessionKeback to summary
private int[] sessionKe
T0back to summary
private static final int[] T0
T1back to summary
private static final int[] T1
T2back to summary
private static final int[] T2
T3back to summary
private static final int[] T3
TI0back to summary
private static final int[] TI0
TI1back to summary
private static final int[] TI1
TI2back to summary
private static final int[] TI2
TI3back to summary
private static final int[] TI3
TI4back to summary
private static final int[] TI4
TMI0back to summary
private static final int[] TMI0
TMI1back to summary
private static final int[] TMI1
TMI2back to summary
private static final int[] TMI2
TMI3back to summary
private static final int[] TMI3
WBback to summary
private static final int WB

Constructor Detail

AES_Cryptback to summary
pack-priv AES_Crypt()

Method Detail

decryptBlockback to summary
pack-priv void decryptBlock(byte[] cipher, int cOff, byte[] plain, int pOff)

Implements abstract com.sun.crypto.provider.SymmetricCipher.decryptBlock.

Method for one block of decryption.

Parameters
cipher:byte[]

[in] the ciphertext to be decrypted.

cOff:int

[in] the ciphertext offset in the array of bytes.

plain:byte[]

[out] the decrypted plaintext output.

pOff:int

[in] the plaintext offset in the array of bytes.

encryptBlockback to summary
pack-priv void encryptBlock(byte[] plain, int pOff, byte[] cipher, int cOff)

Implements abstract com.sun.crypto.provider.SymmetricCipher.encryptBlock.

Method for one block of encryption.

Parameters
plain:byte[]

[in] the plaintext to be encrypted.

pOff:int

[in] the plaintext offset in the array of bytes.

cipher:byte[]

[out] the encrypted ciphertext output.

cOff:int

[in] the ciphertext offset in the array of bytes.

genInvRoundKeysback to summary
private static int[] genInvRoundKeys(int[] w, int rounds)

Generate the inverse cipher round keys.

Parameters
w:int[]

[in] the targeted word for substitution.

rounds:int

[in] the number of rounds for generating the round keys.

Returns:int[]

the inverse cipher round keys.

genRoundKeysback to summary
private static int[] genRoundKeys(byte[] key, int rounds)

Generate the cipher's round keys as outlined in section 5.2 of the spec.

Parameters
key:byte[]

[in] the symmetric key byte array.

rounds:int

[in] the number of rounds for generating the round keys.

Returns:int[]

the cipher round keys.

getBlockSizeback to summary
pack-priv int getBlockSize()

Implements abstract com.sun.crypto.provider.SymmetricCipher.getBlockSize.

Return the block cipher size.

Returns:int

the AES block cipher size (in bytes).

implDecryptBlockback to summary
private void implDecryptBlock(byte[] c, int co, byte[] p, int po)

Method for one block of decryption.

Parameters
c:byte[]

[in] the ciphertext to be decrypted.

co:int

[in] the ciphertext offset in the array of bytes.

p:byte[]

[out] the plaintext output.

po:int

[in] the plaintext offset in the array of bytes.

Annotations
@IntrinsicCandidate
implEncryptBlockback to summary
private void implEncryptBlock(byte[] p, int po, byte[] c, int co)

Method for one block of encryption.

Parameters
p:byte[]

[in] the plaintext to be encrypted.

po:int

[in] the plaintext offset in the array of bytes.

c:byte[]

[out] the ciphertext output.

co:int

[in] the ciphertext offset in the array of bytes.

Annotations
@IntrinsicCandidate
initback to summary
pack-priv void init(boolean decrypting, String algorithm, byte[] key) throws InvalidKeyException

Implements abstract com.sun.crypto.provider.SymmetricCipher.init.

Check algorithm and initalize round keys for decryption and encryption.

Parameters
decrypting:boolean

[in] indicates if encrypting (false) or decrypting (true).

algorithm:String

[in] the case insentive string name for the AES cipher.

key:byte[]

[in] the symmetric key byte array for encryption/decryption.

Exceptions
InvalidKeyException:
if an incorrect algorithm is given or if an invalid key size is provided.
isKeySizeValidback to summary
pack-priv static boolean isKeySizeValid(int len)

Verifies if the length argument is a valid key size or not.

Parameters
len:int

the size of the key (in bytes) to be validated.

Returns:boolean

true if the size of the key is valid else false.

subWordback to summary
private static int subWord(int word)

Substitute the word as a step of key expansion.

Parameters
word:int

[in] the targeted word for substitution.

Returns:int

the substituted word.