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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (!WebCryptoAlgorithm::IsKdf(id)) | 115 if (!WebCryptoAlgorithm::IsKdf(id)) |
116 return WebCryptoKeyAlgorithm(); | 116 return WebCryptoKeyAlgorithm(); |
117 return WebCryptoKeyAlgorithm(id, nullptr); | 117 return WebCryptoKeyAlgorithm(id, nullptr); |
118 } | 118 } |
119 | 119 |
120 bool WebCryptoKeyAlgorithm::IsNull() const { | 120 bool WebCryptoKeyAlgorithm::IsNull() const { |
121 return private_.IsNull(); | 121 return private_.IsNull(); |
122 } | 122 } |
123 | 123 |
124 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::Id() const { | 124 WebCryptoAlgorithmId WebCryptoKeyAlgorithm::Id() const { |
125 ASSERT(!IsNull()); | 125 DCHECK(!IsNull()); |
126 return private_->id; | 126 return private_->id; |
127 } | 127 } |
128 | 128 |
129 WebCryptoKeyAlgorithmParamsType WebCryptoKeyAlgorithm::ParamsType() const { | 129 WebCryptoKeyAlgorithmParamsType WebCryptoKeyAlgorithm::ParamsType() const { |
130 ASSERT(!IsNull()); | 130 DCHECK(!IsNull()); |
131 if (!private_->params.get()) | 131 if (!private_->params.get()) |
132 return kWebCryptoKeyAlgorithmParamsTypeNone; | 132 return kWebCryptoKeyAlgorithmParamsTypeNone; |
133 return private_->params->GetType(); | 133 return private_->params->GetType(); |
134 } | 134 } |
135 | 135 |
136 WebCryptoAesKeyAlgorithmParams* WebCryptoKeyAlgorithm::AesParams() const { | 136 WebCryptoAesKeyAlgorithmParams* WebCryptoKeyAlgorithm::AesParams() const { |
137 ASSERT(!IsNull()); | 137 DCHECK(!IsNull()); |
138 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeAes) | 138 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeAes) |
139 return static_cast<WebCryptoAesKeyAlgorithmParams*>(private_->params.get()); | 139 return static_cast<WebCryptoAesKeyAlgorithmParams*>(private_->params.get()); |
140 return 0; | 140 return 0; |
141 } | 141 } |
142 | 142 |
143 WebCryptoHmacKeyAlgorithmParams* WebCryptoKeyAlgorithm::HmacParams() const { | 143 WebCryptoHmacKeyAlgorithmParams* WebCryptoKeyAlgorithm::HmacParams() const { |
144 ASSERT(!IsNull()); | 144 DCHECK(!IsNull()); |
145 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeHmac) | 145 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeHmac) |
146 return static_cast<WebCryptoHmacKeyAlgorithmParams*>( | 146 return static_cast<WebCryptoHmacKeyAlgorithmParams*>( |
147 private_->params.get()); | 147 private_->params.get()); |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 | 150 |
151 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::RsaHashedParams() | 151 WebCryptoRsaHashedKeyAlgorithmParams* WebCryptoKeyAlgorithm::RsaHashedParams() |
152 const { | 152 const { |
153 ASSERT(!IsNull()); | 153 DCHECK(!IsNull()); |
154 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeRsaHashed) | 154 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeRsaHashed) |
155 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>( | 155 return static_cast<WebCryptoRsaHashedKeyAlgorithmParams*>( |
156 private_->params.get()); | 156 private_->params.get()); |
157 return 0; | 157 return 0; |
158 } | 158 } |
159 | 159 |
160 WebCryptoEcKeyAlgorithmParams* WebCryptoKeyAlgorithm::EcParams() const { | 160 WebCryptoEcKeyAlgorithmParams* WebCryptoKeyAlgorithm::EcParams() const { |
161 ASSERT(!IsNull()); | 161 DCHECK(!IsNull()); |
162 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeEc) | 162 if (ParamsType() == kWebCryptoKeyAlgorithmParamsTypeEc) |
163 return static_cast<WebCryptoEcKeyAlgorithmParams*>(private_->params.get()); | 163 return static_cast<WebCryptoEcKeyAlgorithmParams*>(private_->params.get()); |
164 return 0; | 164 return 0; |
165 } | 165 } |
166 | 166 |
167 void WebCryptoKeyAlgorithm::WriteToDictionary( | 167 void WebCryptoKeyAlgorithm::WriteToDictionary( |
168 WebCryptoKeyAlgorithmDictionary* dict) const { | 168 WebCryptoKeyAlgorithmDictionary* dict) const { |
169 ASSERT(!IsNull()); | 169 DCHECK(!IsNull()); |
170 dict->SetString("name", WebCryptoAlgorithm::LookupAlgorithmInfo(Id())->name); | 170 dict->SetString("name", WebCryptoAlgorithm::LookupAlgorithmInfo(Id())->name); |
171 if (private_->params.get()) | 171 if (private_->params.get()) |
172 private_->params.get()->WriteToDictionary(dict); | 172 private_->params.get()->WriteToDictionary(dict); |
173 } | 173 } |
174 | 174 |
175 void WebCryptoKeyAlgorithm::Assign(const WebCryptoKeyAlgorithm& other) { | 175 void WebCryptoKeyAlgorithm::Assign(const WebCryptoKeyAlgorithm& other) { |
176 private_ = other.private_; | 176 private_ = other.private_; |
177 } | 177 } |
178 | 178 |
179 void WebCryptoKeyAlgorithm::Reset() { | 179 void WebCryptoKeyAlgorithm::Reset() { |
180 private_.Reset(); | 180 private_.Reset(); |
181 } | 181 } |
182 | 182 |
183 } // namespace blink | 183 } // namespace blink |
OLD | NEW |