<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25815</bug_id>
          
          <creation_ts>2014-05-19 20:33:03 +0000</creation_ts>
          <short_desc>Spec encourages unsafe handling of secret data for JWK import of RSA/ECC keys</short_desc>
          <delta_ts>2014-10-22 21:26:55 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Web Cryptography</product>
          <component>Web Cryptography API Document</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryan Sleevi">sleevi</reporter>
          <assigned_to name="Ryan Sleevi">sleevi</assigned_to>
          <cc>public-webcrypto</cc>
    
    <cc>virginie.galindo</cc>
    
    <cc>watsonm</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>106378</commentid>
    <comment_count>0</comment_count>
    <who name="Ryan Sleevi">sleevi</who>
    <bug_when>2014-05-19 20:33:03 +0000</bug_when>
    <thetext>The current spec is somewhat underspecified with respect to handling secret data for RSA and ECC keys, and one possible interpretation leads to the unsafe handling of secret data in a manner which may leak information via timing, or require UA-specific cryptographic primitives.

Specifically, language exists of the form

&quot;If jwk does not meet the requirements of Section X of JSON Web Algorithms, then return an error named DataError&quot;

However, this is underspecified for several reasons:
- In the RSA case, d may be specified, but may be inconsistent with n/e
- In the RSA case, d may be specified, but have inconsistent CRT parameters associated
- In the RSA case, d may be specified, but have inconsistent p/q
- In the ECC case, d may be specified, but be invalid according to the point

All of these cases encourage an error return of DataError, which implies a degree of checking on the client side, as &quot;implementation-deduced&quot; errors are typically assigned the error code OperationError.

The computation of consistency checks can leak timing information (and also requires the implementation of multi-precision integers), which are both things that are trying to be avoided in the requirements of UAs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106379</commentid>
    <comment_count>1</comment_count>
    <who name="Ryan Sleevi">sleevi</who>
    <bug_when>2014-05-19 20:38:11 +0000</bug_when>
    <thetext>On the Chromium side, we&apos;ve encountered a number of issues where the inconsistency between DataError and OperationError has been difficult to ascertain in a UA that defers cryptographic operations to another library (eg: NSS, OpenSSL).

Equally, the distinction between OperationError and DataError does not seem to be consistently applied.

For example, in the case of RSA, inconsistent message sizes result in OperationError, whereas in AES, they&apos;re DataError. In ECDH derivation, if an invalid public key is specified (eg: perhaps its parameters are hostile towards the private key / on an invalid point) it&apos;s an OperationError. AES-GCM Decryption Failure is an OperationError (even though it&apos;s the data that is invalid for the tag)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109198</commentid>
    <comment_count>2</comment_count>
    <who name="Ryan Sleevi">sleevi</who>
    <bug_when>2014-07-23 02:28:35 +0000</bug_when>
    <thetext>Another example: A number of language bindings that allow creating language/library-specific keys from primitives (e.g.: n,e,d for RSA) may not compute the other parameters (necessary for output). Further, if just n,e,d are specified, they can lead to unsafe handling of data. For example, in a number of Java JCE implementations, creating an RSA private key with JUST n,e,d will disable RSA blinding attacks, which exist to mitigating timing attacks against RSA.

On the flip side, several cryptographic libraries require that the caller supply all the parameters, as they&apos;re required by PKCS#8. Handling the JWK case would require the UA to perform the MPI math itself.

My proposed resolution for this is:
- Normalize on operation error for any form of weirdness
- Require that JWK RSA keys have all the parameters from JWA, which is valid according to JWA (from talking with Mike, it&apos;s assumed as the default)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111951</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-22 17:51:08 +0000</bug_when>
    <thetext>I agree with normalization to OperationError throughput the specification.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113092</commentid>
    <comment_count>4</comment_count>
    <who name="">virginie.galindo</who>
    <bug_when>2014-10-14 10:05:40 +0000</bug_when>
    <thetext>In order to progress towards exit to Last Call for the Web Crypto API, the
chair suggests the following resolution for that bug. 

Resolution : Bug CLOSED. Editors will implement the changes as described in https://www.w3.org/Bugs/Public/show_bug.cgi?id=25815#c2. 

If none objects before the 20th of Oct @20:00 UTC, this resolution will be
endorsed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113264</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-10-16 00:29:43 +0000</bug_when>
    <thetext>In fact, there is actually only one example where import / export returns OperationError other than for the &quot;underlying key material cannot be accessed&quot; on export.

This is for AES CMAC import where it does a check of the length of the data.

So, it may actually be more convenient - and still very reasonable - to normalize on DataError for import.

With this change and Bug 25741 the situation will be as follows:

- Encrypt/Decrypt/Sign/Verify operations all return OperationError for all parameter validation.
- Import operations will always return DataError for all parameter validation.

It remains to check Generate (which I think should normalize on OperationError) and Export (which doesn&apos;t encounter anything not easily detectable by the UA).

So, DataError for import ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113603</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-10-22 21:26:55 +0000</bug_when>
    <thetext>Import Key: Normalize on DataError. Only AES-CMAC needs changes:

https://dvcs.w3.org/hg/webcrypto-api/rev/4fcabd0b818a

Generate Key: Normalize on OperationError excepy usages validation which is SyntaxError:
- fix one instance where usages validation was specified twice (ECDH). The second was unreachable and invalid:

https://dvcs.w3.org/hg/webcrypto-api/rev/3d94cb8ef334

- fix one instance of parameter validation which was not returning OperationError (HMAC):

https://dvcs.w3.org/hg/webcrypto-api/rev/1e509576870d

The issue referred to in this bug does not affect Export Key.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>