From 8d3ae9cede3dd8946f15aad36ffabcd345456e5d Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Fri, 24 Feb 2012 19:12:38 +0000 Subject: [PATCH] Fix paddedBlock calculation --- .../Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs b/Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs index 4c771e03..66b293c9 100644 --- a/Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs +++ b/Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs @@ -40,7 +40,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers public override byte[] Encrypt(byte[] data) { // Calculate signature - var paddedBlock = new byte[this._key.Modulus.BitLength / 8 - 1]; + var bitLength = this._key.Modulus.BitLength; + + var paddedBlock = new byte[bitLength / 8 + (bitLength % 8 > 0 ? 1 : 0) - 1]; + paddedBlock[0] = 0x01; for (int i = 1; i < paddedBlock.Length - data.Length - 1; i++) {