/** * Creates a new SymmetricCryptor with a new symmetric key * * @return a new SymmetricCryptor * @throws CryptoException */ public static SymmetricCryptor getSymmectricCryptor(boolean cbc) throws CryptoException { Key key = generateKey(); return new SymmetricCryptor(key, cbc); }
/** * Encrypt the cleartext in byte array format. * @param cleartext The text to be encrypted, in byte form * @param The encrypted ciphertext, in byte form */ public byte[] encrypt( byte[] cleartext ) throws CryptoException { return encrypt(cleartext, 0, cleartext.length); }
public static void generateAndSaveKey(String file) throws CryptoException, IOException { SecretKey key = generateKey(); saveKey(file, key); }
@Override public void initialize() throws TeiidComponentException { manager.initialize(); try { key = SymmetricCryptor.generateKey(); } catch (CryptoException e) { throw new TeiidComponentException(e); } }
public BasicCryptor( Key encryptKey, Key decryptKey, String algorithm, IvParameterSpec iv) throws CryptoException { this.encryptKey = encryptKey; this.cipherAlgorithm = algorithm; this.decryptKey = decryptKey; this.iv = iv; if (iv != null) { randBuffer = new byte[iv.getIV().length]; } initEncryptCipher(); initDecryptCipher(); }
/** * Creates a SymmetricCryptor using the supplied byte array as the key * * @param key * @return a new SymmetricCryptor * @throws CryptoException */ public static SymmetricCryptor getSymmectricCryptor(byte[] key, boolean cbc) throws CryptoException { Key secretKey = new SecretKeySpec(key, DEFAULT_SYM_KEY_ALGORITHM); return new SymmetricCryptor(secretKey, cbc); }
/** * Test the {@link Cryptor#encrypt} method. * @throws CryptoException */ @Test public void testPos_EncryptDecryptLongString() throws CryptoException { helpTestEncryptDecrypt( CLEARTEXT ); }
public static SecretKey generateKey() throws CryptoException { try { synchronized(SymmetricCryptor.class) { if (keyGen == null) { keyGen = KeyGenerator.getInstance(DEFAULT_SYM_KEY_ALGORITHM); } keyGen.init(DEFAULT_KEY_BITS); return keyGen.generateKey(); } } catch (GeneralSecurityException e) { throw new CryptoException(CorePlugin.Event.TEIID10021, e); } }
public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("The file to create must be supplied as the only argument."); //$NON-NLS-1$ System.exit(-1); } SymmetricCryptor.generateAndSaveKey(args[0]); } }
/** * Creates a new SymmetricCryptor with a new symmetric key * * @return a new SymmetricCryptor * @throws CryptoException */ public static SymmetricCryptor getSymmectricCryptor(boolean cbc) throws CryptoException { Key key = generateKey(); return new SymmetricCryptor(key, cbc); }
public static void generateAndSaveKey(String file) throws CryptoException, IOException { SecretKey key = generateKey(); saveKey(file, key); }
public BasicCryptor( Key encryptKey, Key decryptKey, String algorithm, IvParameterSpec iv) throws CryptoException { this.encryptKey = encryptKey; this.cipherAlgorithm = algorithm; this.decryptKey = decryptKey; this.iv = iv; if (iv != null) { randBuffer = new byte[iv.getIV().length]; } initEncryptCipher(); initDecryptCipher(); }
/** * Creates a SymmetricCryptor using the supplied byte array as the key * * @param key * @return a new SymmetricCryptor * @throws CryptoException */ public static SymmetricCryptor getSymmectricCryptor(byte[] key, boolean cbc) throws CryptoException { Key secretKey = new SecretKeySpec(key, DEFAULT_SYM_KEY_ALGORITHM); return new SymmetricCryptor(secretKey, cbc); }
@Test public void testLongEncryption() throws Exception { helpTestEncryptDecrypt(CLEARTEXT + CLEARTEXT + CLEARTEXT); }
/** * Encrypt the cleartext in byte array format. * @param cleartext The text to be encrypted, in byte form * @param The encrypted ciphertext, in byte form */ public byte[] encrypt( byte[] cleartext ) throws CryptoException { return encrypt(cleartext, 0, cleartext.length); }
public static SecretKey generateKey() throws CryptoException { try { synchronized(SymmetricCryptor.class) { if (keyGen == null) { keyGen = KeyGenerator.getInstance(DEFAULT_SYM_KEY_ALGORITHM); } keyGen.init(DEFAULT_KEY_BITS); return keyGen.generateKey(); } } catch (GeneralSecurityException e) { throw new CryptoException(CorePlugin.Event.TEIID10021, e); } }
public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("The file to create must be supplied as the only argument."); //$NON-NLS-1$ System.exit(-1); } SymmetricCryptor.generateAndSaveKey(args[0]); } }
public static SymmetricCryptor getSymmectricCryptor(byte[] key, String algorithm, String cipherAlgorithm, IvParameterSpec iv) throws CryptoException { Key secretKey = new SecretKeySpec(key, algorithm); return new SymmetricCryptor(secretKey, cipherAlgorithm, iv); }
/** * Test the {@link Cryptor#encrypt} method. * @throws CryptoException */ @Test public void testPos_EncryptDecryptStringsOfBlanks() throws CryptoException { String BLANKS = " "; //$NON-NLS-1$ for ( int k = 1; k < BLANKS.length(); k++ ) { // Use substring starting at index 0, and 'k' characters long String cleartext = BLANKS.substring(0,k); helpTestEncryptDecrypt( cleartext ); } }
public static SymmetricCryptor getSymmectricCryptor(byte[] key, String algorithm, String cipherAlgorithm, IvParameterSpec iv) throws CryptoException { Key secretKey = new SecretKeySpec(key, algorithm); return new SymmetricCryptor(secretKey, cipherAlgorithm, iv); }