1 | <?php |
||
56 | class IsValidEncryptionIV implements Check, ListCheck |
||
57 | { |
||
58 | // saves us having to implement inspectList() ourselves |
||
59 | use ListCheckHelper; |
||
60 | |||
61 | /** |
||
62 | * what kind of encryption are we using? |
||
63 | * @var string |
||
64 | */ |
||
65 | private $encryptionType; |
||
66 | |||
67 | /** |
||
68 | * constructor |
||
69 | * |
||
70 | * @param string $encryptionType |
||
71 | * the OpenSSL encryption cipher that we are using |
||
72 | */ |
||
73 | public function __construct(string $encryptionType) |
||
77 | |||
78 | /** |
||
79 | * do we have an encryption initialisation vector that we can use? |
||
80 | * |
||
81 | * the initialisation vector (IV for short) is often used in configs |
||
82 | * as a 'shared secret' |
||
83 | * |
||
84 | * @param string $encryptionType |
||
85 | * what kind of encryption are we using? |
||
86 | * @param string $iv |
||
87 | * what initialisation vector are we checking? |
||
88 | * @return bool |
||
89 | * TRUE if $iv is a valid initialisation vector for the given |
||
90 | * $encryptionType |
||
91 | * FALSE otherwise |
||
92 | */ |
||
93 | public static function check(string $encryptionType, string $iv) : bool |
||
111 | |||
112 | /** |
||
113 | * do we have an encryption type that we can use? |
||
114 | * |
||
115 | * @param string $iv |
||
116 | * what initialisation vector are we checking? |
||
117 | * @return bool |
||
118 | * TRUE if $iv is a valid initialisation vector for the given |
||
119 | * $encryptionType |
||
120 | * FALSE otherwise |
||
121 | */ |
||
122 | public function inspect($iv) |
||
127 | |||
128 | /** |
||
129 | * do we have an encryption type that we can use? |
||
130 | * |
||
131 | * @param string $encryptionType |
||
132 | * what kind of encryption are we using? |
||
133 | * @param array|Traversable $list |
||
134 | * the list of initialisation vectors to examine |
||
135 | * @return bool |
||
136 | * TRUE if all the items in $list are valid initialisation vectors |
||
137 | * for the given $encryptionType |
||
138 | * FALSE otherwise |
||
139 | */ |
||
140 | public static function checkList(string $encryptionType, $list) : bool |
||
146 | } |