@@ -55,13 +55,47 @@ class OpenSSL extends Abstraction implements Simulator, Restorable
5555 */
5656 private $ keepUncrypted ;
5757
58+ private $ weakAlgorithms = [
59+ 'rc2 ' => true ,
60+ 'rc2-40 ' => true ,
61+ 'rc2-64 ' => true ,
62+ 'rc2-128 ' => true ,
63+ 'rc2-40-cbc ' => true ,
64+ 'rc2-64-cbc ' => true ,
65+ 'rc2-cbc ' => true ,
66+ 'rc2-cfb ' => true ,
67+ 'rc2-ecb ' => true ,
68+ 'rc2-ofb ' => true ,
69+ 'rc4 ' => true ,
70+ 'rc4-40 ' => true ,
71+ 'des ' => true ,
72+ 'des-cbc ' => true ,
73+ 'des-cfb ' => true ,
74+ 'des-ecb ' => true ,
75+ 'des-ede ' => true ,
76+ 'des-ede-cbc ' => true ,
77+ 'des-ede-cfb ' => true ,
78+ 'des-ede-ofb ' => true ,
79+ 'des-ede3 ' => true ,
80+ 'des-ede3-cbc ' => true ,
81+ 'des-ede3-cfb ' => true ,
82+ 'des-ede3-ofb ' => true ,
83+ 'des-ofb ' => true ,
84+ 'des3 ' => true ,
85+ 'desx ' => true ,
86+ 'seed ' => true ,
87+ 'seed-cbc ' => true ,
88+ 'seed-cfb ' => true ,
89+ 'seed-ecb ' => true ,
90+ 'seed-ofb ' => true ,
91+ ];
5892
5993 /**
6094 * @inheritDoc
6195 */
6296 public function crypt (Target $ target , Result $ result )
6397 {
64- if ($ this ->getExecutable ( $ target )-> isUsingWeakAlgorithm ()) {
98+ if ($ this ->isUsingWeakAlgorithm ()) {
6599 $ name = strtolower (get_class ($ this ));
66100
67101 $ result ->warn ($ name . ': The ' . $ this ->algorithm . ' algorithm is considered weak ' );
@@ -76,7 +110,7 @@ public function crypt(Target $target, Result $result)
76110 */
77111 public function simulate (Target $ target , Result $ result )
78112 {
79- if ($ this ->getExecutable ( $ target )-> isUsingWeakAlgorithm ()) {
113+ if ($ this ->isUsingWeakAlgorithm ()) {
80114 $ name = strtolower (get_class ($ this ));
81115
82116 $ result ->warn ($ name . ': The ' . $ this ->algorithm . ' algorithm is considered weak ' );
@@ -85,6 +119,15 @@ public function simulate(Target $target, Result $result)
85119 return parent ::simulate ($ target , $ result );
86120 }
87121
122+ public function isUsingWeakAlgorithm (): bool
123+ {
124+ if (null === $ this ->algorithm ) {
125+ throw new Exception ('algorithm is not set ' );
126+ }
127+
128+ return isset ($ this ->weakAlgorithms [$ this ->algorithm ]);
129+ }
130+
88131 /**
89132 * Setup
90133 *
0 commit comments