| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 ASSERT_NOT_REACHED(); | 55 ASSERT_NOT_REACHED(); |
| 56 return 0; | 56 return 0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 struct KeyUsageMapping { | 59 struct KeyUsageMapping { |
| 60 blink::WebCryptoKeyUsage value; | 60 blink::WebCryptoKeyUsage value; |
| 61 const char* const name; | 61 const char* const name; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Keep this array sorted. | 64 // The order of this array is the same order that will appear in Key.usages. It |
| 65 // must be kept ordered as described by the Web Crypto spec. |
| 65 const KeyUsageMapping keyUsageMappings[] = { | 66 const KeyUsageMapping keyUsageMappings[] = { |
| 67 { blink::WebCryptoKeyUsageEncrypt, "encrypt" }, |
| 66 { blink::WebCryptoKeyUsageDecrypt, "decrypt" }, | 68 { blink::WebCryptoKeyUsageDecrypt, "decrypt" }, |
| 69 { blink::WebCryptoKeyUsageSign, "sign" }, |
| 70 { blink::WebCryptoKeyUsageVerify, "verify" }, |
| 67 { blink::WebCryptoKeyUsageDeriveKey, "deriveKey" }, | 71 { blink::WebCryptoKeyUsageDeriveKey, "deriveKey" }, |
| 68 { blink::WebCryptoKeyUsageEncrypt, "encrypt" }, | 72 { blink::WebCryptoKeyUsageWrapKey, "wrapKey" }, |
| 69 { blink::WebCryptoKeyUsageSign, "sign" }, | |
| 70 { blink::WebCryptoKeyUsageUnwrapKey, "unwrapKey" }, | 73 { blink::WebCryptoKeyUsageUnwrapKey, "unwrapKey" }, |
| 71 { blink::WebCryptoKeyUsageVerify, "verify" }, | |
| 72 { blink::WebCryptoKeyUsageWrapKey, "wrapKey" }, | |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 6) + 1, update_keyUsageMap
pings); | 76 COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 6) + 1, update_keyUsageMap
pings); |
| 76 | 77 |
| 77 const char* keyUsageToString(blink::WebCryptoKeyUsage usage) | 78 const char* keyUsageToString(blink::WebCryptoKeyUsage usage) |
| 78 { | 79 { |
| 79 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { | 80 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { |
| 80 if (keyUsageMappings[i].value == usage) | 81 if (keyUsageMappings[i].value == usage) |
| 81 return keyUsageMappings[i].name; | 82 return keyUsageMappings[i].name; |
| 82 } | 83 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 217 } |
| 217 return true; | 218 return true; |
| 218 } | 219 } |
| 219 | 220 |
| 220 void Key::trace(Visitor* visitor) | 221 void Key::trace(Visitor* visitor) |
| 221 { | 222 { |
| 222 visitor->trace(m_algorithm); | 223 visitor->trace(m_algorithm); |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace WebCore | 226 } // namespace WebCore |
| OLD | NEW |