Skip to content

Commit e0a1399

Browse files
committed
exclude reporting algorithms with CFB-1 cipher mode as supported (due #35)
1 parent 031f953 commit e0a1399

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/main/java/org/jruby/ext/openssl/Cipher.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ private static String[] registeredCipherModes(final String alg) { // e.g. "AES"
205205
final Provider provider = providers[i];
206206
final String name = provider.getName() == null ? "" : provider.getName();
207207
// skip those that are known to provide no Cipher engines :
208-
if ( name.indexOf("JGSS") >= 0 ) continue; // SunJGSS
209-
if ( name.indexOf("SASL") >= 0 ) continue; // SunSASL
210-
if ( name.indexOf("XMLD") >= 0 ) continue; // XMLDSig
211-
if ( name.indexOf("PCSC") >= 0 ) continue; // SunPCSC
212-
if ( name.indexOf("JSSE") >= 0 ) continue; // SunJSSE
208+
if ( name.contains("JGSS") ) continue; // SunJGSS
209+
if ( name.contains("SASL") ) continue; // SunSASL
210+
if ( name.contains("XMLD") ) continue; // XMLDSig
211+
if ( name.contains("PCSC") ) continue; // SunPCSC
212+
if ( name.contains("JSSE") ) continue; // SunJSSE
213213

214214
final Provider.Service service = provider.getService("Cipher", alg);
215215
if ( service != null ) {
@@ -243,8 +243,9 @@ public static final class Algorithm {
243243
}
244244

245245
private static final Set<String> KNOWN_BLOCK_MODES;
246+
// NOTE: CFB1 does not work as (OpenSSL) expects with BC (@see GH-35)
246247
private static final String[] OPENSSL_BLOCK_MODES = {
247-
"CBC", "CFB", "CFB1", "CFB8", "ECB", "OFB" // that Java supports
248+
"CBC", "CFB", /* "CFB1", */ "CFB8", "ECB", "OFB" // that Java supports
248249
};
249250

250251
static {
@@ -1145,6 +1146,7 @@ public IRubyObject do_final(final ThreadContext context) {
11451146
}
11461147
}
11471148
catch (GeneralSecurityException e) { // cipher.doFinal
1149+
debugStackTrace(runtime, e);
11481150
throw newCipherError(runtime, e);
11491151
}
11501152
catch (RuntimeException e) {

src/test/ruby/test_cipher.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def test_instantiate_supported_ciphers
7171
end
7272
end
7373

74+
def test_excludes_cfb1_ciphers # due no support in BC for CFB-1
75+
assert ! OpenSSL::Cipher.ciphers.find { |name| name =~ /CFB1/i }
76+
end if defined? JRUBY_VERSION
77+
7478
def test_encrypt_decrypt_des_ede3 # borrowed from OpenSSL suite
7579
c1 = OpenSSL::Cipher::Cipher.new("DES-EDE3-CBC")
7680
c2 = OpenSSL::Cipher::DES.new(:EDE3, "CBC")

0 commit comments

Comments
 (0)