This is my first post on Stackoverflow so i will appreciate any suggestions on how to improve.
I tried the following from here So im trying to encode a string message, let it be "test", with the Microsoft RSACryptoServiceProvider with the help of BouncyCastle.
I've got a given public key where the server provider already described me how the public key is structured.
public key: 48015250010000010100970348B03E911DCCE5ED8F555C2116DBC4D7E96D4C1CDC4BBBAAD26BAA54B5C834F604F9DFB391459459772FB51D00AFD0FE3A9B2DA724E62113A9E8C95BEF377CB5FCF7FEBE42E5282A0DA50F01D5D2635DD958F9836CFB4F8B616777C0CF67DB9A5530AD679E321972E4D4F4F33DED057CB690417A3B42FBFCE2AD9FDD80C815AF1EC858C796D4EA2F17954E4BFAD08E3E0397FA34122AC5951D889B06359A401E5506E50FA176B5A77FAB84E25CFCDBF2330AA173DA1156C8B79D6DB6BFAE828B00811183E63F137648E1FC1786B52D815C248BCADDDF6A17C941414F67A23ADFE82FE76196B64B96E36F8604FA00E8E357F5AE6C83B992D622D5E9CD9C1D00000003010001
The public key is a hexstring and i extracted the modulus and exponent in seperate variables and saved them as Base64 Strings. The modulus and exponent are saved in another variable as a xml string for use as the RSAKeyValue.
string strModulusAndExponentAsXml = "<RSAKeyValue><Modulus>00970348B03E911DCCE5ED8F555C2116DBC4D7E96D4C1CDC4BBBAAD26BAA54B5C834F604F9DFB391459459772FB51D00AFD0FE3A9B2DA724E62113A9E8C95BEF377CB5FCF7FEBE42E5282A0DA50F01D5D2635DD958F9836CFB4F8B616777C0CF67DB9A5530AD679E321972E4D4F4F33DED057CB690417A3B42FBFCE2AD9FDD80C815AF1EC858C796D4EA2F17954E4BFAD08E3E0397FA34122AC5951D889B06359A401E5506E50FA176B5A77FAB84E25CFCDBF2330AA173DA1156C8B79D6DB6BFAE828B00811183E63F137648E1FC1786B52D815C248BCADDDF6A17C941414F67A23ADFE82FE76196B64B96E36F8604FA00E8E357F5AE6C83B992D622D5E9CD9C1D</Modulus><Exponent>010001</Exponent></RSAKeyValue>";
string strModulusAndExponentAsBase64 = Base64Encode(strModulusAndExponentAsXml);
Now i want to create a Asn1Object and provide the byte parameter
Asn1Object obj = Asn1Object.FromByteArray(Convert.FromBase64String(strModulusAndExponentAsBase64));
and here it fails, i get the error:
System.IO.IOException: 'unknown tag 28 encountered'
Does anyone know what im doing wrong, so i can create the Asn1Ojbect with the given exponent and modulus? Let me know if anything is unclear.