equal
deleted
inserted
replaced
151 // Get local supported algorithm collection complying to |
151 // Get local supported algorithm collection complying to |
152 // algorithm constraints |
152 // algorithm constraints |
153 static Collection<SignatureAndHashAlgorithm> |
153 static Collection<SignatureAndHashAlgorithm> |
154 getSupportedAlgorithms(AlgorithmConstraints constraints) { |
154 getSupportedAlgorithms(AlgorithmConstraints constraints) { |
155 |
155 |
156 Collection<SignatureAndHashAlgorithm> supported = |
156 Collection<SignatureAndHashAlgorithm> supported = new ArrayList<>(); |
157 new ArrayList<SignatureAndHashAlgorithm>(); |
|
158 synchronized (priorityMap) { |
157 synchronized (priorityMap) { |
159 for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) { |
158 for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) { |
160 if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && |
159 if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && |
161 constraints.permits(SIGNATURE_PRIMITIVE_SET, |
160 constraints.permits(SIGNATURE_PRIMITIVE_SET, |
162 sigAlg.algorithm, null)) { |
161 sigAlg.algorithm, null)) { |
169 } |
168 } |
170 |
169 |
171 // Get supported algorithm collection from an untrusted collection |
170 // Get supported algorithm collection from an untrusted collection |
172 static Collection<SignatureAndHashAlgorithm> getSupportedAlgorithms( |
171 static Collection<SignatureAndHashAlgorithm> getSupportedAlgorithms( |
173 Collection<SignatureAndHashAlgorithm> algorithms ) { |
172 Collection<SignatureAndHashAlgorithm> algorithms ) { |
174 Collection<SignatureAndHashAlgorithm> supported = |
173 Collection<SignatureAndHashAlgorithm> supported = new ArrayList<>(); |
175 new ArrayList<SignatureAndHashAlgorithm>(); |
|
176 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
174 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
177 if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { |
175 if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { |
178 supported.add(sigAlg); |
176 supported.add(sigAlg); |
179 } |
177 } |
180 } |
178 } |
182 return supported; |
180 return supported; |
183 } |
181 } |
184 |
182 |
185 static String[] getAlgorithmNames( |
183 static String[] getAlgorithmNames( |
186 Collection<SignatureAndHashAlgorithm> algorithms) { |
184 Collection<SignatureAndHashAlgorithm> algorithms) { |
187 ArrayList<String> algorithmNames = new ArrayList<String>(); |
185 ArrayList<String> algorithmNames = new ArrayList<>(); |
188 if (algorithms != null) { |
186 if (algorithms != null) { |
189 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
187 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
190 algorithmNames.add(sigAlg.algorithm); |
188 algorithmNames.add(sigAlg.algorithm); |
191 } |
189 } |
192 } |
190 } |
195 return algorithmNames.toArray(array); |
193 return algorithmNames.toArray(array); |
196 } |
194 } |
197 |
195 |
198 static Set<String> getHashAlgorithmNames( |
196 static Set<String> getHashAlgorithmNames( |
199 Collection<SignatureAndHashAlgorithm> algorithms) { |
197 Collection<SignatureAndHashAlgorithm> algorithms) { |
200 Set<String> algorithmNames = new HashSet<String>(); |
198 Set<String> algorithmNames = new HashSet<>(); |
201 if (algorithms != null) { |
199 if (algorithms != null) { |
202 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
200 for (SignatureAndHashAlgorithm sigAlg : algorithms) { |
203 if (sigAlg.hash.value > 0) { |
201 if (sigAlg.hash.value > 0) { |
204 algorithmNames.add(sigAlg.hash.standardName); |
202 algorithmNames.add(sigAlg.hash.standardName); |
205 } |
203 } |