From e30487207ba23731c64046d6ca8d8a4200ca2321 Mon Sep 17 00:00:00 2001 From: Syrone Wong Date: Wed, 17 Aug 2016 17:02:30 +0800 Subject: [PATCH] Add error message Signed-off-by: Syrone Wong --- shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs b/shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs index e9272c54..ccbd926f 100644 --- a/shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs +++ b/shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs @@ -72,7 +72,7 @@ namespace Shadowsocks.Encryption } MbedTLS.cipher_init(ctx); if (MbedTLS.cipher_setup( ctx, MbedTLS.cipher_info_from_string( _cipherMbedName ) ) != 0 ) - throw new Exception(); + throw new Exception("Cannot initialize mbed TLS cipher context"); /* * MbedTLS takes key length by bit * cipher_setkey() will set the correct key schedule @@ -85,11 +85,11 @@ namespace Shadowsocks.Encryption * */ if (MbedTLS.cipher_setkey(ctx, realkey, keyLen * 8, isCipher ? MbedTLS.MBEDTLS_ENCRYPT : MbedTLS.MBEDTLS_DECRYPT) != 0 ) - throw new Exception(); + throw new Exception("Cannot set mbed TLS cipher key"); if (MbedTLS.cipher_set_iv(ctx, iv, ivLen) != 0) - throw new Exception(); + throw new Exception("Cannot set mbed TLS cipher IV"); if (MbedTLS.cipher_reset(ctx) != 0) - throw new Exception(); + throw new Exception("Cannot finalize mbed TLS cipher context"); } protected override void cipherUpdate(bool isCipher, int length, byte[] buf, byte[] outbuf) @@ -109,7 +109,7 @@ namespace Shadowsocks.Encryption ctx = _decryptCtx; } if (MbedTLS.cipher_update(ctx, buf, length, outbuf, ref length) != 0 ) - throw new Exception(); + throw new Exception("Cannot update mbed TLS cipher context"); } #region IDisposable