proposal: crypto/rsa: support RSA/ECB/OAEPWithSHA-256AndMGF1Padding #72781
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Proposal-Crypto
Proposal related to crypto packages or other security issues
Milestone
Proposal Details
Hello, everyone.
Currently, I've encountered an issue where the RSA encryption algorithms are inconsistent across different languages during the project integration process. To address this problem, I had no choice but to modify some code in the
crypto
basic library.Process:
RSA/ECB/OAEPWithSHA-256AndMGF1Padding
method.DecryptOAEP
method incrypto
only provides a single input parameter for theHash
algorithm. When I usedsha256.New()
to create the hash, the lack ofMGF1Padding
caused the decryption to fail.Code:
PrivateKey
provides aDecrypt
method, which can be implemented through the extensibleopts crypto.DecrypterOpts
, thus solving my problem.RSA/ECB/OAEPWithSHA-256AndMGF1Padding
, and the official also provides standard APIs.RSA/ECB/OAEPWithSHA-256AndMGF1Padding
. Unfortunately, I couldn't find such a method.Optimization suggestion:
Can you geniuses provide an external interface that exposes a method similar to
func (priv *PrivateKey) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
?The following is the code I used to solve my problem. I hope it can be of some help. Of course, there is still much room for improvement.
I'm looking forward to your replies.
The text was updated successfully, but these errors were encountered: