Beispiel #1
0
  public byte[] decryptWithARIA128CBC(byte dataBytes[], byte cryptKey[], byte ivec[])
      throws InvalidKeyException {
    if (dataBytes == null || cryptKey == null) return null;
    if (dataBytes.length % ARIA128_BLOCKSIZE != 0 || cryptKey.length != ARIA128_BLOCKSIZE) {
      System.out.println(
          "[decryptWithARIA128] : dataBytes length should be the multiple of 16 and cryptKey length should be 16");
      throw new InvalidKeyException(
          "[decryptWithARIA128] : dataBytes length should be the multiple of 16 and cryptKey length should be 16");
    }

    int inLength = dataBytes.length;
    byte outData[] = new byte[inLength];

    int outLength =
        ARIA_CBC.ARIA_CBC(
            ARIA_CBC.ARIA_DECRYPT,
            ARIA_CBC.ARIA128_BITSIZE,
            cryptKey,
            ivec,
            dataBytes,
            dataBytes.length,
            outData);

    byte resultOutData[] = new byte[outLength];
    System.arraycopy(outData, 0, resultOutData, 0, outLength);
    return resultOutData;
  }
Beispiel #2
0
  public byte[] encryptWithARIA128CBC(byte dataBytes[], byte cryptKey[], byte ivec[])
      throws InvalidKeyException {
    if (dataBytes == null || cryptKey == null) return null;
    if (cryptKey.length != ARIA128_BLOCKSIZE) {
      System.out.println("[encryptWithARIA128] : cryptKey length should be 16");
      throw new InvalidKeyException("[encryptWithARIA128] : cryptKey length should be 16");
    }

    int inLength = dataBytes.length;
    int outLength = (inLength / ARIA_CBC.ARIA_BLOCK_SIZE + 1) * ARIA_CBC.ARIA_BLOCK_SIZE;
    byte outData[] = new byte[outLength];

    ARIA_CBC.ARIA_CBC(
        ARIA_CBC.ARIA_ENCRYPT,
        ARIA_CBC.ARIA128_BITSIZE,
        cryptKey,
        ivec,
        dataBytes,
        dataBytes.length,
        outData);
    return outData;
  }