kvn@4205: /* ascarpino@9788: * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. kvn@4205: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. kvn@4205: * kvn@4205: * This code is free software; you can redistribute it and/or modify it kvn@4205: * under the terms of the GNU General Public License version 2 only, as kvn@4205: * published by the Free Software Foundation. kvn@4205: * kvn@4205: * This code is distributed in the hope that it will be useful, but WITHOUT kvn@4205: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or kvn@4205: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License kvn@4205: * version 2 for more details (a copy is included in the LICENSE file that kvn@4205: * accompanied this code). kvn@4205: * kvn@4205: * You should have received a copy of the GNU General Public License version kvn@4205: * 2 along with this work; if not, write to the Free Software Foundation, kvn@4205: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. kvn@4205: * kvn@4205: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA kvn@4205: * or visit www.oracle.com if you need additional information or have any kvn@4205: * questions. kvn@4205: * kvn@4205: */ kvn@4205: kvn@4205: /** kvn@4205: * @author Tom Deneau kvn@4205: */ kvn@4205: kvn@4205: import javax.crypto.Cipher; kvn@4205: kvn@4205: public class TestAESEncode extends TestAESBase { kvn@4205: @Override kvn@4205: public void run() { kvn@4205: try { ascarpino@9788: if (mode.equals("GCM")) { ascarpino@9789: gcm_init(true); ascarpino@9788: } else if (!noReinit) { ascarpino@9788: cipher.init(Cipher.ENCRYPT_MODE, key, algParams); ascarpino@9788: } kvn@6653: encode = new byte[encodeLength]; kvn@6653: if (testingMisalignment) { kvn@6653: int tempSize = cipher.update(input, encInputOffset, (msgSize - lastChunkSize), encode, encOutputOffset); kvn@6653: cipher.doFinal(input, (encInputOffset + msgSize - lastChunkSize), lastChunkSize, encode, (encOutputOffset + tempSize)); kvn@6653: } else { kvn@6653: cipher.doFinal(input, encInputOffset, msgSize, encode, encOutputOffset); kvn@6653: } kvn@4205: if (checkOutput) { kvn@4205: compareArrays(encode, expectedEncode); kvn@4205: } kvn@4205: } kvn@4205: catch (Exception e) { kvn@4205: e.printStackTrace(); kvn@4205: System.exit(1); kvn@4205: } kvn@4205: } kvn@4205: kvn@4205: @Override kvn@4205: void childShowCipher() { kvn@4205: showCipher(cipher, "Encryption"); kvn@4205: } kvn@4205: kvn@4205: }