@@ -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
|
||||
|
||||
Reference in New Issue
Block a user