File tree 2 files changed +48
-34
lines changed
2 files changed +48
-34
lines changed Original file line number Diff line number Diff line change @@ -215,24 +215,31 @@ class CipherJob final : public CryptoJob<CipherTraits> {
215
215
WebCryptoCipherMode cipher_mode () const { return cipher_mode_; }
216
216
217
217
void DoThreadPoolWork () override {
218
- switch (CipherTraits::DoCipher (
219
- AsyncWrap::env (),
220
- key (),
221
- cipher_mode_,
222
- *CryptoJob<CipherTraits>::params (),
223
- in_,
224
- &out_)) {
225
- case WebCryptoCipherStatus::OK:
226
- // Success!
227
- break ;
228
- case WebCryptoCipherStatus::INVALID_KEY_TYPE:
229
- // Fall through
230
- // TODO(@jasnell): Separate error for this
231
- case WebCryptoCipherStatus::FAILED: {
232
- CryptoErrorVector* errors = CryptoJob<CipherTraits>::errors ();
233
- errors->Capture ();
234
- if (errors->empty ())
235
- errors->push_back (std::string (" Cipher job failed." ));
218
+ const WebCryptoCipherStatus status =
219
+ CipherTraits::DoCipher (
220
+ AsyncWrap::env (),
221
+ key (),
222
+ cipher_mode_,
223
+ *CryptoJob<CipherTraits>::params (),
224
+ in_,
225
+ &out_);
226
+ if (status == WebCryptoCipherStatus::OK) {
227
+ // Success!
228
+ return ;
229
+ }
230
+ CryptoErrorVector* errors = CryptoJob<CipherTraits>::errors ();
231
+ errors->Capture ();
232
+ if (errors->empty ()) {
233
+ switch (status) {
234
+ case WebCryptoCipherStatus::OK:
235
+ UNREACHABLE ();
236
+ break ;
237
+ case WebCryptoCipherStatus::INVALID_KEY_TYPE:
238
+ errors->emplace_back (" Invalid key type." );
239
+ break ;
240
+ case WebCryptoCipherStatus::FAILED:
241
+ errors->emplace_back (" Cipher job failed." );
242
+ break ;
236
243
}
237
244
}
238
245
}
Original file line number Diff line number Diff line change @@ -337,22 +337,29 @@ class KeyExportJob final : public CryptoJob<KeyExportTraits> {
337
337
WebCryptoKeyFormat format () const { return format_; }
338
338
339
339
void DoThreadPoolWork () override {
340
- switch (KeyExportTraits::DoExport (
341
- key_,
342
- format_,
343
- *CryptoJob<KeyExportTraits>::params (),
344
- &out_)) {
345
- case WebCryptoKeyExportStatus::OK:
346
- // Success!
347
- break ;
348
- case WebCryptoKeyExportStatus::INVALID_KEY_TYPE:
349
- // Fall through
350
- // TODO(@jasnell): Separate error for this
351
- case WebCryptoKeyExportStatus::FAILED: {
352
- CryptoErrorVector* errors = CryptoJob<KeyExportTraits>::errors ();
353
- errors->Capture ();
354
- if (errors->empty ())
355
- errors->push_back (" Key export failed." );
340
+ const WebCryptoKeyExportStatus status =
341
+ KeyExportTraits::DoExport (
342
+ key_,
343
+ format_,
344
+ *CryptoJob<KeyExportTraits>::params (),
345
+ &out_);
346
+ if (status == WebCryptoKeyExportStatus::OK) {
347
+ // Success!
348
+ return ;
349
+ }
350
+ CryptoErrorVector* errors = CryptoJob<KeyExportTraits>::errors ();
351
+ errors->Capture ();
352
+ if (errors->empty ()) {
353
+ switch (status) {
354
+ case WebCryptoKeyExportStatus::OK:
355
+ UNREACHABLE ();
356
+ break ;
357
+ case WebCryptoKeyExportStatus::INVALID_KEY_TYPE:
358
+ errors->emplace_back (" Invalid key type." );
359
+ break ;
360
+ case WebCryptoKeyExportStatus::FAILED:
361
+ errors->emplace_back (" Cipher job failed." );
362
+ break ;
356
363
}
357
364
}
358
365
}
You can’t perform that action at this time.
0 commit comments