/** * Encrypt with the encryption key and key usage. * * @param plainText The plain test * @param key The encryption key * @param usage The key usage * @return The encrypted data * @throws KrbException e */ public static EncryptedData encrypt(byte[] plainText, EncryptionKey key, KeyUsage usage) throws KrbException { EncTypeHandler handler = getEncHandler(key.getKeyType()); byte[] cipher = handler.encrypt(plainText, key.getKeyData(), usage.getValue()); EncryptedData ed = new EncryptedData(); ed.setCipher(cipher); ed.setEType(key.getKeyType()); if (key.getKvno() > 0) { ed.setKvno(key.getKvno()); } return ed; }
/** * Encrypt with the encryption key and key usage. * * @param plainText The plain test * @param key The encryption key * @param usage The key usage * @return The encrypted data * @throws KrbException e */ public static EncryptedData encrypt(byte[] plainText, EncryptionKey key, KeyUsage usage) throws KrbException { EncTypeHandler handler = getEncHandler(key.getKeyType()); byte[] cipher = handler.encrypt(plainText, key.getKeyData(), usage.getValue()); EncryptedData ed = new EncryptedData(); ed.setCipher(cipher); ed.setEType(key.getKeyType()); if (key.getKvno() > 0) { ed.setKvno(key.getKvno()); } return ed; }