Blame SOURCES/rfc8251.txt

3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Internet Engineering Task Force (IETF)                         JM. Valin
3e7c87
Request for Comments: 8251                           Mozilla Corporation
3e7c87
Updates: 6716                                                     K. Vos
3e7c87
Category: Standards Track                                        vocTone
3e7c87
ISSN: 2070-1721                                             October 2017
3e7c87
3e7c87
3e7c87
                    Updates to the Opus Audio Codec
3e7c87
3e7c87
Abstract
3e7c87
3e7c87
   This document addresses minor issues that were found in the
3e7c87
   specification of the Opus audio codec in RFC 6716.  It updates the
3e7c87
   normative decoder implementation included in Appendix A of RFC 6716.
3e7c87
   The changes fix real and potential security-related issues, as well
3e7c87
   as minor quality-related issues.
3e7c87
3e7c87
Status of This Memo
3e7c87
3e7c87
   This is an Internet Standards Track document.
3e7c87
3e7c87
   This document is a product of the Internet Engineering Task Force
3e7c87
   (IETF).  It represents the consensus of the IETF community.  It has
3e7c87
   received public review and has been approved for publication by the
3e7c87
   Internet Engineering Steering Group (IESG).  Further information on
3e7c87
   Internet Standards is available in Section 2 of RFC 7841.
3e7c87
3e7c87
   Information about the current status of this document, any errata,
3e7c87
   and how to provide feedback on it may be obtained at
3e7c87
   https://www.rfc-editor.org/info/rfc8251.
3e7c87
3e7c87
Copyright Notice
3e7c87
3e7c87
   Copyright (c) 2017 IETF Trust and the persons identified as the
3e7c87
   document authors.  All rights reserved.
3e7c87
3e7c87
   This document is subject to BCP 78 and the IETF Trust's Legal
3e7c87
   Provisions Relating to IETF Documents
3e7c87
   (https://trustee.ietf.org/license-info) in effect on the date of
3e7c87
   publication of this document.  Please review these documents
3e7c87
   carefully, as they describe your rights and restrictions with respect
3e7c87
   to this document.  Code Components extracted from this document must
3e7c87
   include Simplified BSD License text as described in Section 4.e of
3e7c87
   the Trust Legal Provisions and are provided without warranty as
3e7c87
   described in the Simplified BSD License.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 1]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
Table of Contents
3e7c87
3e7c87
   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
3e7c87
   2.  Terminology . . . . . . . . . . . . . . . . . . . . . . . . .   3
3e7c87
   3.  Stereo State Reset in SILK  . . . . . . . . . . . . . . . . .   3
3e7c87
   4.  Parsing of the Opus Packet Padding  . . . . . . . . . . . . .   4
3e7c87
   5.  Resampler Buffer  . . . . . . . . . . . . . . . . . . . . . .   4
3e7c87
   6.  Integer Wrap-Around in Inverse Gain Computation . . . . . . .   6
3e7c87
   7.  Integer Wrap-Around in LSF Decoding . . . . . . . . . . . . .   7
3e7c87
   8.  Cap on Band Energy  . . . . . . . . . . . . . . . . . . . . .   7
3e7c87
   9.  Hybrid Folding  . . . . . . . . . . . . . . . . . . . . . . .   8
3e7c87
   10. Downmix to Mono . . . . . . . . . . . . . . . . . . . . . . .   9
3e7c87
   11. New Test Vectors  . . . . . . . . . . . . . . . . . . . . . .   9
3e7c87
   12. Security Considerations . . . . . . . . . . . . . . . . . . .  11
3e7c87
   13. IANA Considerations . . . . . . . . . . . . . . . . . . . . .  11
3e7c87
   14. Normative References  . . . . . . . . . . . . . . . . . . . .  11
3e7c87
   Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . .  11
3e7c87
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  12
3e7c87
3e7c87
1.  Introduction
3e7c87
3e7c87
   This document addresses minor issues that were discovered in the
3e7c87
   reference implementation of the Opus codec.  Unlike most IETF
3e7c87
   specifications, RFC 6716 [RFC6716] defines Opus in terms of a
3e7c87
   normative reference decoder implementation rather than from the
3e7c87
   associated text description.  Appendix A of that RFC includes the
3e7c87
   reference decoder implementation, which is why only issues affecting
3e7c87
   the decoder are listed here.  An up-to-date implementation of the
3e7c87
   Opus encoder can be found at <https://opus-codec.org/>.
3e7c87
3e7c87
   Some of the changes in this document update normative behavior in a
3e7c87
   way that requires new test vectors.  Only the C implementation is
3e7c87
   affected, not the English text of the specification.  This
3e7c87
   specification remains fully compatible with RFC 6716 [RFC6716].
3e7c87
3e7c87
   Note: Due to RFC formatting conventions, lines exceeding the column
3e7c87
   width in the patch are split using a backslash character.  The
3e7c87
   backslashes at the end of a line and the white space at the beginning
3e7c87
   of the following line are not part of the patch.  Referenced line
3e7c87
   numbers are approximations.  A properly formatted patch including all
3e7c87
   changes is available at 
3e7c87
   materials-98-codec-opus-update-00.patch> and has a SHA-1 hash of
3e7c87
   029e3aa88fc342c91e67a21e7bfbc9458661cd5f.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 2]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
2.  Terminology
3e7c87
3e7c87
   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
3e7c87
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
3e7c87
   "OPTIONAL" in this document are to be interpreted as described in
3e7c87
   BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
3e7c87
   capitals, as shown here.
3e7c87
3e7c87
3.  Stereo State Reset in SILK
3e7c87
3e7c87
   The reference implementation does not reinitialize the stereo state
3e7c87
   during a mode switch.  The old stereo memory can produce a brief
3e7c87
   impulse (i.e., single sample) in the decoded audio.  This can be
3e7c87
   fixed by changing silk/dec_API.c around line 72:
3e7c87
3e7c87
   
3e7c87
        for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
3e7c87
            ret  = silk_init_decoder( &channel_state[ n ] );
3e7c87
        }
3e7c87
   +    silk_memset(&((silk_decoder *)decState)->sStereo, 0,
3e7c87
   +                sizeof(((silk_decoder *)decState)->sStereo));
3e7c87
   +    /* Not strictly needed, but it's cleaner that way */
3e7c87
   +    ((silk_decoder *)decState)->prev_decode_only_middle = 0;
3e7c87
3e7c87
        return ret;
3e7c87
    }
3e7c87
   
3e7c87
3e7c87
   This change affects the normative output of the decoder, but the
3e7c87
   amount of change is within the tolerance and is too small to make the
3e7c87
   test vector check fail.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 3]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
4.  Parsing of the Opus Packet Padding
3e7c87
3e7c87
   It was discovered that some invalid packets of a very large size
3e7c87
   could trigger an out-of-bounds read in the Opus packet parsing code
3e7c87
   responsible for padding.  This is due to an integer overflow if the
3e7c87
   signaled padding exceeds 2^31-1 bytes (the actual packet may be
3e7c87
   smaller).  The code can be fixed by decrementing the (signed) len
3e7c87
   value, instead of incrementing a separate padding counter.  This is
3e7c87
   done by applying the following changes around line 596 of
3e7c87
   src/opus_decoder.c:
3e7c87
3e7c87
   
3e7c87
          /* Padding flag is bit 6 */
3e7c87
          if (ch&0x40)
3e7c87
          {
3e7c87
   -         int padding=0;
3e7c87
             int p;
3e7c87
             do {
3e7c87
                if (len<=0)
3e7c87
                   return OPUS_INVALID_PACKET;
3e7c87
                p = *data++;
3e7c87
                len--;
3e7c87
   -            padding += p==255 ? 254: p;
3e7c87
   +            len -= p==255 ? 254: p;
3e7c87
             } while (p==255);
3e7c87
   -         len -= padding;
3e7c87
          }
3e7c87
   
3e7c87
3e7c87
   This packet-parsing issue is limited to reading memory up to about 60
3e7c87
   KB beyond the compressed buffer.  This can only be triggered by a
3e7c87
   compressed packet more than about 16 MB long, so it's not a problem
3e7c87
   for RTP.  In theory, it could crash a file decoder (e.g., Opus in
3e7c87
   Ogg) if the memory just after the incoming packet is out of range,
3e7c87
   but our attempts to trigger such a crash in a production application
3e7c87
   built using an affected version of the Opus decoder failed.
3e7c87
3e7c87
5.  Resampler Buffer
3e7c87
3e7c87
   The SILK resampler had the following issues:
3e7c87
3e7c87
   1.  The calls to memcpy() were using sizeof(opus_int32), but the type
3e7c87
       of the local buffer was opus_int16.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 4]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
   2.  Because the size was wrong, this potentially allowed the source
3e7c87
       and destination regions of the memcpy() to overlap on the copy
3e7c87
       from "buf" to "buf".  We believe that nSamplesIn (number of input
3e7c87
       samples) is at least fs_in_khZ (sampling rate in kHz), which is
3e7c87
       at least 8.  Since RESAMPLER_ORDER_FIR_12 is only 8, that should
3e7c87
       not be a problem once the type size is fixed.
3e7c87
3e7c87
   3.  The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the
3e7c87
       data stored in it was actually twice the input batch size
3e7c87
       (nSamplesIn<<1).
3e7c87
3e7c87
   The code can be fixed by applying the following changes around line
3e7c87
   78 of silk/resampler_private_IIR_FIR.c:
3e7c87
3e7c87
   
3e7c87
3e7c87
    )
3e7c87
    {
3e7c87
        silk_resampler_state_struct *S = \
3e7c87
   (silk_resampler_state_struct *)SS;
3e7c87
        opus_int32 nSamplesIn;
3e7c87
        opus_int32 max_index_Q16, index_increment_Q16;
3e7c87
   -    opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + \
3e7c87
   RESAMPLER_ORDER_FIR_12 ];
3e7c87
   +    opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + \
3e7c87
   RESAMPLER_ORDER_FIR_12 ];
3e7c87
3e7c87
        /* Copy buffered samples to start of buffer */
3e7c87
   -    silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \
3e7c87
   * sizeof( opus_int32 ) );
3e7c87
   +    silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \
3e7c87
   * sizeof( opus_int16 ) );
3e7c87
3e7c87
        /* Iterate over blocks of frameSizeIn input samples */
3e7c87
        index_increment_Q16 = S->invRatio_Q16;
3e7c87
        while( 1 ) {
3e7c87
            nSamplesIn = silk_min( inLen, S->batchSize );
3e7c87
3e7c87
            /* Upsample 2x */
3e7c87
            silk_resampler_private_up2_HQ( S->sIIR, &buf[ \
3e7c87
   RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn );
3e7c87
3e7c87
            max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 \
3e7c87
   );         /* + 1 because 2x upsampling */
3e7c87
            out = silk_resampler_private_IIR_FIR_INTERPOL( out, \
3e7c87
   buf, max_index_Q16, index_increment_Q16 );
3e7c87
            in += nSamplesIn;
3e7c87
            inLen -= nSamplesIn;
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 5]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
            if( inLen > 0 ) {
3e7c87
                /* More iterations to do; copy last part of \
3e7c87
   filtered signal to beginning of buffer */
3e7c87
   -            silk_memcpy( buf, &buf[ nSamplesIn << 1 ], \
3e7c87
   RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) );
3e7c87
   +            silk_memmove( buf, &buf[ nSamplesIn << 1 ], \
3e7c87
   RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
3e7c87
            } else {
3e7c87
                break;
3e7c87
            }
3e7c87
        }
3e7c87
3e7c87
        /* Copy last part of filtered signal to the state for \
3e7c87
   the next call */
3e7c87
   -    silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \
3e7c87
   RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) );
3e7c87
   +    silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \
3e7c87
   RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
3e7c87
    }
3e7c87
   
3e7c87
3e7c87
6.  Integer Wrap-Around in Inverse Gain Computation
3e7c87
3e7c87
   It was discovered through decoder fuzzing that some bitstreams could
3e7c87
   produce integer values exceeding 32 bits in
3e7c87
   LPC_inverse_pred_gain_QA(), causing a wrap-around.  The C standard
3e7c87
   considers this behavior as undefined.  The following patch around
3e7c87
   line 87 of silk/LPC_inv_pred_gain.c detects values that do not fit in
3e7c87
   a 32-bit integer and considers the corresponding filters unstable:
3e7c87
3e7c87
  
3e7c87
           /* Update AR coefficient */
3e7c87
           for( n = 0; n < k; n++ ) {
3e7c87
  -            tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( \
3e7c87
  Aold_QA[ k - n - 1 ], rc_Q31, 31 );
3e7c87
  -            Anew_QA[ n ] = MUL32_FRAC_Q( tmp_QA, rc_mult2 , mult2Q );
3e7c87
  +            opus_int64 tmp64;
3e7c87
  +            tmp_QA = silk_SUB_SAT32( Aold_QA[ n ], MUL32_FRAC_Q( \
3e7c87
  Aold_QA[ k - n - 1 ], rc_Q31, 31 ) );
3e7c87
  +            tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( tmp_QA, \
3e7c87
  rc_mult2 ), mult2Q);
3e7c87
  +            if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) {
3e7c87
  +               return 0;
3e7c87
  +            }
3e7c87
  +            Anew_QA[ n ] = ( opus_int32 )tmp64;
3e7c87
           }
3e7c87
  
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 6]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
7.  Integer Wrap-Around in LSF Decoding
3e7c87
3e7c87
   It was discovered -- also from decoder fuzzing -- that an integer
3e7c87
   wrap-around could occur when decoding bitstreams with extremely large
3e7c87
   values for the high Line Spectral Frequency (LSF) parameters.  The
3e7c87
   end result of the wrap-around is an illegal read access on the stack,
3e7c87
   which the authors do not believe is exploitable but should
3e7c87
   nonetheless be fixed.  The following patch around line 137 of silk/
3e7c87
   NLSF_stabilize.c prevents the problem:
3e7c87
3e7c87
   
3e7c87
              /* Keep delta_min distance between the NLSFs */
3e7c87
            for( i = 1; i < L; i++ )
3e7c87
   -            NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
3e7c87
   NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
3e7c87
   +            NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
3e7c87
   silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
3e7c87
3e7c87
            /* Last NLSF should be no higher than 1 - NDeltaMin[L] */
3e7c87
   
3e7c87
3e7c87
8.  Cap on Band Energy
3e7c87
3e7c87
   On extreme bitstreams, it is possible for log-domain band energy
3e7c87
   levels to exceed the maximum single-precision floating point value
3e7c87
   once converted to a linear scale.  This would later cause the decoded
3e7c87
   values to be NaN (not a number), possibly causing problems in the
3e7c87
   software using the PCM values.  This can be avoided with the
3e7c87
   following patch around line 552 of celt/quant_bands.c:
3e7c87
3e7c87
   
3e7c87
          {
3e7c87
             opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
3e7c87
                             SHL16((opus_val16)eMeans[i],6));
3e7c87
   +         lg = MIN32(QCONST32(32.f, 16), lg);
3e7c87
             eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
3e7c87
          }
3e7c87
          for (;i<m->nbEBands;i++)
3e7c87
   
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 7]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
9.  Hybrid Folding
3e7c87
3e7c87
   When encoding in hybrid mode at low bitrate, we sometimes only have
3e7c87
   enough bits to code a single Constrained-Energy Lapped Transform
3e7c87
   (CELT) band (8 - 9.6 kHz).  When that happens, the second band (CELT
3e7c87
   band 18, from 9.6 - 12 kHz) cannot use folding because it is wider
3e7c87
   than the amount already coded and falls back to white noise.  Because
3e7c87
   it can also happen on transients (e.g., stops), it can cause audible
3e7c87
   pre-echo.
3e7c87
3e7c87
   To address the issue, we change the folding behavior so that it is
3e7c87
   never forced to fall back to Linear Congruential Generator (LCG) due
3e7c87
   to the first band not containing enough coefficients to fold onto the
3e7c87
   second band.  This is achieved by simply repeating part of the first
3e7c87
   band in the folding of the second band.  This changes the code in
3e7c87
   celt/bands.c around line 1237:
3e7c87
3e7c87
  
3e7c87
            b = 0;
3e7c87
         }
3e7c87
3e7c87
  -      if (resynth && M*eBands[i]-N >= M*eBands[start] && \
3e7c87
  (update_lowband || lowband_offset==0))
3e7c87
  +      if (resynth && (M*eBands[i]-N >= M*eBands[start] || \
3e7c87
  i==start+1) && (update_lowband || lowband_offset==0))
3e7c87
               lowband_offset = i;
3e7c87
3e7c87
  +      if (i == start+1)
3e7c87
  +      {
3e7c87
  +         int n1, n2;
3e7c87
  +         int offset;
3e7c87
  +         n1 = M*(eBands[start+1]-eBands[start]);
3e7c87
  +         n2 = M*(eBands[start+2]-eBands[start+1]);
3e7c87
  +         offset = M*eBands[start];
3e7c87
  +         /* Duplicate enough of the first band folding data to \
3e7c87
  be able to fold the second band.
3e7c87
  +            Copies no data for CELT-only mode. */
3e7c87
  +         OPUS_COPY(&norm[offset+n1], &norm[offset+2*n1 - n2], n2-n1);
3e7c87
  +         if (C==2)
3e7c87
  +            OPUS_COPY(&norm2[offset+n1], &norm2[offset+2*n1 - n2], \
3e7c87
  n2-n1);
3e7c87
  +      }
3e7c87
  +
3e7c87
         tf_change = tf_res[i];
3e7c87
         if (i>=m->effEBands)
3e7c87
         {
3e7c87
  
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 8]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
   as well as around line 1260:
3e7c87
3e7c87
   
3e7c87
             fold_start = lowband_offset;
3e7c87
             while(M*eBands[--fold_start] > effective_lowband);
3e7c87
             fold_end = lowband_offset-1;
3e7c87
   -         while(M*eBands[++fold_end] < effective_lowband+N);
3e7c87
   +         while(++fold_end < i && M*eBands[fold_end] < \
3e7c87
   effective_lowband+N);
3e7c87
             x_cm = y_cm = 0;
3e7c87
             fold_i = fold_start; do {
3e7c87
               x_cm |= collapse_masks[fold_i*C+0];
3e7c87
3e7c87
   
3e7c87
3e7c87
   The fix does not impact compatibility, because the improvement does
3e7c87
   not depend on the encoder doing anything special.  There is also no
3e7c87
   reasonable way for an encoder to use the original behavior to improve
3e7c87
   quality over the proposed change.
3e7c87
3e7c87
10.  Downmix to Mono
3e7c87
3e7c87
   The last issue is not strictly a bug, but it is an issue that has
3e7c87
   been reported when downmixing an Opus decoded stream to mono, whether
3e7c87
   this is done inside the decoder or as a post-processing step on the
3e7c87
   stereo decoder output.  Opus intensity stereo allows optionally
3e7c87
   coding the two channels 180 degrees out of phase on a per-band basis.
3e7c87
   This provides better stereo quality than forcing the two channels to
3e7c87
   be in phase, but when the output is downmixed to mono, the energy in
3e7c87
   the affected bands is canceled, sometimes resulting in audible
3e7c87
   artifacts.
3e7c87
3e7c87
   As a work-around for this issue, the decoder MAY choose not to apply
3e7c87
   the 180-degree phase shift.  This can be useful when downmixing to
3e7c87
   mono inside or outside of the decoder (e.g., requested explicitly
3e7c87
   from an API).
3e7c87
3e7c87
11.  New Test Vectors
3e7c87
3e7c87
   Changes in Sections 9 and 10 have sufficient impact on the test
3e7c87
   vectors to make them fail.  For this reason, this document also
3e7c87
   updates the Opus test vectors.  The new test vectors now include two
3e7c87
   decoded outputs for the same bitstream.  The outputs with suffix 'm'
3e7c87
   do not apply the CELT 180-degree phase shift as allowed in
3e7c87
   Section 10, while the outputs without the suffix do.  An
3e7c87
   implementation is compliant as long as it passes either set of
3e7c87
   vectors.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                    [Page 9]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
   Any Opus implementation that passes either the original test vectors
3e7c87
   from RFC 6716 [RFC6716] or one of the new sets of test vectors is
3e7c87
   compliant with the Opus specification.  However, newer
3e7c87
   implementations SHOULD be based on the new test vectors rather than
3e7c87
   the old ones.
3e7c87
3e7c87
   The new test vectors are located at
3e7c87
   
3e7c87
   newvectors-00.tar.gz>.  The SHA-1 hashes of the test vectors are:
3e7c87
3e7c87
   e49b2862ceec7324790ed8019eb9744596d5be01  testvector01.bit
3e7c87
   b809795ae1bcd606049d76de4ad24236257135e0  testvector02.bit
3e7c87
   e0c4ecaeab44d35a2f5b6575cd996848e5ee2acc  testvector03.bit
3e7c87
   a0f870cbe14ebb71fa9066ef3ee96e59c9a75187  testvector04.bit
3e7c87
   9b3d92b48b965dfe9edf7b8a85edd4309f8cf7c8  testvector05.bit
3e7c87
   28e66769ab17e17f72875283c14b19690cbc4e57  testvector06.bit
3e7c87
   bacf467be3215fc7ec288f29e2477de1192947a6  testvector07.bit
3e7c87
   ddbe08b688bbf934071f3893cd0030ce48dba12f  testvector08.bit
3e7c87
   3932d9d61944dab1201645b8eeaad595d5705ecb  testvector09.bit
3e7c87
   521eb2a1e0cc9c31b8b740673307c2d3b10c1900  testvector10.bit
3e7c87
   6bc8f3146fcb96450c901b16c3d464ccdf4d5d96  testvector11.bit
3e7c87
   338c3f1b4b97226bc60bc41038becbc6de06b28f  testvector12.bit
3e7c87
   f5ef93884da6a814d311027918e9afc6f2e5c2c8  testvector01.dec
3e7c87
   48ac1ff1995250a756e1e17bd32acefa8cd2b820  testvector02.dec
3e7c87
   d15567e919db2d0e818727092c0af8dd9df23c95  testvector03.dec
3e7c87
   1249dd28f5bd1e39a66fd6d99449dca7a8316342  testvector04.dec
3e7c87
   b85675d81deef84a112c466cdff3b7aaa1d2fc76  testvector05.dec
3e7c87
   55f0b191e90bfa6f98b50d01a64b44255cb4813e  testvector06.dec
3e7c87
   61e8b357ab090b1801eeb578a28a6ae935e25b7b  testvector07.dec
3e7c87
   a58539ee5321453b2ddf4c0f2500e856b3966862  testvector08.dec
3e7c87
   bb96aad2cde188555862b7bbb3af6133851ef8f4  testvector09.dec
3e7c87
   1b6cdf0413ac9965b16184b1bea129b5c0b2a37a  testvector10.dec
3e7c87
   b1fff72b74666e3027801b29dbc48b31f80dee0d  testvector11.dec
3e7c87
   98e09bbafed329e341c3b4052e9c4ba5fc83f9b1  testvector12.dec
3e7c87
   1e7d984ea3fbb16ba998aea761f4893fbdb30157  testvector01m.dec
3e7c87
   48ac1ff1995250a756e1e17bd32acefa8cd2b820  testvector02m.dec
3e7c87
   d15567e919db2d0e818727092c0af8dd9df23c95  testvector03m.dec
3e7c87
   1249dd28f5bd1e39a66fd6d99449dca7a8316342  testvector04m.dec
3e7c87
   d70b0bad431e7d463bc3da49bd2d49f1c6d0a530  testvector05m.dec
3e7c87
   6ac1648c3174c95fada565161a6c78bdbe59c77d  testvector06m.dec
3e7c87
   fc5e2f709693738324fb4c8bdc0dad6dda04e713  testvector07m.dec
3e7c87
   aad2ba397bf1b6a18e8e09b50e4b19627d479f00  testvector08m.dec
3e7c87
   6feb7a7b9d7cdc1383baf8d5739e2a514bd0ba08  testvector09m.dec
3e7c87
   1b6cdf0413ac9965b16184b1bea129b5c0b2a37a  testvector10m.dec
3e7c87
   fd3d3a7b0dfbdab98d37ed9aa04b659b9fefbd18  testvector11m.dec
3e7c87
   98e09bbafed329e341c3b4052e9c4ba5fc83f9b1  testvector12m.dec
3e7c87
3e7c87
   Note that the decoder input bitstream files (.bit) are unchanged.
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                   [Page 10]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
12.  Security Considerations
3e7c87
3e7c87
   This document fixes two security issues reported on Opus that affect
3e7c87
   the reference implementation in RFC 6716 [RFC6716]: CVE-2013-0899
3e7c87
   <https://nvd.nist.gov/vuln/detail/CVE-2013-0899> and CVE-2017-0381
3e7c87
   <https://nvd.nist.gov/vuln/detail/CVE-2017-0381>.  CVE-2013-0899
3e7c87
   theoretically could have caused an information leak.  The leaked
3e7c87
   information would have gone through the decoder process before being
3e7c87
   accessible to the attacker.  The update in Section 4 fixes this.
3e7c87
   CVE-2017-0381 could have resulted in a 16-bit out-of-bounds read from
3e7c87
   a fixed location.  The update in Section 7 fixes this.  Beyond the
3e7c87
   two fixed Common Vulnerabilities and Exposures (CVEs), this document
3e7c87
   adds no new security considerations beyond those in RFC 6716
3e7c87
   [RFC6716].
3e7c87
3e7c87
13.  IANA Considerations
3e7c87
3e7c87
   This document does not require any IANA actions.
3e7c87
3e7c87
14.  Normative References
3e7c87
3e7c87
   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
3e7c87
              Requirement Levels", BCP 14, RFC 2119,
3e7c87
              DOI 10.17487/RFC2119, March 1997,
3e7c87
              <https://www.rfc-editor.org/info/rfc2119>.
3e7c87
3e7c87
   [RFC6716]  Valin, JM., Vos, K., and T. Terriberry, "Definition of the
3e7c87
              Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716,
3e7c87
              September 2012, <https://www.rfc-editor.org/info/rfc6716>.
3e7c87
3e7c87
   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
3e7c87
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
3e7c87
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.
3e7c87
3e7c87
Acknowledgements
3e7c87
3e7c87
   We would like to thank Juri Aedla for reporting the issue with the
3e7c87
   parsing of the Opus padding.  Thanks to Felicia Lim for reporting the
3e7c87
   LSF integer overflow issue.  Also, thanks to Tina le Grand, Jonathan
3e7c87
   Lennox, and Mark Harris for their feedback on this document.
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                   [Page 11]
3e7c87

3e7c87
RFC 8251                       Opus Update                  October 2017
3e7c87
3e7c87
3e7c87
Authors' Addresses
3e7c87
3e7c87
   Jean-Marc Valin
3e7c87
   Mozilla Corporation
3e7c87
   331 E. Evelyn Avenue
3e7c87
   Mountain View, CA  94041
3e7c87
   United States of America
3e7c87
3e7c87
   Phone: +1 650 903-0800
3e7c87
   Email: jmvalin@jmvalin.ca
3e7c87
3e7c87
3e7c87
   Koen Vos
3e7c87
   vocTone
3e7c87
3e7c87
   Email: koenvos74@gmail.com
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
3e7c87
Valin & Vos                  Standards Track                   [Page 12]
3e7c87