test/compiler/7184394/TestAESDecode.java

Tue, 04 Feb 2020 18:13:14 +0800

author
aoqi
date
Tue, 04 Feb 2020 18:13:14 +0800
changeset 9806
758c07667682
parent 6876
710a3c8b516e
parent 9789
e55d4d896e30
permissions
-rw-r--r--

Merge

kvn@4205 1 /*
kvn@6653 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
kvn@4205 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
kvn@4205 4 *
kvn@4205 5 * This code is free software; you can redistribute it and/or modify it
kvn@4205 6 * under the terms of the GNU General Public License version 2 only, as
kvn@4205 7 * published by the Free Software Foundation.
kvn@4205 8 *
kvn@4205 9 * This code is distributed in the hope that it will be useful, but WITHOUT
kvn@4205 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kvn@4205 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kvn@4205 12 * version 2 for more details (a copy is included in the LICENSE file that
kvn@4205 13 * accompanied this code).
kvn@4205 14 *
kvn@4205 15 * You should have received a copy of the GNU General Public License version
kvn@4205 16 * 2 along with this work; if not, write to the Free Software Foundation,
kvn@4205 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
kvn@4205 18 *
kvn@4205 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
kvn@4205 20 * or visit www.oracle.com if you need additional information or have any
kvn@4205 21 * questions.
kvn@4205 22 *
kvn@4205 23 */
kvn@4205 24
kvn@4205 25 /**
kvn@4205 26 * @author Tom Deneau
kvn@4205 27 */
kvn@4205 28
kvn@4205 29 import javax.crypto.Cipher;
kvn@4205 30
kvn@4205 31 public class TestAESDecode extends TestAESBase {
kvn@4205 32 @Override
kvn@4205 33 public void run() {
kvn@4205 34 try {
ascarpino@9789 35 if (mode.equals("GCM")) {
ascarpino@9789 36 gcm_init(false);
ascarpino@9789 37 } else if (!noReinit) {
ascarpino@9789 38 dCipher.init(Cipher.DECRYPT_MODE, key, algParams);
ascarpino@9789 39 }
kvn@6653 40 decode = new byte[decodeLength];
kvn@6653 41 if (testingMisalignment) {
kvn@6653 42 int tempSize = dCipher.update(encode, encOutputOffset, (decodeMsgSize - lastChunkSize), decode, decOutputOffset);
kvn@6653 43 dCipher.doFinal(encode, (encOutputOffset + decodeMsgSize - lastChunkSize), lastChunkSize, decode, (decOutputOffset + tempSize));
kvn@6653 44 } else {
kvn@6653 45 dCipher.doFinal(encode, encOutputOffset, decodeMsgSize, decode, decOutputOffset);
kvn@6653 46 }
kvn@4205 47 if (checkOutput) {
kvn@4205 48 compareArrays(decode, expectedDecode);
kvn@4205 49 }
kvn@4205 50 }
kvn@4205 51 catch (Exception e) {
kvn@4205 52 e.printStackTrace();
kvn@4205 53 System.exit(1);
kvn@4205 54 }
kvn@4205 55 }
kvn@4205 56
kvn@4205 57 @Override
kvn@4205 58 void childShowCipher() {
kvn@4205 59 showCipher(dCipher, "Decryption");
kvn@4205 60 }
kvn@4205 61
kvn@4205 62 }

mercurial