OAEP padding error

Alo!
Uporabljam za enkripcijo parametrov RSA kritpo algoritem. Skriptira mi ga vredi, potem pa pri dekripciji dobim tole napako. Zanima me, v cem sem zgresil? a je treba se kaj nastavt, kaksne pravice na network service dodat al pa kaj drugega?

Koda:
 /// <summary>
        /// private and public keys
        /// </summary>
        private static RSAParameters paramPublic, paramPrivate;

        /// <summary>
        /// decrypt parameter to normal state
        /// </summary>
        /// <param name="parameter">parameter to decyrpt</param>
        /// <returns>get valid normal string or throw exception otherwise</returns>
        public static string DecryptParameters( string parameter )
        {  
            try
            {
                RSACryptoServiceProvider cyrpto = new RSACryptoServiceProvider();
                cyrpto.ImportParameters(paramPrivate); //get private key
                //encode string
                byte[] decryptedValue = cyrpto.Decrypt(Encoding.Unicode.GetBytes(parameter), true);
                //return value
                return Encoding.Unicode.GetString(decryptedValue);
            }
            catch (CryptographicException error)
            {
                throw new Luis.LuisException(error.Message, ErrorTypes.CYRPTOGRPHIC_ERROR);
            }                                                                
        }       






























Avtor: bojanv, objavljeno na portalu SloDug.si (Arhiv)

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.

PRiMoZ
PRiMoZ - ponedeljek, 11. september 2006

Poizkusi z različnimi možnostmi &quot;PaddingMode&quot; parametra.Sedaj ko sem pa pogledal kodo pa vidim, da je verjetno problem v tem:&nbsp;&nbsp;&nbsp; namesto encoding.unicode uporabljal raje Convert.FromBase64String&nbsp;&nbsp;