/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4923484
* @summary encryption/decryption test for using OAEPParameterSpec.
* @author Valerie Peng
*/
public class TestOAEPWithParams {
"MD5", "SHA1", "SHA-256"
};
private static int DATA_LENGTH[] = {
62, 54, 30
};
// basic test using MD5
}
}
throws Exception {
"andMGF1Padding", cp);
(byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x02
};
(byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x04
};
byte[] plainText = new byte[dataLength];
byte[] cipherText, recovered;
// do encryption with parameters#1
// test#1: decrypt with parameters#1
throw new Exception("Decrypted data does not match");
}
// test#2: decrypt without parameters
try {
throw new Exception("Should throw BadPaddingException");
} catch (BadPaddingException bpe) {
// expected
}
// test#3: decrypt with different parameters
try {
throw new Exception("Should throw BadPaddingException");
} catch (BadPaddingException bpe) {
// expected
}
// do encryption without parameters
// test#1: decrypt with parameters got from cipher
throw new Exception("Decrypted data does not match");
}
// test#2: decrypt without parameters
throw new Exception("Decrypted data does not match");
}
// test#3: decrypt with different parameters
try {
throw new Exception("Should throw BadPaddingException");
} catch (BadPaddingException bpe) {
// expected
}
}
}