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