Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 if (!WebCryptoAlgorithm::isHash(hash)) | 86 if (!WebCryptoAlgorithm::isHash(hash)) |
| 87 return WebCryptoKeyAlgorithm(); | 87 return WebCryptoKeyAlgorithm(); |
| 88 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash))) ); | 88 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithm Params(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash))) ); |
| 89 } | 89 } |
| 90 | 90 |
| 91 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc(WebCryptoAlgorithmId id, W ebCryptoNamedCurve namedCurve) | 91 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc(WebCryptoAlgorithmId id, W ebCryptoNamedCurve namedCurve) |
| 92 { | 92 { |
| 93 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoEcKeyAlgorithmParams( namedCurve))); | 93 return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoEcKeyAlgorithmParams( namedCurve))); |
| 94 } | 94 } |
| 95 | 95 |
| 96 WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createKdf(WebCryptoAlgorithmId kdf) | |
| 97 { | |
| 98 if (!WebCryptoAlgorithm::isKdf(kdf)) | |
| 99 return WebCryptoKeyAlgorithm(); | |
| 100 return WebCryptoKeyAlgorithm(kdf, adoptPtr(new WebCryptoKdfKeyAlgorithmParam s())); | |
| 101 } | |
| 102 | |
| 96 bool WebCryptoKeyAlgorithm::isNull() const | 103 bool WebCryptoKeyAlgorithm::isNull() const |
| 97 { | 104 { |
| 98 return m_private.isNull(); | 105 return m_private.isNull(); |
| 99 } | 106 } |
| 100 | 107 |
| 101 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::id() const | 108 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::id() const |
| 102 { | 109 { |
| 103 ASSERT(!isNull()); | 110 ASSERT(!isNull()); |
| 104 return m_private->id; | 111 return m_private->id; |
| 105 } | 112 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 } | 144 } |
| 138 | 145 |
| 139 WebCryptoEcKeyAlgorithmParams* WebCryptoKeyAlgorithm::ecParams() const | 146 WebCryptoEcKeyAlgorithmParams* WebCryptoKeyAlgorithm::ecParams() const |
| 140 { | 147 { |
| 141 ASSERT(!isNull()); | 148 ASSERT(!isNull()); |
| 142 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeEc) | 149 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeEc) |
| 143 return static_cast<WebCryptoEcKeyAlgorithmParams*>(m_private->params.get ()); | 150 return static_cast<WebCryptoEcKeyAlgorithmParams*>(m_private->params.get ()); |
| 144 return 0; | 151 return 0; |
| 145 } | 152 } |
| 146 | 153 |
| 154 WebCryptoKdfKeyAlgorithmParams* WebCryptoKeyAlgorithm::kdfParams() const | |
| 155 { | |
| 156 ASSERT(!isNull()); | |
| 157 if (paramsType() == WebCryptoKeyAlgorithmParamsTypeKdf) | |
| 158 return static_cast<WebCryptoKdfKeyAlgorithmParams*>(m_private->params.ge t()); | |
| 159 return 0; | |
| 160 } | |
| 161 | |
| 147 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d ict) const | 162 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d ict) const |
| 148 { | 163 { |
| 149 ASSERT(!isNull()); | 164 ASSERT(!isNull()); |
| 150 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name) ; | 165 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name) ; |
| 151 m_private->params.get()->writeToDictionary(dict); | 166 if (m_private->params.get()) |
|
eroman
2015/01/07 00:40:31
This change seems like it is sufficient, rather th
nharper
2015/01/08 00:58:39
The introduction of KdfKeyParams was to make somet
| |
| 167 m_private->params.get()->writeToDictionary(dict); | |
| 152 } | 168 } |
| 153 | 169 |
| 154 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) | 170 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) |
| 155 { | 171 { |
| 156 m_private = other.m_private; | 172 m_private = other.m_private; |
| 157 } | 173 } |
| 158 | 174 |
| 159 void WebCryptoKeyAlgorithm::reset() | 175 void WebCryptoKeyAlgorithm::reset() |
| 160 { | 176 { |
| 161 m_private.reset(); | 177 m_private.reset(); |
| 162 } | 178 } |
| 163 | 179 |
| 164 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |