org.apache.hadoop.hbase.io.crypto
Class Encryption

java.lang.Object
  extended by org.apache.hadoop.hbase.io.crypto.Encryption

@InterfaceAudience.Public
@InterfaceStability.Unstable
public final class Encryption
extends Object

A facade for encryption algorithms and related support.


Nested Class Summary
static class Encryption.Context
          Crypto context
 
Method Summary
static void decrypt(byte[] dest, int destOffset, 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, 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(OutputStream out, InputStream in, int outLen, Decryptor d)
          Decrypt a stream of ciphertext given a decryptor
static void decrypt(OutputStream out, InputStream in, int outLen, Encryption.Context context, byte[] iv)
          Decrypt a stream of ciphertext given a context and IV
static void decryptWithSubjectKey(OutputStream out, InputStream in, int outLen, String subject, org.apache.hadoop.conf.Configuration conf, Cipher cipher, byte[] iv)
          Decrypts a block of ciphertext with the symmetric key resolved for the given subject
static void encrypt(OutputStream out, byte[] src, int offset, int length, Encryption.Context context, byte[] iv)
          Encrypt a block of plaintext
static void encrypt(OutputStream out, byte[] src, int offset, int length, Encryptor e)
          Encrypt a block of plaintext
static void encrypt(OutputStream out, InputStream in, Encryption.Context context, byte[] iv)
          Encrypt a stream of plaintext given a context and IV
static void encrypt(OutputStream out, InputStream in, Encryptor e)
          Encrypt a stream of plaintext given an encryptor
static void encryptWithSubjectKey(OutputStream out, InputStream in, String subject, org.apache.hadoop.conf.Configuration conf, Cipher cipher, byte[] iv)
          Encrypts a block of plaintext with the symmetric key resolved for the given subject
static Cipher getCipher(org.apache.hadoop.conf.Configuration conf, String name)
          Get an cipher given a name
static CipherProvider getCipherProvider(org.apache.hadoop.conf.Configuration conf)
           
static KeyProvider getKeyProvider(org.apache.hadoop.conf.Configuration conf)
           
static Key getSecretKeyForSubject(String subject, org.apache.hadoop.conf.Configuration conf)
          Resolves a key for the given subject
static String[] getSupportedCiphers()
          Get names of supported encryption algorithms
static String[] getSupportedCiphers(org.apache.hadoop.conf.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(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(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(org.apache.hadoop.conf.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(String... args)
          Return a 128 bit key derived from the concatenation of the supplied arguments using PBKDF2WithHmacSHA1 at 10,000 iterations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newContext

public static Encryption.Context newContext()

newContext

public static Encryption.Context newContext(org.apache.hadoop.conf.Configuration conf)

getCipher

public static Cipher getCipher(org.apache.hadoop.conf.Configuration conf,
                               String name)
Get an cipher given a name

Parameters:
name - the cipher name
Returns:
the cipher, or null if a suitable one could not be found

getSupportedCiphers

public static String[] getSupportedCiphers()
Get names of supported encryption algorithms

Returns:
Array of strings, each represents a supported encryption algorithm

getSupportedCiphers

public static String[] getSupportedCiphers(org.apache.hadoop.conf.Configuration conf)
Get names of supported encryption algorithms

Returns:
Array of strings, each represents a supported encryption algorithm

hash128

public static byte[] hash128(String... args)
Return the MD5 digest of the concatenation of the supplied arguments.


hash128

public static byte[] hash128(byte[]... args)
Return the MD5 digest of the concatenation of the supplied arguments.


hash256

public static byte[] hash256(String... args)
Return the SHA-256 digest of the concatenation of the supplied arguments.


hash256

public static byte[] hash256(byte[]... args)
Return the SHA-256 digest of the concatenation of the supplied arguments.


pbkdf128

public static byte[] pbkdf128(String... args)
Return a 128 bit key derived from the concatenation of the supplied arguments using PBKDF2WithHmacSHA1 at 10,000 iterations.


pbkdf128

public static byte[] pbkdf128(byte[]... args)
Return a 128 bit key derived from the concatenation of the supplied arguments using PBKDF2WithHmacSHA1 at 10,000 iterations.


encrypt

public static void encrypt(OutputStream out,
                           byte[] src,
                           int offset,
                           int length,
                           Encryptor e)
                    throws IOException
Encrypt a block of plaintext

The encryptor's state will be finalized. It should be reinitialized or returned to the pool.

Parameters:
out - ciphertext
src - plaintext
offset -
length -
e -
Throws:
IOException

encrypt

public static void encrypt(OutputStream out,
                           byte[] src,
                           int offset,
                           int length,
                           Encryption.Context context,
                           byte[] iv)
                    throws IOException
Encrypt a block of plaintext

Parameters:
out - ciphertext
src - plaintext
offset -
length -
context -
iv -
Throws:
IOException

encrypt

public static void encrypt(OutputStream out,
                           InputStream in,
                           Encryptor e)
                    throws IOException
Encrypt a stream of plaintext given an encryptor

The encryptor's state will be finalized. It should be reinitialized or returned to the pool.

Parameters:
out - ciphertext
in - plaintext
e -
Throws:
IOException

encrypt

public static void encrypt(OutputStream out,
                           InputStream in,
                           Encryption.Context context,
                           byte[] iv)
                    throws IOException
Encrypt a stream of plaintext given a context and IV

Parameters:
out - ciphertext
in - plaintet
context -
iv -
Throws:
IOException

decrypt

public static void decrypt(byte[] dest,
                           int destOffset,
                           InputStream in,
                           int destSize,
                           Decryptor d)
                    throws IOException
Decrypt a block of ciphertext read in from a stream with the given cipher and context

The decryptor's state will be finalized. It should be reinitialized or returned to the pool.

Parameters:
dest -
destOffset -
in -
destSize -
d -
Throws:
IOException

decrypt

public static void decrypt(byte[] dest,
                           int destOffset,
                           InputStream in,
                           int destSize,
                           Encryption.Context context,
                           byte[] iv)
                    throws IOException
Decrypt a block of ciphertext from a stream given a context and IV

Parameters:
dest -
destOffset -
in -
destSize -
context -
iv -
Throws:
IOException

decrypt

public static void decrypt(OutputStream out,
                           InputStream in,
                           int outLen,
                           Decryptor d)
                    throws IOException
Decrypt a stream of ciphertext given a decryptor

Parameters:
out -
in -
outLen -
d -
Throws:
IOException

decrypt

public static void decrypt(OutputStream out,
                           InputStream in,
                           int outLen,
                           Encryption.Context context,
                           byte[] iv)
                    throws IOException
Decrypt a stream of ciphertext given a context and IV

Parameters:
out -
in -
outLen -
context -
iv -
Throws:
IOException

getSecretKeyForSubject

public static Key getSecretKeyForSubject(String subject,
                                         org.apache.hadoop.conf.Configuration conf)
                                  throws IOException
Resolves a key for the given subject

Parameters:
subject -
conf -
Returns:
a key for the given subject
Throws:
IOException - if the key is not found

encryptWithSubjectKey

public static void encryptWithSubjectKey(OutputStream out,
                                         InputStream in,
                                         String subject,
                                         org.apache.hadoop.conf.Configuration conf,
                                         Cipher cipher,
                                         byte[] iv)
                                  throws IOException
Encrypts a block of plaintext with the symmetric key resolved for the given subject

Parameters:
out - ciphertext
in - plaintext
conf - configuration
cipher - the encryption algorithm
iv - the initialization vector, can be null
Throws:
IOException

decryptWithSubjectKey

public static void decryptWithSubjectKey(OutputStream out,
                                         InputStream in,
                                         int outLen,
                                         String subject,
                                         org.apache.hadoop.conf.Configuration conf,
                                         Cipher cipher,
                                         byte[] iv)
                                  throws IOException
Decrypts a block of ciphertext with the symmetric key resolved for the given subject

Parameters:
out - plaintext
in - ciphertext
outLen - the expected plaintext length
subject - the subject's key alias
conf - configuration
cipher - the encryption algorithm
iv - the initialization vector, can be null
Throws:
IOException

getCipherProvider

public static CipherProvider getCipherProvider(org.apache.hadoop.conf.Configuration conf)

getKeyProvider

public static KeyProvider getKeyProvider(org.apache.hadoop.conf.Configuration conf)

incrementIv

public static void incrementIv(byte[] iv)

incrementIv

public static void incrementIv(byte[] iv,
                               int v)


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.