<?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>26413</bug_id>
          
          <creation_ts>2014-07-22 21:49:16 +0000</creation_ts>
          <short_desc>Inconsistent handling of usages parameter between importKey and generateKey</short_desc>
          <delta_ts>2014-09-26 00:44:17 +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="Mark Watson">watsonm</assigned_to>
          <cc>public-webcrypto</cc>
    
    <cc>rlb</cc>
    
    <cc>watsonm</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>109187</commentid>
    <comment_count>0</comment_count>
    <who name="Ryan Sleevi">sleevi</who>
    <bug_when>2014-07-22 21:49:16 +0000</bug_when>
    <thetext>The per-algorithm definitions for import key traditionally include a &apos;usages&apos; check to ensure that the caller&apos;s supplied set of usages intersects with the set of operations defined for that algorithm.

For example, an attempt to generateKey for RSASSA-PKCS1-v1_5 with usages of [&quot;encrypt&quot;, &quot;decrypt&quot;] will fail, because of Step 1 of the &quot;Generate Key&quot; phase in https://dvcs.w3.org/hg/webcrypto-api/raw-file/ee10c81e1141/spec/Overview.html#rsassa-pkcs1-operations

However, attempting to importKey with the same usages will, presumably, succeed.

This is not true for all algorithms. For example, AES-CTR (
https://dvcs.w3.org/hg/webcrypto-api/raw-file/ee10c81e1141/spec/Overview.html#aes-ctr-operations ) has checks for usages as Step 2 of Generate Key and Step 1 of Import Key.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110891</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Barnes">rlb</who>
    <bug_when>2014-09-02 23:53:28 +0000</bug_when>
    <thetext>In addition, the errors returned by these methods in the case of unrecognized usages are different.

generateKey -&gt; InvalidAccessError
deriveKey -&gt; SyntaxError
importKey -&gt; SyntaxError

By majority rule, it seems we should change generateKey to SyntaxError.  That also seems to make sense, compared to, say, how unrecognized format values are handled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112058</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-24 01:21:22 +0000</bug_when>
    <thetext>SyntaxError seems appropriate here: &quot;A required parameter was missing or out-of-range&quot;

Usage checking should be provided consistently for all algorithms for importKey and generateKey operations. In the import case the checking may be dependent on the key type (public/private).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112225</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-26 00:44:17 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcrypto-api/rev/d461dd0a2bdd
https://dvcs.w3.org/hg/webcrypto-api/rev/13846e3198f6
https://dvcs.w3.org/hg/webcrypto-api/rev/ac6406fe7075</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>