Code Monkey home page Code Monkey logo

Comments (4)

MicahZoltu avatar MicahZoltu commented on July 19, 2024

I poked around over in https://github.com/PeculiarVentures/webcrypto-core and wrote a quick failing test:

  it("convert from offset Uint8Array", () => {
    const source = new Uint8Array([0,1,2,3,4,5,6,7,8,9])
    const offset = source.subarray(5, 10)
    const data = BufferSourceConverter.toUint8Array(offset)
    assert.equal(Convert.ToHex(data), '0506070809')
  })

The underlying issue here is that you are using the buffer of the provided view, rather than using the view. If someone provides a view as a parameter, the offset and length of that view must be respected and the underlying buffer should not be used directly as the key. Unfortunately, fixing this is likely going to be a pretty big task since it is a minor architectural change to how you deal with arbitrary input data.

It does appear that the MDN Documentation for importKey does not match what either Firefox or Chrome does. It says it takes an ArrayBuffer, but in reality it takes ArrayBuffer/TypedArray/DataView. I have submitted an update to MDN to correct this.

from webcrypto.

microshine avatar microshine commented on July 19, 2024

@MicahZoltu Thank you for pointing to this problem and shared information. I'll fix it shortly

from webcrypto.

microshine avatar microshine commented on July 19, 2024

@MicahZoltu I published @peculiar/[email protected]. Can you try it?

from webcrypto.

MicahZoltu avatar MicahZoltu commented on July 19, 2024

1.0.19 fixed the problem for me. Thanks!

from webcrypto.

Related Issues (20)

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.