--- sample-code-fpwd.js.orig 2012-09-05 16:58:38.242271000 -0700 +++ sample-code-fpwd.js 2012-09-05 17:16:31.113831000 -0700 @@ -37,8 +37,8 @@ //////////////////////////////////////////////////////////////////////////////////// // Algorithm Object -var algorithm = { - name: "RSAES-PKCS1-v1_5", +var algorithmKeyGen = { + name: "RSASSA-PKCS1-v1_5", // AlgorithmParams params: { modulusLength: 2048, @@ -46,7 +46,15 @@ } }; -var keyGen = window.crypto.createKeyGenerator(algorithm, +var algorithmSign = { + name: "RSASSA-PKCS1-v1_5", + // AlgorithmParams + params: { + hash: "SHA-256 algorithm alias" + } +}; + +var keyGen = window.crypto.createKeyGenerator(algorithmKeyGen, false, // temporary false, // extractable ["sign"]); @@ -57,7 +65,7 @@ console.log("Key ID: " + event.target.key.id); // create a "signer" CryptoOperation object - var signer = window.crypto.createSigner(algorithm, event.target.key); + var signer = window.crypto.createSigner(algorithmSign, event.target.key); signer.oncomplete = function signer_oncomplete(event) { console.log("The signer CryptoOperation is finished, the signature is: " + @@ -76,26 +84,11 @@ signer.complete(); }; -keyGen.oninit = function onKeyGenInit(event) -{ - console.log("KeyGen CryptoOperation object is initialized"); -}; - keyGen.onerror = function onKeyGenError(event) { console.error("KeyGen error: " + event.target.error); // is this correct? event.target.error? }; -keyGen.onabort = function onKeyGenAbort(event) -{ - console.error("KeyGen abort: " + event.target.error); -}; - -keyGen.onprogress = function onKeyGenProgress(event) -{ - console.error("KeyGen Progress!"); -}; - // Generate the keypair, the key object is available inside the oncomplete handler keyGen.generate(); @@ -118,15 +111,22 @@ // var secretMessageToAlice = anArrayBufferView; // var alicePubKey = aJWKFormattedPublicKey; -var aesAlgorithm = { +var aesAlgorithmKeyGen = { + name: "AES-CBC", + params: { + length: 128 + } +}; + +var aesAlgorithmEncrypt = { name: "AES-CBC", params: { - iv: "NjAwNzY3ODgzOTg0NjEzOA==" + iv: "NjAwNzY3ODgzOTg0NjEzOA==" /* XXX use getRandomValues to generate the IV */ } }; // Create a keygenerator to produce a one-time-use AES key to encrypt some data -var cryptoKeyGen = window.crypto.createKeyGenerator(aesAlgorithm, +var cryptoKeyGen = window.crypto.createKeyGenerator(aesAlgorithmKeyGen, false, // temporary false, // extractable ["encrypt"]); @@ -142,8 +142,6 @@ name: "RSAES-PKCS1-v1_5", // AlgorithmParams params: { - modulusLength: 2048, - publicExponent: 65537 } }; @@ -162,7 +160,7 @@ var pubKeyCryptoOp = window.crypto.createEncrypter(alicePubKeyAlg, alicePubKey); - var aesSymmetricCryptoOp = window.crypto.createEncrypter(aesAlgorithm, aesKey); + var aesSymmetricCryptoOp = window.crypto.createEncrypter(aesAlgorithmEncrypt, aesKey); aesSymmetricCryptoOp.oncomplete = function aes_oncomplete(event) { @@ -172,9 +170,9 @@ // Now, we need to wrap the AES key with Alice's public key pubKeyCryptoOp.oncomplete = function pkco_oncomplete(event) { - var wrappedKey = event.target.result; - // Now we can send the cipherMessage and wrappedKey to Alice - // sendMessage(cipherMessage, wrappedKey); // Ficticious application function + var wrappingKey = event.target.result; + // Now we can send the cipherMessage and wrappingKey to Alice + // sendMessage(cipherMessage, wrappingKey); // Ficticious application function }; pubKeyCryptoOp.init(); pubKeyCryptoOp.processData(secretMessageToAlice);