| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 typedef ArrayBufferOrArrayBufferView BufferSource; | 53 typedef ArrayBufferOrArrayBufferView BufferSource; |
| 54 | 54 |
| 55 struct AlgorithmNameMapping { | 55 struct AlgorithmNameMapping { |
| 56 // Must be an upper case ASCII string. | 56 // Must be an upper case ASCII string. |
| 57 const char* const algorithmName; | 57 const char* const algorithmName; |
| 58 // Must be strlen(algorithmName). | 58 // Must be strlen(algorithmName). |
| 59 unsigned char algorithmNameLength; | 59 unsigned char algorithmNameLength; |
| 60 WebCryptoAlgorithmId algorithmId; | 60 WebCryptoAlgorithmId algorithmId; |
| 61 | 61 |
| 62 #if ENABLE(ASSERT) | 62 #if DCHECK_IS_ON() |
| 63 bool operator<(const AlgorithmNameMapping&) const; | 63 bool operator<(const AlgorithmNameMapping&) const; |
| 64 #endif | 64 #endif |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 // Must be sorted by length, and then by reverse string. | 67 // Must be sorted by length, and then by reverse string. |
| 68 // Also all names must be upper case ASCII. | 68 // Also all names must be upper case ASCII. |
| 69 const AlgorithmNameMapping algorithmNameMappings[] = { | 69 const AlgorithmNameMapping algorithmNameMappings[] = { |
| 70 {"HMAC", 4, WebCryptoAlgorithmIdHmac}, | 70 {"HMAC", 4, WebCryptoAlgorithmIdHmac}, |
| 71 {"HKDF", 4, WebCryptoAlgorithmIdHkdf}, | 71 {"HKDF", 4, WebCryptoAlgorithmIdHkdf}, |
| 72 {"ECDH", 4, WebCryptoAlgorithmIdEcdh}, | 72 {"ECDH", 4, WebCryptoAlgorithmIdEcdh}, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 {"RSA-OAEP", 8, WebCryptoAlgorithmIdRsaOaep}, | 84 {"RSA-OAEP", 8, WebCryptoAlgorithmIdRsaOaep}, |
| 85 {"RSASSA-PKCS1-V1_5", 17, WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, | 85 {"RSASSA-PKCS1-V1_5", 17, WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // Reminder to update the table mapping names to IDs whenever adding a new | 88 // Reminder to update the table mapping names to IDs whenever adding a new |
| 89 // algorithm ID. | 89 // algorithm ID. |
| 90 static_assert(WebCryptoAlgorithmIdLast + 1 == | 90 static_assert(WebCryptoAlgorithmIdLast + 1 == |
| 91 WTF_ARRAY_LENGTH(algorithmNameMappings), | 91 WTF_ARRAY_LENGTH(algorithmNameMappings), |
| 92 "algorithmNameMappings needs to be updated"); | 92 "algorithmNameMappings needs to be updated"); |
| 93 | 93 |
| 94 #if ENABLE(ASSERT) | 94 #if DCHECK_IS_ON() |
| 95 | 95 |
| 96 // Essentially std::is_sorted() (however that function is new to C++11). | 96 // Essentially std::is_sorted() (however that function is new to C++11). |
| 97 template <typename Iterator> | 97 template <typename Iterator> |
| 98 bool isSorted(Iterator begin, Iterator end) { | 98 bool isSorted(Iterator begin, Iterator end) { |
| 99 if (begin == end) | 99 if (begin == end) |
| 100 return true; | 100 return true; |
| 101 | 101 |
| 102 Iterator prev = begin; | 102 Iterator prev = begin; |
| 103 Iterator cur = begin + 1; | 103 Iterator cur = begin + 1; |
| 104 | 104 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 } // namespace | 1093 } // namespace |
| 1094 | 1094 |
| 1095 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, | 1095 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, |
| 1096 WebCryptoOperation op, | 1096 WebCryptoOperation op, |
| 1097 WebCryptoAlgorithm& algorithm, | 1097 WebCryptoAlgorithm& algorithm, |
| 1098 AlgorithmError* error) { | 1098 AlgorithmError* error) { |
| 1099 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); | 1099 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 } // namespace blink | 1102 } // namespace blink |
| OLD | NEW |