Class CryptoHelper
- java.lang.Object
-
- in.dragonbra.javasteam.util.crypto.CryptoHelper
-
public class CryptoHelper extends java.lang.Object- Since:
- 2018-02-24
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSEC_PROV
-
Constructor Summary
Constructors Constructor Description CryptoHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]crcHash(byte[] input)Performs CRC32 on an input byte array using the CrcStandard.Crc32Bit parametersstatic byte[]generateRandomBlock(int size)Generate an array of random bytes given the input lengthstatic byte[]symmetricDecrypt(byte[] input, byte[] key)Decrypts using AES/CBC/PKCS7 with an input byte array and key, using the random IV prepended using AES/ECB/Nonestatic byte[]symmetricDecrypt(byte[] input, byte[] key, Passable<byte[]> iv)Decrypts using AES/CBC/PKCS7 with an input byte array and key, using the random IV prepended using AES/ECB/Nonestatic byte[]symmetricDecryptHMACIV(byte[] input, byte[] key, byte[] hmacSecret)Decrypts using AES/CBC/PKCS7 with an input byte array and key, using the IV (comprised of random bytes and the HMAC-SHA1 of the random bytes and plaintext) prepended using AES/ECB/Nonestatic byte[]symmetricEncrypt(byte[] input, byte[] key)Performs an encryption using AES/CBC/PKCS7 with an input byte array and key, with a random IV prepended using AES/ECB/Nonestatic byte[]symmetricEncryptWithHMACIV(byte[] input, byte[] key, byte[] hmacSecret)Performs an encryption using AES/CBC/PKCS7 with an input byte array and key, with a IV (comprised of random bytes and the HMAC-SHA1 of the random bytes and plaintext) prepended using AES/ECB/Nonestatic byte[]symmetricEncryptWithIV(byte[] input, byte[] key, byte[] iv)Performs an encryption using AES/CBC/PKCS7 with an input byte array and key, with a random IV prepended using AES/ECB/None
-
-
-
Method Detail
-
generateRandomBlock
public static byte[] generateRandomBlock(int size)
Generate an array of random bytes given the input length- Parameters:
size- the size of the block to generate- Returns:
- the generated block
-
crcHash
public static byte[] crcHash(byte[] input)
Performs CRC32 on an input byte array using the CrcStandard.Crc32Bit parameters- Parameters:
input- array to hash- Returns:
- the hashed result
-
symmetricDecrypt
public static byte[] symmetricDecrypt(byte[] input, byte[] key) throws CryptoExceptionDecrypts using AES/CBC/PKCS7 with an input byte array and key, using the random IV prepended using AES/ECB/None- Parameters:
input- array to decryptkey- encryption key- Returns:
- decrypted message
- Throws:
CryptoException- deception while encrypting
-
symmetricDecrypt
public static byte[] symmetricDecrypt(byte[] input, byte[] key, Passable<byte[]> iv) throws CryptoExceptionDecrypts using AES/CBC/PKCS7 with an input byte array and key, using the random IV prepended using AES/ECB/None- Parameters:
input- array to decryptkey- encryption keyiv- the random IV- Returns:
- decrypted message
- Throws:
CryptoException- deception while encrypting
-
symmetricEncryptWithIV
public static byte[] symmetricEncryptWithIV(byte[] input, byte[] key, byte[] iv) throws CryptoExceptionPerforms an encryption using AES/CBC/PKCS7 with an input byte array and key, with a random IV prepended using AES/ECB/None- Parameters:
input- array to encryptkey- encryption keyiv- the random IV- Returns:
- encrypted message
- Throws:
CryptoException- exception while encrypting
-
symmetricEncrypt
public static byte[] symmetricEncrypt(byte[] input, byte[] key) throws CryptoExceptionPerforms an encryption using AES/CBC/PKCS7 with an input byte array and key, with a random IV prepended using AES/ECB/None- Parameters:
input- array to encryptkey- encryption key- Returns:
- encrypted message
- Throws:
CryptoException- exception while encrypting
-
symmetricDecryptHMACIV
public static byte[] symmetricDecryptHMACIV(byte[] input, byte[] key, byte[] hmacSecret) throws CryptoExceptionDecrypts using AES/CBC/PKCS7 with an input byte array and key, using the IV (comprised of random bytes and the HMAC-SHA1 of the random bytes and plaintext) prepended using AES/ECB/None- Parameters:
input- array to decryptkey- encryption keyhmacSecret- the IV- Returns:
- decrypted message
- Throws:
CryptoException- exception while decrypting
-
symmetricEncryptWithHMACIV
public static byte[] symmetricEncryptWithHMACIV(byte[] input, byte[] key, byte[] hmacSecret) throws CryptoExceptionPerforms an encryption using AES/CBC/PKCS7 with an input byte array and key, with a IV (comprised of random bytes and the HMAC-SHA1 of the random bytes and plaintext) prepended using AES/ECB/None- Parameters:
input- array to encryptkey- encryption keyhmacSecret- the IV- Returns:
- encrypted message
- Throws:
CryptoException- exception while encrypting
-
-