Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aliddeke
Copy link
Contributor

@aliddeke aliddeke commented Jul 29, 2016

This commit fixes #122.
Enables support for import of JWK format, whereas before it was hard-coded to PKCS8 for private keys and SPKI for public keys.

* This allows support for import of JWK format, whereas before it was hard-coded to PKCS8 for private keys and SPKI for public keys.
*/

(function() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a "use strict" here.

 * Use identity operator to compare 'typeof' expressions.
 * Clarify types function parameter documentation.
 * Re-order inclusion of KeyFormat.js to be above dependents.
 * Replace all uses of format hard-coded strings with KeyFormat definitions.
input = (typeof input == "string") ? JSON.parse(input) : input;
input = (typeof input === "string") ? JSON.parse(input) : input;
/* input must be a JSON object */
if (typeof input !== "object") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you also need to do both checks: typeof x === "object" && x.constructor === Object. Just typeof isn't good enough because it will also catch other things that are not pure JavaScript objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated/tested/pushed a change that checks both of these conditions.

On Wed, Aug 3, 2016 at 1:23 PM, Wesley Miaw [email protected]
wrote:

In core/src/main/javascript/crypto/KeyFormat.js
#126 (comment):

             } catch (e) {
                 throw new MslCryptoException(MslError.INVALID_PUBLIC_KEY, format + " " + input, e);
             }
         }
         else if (format == KeyFormat.JWK) {
             try {
  •                input = (typeof input == "string") ? JSON.parse(input) : input;
    
  •                input = (typeof input === "string") ? JSON.parse(input) : input;
    
  •                /\* input must be a JSON object */
    
  •                if (typeof input !== "object") {
    

Actually you also need to do both checks: typeof x === "object" &&
x.constructor === Object. Just typeof isn't good enough because it will
also catch other things that are not pure JavaScript objects.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Netflix/msl/pull/126/files/1a843eda7f6b25ba0a3e0cddc74e828550afaef3..551ff692b66d2cce101c37884f043c37dcfb267f#r73413319,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATkwwxH9UidKF7MGvcZdHB-A-8YLlPy5ks5qcPi8gaJpZM4JYcJT
.

@wmiaw wmiaw self-assigned this Aug 3, 2016
@wmiaw wmiaw merged commit 7766eaf into master Aug 4, 2016
@wmiaw wmiaw deleted the PKInputFormats-Issue122 branch August 4, 2016 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support other key formats in JavaScript PrivateKey and PublicKey

3 participants