Skip to content

Commit

Permalink
remove M2Crypto completely
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jan 12, 2015
1 parent a4b0ea5 commit 80b8bd7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 138 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ cache:
- dante-1.4.0
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq build-essential libssl-dev swig python-m2crypto python-numpy dnsutils iproute nginx bc
- sudo apt-get install -qq build-essential dnsutils iproute nginx bc
- sudo dd if=/dev/urandom of=/usr/share/nginx/www/file bs=1M count=10
- sudo service nginx restart
- pip install m2crypto salsa20 pep8 pyflakes nose coverage
- pip install pep8 pyflakes nose coverage
- sudo tests/socksify/install.sh
- sudo tests/libsodium/install.sh
- sudo tests/setup_tc.sh
Expand Down
119 changes: 0 additions & 119 deletions shadowsocks/crypto/m2.py

This file was deleted.

11 changes: 2 additions & 9 deletions shadowsocks/crypto/rc4_md5.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import hashlib

from shadowsocks.crypto import openssl

__all__ = ['ciphers']

Expand All @@ -35,15 +36,7 @@ def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None,
md5.update(key)
md5.update(iv)
rc4_key = md5.digest()

try:
from shadowsocks.crypto import openssl
return openssl.OpenSSLCrypto(b'rc4', rc4_key, b'', op)
except Exception:
import M2Crypto.EVP
return M2Crypto.EVP.Cipher(b'rc4', rc4_key, b'', op,
key_as_bytes=0, d='md5', salt=None, i=1,
padding=1)
return openssl.OpenSSLCrypto(b'rc4', rc4_key, b'', op)


ciphers = {
Expand Down
10 changes: 2 additions & 8 deletions shadowsocks/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,18 @@
import hashlib
import logging

from shadowsocks.crypto import m2, rc4_md5, openssl, sodium, table
from shadowsocks.crypto import rc4_md5, openssl, sodium, table


method_supported = {}
method_supported.update(rc4_md5.ciphers)
method_supported.update(openssl.ciphers)
method_supported.update(sodium.ciphers)
# let M2Crypto override openssl
method_supported.update(m2.ciphers)
method_supported.update(table.ciphers)


def random_string(length):
try:
import M2Crypto.Rand
return M2Crypto.Rand.rand_bytes(length)
except ImportError:
return os.urandom(length)
return os.urandom(length)


cached_keys = {}
Expand Down

0 comments on commit 80b8bd7

Please sign in to comment.