Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

RSA encryption using OAEP with SHA256 hash algorithm

Discussion in 'Scripting' started by sajjadrad, Sep 18, 2020.

  1. sajjadrad

    sajjadrad

    Joined:
    Jan 19, 2018
    Posts:
    8
    I want to use RSA encryption with SHA256 padding but as I found that RSACryptoServiceProvider doesn't support OaepSHA256 as padding and they suggest to use RSACng which is a new implementation of the RSA algorithm to support more things like SHA256 as padding.

    The problem is here that I got this error while initiating RSACng (and I guess unity doesn't implement RSACng yet):
    Code (CSharp):
    1. NotImplementedException: The method or operation is not implemented.
    Initiation code:
    Code (CSharp):
    1. rsa = new RSACng();
    1. Is there anything wrong with my codes or knowledge?
    2. Is there any other way to use RSACng in Unity?
    3. Is there any other way to use SHA256 as padding for RSA encryption in Unity?
    Ps. I want to use RSA encryption for server/client communication on UDP connection. As I know SHA1 and PKCS1 (which supported by RSACryptoServiceProvider) are not secure and fast enough for RSA padding.
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,833
    You might try going to your project settings and checking the .NET API compatibility level; make sure it's set to the highest available setting.
     
  3. sajjadrad

    sajjadrad

    Joined:
    Jan 19, 2018
    Posts:
    8
    Thanks for reply, It's already set to 4.x