Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed config.gni. Minor cleanups. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace { 48 namespace {
49 49
50 struct AlgorithmNameMapping { 50 struct AlgorithmNameMapping {
51 // Must be an upper case ASCII string. 51 // Must be an upper case ASCII string.
52 const char* const algorithmName; 52 const char* const algorithmName;
53 // Must be strlen(algorithmName). 53 // Must be strlen(algorithmName).
54 unsigned char algorithmNameLength; 54 unsigned char algorithmNameLength;
55 blink::WebCryptoAlgorithmId algorithmId; 55 blink::WebCryptoAlgorithmId algorithmId;
56 56
57 #if ASSERT_ENABLED 57 #if ENABLE(ASSERT)
58 bool operator<(const AlgorithmNameMapping&) const; 58 bool operator<(const AlgorithmNameMapping&) const;
59 #endif 59 #endif
60 }; 60 };
61 61
62 // Must be sorted by length, and then by reverse string. 62 // Must be sorted by length, and then by reverse string.
63 // Also all names must be upper case ASCII. 63 // Also all names must be upper case ASCII.
64 const AlgorithmNameMapping algorithmNameMappings[] = { 64 const AlgorithmNameMapping algorithmNameMappings[] = {
65 {"HMAC", 4, blink::WebCryptoAlgorithmIdHmac}, 65 {"HMAC", 4, blink::WebCryptoAlgorithmIdHmac},
66 {"SHA-1", 5, blink::WebCryptoAlgorithmIdSha1}, 66 {"SHA-1", 5, blink::WebCryptoAlgorithmIdSha1},
67 {"AES-KW", 6, blink::WebCryptoAlgorithmIdAesKw}, 67 {"AES-KW", 6, blink::WebCryptoAlgorithmIdAesKw},
68 {"SHA-512", 7, blink::WebCryptoAlgorithmIdSha512}, 68 {"SHA-512", 7, blink::WebCryptoAlgorithmIdSha512},
69 {"SHA-384", 7, blink::WebCryptoAlgorithmIdSha384}, 69 {"SHA-384", 7, blink::WebCryptoAlgorithmIdSha384},
70 {"SHA-256", 7, blink::WebCryptoAlgorithmIdSha256}, 70 {"SHA-256", 7, blink::WebCryptoAlgorithmIdSha256},
71 {"AES-CBC", 7, blink::WebCryptoAlgorithmIdAesCbc}, 71 {"AES-CBC", 7, blink::WebCryptoAlgorithmIdAesCbc},
72 {"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm}, 72 {"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm},
73 {"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr}, 73 {"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr},
74 {"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep}, 74 {"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep},
75 {"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5}, 75 {"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5},
76 }; 76 };
77 77
78 #if ASSERT_ENABLED 78 #if ENABLE(ASSERT)
79 79
80 // Essentially std::is_sorted() (however that function is new to C++11). 80 // Essentially std::is_sorted() (however that function is new to C++11).
81 template <typename Iterator> 81 template <typename Iterator>
82 bool isSorted(Iterator begin, Iterator end) 82 bool isSorted(Iterator begin, Iterator end)
83 { 83 {
84 if (begin == end) 84 if (begin == end)
85 return true; 85 return true;
86 86
87 Iterator prev = begin; 87 Iterator prev = begin;
88 Iterator cur = begin + 1; 88 Iterator cur = begin + 1;
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 720 }
721 721
722 } // namespace 722 } // namespace
723 723
724 bool normalizeAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, bli nk::WebCryptoAlgorithm& algorithm, AlgorithmError* error) 724 bool normalizeAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, bli nk::WebCryptoAlgorithm& algorithm, AlgorithmError* error)
725 { 725 {
726 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error); 726 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error);
727 } 727 }
728 728
729 } // namespace WebCore 729 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698