@InterfaceAudience.Public @InterfaceStability.Evolving public final class Encryption extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Encryption.Context
Crypto context
|
| Modifier and Type | Method and Description |
|---|---|
static void |
decrypt(byte[] dest,
int destOffset,
java.io.InputStream in,
int destSize,
Decryptor d)
Decrypt a block of ciphertext read in from a stream with the given
cipher and context
|
static void |
decrypt(byte[] dest,
int destOffset,
java.io.InputStream in,
int destSize,
Encryption.Context context,
byte[] iv)
Decrypt a block of ciphertext from a stream given a context and IV
|
static void |
decrypt(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
Decryptor d)
Decrypt a stream of ciphertext given a decryptor
|
static void |
decrypt(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
Encryption.Context context,
byte[] iv)
Decrypt a stream of ciphertext given a context and IV
|
static void |
decryptWithSubjectKey(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
java.lang.String subject,
Configuration conf,
Cipher cipher,
byte[] iv)
Decrypts a block of ciphertext with the symmetric key resolved for the given subject
|
static void |
encrypt(java.io.OutputStream out,
byte[] src,
int offset,
int length,
Encryption.Context context,
byte[] iv)
Encrypt a block of plaintext
|
static void |
encrypt(java.io.OutputStream out,
byte[] src,
int offset,
int length,
Encryptor e)
Encrypt a block of plaintext
|
static void |
encrypt(java.io.OutputStream out,
java.io.InputStream in,
Encryption.Context context,
byte[] iv)
Encrypt a stream of plaintext given a context and IV
|
static void |
encrypt(java.io.OutputStream out,
java.io.InputStream in,
Encryptor e)
Encrypt a stream of plaintext given an encryptor
|
static void |
encryptWithSubjectKey(java.io.OutputStream out,
java.io.InputStream in,
java.lang.String subject,
Configuration conf,
Cipher cipher,
byte[] iv)
Encrypts a block of plaintext with the symmetric key resolved for the given subject
|
static Cipher |
getCipher(Configuration conf,
java.lang.String name)
Get an cipher given a name
|
static CipherProvider |
getCipherProvider(Configuration conf) |
static KeyProvider |
getKeyProvider(Configuration conf) |
static java.security.Key |
getSecretKeyForSubject(java.lang.String subject,
Configuration conf)
Resolves a key for the given subject
|
static java.lang.String[] |
getSupportedCiphers()
Get names of supported encryption algorithms
|
static java.lang.String[] |
getSupportedCiphers(Configuration conf)
Get names of supported encryption algorithms
|
static byte[] |
hash128(byte[]... args)
Return the MD5 digest of the concatenation of the supplied arguments.
|
static byte[] |
hash128(java.lang.String... args)
Return the MD5 digest of the concatenation of the supplied arguments.
|
static byte[] |
hash256(byte[]... args)
Return the SHA-256 digest of the concatenation of the supplied arguments.
|
static byte[] |
hash256(java.lang.String... args)
Return the SHA-256 digest of the concatenation of the supplied arguments.
|
static void |
incrementIv(byte[] iv) |
static void |
incrementIv(byte[] iv,
int v) |
static Encryption.Context |
newContext() |
static Encryption.Context |
newContext(Configuration conf) |
static byte[] |
pbkdf128(byte[]... args)
Return a 128 bit key derived from the concatenation of the supplied
arguments using PBKDF2WithHmacSHA1 at 10,000 iterations.
|
static byte[] |
pbkdf128(java.lang.String... args)
Return a 128 bit key derived from the concatenation of the supplied
arguments using PBKDF2WithHmacSHA1 at 10,000 iterations.
|
public static Encryption.Context newContext()
public static Encryption.Context newContext(Configuration conf)
public static Cipher getCipher(Configuration conf, java.lang.String name)
name - the cipher namepublic static java.lang.String[] getSupportedCiphers()
public static java.lang.String[] getSupportedCiphers(Configuration conf)
public static byte[] hash128(java.lang.String... args)
public static byte[] hash128(byte[]... args)
public static byte[] hash256(java.lang.String... args)
public static byte[] hash256(byte[]... args)
public static byte[] pbkdf128(java.lang.String... args)
public static byte[] pbkdf128(byte[]... args)
public static void encrypt(java.io.OutputStream out,
byte[] src,
int offset,
int length,
Encryptor e)
throws java.io.IOException
The encryptor's state will be finalized. It should be reinitialized or returned to the pool.
out - ciphertextsrc - plaintextoffset - length - e - java.io.IOExceptionpublic static void encrypt(java.io.OutputStream out,
byte[] src,
int offset,
int length,
Encryption.Context context,
byte[] iv)
throws java.io.IOException
out - ciphertextsrc - plaintextoffset - length - context - iv - java.io.IOExceptionpublic static void encrypt(java.io.OutputStream out,
java.io.InputStream in,
Encryptor e)
throws java.io.IOException
The encryptor's state will be finalized. It should be reinitialized or returned to the pool.
out - ciphertextin - plaintexte - java.io.IOExceptionpublic static void encrypt(java.io.OutputStream out,
java.io.InputStream in,
Encryption.Context context,
byte[] iv)
throws java.io.IOException
out - ciphertextin - plaintetcontext - iv - java.io.IOExceptionpublic static void decrypt(byte[] dest,
int destOffset,
java.io.InputStream in,
int destSize,
Decryptor d)
throws java.io.IOException
The decryptor's state will be finalized. It should be reinitialized or returned to the pool.
dest - destOffset - in - destSize - d - java.io.IOExceptionpublic static void decrypt(byte[] dest,
int destOffset,
java.io.InputStream in,
int destSize,
Encryption.Context context,
byte[] iv)
throws java.io.IOException
dest - destOffset - in - destSize - context - iv - java.io.IOExceptionpublic static void decrypt(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
Decryptor d)
throws java.io.IOException
out - in - outLen - d - java.io.IOExceptionpublic static void decrypt(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
Encryption.Context context,
byte[] iv)
throws java.io.IOException
out - in - outLen - context - iv - java.io.IOExceptionpublic static java.security.Key getSecretKeyForSubject(java.lang.String subject,
Configuration conf)
throws java.io.IOException
subject - conf - java.io.IOException - if the key is not foundpublic static void encryptWithSubjectKey(java.io.OutputStream out,
java.io.InputStream in,
java.lang.String subject,
Configuration conf,
Cipher cipher,
byte[] iv)
throws java.io.IOException
out - ciphertextin - plaintextconf - configurationcipher - the encryption algorithmiv - the initialization vector, can be nulljava.io.IOExceptionpublic static void decryptWithSubjectKey(java.io.OutputStream out,
java.io.InputStream in,
int outLen,
java.lang.String subject,
Configuration conf,
Cipher cipher,
byte[] iv)
throws java.io.IOException
out - plaintextin - ciphertextoutLen - the expected plaintext lengthsubject - the subject's key aliasconf - configurationcipher - the encryption algorithmiv - the initialization vector, can be nulljava.io.IOExceptionpublic static CipherProvider getCipherProvider(Configuration conf)
public static KeyProvider getKeyProvider(Configuration conf)
public static void incrementIv(byte[] iv)
public static void incrementIv(byte[] iv,
int v)