Is there a replacement for the deprecated public_key:encrypt_public?

I have an older application that uses public_key:encrypt_public/4, like so:

public_key:encrypt_public(Msg, RsaPubKey, [{rsa_pad, RsaPadding}])

RsaPadding may be either rsa_pkcs1_padding or rsa_pkcs1_oaep_padding, depending on circumstances.

Since OTP 27, this raises a warning:

public_key:encrypt_public/3 is deprecated; do not use

Looking at the documentation, it laconically says that this is a legacy function which, for security reasons, should not be used with rsa_pkcs1_padding. It does not mention any alternative or replacement, though.

The deprecation was reverted in OTP-27.1, as it is rsa_pkcs1_padding that is vulnerable to several attacks and rsa_pkcs1_oaep_padding is better. We still do not recommend that you use rsa_pkcs1_padding although new OpenSSL crypto libs have a mitigation for the vulnerability, this padding has proven to be very problematic and and broken several times first time in 1998. So from our perspective we still think that moving on to other and better alternatives is the way to go.

1 Like

It does mention that for digital signatures sign/verify is a better choice. But for other cases I guess rsa_pkcs1_oaep_padding can be the choice, and that is also why we reverted the deprecation.

1 Like

Thank you :slight_smile: