diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-01-12 17:46:20 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-01-12 17:46:20 +0900 |
| commit | c653c72dc84b7c5fe99f2aa189e9cf1da80a9ed5 (patch) | |
| tree | ec0497de2d684cc0b5030c94e0334c73754b8954 /src/MSEHandshake.cc | |
| parent | cc36df2625c1fee8e4f013becff07d3b4c38b12d (diff) | |
Add --bt-force-encryption option
This option requires BitTorrent message payload encryption with
arc4. This is a shorthand of --bt-requre-crypto
--bt-min-crypto-level=arc4. If true is given, deny legacy BitTorrent
handshake and only use Obfuscation handshake and always encrypt
message payload. This option defaults to false.
Diffstat (limited to 'src/MSEHandshake.cc')
| -rw-r--r-- | src/MSEHandshake.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index c4d3c98a..3b3f67fc 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -284,7 +284,8 @@ void MSEHandshake::sendInitiatorStep2() ptr += sizeof(VC); // crypto_provide memset(ptr, 0, CRYPTO_BITFIELD_LENGTH); - if(option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { + if(!option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) && + option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { ptr[3] = CRYPTO_PLAIN_TEXT; } ptr[3] |= CRYPTO_ARC4; @@ -347,7 +348,8 @@ bool MSEHandshake::receiveInitiatorCryptoSelectAndPadDLength() //verifyCryptoSelect unsigned char* rbufptr = rbuf_; decryptor_->encrypt(CRYPTO_BITFIELD_LENGTH, rbufptr, rbufptr); - if(rbufptr[3]&CRYPTO_PLAIN_TEXT && + if((rbufptr[3]&CRYPTO_PLAIN_TEXT) && + !option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) && option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer prefers plaintext.", cuid_)); @@ -447,7 +449,8 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength decryptor_->encrypt(CRYPTO_BITFIELD_LENGTH, rbufptr, rbufptr); // TODO choose the crypto type based on the preference. // For now, choose ARC4. - if(rbufptr[3]&CRYPTO_PLAIN_TEXT && + if((rbufptr[3]&CRYPTO_PLAIN_TEXT) && + !option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) && option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer provides plaintext.", cuid_)); |
