//02 002 void config_encryption(const char *password, const char *method) { SSLeay_add_all_algorithms(); sodium_init(); _method = encryption_method_from_string(method); if (_method == ENCRYPTION_TABLE) { get_table((unsigned char *) password); cipher = CIPHER_TABLE; } else if (_method == ENCRYPTION_SALSA20 || _method == ENCRYPTION_CHACHA20) { cipher = CIPHER_SODIUM; _key_len = 32; unsigned char tmp[EVP_MAX_IV_LENGTH];; EVP_BytesToKey(EVP_aes_256_cfb(), EVP_md5(), NULL, (unsigned char *)password, strlen(password), 1, _key, tmp); shadowsocks_key = _key; } else { cipher = CIPHER_OPENSSL; const char *name = shadowsocks_encryption_names[_method]; if (_method == ENCRYPTION_RC4_MD5) { name = "RC4"; } _cipher = EVP_get_cipherbyname(name); if (_cipher == NULL) { // assert(0); // TODO printf("_cipher is nil! \r\nThe %s doesn't supported!\r\n please chose anthor!",name); } else { unsigned char tmp[EVP_MAX_IV_LENGTH]; _key_len = EVP_BytesToKey(_cipher, EVP_md5(), NULL, (unsigned char *)password, strlen(password), 1, _key, tmp); shadowsocks_key = _key; } // printf("%d\n", _key_len); } }
void config_encryption(const char *password, const char *method) { SSLeay_add_all_algorithms(); _method = encryption_method_from_string(method); if (_method != EncryptionTable) { const char *name = encryption_names[_method]; _cipher = EVP_get_cipherbyname(name); if (_cipher == NULL) { // assert(0); // TODO } unsigned char tmp[EVP_MAX_IV_LENGTH]; _key_len = EVP_BytesToKey(_cipher, EVP_md5(), NULL, password, strlen(password), 1, _key, tmp); } else { get_table(password); } }
void config_encryption(const char *password, const char *method) { SSLeay_add_all_algorithms(); _method = encryption_method_from_string(method); if (_method != ENCRYPTION_TABLE) { const char *name = shadowsocks_encryption_names[_method]; _cipher = EVP_get_cipherbyname(name); if (_cipher == NULL) { // assert(0); // TODO printf("_cipher is nil! \r\nThe %s doesn't supported!\r\n please chose anthor!",name); } else { unsigned char tmp[EVP_MAX_IV_LENGTH]; _key_len = EVP_BytesToKey(_cipher, EVP_md5(), NULL, (unsigned char *)password, strlen(password), 1, (unsigned char *)_key, tmp); shadowsocks_key = _key; } // printf("%d\n", _key_len); } else { get_table((unsigned char *)password); } }