OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 // FIXME: This creates a new javascript array each time. What should happen | 152 // FIXME: This creates a new javascript array each time. What should happen |
153 // instead is return the same (immutable) array. (Javascript callers can | 153 // instead is return the same (immutable) array. (Javascript callers can |
154 // distinguish this by doing an == test on the arrays and seeing they are | 154 // distinguish this by doing an == test on the arrays and seeing they are |
155 // different). | 155 // different). |
156 Vector<String> CryptoKey::usages() const { | 156 Vector<String> CryptoKey::usages() const { |
157 Vector<String> result; | 157 Vector<String> result; |
158 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { | 158 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { |
159 WebCryptoKeyUsage usage = keyUsageMappings[i].value; | 159 WebCryptoKeyUsage usage = keyUsageMappings[i].value; |
160 if (m_key.usages() & usage) | 160 if (m_key.usages() & usage) |
161 result.append(keyUsageToString(usage)); | 161 result.push_back(keyUsageToString(usage)); |
162 } | 162 } |
163 return result; | 163 return result; |
164 } | 164 } |
165 | 165 |
166 bool CryptoKey::canBeUsedForAlgorithm(const WebCryptoAlgorithm& algorithm, | 166 bool CryptoKey::canBeUsedForAlgorithm(const WebCryptoAlgorithm& algorithm, |
167 WebCryptoKeyUsage usage, | 167 WebCryptoKeyUsage usage, |
168 CryptoResult* result) const { | 168 CryptoResult* result) const { |
169 // This order of tests on keys is done throughout the WebCrypto spec when | 169 // This order of tests on keys is done throughout the WebCrypto spec when |
170 // testing if a key can be used for an algorithm. | 170 // testing if a key can be used for an algorithm. |
171 // | 171 // |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 result->completeWithError(WebCryptoErrorTypeType, | 231 result->completeWithError(WebCryptoErrorTypeType, |
232 "Invalid keyUsages argument"); | 232 "Invalid keyUsages argument"); |
233 return false; | 233 return false; |
234 } | 234 } |
235 mask |= usage; | 235 mask |= usage; |
236 } | 236 } |
237 return true; | 237 return true; |
238 } | 238 } |
239 | 239 |
240 } // namespace blink | 240 } // namespace blink |
OLD | NEW |