CryptographicException: The data to be encrypted exceeds the maximum for this modulus of 117 bytes.

General support.
Post Reply
User avatar
ve_game
Member
Member
Posts: 14
Joined: Thu Jun 04, 2020 10:17 am

Hi
After purchasing a certain amount of weapons
This error occurs.
"CryptographicException: The data to be encrypted exceeds the maximum for this modulus of 117 bytes.
System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter.CreateKeyExchange (System.Byte[] rgbData) (at <eae584ce26bc40229c1b1aa476bfa589>:0)"

Here is a weapon from the database
0,2-0,3-0,8-0,42-0,21-0,19-0,9-0,22-0,20-0,0-0,6-0,12-0,7-0,5-0,10-0,13-0,11-0,4-0,1-0,17-0,49-0,50-0,51-0,53-0,45-
If I manually delete one weapon from the database
The purchase is successful.

Here is the whole mistake
CryptographicException: The data to be encrypted exceeds the maximum for this modulus of 117 bytes.
System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter.CreateKeyExchange (System.Byte[] rgbData) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Security.Cryptography.RSACryptoServiceProvider.Encrypt (System.Byte[] rgb, System.Boolean fOAEP) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
bl_RSA.Encrypter (System.String data, System.String publicKey) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/General/bl_RSA.cs:26)
bl_DataBaseUtils.AddSecureField (UnityEngine.WWWForm wf, System.String key, System.String value) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/Utils/bl_DataBaseUtils.cs:221)
bl_ShopManager+<ProcessBuy>d__41.MoveNext () (at Assets/Addons/Shop/Scripts/Runtime/Core/bl_ShopManager.cs:277)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <10564ed154d647e194bef4aef8878649>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
bl_ShopManager:BuyCurrent() (at Assets/Addons/Shop/Scripts/Runtime/Core/bl_ShopManager.cs:255)



Sorry for the bad english.
User avatar
Lovatto
Admin
Admin
Posts: 1772
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Hi,

Try the following:

- In the script bl_RSA.cs change the value of the constant 'KEY_LENGHT' to 2048
- in the script bl_Security.php (hosted on your server) -> function generateKeyPair() -> change this line:

Code: Select all

$keys = $rsa->createKey();
to this:

Code: Select all

$keys = $rsa->createKey(2048);
That should do it,
Regards.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
ThePrimePillow
Contributor
Contributor
Posts: 65
Joined: Thu Feb 22, 2018 10:10 pm

Lovatto wrote: Wed May 05, 2021 1:23 am Hi,

Try the following:

- In the script bl_RSA.cs change the value of the constant 'KEY_LENGHT' to 2048
- in the script bl_Security.php (hosted on your server) -> function generateKeyPair() -> change this line:

Code: Select all

$keys = $rsa->createKey();
to this:

Code: Select all

$keys = $rsa->createKey(2048);
That should do it,
Regards.
I'm getting a similar error:

Code: Select all

CryptographicException: Input string does not contain a valid encoding of the 'RSA' 'Modulus' parameter.
System.Security.Cryptography.RSA.FromXmlString (System.String xmlString) (at <437ba245d8404784b9fbab9b439ac908>:0)
bl_RSA.Encrypter (System.String data, System.String publicKey) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/General/bl_RSA.cs:23)
bl_DataBaseUtils.AddSecureField (UnityEngine.WWWForm wf, System.String key, System.String value) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/Utils/bl_DataBaseUtils.cs:221)
bl_LoginPro+<RegisterProcess>d__43.MoveNext () (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:461)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <480508088aee40cab70818ff164a29d5>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
bl_LoginPro:SinUp(String, String, String, String) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:444)
bl_SignUp:SignUp() (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/UI/bl_SignUp.cs:98)
UnityEngine.UI.Button:OnSubmit(BaseEventData)
MFPS.ULogin.bl_SubmitButton:Update() (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/UI/Navigation/bl_SubmitButton.cs:26)
But when I try your solution I get this error:

Code: Select all

CryptographicException: Specified key is not a valid size for this algorithm.
System.Security.Cryptography.AsymmetricAlgorithm.set_KeySize (System.Int32 value) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Security.Cryptography.RSACryptoServiceProvider.Common (System.Int32 dwKeySize, System.Boolean parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Security.Cryptography.RSACryptoServiceProvider..ctor (System.Int32 dwKeySize) (at <437ba245d8404784b9fbab9b439ac908>:0)
bl_RSA.Encrypter (System.String data, System.String publicKey) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/General/bl_RSA.cs:22)
bl_DataBaseUtils.AddSecureField (UnityEngine.WWWForm wf, System.String key, System.String value) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/Utils/bl_DataBaseUtils.cs:221)
bl_LoginPro+<RegisterProcess>d__43.MoveNext () (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:461)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <480508088aee40cab70818ff164a29d5>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
bl_LoginPro:SinUp(String, String, String, String) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:444)
bl_SignUp:SignUp() (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/UI/bl_SignUp.cs:98)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.3.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
User avatar
Lovatto
Admin
Admin
Posts: 1772
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Make sure the length value is 2048 and that you set it correctly in both places: bl_RSA.cs and bl_Security.php (the one hosted in your server)
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
ThePrimePillow
Contributor
Contributor
Posts: 65
Joined: Thu Feb 22, 2018 10:10 pm

Lovatto wrote: Wed May 05, 2021 11:09 am Make sure the length value is 2048 and that you set it correctly in both places: bl_RSA.cs and bl_Security.php (the one hosted in your server)
Now im getting:

Code: Select all

CryptographicException: Input string does not contain a valid encoding of the 'RSA' 'Modulus' parameter.
System.Security.Cryptography.RSA.FromXmlString (System.String xmlString) (at <437ba245d8404784b9fbab9b439ac908>:0)
bl_RSA.Encrypter (System.String data, System.String publicKey) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/General/bl_RSA.cs:23)
bl_DataBaseUtils.AddSecureField (UnityEngine.WWWForm wf, System.String key, System.String value) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Internal/Utils/bl_DataBaseUtils.cs:221)
bl_LoginPro+<RegisterProcess>d__43.MoveNext () (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:461)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <480508088aee40cab70818ff164a29d5>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
bl_LoginPro:SinUp(String, String, String, String) (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/Main/bl_LoginPro.cs:444)
bl_SignUp:SignUp() (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/UI/bl_SignUp.cs:98)
UnityEngine.UI.Button:OnSubmit(BaseEventData)
MFPS.ULogin.bl_SubmitButton:Update() (at Assets/Addons/ULoginSystemPro/Content/Scripts/Runtime/UI/Navigation/bl_SubmitButton.cs:26)
User avatar
ve_game
Member
Member
Posts: 14
Joined: Thu Jun 04, 2020 10:17 am

Lovatto wrote: Wed May 05, 2021 1:23 am Hi,

Try the following:

- In the script bl_RSA.cs change the value of the constant 'KEY_LENGHT' to 2048
- in the script bl_Security.php (hosted on your server) -> function generateKeyPair() -> change this line:

Code: Select all

$keys = $rsa->createKey();
to this:

Code: Select all

$keys = $rsa->createKey(2048);
That should do it,
Regards.
Thank you so much .
Helped :)
User avatar
ThePrimePillow
Contributor
Contributor
Posts: 65
Joined: Thu Feb 22, 2018 10:10 pm

bump
Post Reply