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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 { WebCryptoKeyUsageEncrypt, "encrypt" }, | 68 { WebCryptoKeyUsageEncrypt, "encrypt" }, |
69 { WebCryptoKeyUsageDecrypt, "decrypt" }, | 69 { WebCryptoKeyUsageDecrypt, "decrypt" }, |
70 { WebCryptoKeyUsageSign, "sign" }, | 70 { WebCryptoKeyUsageSign, "sign" }, |
71 { WebCryptoKeyUsageVerify, "verify" }, | 71 { WebCryptoKeyUsageVerify, "verify" }, |
72 { WebCryptoKeyUsageDeriveKey, "deriveKey" }, | 72 { WebCryptoKeyUsageDeriveKey, "deriveKey" }, |
73 { WebCryptoKeyUsageDeriveBits, "deriveBits" }, | 73 { WebCryptoKeyUsageDeriveBits, "deriveBits" }, |
74 { WebCryptoKeyUsageWrapKey, "wrapKey" }, | 74 { WebCryptoKeyUsageWrapKey, "wrapKey" }, |
75 { WebCryptoKeyUsageUnwrapKey, "unwrapKey" }, | 75 { WebCryptoKeyUsageUnwrapKey, "unwrapKey" }, |
76 }; | 76 }; |
77 | 77 |
78 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, update_keyUsageMappings); | 78 static_assert(EndOfWebCryptoKeyUsage == (1 << 7) + 1, "keyUsageMappings needs to
be updated"); |
79 | 79 |
80 const char* keyUsageToString(WebCryptoKeyUsage usage) | 80 const char* keyUsageToString(WebCryptoKeyUsage usage) |
81 { | 81 { |
82 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { | 82 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { |
83 if (keyUsageMappings[i].value == usage) | 83 if (keyUsageMappings[i].value == usage) |
84 return keyUsageMappings[i].name; | 84 return keyUsageMappings[i].name; |
85 } | 85 } |
86 ASSERT_NOT_REACHED(); | 86 ASSERT_NOT_REACHED(); |
87 return 0; | 87 return 0; |
88 } | 88 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!usage) { | 179 if (!usage) { |
180 result->completeWithError(WebCryptoErrorTypeType, "Invalid keyUsages
argument"); | 180 result->completeWithError(WebCryptoErrorTypeType, "Invalid keyUsages
argument"); |
181 return false; | 181 return false; |
182 } | 182 } |
183 mask |= usage; | 183 mask |= usage; |
184 } | 184 } |
185 return true; | 185 return true; |
186 } | 186 } |
187 | 187 |
188 } // namespace blink | 188 } // namespace blink |
OLD | NEW |