8180392: SunJCE provider should throw exceptions for unsupported mode and padding combinations

Change JCA Cipher class to create obj to ensure the mode and padding combination is supported

Reviewed-by: xuelei
This commit is contained in:
Valerie Peng 2019-07-25 02:16:49 +00:00
parent 74c3432b28
commit 6b662abe74
8 changed files with 188 additions and 69 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -271,7 +271,9 @@ final class CipherCore {
padding = null;
} else if (paddingScheme.equalsIgnoreCase("ISO10126Padding")) {
padding = new ISO10126Padding(blockSize);
} else if (!paddingScheme.equalsIgnoreCase("PKCS5Padding")) {
} else if (paddingScheme.equalsIgnoreCase("PKCS5Padding")) {
padding = new PKCS5Padding(blockSize);
} else {
throw new NoSuchPaddingException("Padding: " + paddingScheme
+ " not implemented");
}