Git Product home page Git Product logo

Comments (7)

travist avatar travist commented on August 16, 2024

As far as I understand (would love to get @zoloft input on this) but you can only decrypt using the private key, and encrypt using either or. Since you are trying to decrypt using the public key, this would not work.

from jsencrypt.

fmgdias avatar fmgdias commented on August 16, 2024

Mathematically it should work in RSA. "Encrypt" with the private key, "decrypt" with the public key.
That way I can validate that the message came from a secure place

" ...
RSA works on a public/private key pair. Non repudiation relies on a sender having a key pair, and the sender and receiver agreeing that the public key is in fact the public key of the sender.

A sender then constructs a document (normally plain text), then creates a cryptographic hash of the document (eg with MD5), then encrypts the hash with the private key.

The receiver decrypts the document hash using the sender's public key, then runs the same hash algorithm to obtain a verification hash. The verification hash and the decrypted hash should match. If they do, then the document originated from the sender (and the sender can't repudiate it).

This relies on the fact that noone else could create an encoded hash that decrypts correctly with the public key. And noone can alter the document without creating a hash mismatch. If both these are true, then the user of the sender's private key is the only person able to create the document [which is hopefully the sender - but it may be compromised by some means].

This rather roundabout method is used because (a) the document is in plain text so doesn't need decrypting for casual reading (b) encrypting the whole document using RSA is a computationally intense process, much cheaper computationally to use MD5, then only use RSA for the hash.

Check this: http://crypto.stackexchange.com/questions/2123/rsa-encryption-with-private-key-and-decryption-with-a-public-key

from jsencrypt.

zoloft avatar zoloft commented on August 16, 2024

Sorry for the late reply just noticed it. The problem is in Tom Wu's library. I honestly don't do any check in the extension of Tom Wu's RSA key object and from what I could remember of his code he probably doesn't as well. My first thought is that there may be a bug in his BigInteger library (jsbn) but I would need some spare time to check it that, unfortunately, I don't have. There are quite a few things I would like to check on Tom Wu's library honestly and changes that I would like to do on this library as well I just don't have enough time to work on it :(

from jsencrypt.

FlyingOE avatar FlyingOE commented on August 16, 2024

Is there any progress on this? I traced the current version on github, and found that the problem is not with BigInt lib, but rather with RSA key object itself -- the computation logic assumes a public->private communication, and doesn't account for the private->public case, which resulted in an erroneous referece to a null this.d value.

from jsencrypt.

ronaldoklais avatar ronaldoklais commented on August 16, 2024

No solution for this problem?

from jsencrypt.

sunnyjocker avatar sunnyjocker commented on August 16, 2024

i'm stuck in this private -> public issue too, it seems no solution, so sad...

from jsencrypt.

savs90 avatar savs90 commented on August 16, 2024

Public key is used only for encryption. Private key can decrypt and encrypt both. The idea of RSA is not to be able to decrypt with the public key. The reason is that the public key contains only N and E and the private key have additional D which is a must for decryption.

more info:
https://en.wikipedia.org/wiki/RSA_(cryptosystem)

So in conclusion i would say that this effect is by RSA design.

What @fmgdias is describing in his second comment is signing/verification and not encryption/decryption process.

from jsencrypt.

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.