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::createWithoutParams(WebCryptoAlgori
thmId id) |
| 97 { |
| 98 if (!WebCryptoAlgorithm::isKdf(id)) |
| 99 return WebCryptoKeyAlgorithm(); |
| 100 return WebCryptoKeyAlgorithm(id, nullptr); |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
147 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d
ict) const | 154 void WebCryptoKeyAlgorithm::writeToDictionary(WebCryptoKeyAlgorithmDictionary* d
ict) const |
148 { | 155 { |
149 ASSERT(!isNull()); | 156 ASSERT(!isNull()); |
150 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name)
; | 157 dict->setString("name", WebCryptoAlgorithm::lookupAlgorithmInfo(id())->name)
; |
151 m_private->params.get()->writeToDictionary(dict); | 158 if (m_private->params.get()) |
| 159 m_private->params.get()->writeToDictionary(dict); |
152 } | 160 } |
153 | 161 |
154 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) | 162 void WebCryptoKeyAlgorithm::assign(const WebCryptoKeyAlgorithm& other) |
155 { | 163 { |
156 m_private = other.m_private; | 164 m_private = other.m_private; |
157 } | 165 } |
158 | 166 |
159 void WebCryptoKeyAlgorithm::reset() | 167 void WebCryptoKeyAlgorithm::reset() |
160 { | 168 { |
161 m_private.reset(); | 169 m_private.reset(); |
162 } | 170 } |
163 | 171 |
164 } // namespace blink | 172 } // namespace blink |
OLD | NEW |