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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 Key::Key(const WebKit::WebCryptoKey& key) | 96 Key::Key(const WebKit::WebCryptoKey& key) |
97 : m_key(key) | 97 : m_key(key) |
98 { | 98 { |
99 ScriptWrappable::init(this); | 99 ScriptWrappable::init(this); |
100 } | 100 } |
101 | 101 |
102 String Key::type() const | 102 String Key::type() const |
103 { | 103 { |
104 return ASCIILiteral(keyTypeToString(m_key.type())); | 104 return keyTypeToString(m_key.type()); |
105 } | 105 } |
106 | 106 |
107 bool Key::extractable() const | 107 bool Key::extractable() const |
108 { | 108 { |
109 return m_key.extractable(); | 109 return m_key.extractable(); |
110 } | 110 } |
111 | 111 |
112 Algorithm* Key::algorithm() | 112 Algorithm* Key::algorithm() |
113 { | 113 { |
114 if (!m_algorithm) | 114 if (!m_algorithm) |
115 m_algorithm = Algorithm::create(m_key.algorithm()); | 115 m_algorithm = Algorithm::create(m_key.algorithm()); |
116 return m_algorithm.get(); | 116 return m_algorithm.get(); |
117 } | 117 } |
118 | 118 |
119 // FIXME: This creates a new javascript array each time. What should happen | 119 // FIXME: This creates a new javascript array each time. What should happen |
120 // instead is return the same (immutable) array. (Javascript callers can | 120 // instead is return the same (immutable) array. (Javascript callers can |
121 // distinguish this by doing an == test on the arrays and seeing they are | 121 // distinguish this by doing an == test on the arrays and seeing they are |
122 // different). | 122 // different). |
123 Vector<String> Key::usages() const | 123 Vector<String> Key::usages() const |
124 { | 124 { |
125 Vector<String> result; | 125 Vector<String> result; |
126 for (int i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { | 126 for (int i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { |
127 WebKit::WebCryptoKeyUsage usage = keyUsageMappings[i].value; | 127 WebKit::WebCryptoKeyUsage usage = keyUsageMappings[i].value; |
128 if (m_key.usages() & usage) | 128 if (m_key.usages() & usage) |
129 result.append(ASCIILiteral(keyUsageToString(usage))); | 129 result.append(keyUsageToString(usage)); |
130 } | 130 } |
131 return result; | 131 return result; |
132 } | 132 } |
133 | 133 |
134 bool Key::parseFormat(const String& formatString, WebKit::WebCryptoKeyFormat& fo
rmat) | 134 bool Key::parseFormat(const String& formatString, WebKit::WebCryptoKeyFormat& fo
rmat) |
135 { | 135 { |
136 // There are few enough values that testing serially is fast enough. | 136 // There are few enough values that testing serially is fast enough. |
137 if (formatString == "raw") { | 137 if (formatString == "raw") { |
138 format = WebKit::WebCryptoKeyFormatRaw; | 138 format = WebKit::WebCryptoKeyFormatRaw; |
139 return true; | 139 return true; |
(...skipping 20 matching lines...) Expand all Loading... |
160 for (size_t i = 0; i < usages.size(); ++i) { | 160 for (size_t i = 0; i < usages.size(); ++i) { |
161 WebKit::WebCryptoKeyUsageMask usage = keyUsageStringToMask(usages[i]); | 161 WebKit::WebCryptoKeyUsageMask usage = keyUsageStringToMask(usages[i]); |
162 if (!usage) | 162 if (!usage) |
163 return false; | 163 return false; |
164 mask |= usage; | 164 mask |= usage; |
165 } | 165 } |
166 return true; | 166 return true; |
167 } | 167 } |
168 | 168 |
169 } // namespace WebCore | 169 } // namespace WebCore |
OLD | NEW |