GithubHelp home page GithubHelp logo

kevlened / msrcrypto Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 21.0 243.04 MB

GitHub mirror of the MSR JavaScript Cryptography Library

Home Page: https://www.microsoft.com/en-us/download/details.aspx?id=52439

License: Other

C# 0.98% ASP 0.01% JavaScript 97.37% HTML 1.25% CSS 0.32% VBScript 0.09%

msrcrypto's People

Contributors

ali-hk avatar jamesrez avatar kevlened avatar sirpy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

msrcrypto's Issues

AES-GCM import key not working

The following works on browser webcrypto but not when using msrcrypto, it throws an error with message about "keyData". I've tested both in browser and in expo react native in both it throws the same error.

try {
    await crypto.subtle.importKey(
      "raw",
      new Uint8Array([1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1]),
      "AES-GCM",
      false,
      ["encrypt", "decrypt"]
    );
  } catch (e) {
    console.log(e.message);
  }

The error from expo

[Unhandled promise rejection: Error: keyData]
- node_modules/msrcrypto/dist/msrcrypto.js:9130:28 in buildParameterCollection
- node_modules/msrcrypto/dist/msrcrypto.js:9174:38 in executeOperation
- ... 12 more stack frames from framework internals

working with extractable=false fails

If I pass "false" to the extractable parameter in importkey an error is thrown at line 9112
with the message "extractable"

looking at the code the problem seem to be here:

if (!actualParam) {

the correct way to check if a variable is present would be to check if it is ===undefined otherwise you don't allow "false" as a valid value

HMAC generateKey is generating bytes instead of bits

HMAC algorithm length during generateKey is in bits, msrCrypto currently generates bytes instead.

See the diff between msrCrypto and other conforming implementations.

Correct (e.g. chromium)
Screenshot 2021-11-10 at 12 44 01

Incorrect (current behaviour)
Screenshot 2021-11-10 at 12 44 46

Update to New Source

Thank you for maintaining this library's version in the node ecosystem.
As you may have seen, due to some vulnerabilities our team found in the original Microsoft library, we worked through coordinated disclosure with Microsoft and this has resulted in fixes being applied and made public in CVE-2018-8319.
As they have numbered the fixed version 1.4.1 (see https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2018-8319), which "collides" with the versioning you have currently in this package, I suggest updating the NPM package to the new (secure) code available from Microsoft to help the downstream projects consuming this NPM library from using the insecure versions of the code.
Please feel free to contact me here or offline if you have questions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.