| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 {"AES-CBC", 7, WebCryptoAlgorithmIdAesCbc}, | 77 {"AES-CBC", 7, WebCryptoAlgorithmIdAesCbc}, |
| 78 {"AES-GCM", 7, WebCryptoAlgorithmIdAesGcm}, | 78 {"AES-GCM", 7, WebCryptoAlgorithmIdAesGcm}, |
| 79 {"AES-CTR", 7, WebCryptoAlgorithmIdAesCtr}, | 79 {"AES-CTR", 7, WebCryptoAlgorithmIdAesCtr}, |
| 80 {"RSA-PSS", 7, WebCryptoAlgorithmIdRsaPss}, | 80 {"RSA-PSS", 7, WebCryptoAlgorithmIdRsaPss}, |
| 81 {"RSA-OAEP", 8, WebCryptoAlgorithmIdRsaOaep}, | 81 {"RSA-OAEP", 8, WebCryptoAlgorithmIdRsaOaep}, |
| 82 {"RSASSA-PKCS1-V1_5", 17, WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, | 82 {"RSASSA-PKCS1-V1_5", 17, WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // Reminder to update the table mapping names to IDs whenever adding a new | 85 // Reminder to update the table mapping names to IDs whenever adding a new |
| 86 // algorithm ID. | 86 // algorithm ID. |
| 87 COMPILE_ASSERT(WebCryptoAlgorithmIdLast + 1 == WTF_ARRAY_LENGTH(algorithmNameMap
pings), UPDATE_algorithmNameMappings); | 87 static_assert(WebCryptoAlgorithmIdLast + 1 == WTF_ARRAY_LENGTH(algorithmNameMapp
ings), "algorithmNameMappings needs to be updated"); |
| 88 | 88 |
| 89 #if ENABLE(ASSERT) | 89 #if ENABLE(ASSERT) |
| 90 | 90 |
| 91 // Essentially std::is_sorted() (however that function is new to C++11). | 91 // Essentially std::is_sorted() (however that function is new to C++11). |
| 92 template <typename Iterator> | 92 template <typename Iterator> |
| 93 bool isSorted(Iterator begin, Iterator end) | 93 bool isSorted(Iterator begin, Iterator end) |
| 94 { | 94 { |
| 95 if (begin == end) | 95 if (begin == end) |
| 96 return true; | 96 return true; |
| 97 | 97 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 WebCryptoNamedCurve value; | 677 WebCryptoNamedCurve value; |
| 678 }; | 678 }; |
| 679 | 679 |
| 680 const CurveNameMapping curveNameMappings[] = { | 680 const CurveNameMapping curveNameMappings[] = { |
| 681 { "P-256", WebCryptoNamedCurveP256 }, | 681 { "P-256", WebCryptoNamedCurveP256 }, |
| 682 { "P-384", WebCryptoNamedCurveP384 }, | 682 { "P-384", WebCryptoNamedCurveP384 }, |
| 683 { "P-521", WebCryptoNamedCurveP521 } | 683 { "P-521", WebCryptoNamedCurveP521 } |
| 684 }; | 684 }; |
| 685 | 685 |
| 686 // Reminder to update curveNameMappings when adding a new curve. | 686 // Reminder to update curveNameMappings when adding a new curve. |
| 687 COMPILE_ASSERT(WebCryptoNamedCurveLast + 1 == WTF_ARRAY_LENGTH(curveNameMappings
), UPDATE_curveNameMappings); | 687 static_assert(WebCryptoNamedCurveLast + 1 == WTF_ARRAY_LENGTH(curveNameMappings)
, "curveNameMappings needs to be updated"); |
| 688 | 688 |
| 689 bool parseNamedCurve(const Dictionary& raw, WebCryptoNamedCurve& namedCurve, Err
orContext context, AlgorithmError* error) | 689 bool parseNamedCurve(const Dictionary& raw, WebCryptoNamedCurve& namedCurve, Err
orContext context, AlgorithmError* error) |
| 690 { | 690 { |
| 691 String namedCurveString; | 691 String namedCurveString; |
| 692 if (!DictionaryHelper::get(raw, "namedCurve", namedCurveString)) { | 692 if (!DictionaryHelper::get(raw, "namedCurve", namedCurveString)) { |
| 693 setTypeError(context.toString("namedCurve", "Missing or not a string"),
error); | 693 setTypeError(context.toString("namedCurve", "Missing or not a string"),
error); |
| 694 return false; | 694 return false; |
| 695 } | 695 } |
| 696 | 696 |
| 697 for (size_t i = 0; i < WTF_ARRAY_LENGTH(curveNameMappings); ++i) { | 697 for (size_t i = 0; i < WTF_ARRAY_LENGTH(curveNameMappings); ++i) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 } | 913 } |
| 914 | 914 |
| 915 } // namespace | 915 } // namespace |
| 916 | 916 |
| 917 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W
ebCryptoAlgorithm& algorithm, AlgorithmError* error) | 917 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W
ebCryptoAlgorithm& algorithm, AlgorithmError* error) |
| 918 { | 918 { |
| 919 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); | 919 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); |
| 920 } | 920 } |
| 921 | 921 |
| 922 } // namespace blink | 922 } // namespace blink |
| OLD | NEW |