public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage) throws KrbCryptoException {
   try {
     return Des3.encrypt(key, usage, ivec, data, 0, data.length);
   } catch (GeneralSecurityException e) {
     KrbCryptoException ke = new KrbCryptoException(e.getMessage());
     ke.initCause(e);
     throw ke;
   }
 }
 public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
     throws KrbApErrException, KrbCryptoException {
   try {
     return Des3.decrypt(key, usage, ivec, cipher, 0, cipher.length);
   } catch (GeneralSecurityException e) {
     KrbCryptoException ke = new KrbCryptoException(e.getMessage());
     ke.initCause(e);
     throw ke;
   }
 }
  /**
   * Calculates keyed checksum.
   *
   * @param data the data used to generate the checksum.
   * @param size length of the data.
   * @param key the key used to encrypt the checksum.
   * @return keyed checksum.
   */
  public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key, int usage)
      throws KrbCryptoException {

    try {
      return Aes128.calculateChecksum(key, usage, data, 0, size);
    } catch (GeneralSecurityException e) {
      KrbCryptoException ke = new KrbCryptoException(e.getMessage());
      ke.initCause(e);
      throw ke;
    }
  }
  /**
   * Verifies keyed checksum.
   *
   * @param data the data.
   * @param size the length of data.
   * @param key the key used to encrypt the checksum.
   * @param checksum
   * @return true if verification is successful.
   */
  public boolean verifyKeyedChecksum(byte[] data, int size, byte[] key, byte[] checksum, int usage)
      throws KrbCryptoException {

    try {
      byte[] newCksum = Aes128.calculateChecksum(key, usage, data, 0, size);
      return isChecksumEqual(checksum, newCksum);
    } catch (GeneralSecurityException e) {
      KrbCryptoException ke = new KrbCryptoException(e.getMessage());
      ke.initCause(e);
      throw ke;
    }
  }