Package org.apache.hadoop.hbase.security
Class EncryptionUtil
java.lang.Object
org.apache.hadoop.hbase.security.EncryptionUtil
Some static utility methods for encryption uses in hbase-client.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor to keep this class from being instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic CryptoAEScreateCryptoAES(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.CryptoCipherMeta cryptoCipherMeta, org.apache.hadoop.conf.Configuration conf) Helper to create an instance of CryptoAES.private static KeygetUnwrapKey(org.apache.hadoop.conf.Configuration conf, String subject, org.apache.hadoop.hbase.shaded.protobuf.generated.EncryptionProtos.WrappedKey wrappedKey, Cipher cipher, Key kek) static KeyunwrapKey(org.apache.hadoop.conf.Configuration conf, byte[] keyBytes) Helper forunwrapKey(Configuration, String, byte[])which automatically uses the configured master and alternative keys, rather than having to specify a key type to unwrap with.static KeyUnwrap a key by decrypting it with the secret key of the given subject.static KeyUnwrap a key by decrypting it with the secret key of the given subject.static KeyunwrapWALKey(org.apache.hadoop.conf.Configuration conf, String subject, byte[] value) Unwrap a wal key by decrypting it with the secret key of the given subject.static byte[]Protect a key by encrypting it with the secret key of the given subject.static byte[]Protect a key by encrypting it with the secret key of the given subject.static byte[]Protect a key by encrypting it with the secret key of the given subject or kek.
-
Field Details
-
LOG
-
-
Constructor Details
-
EncryptionUtil
private EncryptionUtil()Private constructor to keep this class from being instantiated.
-
-
Method Details
-
wrapKey
public static byte[] wrapKey(org.apache.hadoop.conf.Configuration conf, byte[] key, String algorithm) throws IOException Protect a key by encrypting it with the secret key of the given subject. The configuration must be set up correctly for key alias resolution.- Parameters:
conf- configurationkey- the raw key bytesalgorithm- the algorithm to use with this key material- Returns:
- the encrypted key bytes
- Throws:
IOException
-
wrapKey
public static byte[] wrapKey(org.apache.hadoop.conf.Configuration conf, String subject, Key key) throws IOException Protect a key by encrypting it with the secret key of the given subject. The configuration must be set up correctly for key alias resolution.- Parameters:
conf- configurationsubject- subject key aliaskey- the key- Returns:
- the encrypted key bytes
- Throws:
IOException
-
wrapKey
public static byte[] wrapKey(org.apache.hadoop.conf.Configuration conf, String subject, Key key, Key kek) throws IOException Protect a key by encrypting it with the secret key of the given subject or kek. The configuration must be set up correctly for key alias resolution. Only one of thesubjectorkekneeds to be specified and the other one can benull.- Parameters:
conf- configurationsubject- subject key aliaskey- the keykek- the key encryption key- Returns:
- the encrypted key bytes
- Throws:
IOException
-
unwrapKey
public static Key unwrapKey(org.apache.hadoop.conf.Configuration conf, String subject, byte[] value) throws IOException, KeyException Unwrap a key by decrypting it with the secret key of the given subject. The configuration must be set up correctly for key alias resolution.- Parameters:
conf- configurationsubject- subject key aliasvalue- the encrypted key bytes- Returns:
- the raw key bytes
- Throws:
IOExceptionKeyException
-
unwrapKey
public static Key unwrapKey(org.apache.hadoop.conf.Configuration conf, String subject, byte[] value, Key kek) throws IOException, KeyException Unwrap a key by decrypting it with the secret key of the given subject. The configuration must be set up correctly for key alias resolution. Only one of thesubjectorkekneeds to be specified and the other one can benull.- Parameters:
conf- configurationsubject- subject key aliasvalue- the encrypted key byteskek- the key encryption key- Returns:
- the raw key bytes
- Throws:
IOExceptionKeyException
-
getUnwrapKey
private static Key getUnwrapKey(org.apache.hadoop.conf.Configuration conf, String subject, org.apache.hadoop.hbase.shaded.protobuf.generated.EncryptionProtos.WrappedKey wrappedKey, Cipher cipher, Key kek) throws IOException, KeyException - Throws:
IOExceptionKeyException
-
unwrapWALKey
public static Key unwrapWALKey(org.apache.hadoop.conf.Configuration conf, String subject, byte[] value) throws IOException, KeyException Unwrap a wal key by decrypting it with the secret key of the given subject. The configuration must be set up correctly for key alias resolution.- Parameters:
conf- configurationsubject- subject key aliasvalue- the encrypted key bytes- Returns:
- the raw key bytes
- Throws:
IOException- if key is not found for the subject, or if some I/O error occursKeyException- if fail to unwrap the key
-
unwrapKey
public static Key unwrapKey(org.apache.hadoop.conf.Configuration conf, byte[] keyBytes) throws IOException Helper forunwrapKey(Configuration, String, byte[])which automatically uses the configured master and alternative keys, rather than having to specify a key type to unwrap with. The configuration must be set up correctly for key alias resolution.- Parameters:
conf- the current configurationkeyBytes- the key encrypted by master (or alternative) to unwrap- Returns:
- the key bytes, decrypted
- Throws:
IOException- if the key cannot be unwrapped
-
createCryptoAES
public static CryptoAES createCryptoAES(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.CryptoCipherMeta cryptoCipherMeta, org.apache.hadoop.conf.Configuration conf) throws IOException Helper to create an instance of CryptoAES.- Parameters:
conf- The current configuration.cryptoCipherMeta- The metadata for create CryptoAES.- Returns:
- The instance of CryptoAES.
- Throws:
IOException- if create CryptoAES failed
-