47 Commits
Author SHA1 Message Date
Syrone Wong 3329291ab9 add xchacha20-ietf-poly1305
- update mbedtls to 2.7.0, use new md5 api
- update libsodium to 1.0.16
- static link to openssl 1.1.0g, check libsscrypto repo for detail
2018-03-03 22:22:01 +08:00
Syrone Wong b2645f9f0a Fix bf-cfb name
Don't use Cname
2018-02-15 21:29:40 +08:00
Syrone Wong 4d4f1753c7 Add OpenSSL 1.1.0g support due to hardware acceleration
Note: If you want to compile it by yourself, please make sure
do NOT use `no-asm` configure option, since the main point of
this commit is to utilize assembly in openssl

Add OpenSSL test
2018-02-10 08:27:32 +08:00
Syrone Wong 5d75e19c26 prefer to use aes-256-gcm in libsodium
which is hardware accelerated compared to AES-GCM in mbedtls

We have to drop this commit when mbedtls support hw-accelerated GCM
when compiling with MSVC

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2017-05-31 10:04:00 +08:00
Syrone Wong 2eeebc29d7 Replace circular buffer with the blockcopy variant
to get rid of deep copy

- update NuGet pkg

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2017-05-19 15:56:13 +08:00
Syrone Wong 3b3a8c9077 fix legacy key derivation 2017-04-21 12:39:53 +08:00
Syrone Wong 877644609b spare enough space for UDP packet 2017-04-08 18:59:39 +08:00
Syrone Wong 3de14098d7 add AEAD support 2017-03-31 21:36:45 +08:00
Syrone Wong db1eafbfd8 Tweak OTA mask
sync with shadowsocks-libev

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-12-30 17:28:21 +08:00
noisyfox 4b067346bf Refine random string generate. 2016-12-09 01:39:07 +11:00
Syrone Wong 8fcb66b6ff Refine RNG usage
- Create instance once, bind it to ShadowsocksController

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-11-09 10:28:50 +08:00
Syrone Wong ce26bc15a9 Refine random generator handling
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-10-20 08:15:47 +08:00
Syrone Wong 6e8d6d3d21 Adjust garbage collection
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-09-30 15:15:39 +08:00
破娃酱 c7adac5fb0 Remove lock in SodiumEncryptor (#754)
- Use separate encrypt/decrypt buffer when creating instances
- Revert 3bc77d212a
2016-09-29 19:03:43 -05:00
Syrone Wong 46d95e7411 Get rid of lock(this)
- Use readonly object as lock

Info from stackoverflow:

If I want to be sure that it will be locked for all threads inside my
application:
The lock object has to be static, if it locks access to static state.
Otherwise it has to be instance, because there's no need to lock state of
one class instance, and prevent other threads to work with another class
instance at the same time.

everyone says that the object has to be "readonly" I didn't found the
reason
Well, it doesn't have to be. This is just a best practice, which helps you
to avoid errors.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-09-29 16:39:58 +08:00
Syrone Wong 1dc992e806 Refine encryption
introduce a constructor to store inner method name

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-09-28 10:46:19 +08:00
破娃酱 ea9c7b093a Refine Encryption module (#717)
- use EncryptorInfo struct instead of Dictionary<string, int[]>>
2016-09-13 22:16:37 -05:00
noisyfox be85ab55a7 Fix #561 2016-09-03 08:58:13 +08:00
noisyfox e6e9fc8588 Refactor to make OTA code more independent and clear.
and misc changes
2016-09-03 08:57:33 +08:00
noisyfox 4c5376ce0b Remove unnecessary call to InitKey. 2016-09-03 08:57:31 +08:00
Syrone Wong e30487207b Add error message
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-17 17:02:30 +08:00
Syrone Wong 8637277c27 Cleanup
- drop unused using directive
- add a comment

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-17 15:58:00 +08:00
Syrone Wong 21618ef08d Cleanup
- Drop redundant code.
  I should read code carefully, mbed TLS will set operation
  when invoking mbedtls_cipher_setkey(), the last param
  const mbedtls_operation_t operation is what we want.
- minor changes

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-14 22:29:48 +08:00
Syrone Wong 2fafc52def Refine encryption(#655)
* Refine encryption

- Add AES-CTR, blowfish and camellia ciphers

aes-256-ctr
aes-192-ctr
aes-128-ctr
bf-cfb
camellia-128-cfb
camellia-192-cfb
camellia-256-cfb

- Merge the previous PolarSSL and MbedTLS
- Switch to MbedTLS's cipher layer functions
- Add workaround to set cipher operation(encrypt/decrypt)

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>

* Add function to get MbedTLS cipher context size

and drop hard-coded ctx sizes

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-13 14:28:09 +08:00
Syrone Wong 89a9b49e35 Simplify MD5 handling
- use mbedtls_md5() instead
- update libsscrypto

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-05-28 00:12:02 +08:00
Gang Zhuo ea43e2a72d use ConcurrentDictionary instead of Dictionary 2016-02-25 22:41:20 +08:00
Licshee 687f397ae3 using StringEx 2016-02-06 12:47:45 +08:00
kimw 9194b0325f avoid warning message while compile 2016-01-04 23:57:30 +08:00
kimw 64390d45ac GetTempPath() now supports: return a full path with filename combined which pointed to the temporary directory 2016-01-04 23:56:43 +08:00
kimw 0b16ef7445 Merge upstream
# Conflicts:
#	README.md
#	shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs
#	shadowsocks-csharp/Controller/Service/PACServer.cs
#	shadowsocks-csharp/Controller/Strategy/SimplyChooseByStatisticsStrategy.cs
#	shadowsocks-csharp/Data/cn.txt
#	shadowsocks-csharp/Model/Configuration.cs
#	shadowsocks-csharp/Model/LogViewerConfig.cs
#	shadowsocks-csharp/View/LogForm.Designer.cs
#	shadowsocks-csharp/View/LogForm.cs
#	shadowsocks-csharp/View/MenuViewController.cs
2016-01-04 09:14:55 +08:00
Syrone Wong 131c4940c6 add chacha20-ietf support with updated libsscrypto
ChaCha20 with an extended (96 bit) nonce and a 32-bit counter has
been implemented as crypto_stream_chacha20_ietf() from LibSodium 1.0.4

Please refer to https://tools.ietf.org/html/rfc7539 for details.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2015-12-17 18:25:13 +08:00
Gang Zhuo 961ca041b2 Fix bug 2015-11-25 21:26:45 -05:00
Gang Zhuo dd0d047402 override MD5, so compatible with FIPS 2015-11-23 23:52:54 +08:00
Gang Zhuo d24548a04f rm rc4 and table 2015-10-16 04:36:31 -04:00
Gang Zhuo 098640e792 refact 2015-09-25 04:42:56 -04:00
Gang Zhuo c5e27486fb Protocol V2 2015-09-25 04:03:04 -04:00
Gang Zhuo 3aac1cfcfc Refine the authentication for true CCA 2015-09-23 02:08:41 -04:00
Gang Zhuo 19085a3cd1 Update the hash function
follow with https://github.com/shadowsocks/shadowsocks-libev/commit/5ae4df94e440c4f6826a679a62687ad27303d89b
2015-09-20 23:25:37 -04:00
Gang Zhuo ab1f366049 Combine libsscrypto.dll and libsslcrypto2.dll 2015-09-20 15:13:13 +08:00
Gang Zhuo 1564e9ff81 support onetime auth 2015-09-20 15:13:11 +08:00
Gang Zhuo 72ea01d566 no repeat random number generator
The stock code use class Random to generate IV, the Random is pseudo random number generator. The IV maybe repeat, this will cause shadowsocks-libev closed the sockets with the error message 'invalid password or cipher'. Reference https://github.com/shadowsocks/shadowsocks-libev/issues/389

Solution is use class RNGCryptoServiceProvider to generate IV, of course it's lower performance, but a little bit.
2015-09-19 15:49:19 +08:00
kimw 0a733c61b8 fixed: standardize Logging usage
1. Add Logging.Info()
2. Console.WriteLine() -> Logging.Info()
3. Console.WriteLine() in exceptions -> Logging.LogUsefulException()
2015-09-14 14:58:46 +08:00
clowwindy c767f55b3c add portable mode 2015-08-19 21:39:06 -07:00
kimw 758c497eba same the source code format.
1/ removed dual empty line
2/ removed tailing spaces
3/ converted tabs into spaces
4/ added some TODO comments
2015-08-19 00:24:08 +08:00
clowwindy 3bc77d212a reduce cache size 2015-08-18 21:34:04 -07:00
clowwindy db6701b1b2 refactor package name 2015-01-01 22:05:16 +08:00
clowwindy 5010a01d14 move encrypt package into encryption 2015-01-01 22:04:37 +08:00