Re: JS code examples for ACTION 43

Wan-Teh:

Thank you for the patch, I have applied it to my local copy and am going through the rest of Ryan's feedback and will push a new version soon. I will just go ahead and add the code samples to the draft spec after that.

Ryan, Wan-Teh, Arun:

Should I create a new header - perhaps as a "Example JavaScript Code" appendix? Further, targeted code samples can maybe live right next to the WebIDL of the interface?

Cheers,

David

----- Original Message -----
From: "Wan-Teh Chang" <wtc@google.com>
To: "David Dahl" <ddahl@mozilla.com>
Cc: "public-webcrypto@w3.org Working Group" <public-webcrypto@w3.org>
Sent: Wednesday, September 5, 2012 7:22:49 PM
Subject: Re: JS code examples for ACTION 43

David, Arun,

Thank you for writing the sample code.

Some of the mistakes in your sample code are caused by incomplete
specification of the current API draft. Some mistakes indicate areas
for improvement. I noted some mistakes below. (I didn't correct all
mistakes I found.)

1. In the algorithm object for RSA key pair generation:

// Algorithm Object
var algorithm = {
  name: "RSAES-PKCS1-v1_5",
  // AlgorithmParams
  params: {
    modulusLength: 2048,
    publicExponent: 65537
  }
};

The value of publicExponent needs to be a Uint8Array. So 65537 needs
to be represented as an array of three Uint8 elements: 0x01, 0x00,
0x01.

2. In the onKeyGenComplete function, we have:

  console.log("Key ID: " + event.target.key.id);

This requires adding a |key| attribute to the KeyOperation interface
in Section 13 "KeyOperation interface". But it seems that the |key|
should be the |result| of the KeyOperation object for key generation.
So perhaps this line should read:
  console.log("Key ID: " + event.target.result.id);

3. Call sequences like the following don't work because the methods
are all asynchronous:

      pubKeyCryptoOp.init();
      pubKeyCryptoOp.processData(secretMessageToAlice);
      pubKeyCryptoOp.complete();

4. Please see the attached patch file for additional fixes. If you
have questions about any change in the patch file, please let me know.

Wan-Teh

Received on Thursday, 6 September 2012 15:13:46 UTC