OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 10 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // * |key| is non-null. | 176 // * |key| is non-null. |
177 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer); | 177 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer); |
178 | 178 |
179 // Preconditions: | 179 // Preconditions: |
180 // * |wrapping_key| is non-null | 180 // * |wrapping_key| is non-null |
181 // * |key| is non-null | 181 // * |key| is non-null |
182 Status WrapSymKeyAesKw(SymKey* wrapping_key, | 182 Status WrapSymKeyAesKw(SymKey* wrapping_key, |
183 SymKey* key, | 183 SymKey* key, |
184 blink::WebArrayBuffer* buffer); | 184 blink::WebArrayBuffer* buffer); |
185 | 185 |
| 186 // Unwraps (decrypts) |wrapped_key_data| using AES-KW and places the results in |
| 187 // a WebCryptoKey. Raw key data remains inside NSS. This function should be used |
| 188 // when the input |wrapped_key_data| is known to result in symmetric raw key |
| 189 // data after AES-KW decryption. |
186 // Preconditions: | 190 // Preconditions: |
187 // * |wrapping_key| is non-null | 191 // * |wrapping_key| is non-null |
188 // * |key| is non-null | 192 // * |key| is non-null |
189 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes | 193 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes |
190 // * |algorithm.id()| is for a symmetric key algorithm. | 194 // * |algorithm.id()| is for a symmetric key algorithm. |
191 Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data, | 195 Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data, |
192 SymKey* wrapping_key, | 196 SymKey* wrapping_key, |
193 const blink::WebCryptoAlgorithm& algorithm, | 197 const blink::WebCryptoAlgorithm& algorithm, |
194 bool extractable, | 198 bool extractable, |
195 blink::WebCryptoKeyUsageMask usage_mask, | 199 blink::WebCryptoKeyUsageMask usage_mask, |
196 blink::WebCryptoKey* key); | 200 blink::WebCryptoKey* key); |
197 | 201 |
| 202 // Performs AES-KW decryption on the input |data|. This function should be used |
| 203 // when the input |data| does not directly represent a key and should instead be |
| 204 // interpreted as generic bytes. |
| 205 // Preconditions: |
| 206 // * |key| is non-null |
| 207 // * |data| is at least 24 bytes and a multiple of 8 bytes |
| 208 // * |buffer| is non-null. |
| 209 Status DecryptAesKw(SymKey* key, |
| 210 const CryptoData& data, |
| 211 blink::WebArrayBuffer* buffer); |
| 212 |
198 // Preconditions: | 213 // Preconditions: |
199 // * |wrapping_key| is non-null | 214 // * |wrapping_key| is non-null |
200 // * |key| is non-null | 215 // * |key| is non-null |
201 Status WrapSymKeyRsaEs(PublicKey* wrapping_key, | 216 Status WrapSymKeyRsaEs(PublicKey* wrapping_key, |
202 SymKey* key, | 217 SymKey* key, |
203 blink::WebArrayBuffer* buffer); | 218 blink::WebArrayBuffer* buffer); |
204 | 219 |
205 // Preconditions: | 220 // Preconditions: |
206 // * |wrapping_key| is non-null | 221 // * |wrapping_key| is non-null |
207 // * |key| is non-null | 222 // * |key| is non-null |
208 // * |algorithm.id()| is for a symmetric key algorithm. | 223 // * |algorithm.id()| is for a symmetric key algorithm. |
209 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, | 224 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, |
210 PrivateKey* wrapping_key, | 225 PrivateKey* wrapping_key, |
211 const blink::WebCryptoAlgorithm& algorithm, | 226 const blink::WebCryptoAlgorithm& algorithm, |
212 bool extractable, | 227 bool extractable, |
213 blink::WebCryptoKeyUsageMask usage_mask, | 228 blink::WebCryptoKeyUsageMask usage_mask, |
214 blink::WebCryptoKey* key); | 229 blink::WebCryptoKey* key); |
215 | 230 |
216 } // namespace platform | 231 } // namespace platform |
217 | 232 |
218 } // namespace webcrypto | 233 } // namespace webcrypto |
219 | 234 |
220 } // namespace content | 235 } // namespace content |
221 | 236 |
222 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ | 237 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ |
OLD | NEW |