mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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:
parent
74c3432b28
commit
6b662abe74
8 changed files with 188 additions and 69 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -559,16 +559,16 @@ public class Cipher {
|
|||
// does not support mode or padding we need, ignore
|
||||
continue;
|
||||
}
|
||||
if (canuse == S_YES) {
|
||||
// S_YES, S_MAYBE
|
||||
// even when mode and padding are both supported, they
|
||||
// may not be used together, try out and see if it works
|
||||
try {
|
||||
CipherSpi spi = (CipherSpi)s.newInstance(null);
|
||||
tr.setModePadding(spi);
|
||||
// specify null instead of spi for delayed provider selection
|
||||
return new Cipher(null, s, t, transformation, transforms);
|
||||
} else { // S_MAYBE, try out if it works
|
||||
try {
|
||||
CipherSpi spi = (CipherSpi)s.newInstance(null);
|
||||
tr.setModePadding(spi);
|
||||
return new Cipher(spi, s, t, transformation, transforms);
|
||||
} catch (Exception e) {
|
||||
failure = e;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failure = e;
|
||||
}
|
||||
}
|
||||
throw new NoSuchAlgorithmException
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue