Closed Bug 1025318 Opened 10 years ago Closed 10 years ago

AesCbcParams should enforce a 16 byte IV length

Categories

(Core :: Security, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: ttaubert, Assigned: ttaubert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

dictionary AesCbcParams : Algorithm {
  // The initialization vector. MUST be 16 bytes.
  CryptoOperationData iv;
};

The length of 16 bytes for "iv" is currently unchecked.
Added tests for AES-CTR as well while I was at it.
Assignee: nobody → ttaubert
Status: NEW → ASSIGNED
Attachment #8440139 - Flags: review?(rlb)
Comment on attachment 8440139 [details] [diff] [review]
0002-Bug-1025318-AesCbcParams-should-enforce-a-16-byte-IV.patch

Review of attachment 8440139 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/crypto/WebCryptoTask.cpp
@@ +265,5 @@
>          return;
>        }
>  
>        ATTEMPT_BUFFER_INIT(mIv, params.mIv.Value())
> +      if (mIv.Length() != 16) {

It would be marginally more efficient to do this check before assigning to mIv.  That is, to check params.mIv.Value().Length().  That way you avoid the copy if you're not going to do anything with it.
Attachment #8440139 - Flags: review?(rlb) → review+
(In reply to Richard Barnes [:rbarnes] from comment #2)
> >        ATTEMPT_BUFFER_INIT(mIv, params.mIv.Value())
> > +      if (mIv.Length() != 16) {
> 
> It would be marginally more efficient to do this check before assigning to
> mIv.  That is, to check params.mIv.Value().Length().  That way you avoid the
> copy if you're not going to do anything with it.

I'll leave this as is as discussed over IRC because we'd have to call GetAsArrayBufferView() or GetAsArrayBuffer() to access the length.
https://hg.mozilla.org/mozilla-central/rev/bcea87ef8d6c
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: