/** * Get names of supported encryption algorithms * * @return Array of strings, each represents a supported encryption algorithm */ public static String[] getSupportedCiphers(Configuration conf) { return getCipherProvider(conf).getSupportedCiphers(); }
/** * Get an cipher given a name * @param name the cipher name * @return the cipher, or null if a suitable one could not be found */ public static Cipher getCipher(Configuration conf, String name) { return getCipherProvider(conf).getCipher(name); }
public AES(CipherProvider provider) { super(provider); // The JCE mode for Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // The JCE provider, null if default cipherProvider = provider.getConf().get(CIPHER_PROVIDER_KEY); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
@Test public void testCustomProvider() { Configuration conf = HBaseConfiguration.create(); conf.set(HConstants.CRYPTO_CIPHERPROVIDER_CONF_KEY, MyCipherProvider.class.getName()); CipherProvider provider = Encryption.getCipherProvider(conf); assertTrue(provider instanceof MyCipherProvider); assertTrue(Arrays.asList(provider.getSupportedCiphers()).contains("TEST")); Cipher a = Encryption.getCipher(conf, "TEST"); assertNotNull(a); assertTrue(a.getProvider() instanceof MyCipherProvider); assertEquals("TEST", a.getName()); assertEquals(0, a.getKeyLength()); }
public CommonsCryptoAES(CipherProvider provider) { super(provider); // The mode for Commons Crypto Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // Reads Commons Crypto properties from HBase conf props = readCryptoProps(provider.getConf()); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
/** * Get an cipher given a name * @param name the cipher name * @return the cipher, or null if a suitable one could not be found */ public static Cipher getCipher(Configuration conf, String name) { return getCipherProvider(conf).getCipher(name); }
@Test public void testDefaultProvider() { Configuration conf = HBaseConfiguration.create(); CipherProvider provider = Encryption.getCipherProvider(conf); assertTrue(provider instanceof DefaultCipherProvider); String algorithm = conf.get(HConstants.CRYPTO_KEY_ALGORITHM_CONF_KEY, HConstants.CIPHER_AES); assertTrue(Arrays.asList(provider.getSupportedCiphers()).contains(algorithm)); Cipher a = Encryption.getCipher(conf, algorithm); assertNotNull(a); assertTrue(a.getProvider() instanceof DefaultCipherProvider); assertEquals(a.getName(), algorithm); assertEquals(AES.KEY_LENGTH, a.getKeyLength()); }
public AES(CipherProvider provider) { super(provider); // The JCE mode for Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // The JCE provider, null if default cipherProvider = provider.getConf().get(CIPHER_PROVIDER_KEY); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
/** * Get an cipher given a name * @param name the cipher name * @return the cipher, or null if a suitable one could not be found */ public static Cipher getCipher(Configuration conf, String name) { return getCipherProvider(conf).getCipher(name); }
/** * Get names of supported encryption algorithms * * @return Array of strings, each represents a supported encryption algorithm */ public static String[] getSupportedCiphers(Configuration conf) { return getCipherProvider(conf).getSupportedCiphers(); }
public AES(CipherProvider provider) { super(provider); // The JCE mode for Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // The JCE provider, null if default cipherProvider = provider.getConf().get(CIPHER_PROVIDER_KEY); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
/** * Get an cipher given a name * @param name the cipher name * @return the cipher, or null if a suitable one could not be found */ public static Cipher getCipher(Configuration conf, String name) { return getCipherProvider(conf).getCipher(name); }
/** * Get names of supported encryption algorithms * * @return Array of strings, each represents a supported encryption algorithm */ public static String[] getSupportedCiphers(Configuration conf) { return getCipherProvider(conf).getSupportedCiphers(); }
public CommonsCryptoAES(CipherProvider provider) { super(provider); // The mode for Commons Crypto Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // Reads Commons Crypto properties from HBase conf props = readCryptoProps(provider.getConf()); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
/** * Get names of supported encryption algorithms * * @return Array of strings, each represents a supported encryption algorithm */ public static String[] getSupportedCiphers(Configuration conf) { return getCipherProvider(conf).getSupportedCiphers(); }
public CommonsCryptoAES(CipherProvider provider) { super(provider); // The mode for Commons Crypto Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // Reads Commons Crypto properties from HBase conf props = readCryptoProps(provider.getConf()); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
@Test public void testCustomProvider() { Configuration conf = HBaseConfiguration.create(); conf.set(HConstants.CRYPTO_CIPHERPROVIDER_CONF_KEY, MyCipherProvider.class.getName()); CipherProvider provider = Encryption.getCipherProvider(conf); assertTrue(provider instanceof MyCipherProvider); assertTrue(Arrays.asList(provider.getSupportedCiphers()).contains("TEST")); Cipher a = Encryption.getCipher(conf, "TEST"); assertNotNull(a); assertTrue(a.getProvider() instanceof MyCipherProvider); assertEquals("TEST", a.getName()); assertEquals(0, a.getKeyLength()); }
public AES(CipherProvider provider) { super(provider); // The JCE mode for Ciphers cipherMode = provider.getConf().get(CIPHER_MODE_KEY, "AES/CTR/NoPadding"); // The JCE provider, null if default cipherProvider = provider.getConf().get(CIPHER_PROVIDER_KEY); // RNG algorithm rngAlgorithm = provider.getConf().get(RNG_ALGORITHM_KEY, "SHA1PRNG"); // RNG provider, null if default String rngProvider = provider.getConf().get(RNG_PROVIDER_KEY); try { if (rngProvider != null) { rng = SecureRandom.getInstance(rngAlgorithm, rngProvider); } else { rng = SecureRandom.getInstance(rngAlgorithm); } } catch (GeneralSecurityException e) { LOG.warn("Could not instantiate specified RNG, falling back to default", e); rng = new SecureRandom(); } }
@Test public void testCustomProvider() { Configuration conf = HBaseConfiguration.create(); conf.set(HConstants.CRYPTO_CIPHERPROVIDER_CONF_KEY, MyCipherProvider.class.getName()); CipherProvider provider = Encryption.getCipherProvider(conf); assertTrue(provider instanceof MyCipherProvider); assertTrue(Arrays.asList(provider.getSupportedCiphers()).contains("TEST")); Cipher a = Encryption.getCipher(conf, "TEST"); assertNotNull(a); assertTrue(a.getProvider() instanceof MyCipherProvider); assertEquals("TEST", a.getName()); assertEquals(0, a.getKeyLength()); }
@Test public void testDefaultProvider() { Configuration conf = HBaseConfiguration.create(); CipherProvider provider = Encryption.getCipherProvider(conf); assertTrue(provider instanceof DefaultCipherProvider); String algorithm = conf.get(HConstants.CRYPTO_KEY_ALGORITHM_CONF_KEY, HConstants.CIPHER_AES); assertTrue(Arrays.asList(provider.getSupportedCiphers()).contains(algorithm)); Cipher a = Encryption.getCipher(conf, algorithm); assertNotNull(a); assertTrue(a.getProvider() instanceof DefaultCipherProvider); assertEquals(a.getName(), algorithm); assertEquals(AES.KEY_LENGTH, a.getKeyLength()); }