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

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

Issue 104653004: [webcrypto] order Key.usages alphabetically. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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
« no previous file with comments | « LayoutTests/crypto/encrypt-decrypt-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 ASSERT_NOT_REACHED(); 53 ASSERT_NOT_REACHED();
54 return 0; 54 return 0;
55 } 55 }
56 56
57 struct KeyUsageMapping { 57 struct KeyUsageMapping {
58 blink::WebCryptoKeyUsage value; 58 blink::WebCryptoKeyUsage value;
59 const char* const name; 59 const char* const name;
60 }; 60 };
61 61
62 // Keep this array sorted.
62 const KeyUsageMapping keyUsageMappings[] = { 63 const KeyUsageMapping keyUsageMappings[] = {
64 { blink::WebCryptoKeyUsageDecrypt, "decrypt" },
65 { blink::WebCryptoKeyUsageDeriveKey, "deriveKey" },
63 { blink::WebCryptoKeyUsageEncrypt, "encrypt" }, 66 { blink::WebCryptoKeyUsageEncrypt, "encrypt" },
64 { blink::WebCryptoKeyUsageDecrypt, "decrypt" },
65 { blink::WebCryptoKeyUsageSign, "sign" }, 67 { blink::WebCryptoKeyUsageSign, "sign" },
68 { blink::WebCryptoKeyUsageUnwrapKey, "unwrapKey" },
66 { blink::WebCryptoKeyUsageVerify, "verify" }, 69 { blink::WebCryptoKeyUsageVerify, "verify" },
67 { blink::WebCryptoKeyUsageDeriveKey, "deriveKey" },
68 { blink::WebCryptoKeyUsageWrapKey, "wrapKey" }, 70 { blink::WebCryptoKeyUsageWrapKey, "wrapKey" },
69 { blink::WebCryptoKeyUsageUnwrapKey, "unwrapKey" },
70 }; 71 };
71 72
72 COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 6) + 1, update_keyUsageMap pings); 73 COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 6) + 1, update_keyUsageMap pings);
73 74
74 const char* keyUsageToString(blink::WebCryptoKeyUsage usage) 75 const char* keyUsageToString(blink::WebCryptoKeyUsage usage)
75 { 76 {
76 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { 77 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) {
77 if (keyUsageMappings[i].value == usage) 78 if (keyUsageMappings[i].value == usage)
78 return keyUsageMappings[i].name; 79 return keyUsageMappings[i].name;
79 } 80 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!usage) { 235 if (!usage) {
235 exceptionState.throwTypeError("Invalid keyUsages argument"); 236 exceptionState.throwTypeError("Invalid keyUsages argument");
236 return false; 237 return false;
237 } 238 }
238 mask |= usage; 239 mask |= usage;
239 } 240 }
240 return true; 241 return true;
241 } 242 }
242 243
243 } // namespace WebCore 244 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/crypto/encrypt-decrypt-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698