Skip to content

Commit

Permalink
switch back to OpenSSL 1.0.2 (#369)
Browse files Browse the repository at this point in the history
* switch back to OpenSSL 1.1.1

* update INSTALL.md

* fix changes to INSTALL.md
  • Loading branch information
vaivaswatha authored Jan 10, 2019
1 parent f14c552 commit 6c95aaa
Show file tree
Hide file tree
Showing 15 changed files with 602 additions and 337 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ branches:
only:
- master
before_install:
- ./scripts/build_openssl.sh
- # ./scripts/build_openssl.sh
- sudo add-apt-repository ppa:tah83/secp256k1 -y
- sudo apt-get update
- sudo apt-get install libsecp256k1-dev
Expand All @@ -33,5 +33,5 @@ before_install:
- eval `opam config env`
- rm $HOME/.opam/log/*
script:
- CPLUS_INCLUDE_PATH=${HOME}/openssl/install/include LIBRARY_PATH=${HOME}/openssl/install/lib LD_LIBRARY_PATH=${HOME}/openssl/install/lib make test
- CPLUS_INCLUDE_PATH=${HOME}/openssl/install/include LIBRARY_PATH=${HOME}/openssl/install/lib LD_LIBRARY_PATH=${HOME}/openssl/install/lib make coveralls
- make test
- make coveralls
12 changes: 0 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ RUN apt-get update \
libboost-system-dev \
&& rm -rf /var/lib/apt/lists/*

# ARG OPENSSL_INSTALL_DIR=/opt/openssl
# ENV CPLUS_INCLUDE_PATH=${OPENSSL_INSTALL_DIR}/include
# ENV LIBRARY_PATH=${OPENSSL_INSTALL_DIR}/lib
# ENV LD_LIBRARY_PATH=${OPENSSL_INSTALL_DIR}/lib

# RUN cd ${HOME} \
# && curl -LO https://github.com/openssl/openssl/archive/OpenSSL_1_1_1a.tar.gz \
# && tar zxvf OpenSSL_1_1_1a.tar.gz && cd openssl-OpenSSL_1_1_1a \
# && ./config --prefix=${OPENSSL_INSTALL_DIR} --openssldir=${OPENSSL_INSTALL_DIR} \
# && make -j$(nproc) && make install && cd ${HOME} \
# && rm -rf OpenSSL_1_1_1a.tar.gz openssl-OpenSSL_1_1_1a

RUN cd /scilla && make opamdep \
&& echo '. ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true ' >> ~/.bashrc \
&& eval `opam config env` && \
Expand Down
12 changes: 0 additions & 12 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ RUN apt-get update \
libboost-system-dev \
&& rm -rf /var/lib/apt/lists/*

# ARG OPENSSL_INSTALL_DIR=/opt/openssl
# ENV CPLUS_INCLUDE_PATH=${OPENSSL_INSTALL_DIR}/include
# ENV LIBRARY_PATH=${OPENSSL_INSTALL_DIR}/lib
# ENV LD_LIBRARY_PATH=${OPENSSL_INSTALL_DIR}/lib

# RUN cd ${HOME} \
# && curl -LO https://github.com/openssl/openssl/archive/OpenSSL_1_1_1a.tar.gz \
# && tar zxvf OpenSSL_1_1_1a.tar.gz && cd openssl-OpenSSL_1_1_1a \
# && ./config --prefix=${OPENSSL_INSTALL_DIR} --openssldir=${OPENSSL_INSTALL_DIR} \
# && make -j$(nproc) && make install && cd ${HOME} \
# && rm -rf OpenSSL_1_1_1a.tar.gz openssl-OpenSSL_1_1_1a

RUN cd /scilla && make opamdep \
&& echo '. ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true ' >> ~/.bashrc \
&& eval `opam config env` && \
Expand Down
13 changes: 7 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ than the one specified below.

### Ubuntu

On machines older than Ubuntu 18.04, run these additional commands first: The last three lines must also be added to your `~/.bashrc`.
On machines with Ubuntu 18.04 or later, run these additional commands first: The last three lines must also be added to your `~/.bashrc`.

```
# Add Ubuntu PPA for libsecp256k1-dev
sudo add-apt-repository ppa:tah83/secp256k1 -y
# Fetch, build and install OpenSSL 1.1.1 into ${HOME}/openssl.
# Fetch, build and install OpenSSL 1.0.2n into ${HOME}/openssl.
./scripts/build_openssl.sh
# Exports for using OpenSSL 1.1.1 built above, instead of system OpenSSL.
# Exports for using OpenSSL 1.0.2n built above, instead of system OpenSSL.
export CPLUS_INCLUDE_PATH="${HOME}/openssl/install/include:${CPLUS_INCLUDE_PATH}"
export C_INCLUDE_PATH="${HOME}/openssl/install/include:${CPLUS_INCLUDE_PATH}"
export LIBRARY_PATH="${HOME}/openssl/install/lib:${LIBRARY_PATH}"
export LD_LIBRARY_PATH="${HOME}/openssl/install/lib:${LD_LIBRARY_PATH}"
```
Expand Down Expand Up @@ -61,9 +62,9 @@ to setup the environment for your current shell.
eval `opam config env`
```

Scilla requires OpenSSL 1.1+ and if your platform does not have packages for this, you may need to build OpenSSL
yourself and set $CPLUS_INCLUDE_PATH, $LIBRARY_PATH and $LD_LIBRARY_PATH accordingly (if you install OpenSSL in
a non-default path).
Scilla requires OpenSSL 1.0.2 and if your platform does not have packages for this, you may need to build OpenSSL
yourself and set $CPLUS_INCLUDE_PATH, $C_INCLUDE_PATH, $LIBRARY_PATH and $LD_LIBRARY_PATH accordingly
(if you install OpenSSL in a non-default path).

### Mac OS X

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ default: all
# multiple subcommands and uses the library.
# The library can be loaded in utop for interactive testing.
all:
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build @install
dune build @install
@test -L bin || ln -s _build/install/default/bin .

# Build only scilla-checker and scilla-runner
slim:
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build src/runners/scilla_runner.exe
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build src/runners/scilla_checker.exe
dune build src/runners/scilla_runner.exe
dune build src/runners/scilla_checker.exe
@test -L bin || mkdir bin; ln -s _build/default/src/runners/*.exe bin/

# Launch utop such that it finds the libraroes.
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

git clone https://github.com/openssl/openssl.git ~/openssl/src
cd ~/openssl/src
git checkout tags/OpenSSL_1_1_1
git checkout tags/OpenSSL_1_0_2n
./config --prefix=${HOME}/openssl/install --openssldir=${HOME}/openssl/ssl
make -j4
make install
130 changes: 77 additions & 53 deletions src/cpp/DataConversion.cpp
Original file line number Diff line number Diff line change
@@ -1,79 +1,103 @@
/*
* Copyright (c) 2018 Zilliqa
* This source code is being disclosed to you solely for the purpose of your
* participation in testing Zilliqa. You may view, compile and run the code for
* that purpose and pursuant to the protocols and algorithms that are programmed
* into, and intended by, the code. You may not do anything else with the code
* without express permission from Zilliqa Research Pte. Ltd., including
* modifying or publishing the code (or any part of it), and developing or
* forming another public or private blockchain network. This source code is
* provided 'as is' and no warranties are given as to title or non-infringement,
* merchantability or fitness for purpose and, to the extent permitted by law,
* all liability for your use of the code is disclaimed. Some programs in this
* code are governed by the GNU General Public License v3.0 (available at
* https://www.gnu.org/licenses/gpl-3.0.en.html) ('GPLv3'). The programs that
* are governed by GPLv3.0 are those programs that are located in the folders
* src/depends and tests/depends and which include a reference to GPLv3 in their
* program files.
* Copyright (C) 2019 Zilliqa
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "DataConversion.h"

using namespace std;

const vector<unsigned char> DataConversion::HexStrToUint8Vec(
const string& hex_input) {
vector<uint8_t> out;
boost::algorithm::unhex(hex_input.begin(), hex_input.end(),
back_inserter(out));
return out;
bool DataConversion::HexStrToUint8Vec(const string& hex_input, bytes& out) {
try {
out.clear();
boost::algorithm::unhex(hex_input.begin(), hex_input.end(),
back_inserter(out));
} catch (exception& e) {
LOG_GENERAL(WARNING, "Failed HexStrToUint8Vec conversion");
return false;
}
return true;
}

const array<unsigned char, 32> DataConversion::HexStrToStdArray(
const string& hex_input) {
array<unsigned char, 32> d = {0};
vector<unsigned char> v = HexStrToUint8Vec(hex_input);
copy(v.begin(), v.begin() + min((int)v.size(), 32), d.begin());
return d;
bool DataConversion::HexStrToStdArray(const string& hex_input,
array<uint8_t, 32>& d) {
d = {0};
bytes v;
if (HexStrToUint8Vec(hex_input, v)) {
copy(v.begin(), v.begin() + min((int)v.size(), 32), d.begin());
return true;
}
LOG_GENERAL(WARNING, "Failed HexStrToStdArray conversion");
return false;
}

const array<unsigned char, 64> DataConversion::HexStrToStdArray64(
const string& hex_input) {
array<unsigned char, 64> d = {0};
vector<unsigned char> v = HexStrToUint8Vec(hex_input);
copy(v.begin(), v.begin() + min((int)v.size(), 64), d.begin());
return d;
bool DataConversion::HexStrToStdArray64(const string& hex_input,
array<uint8_t, 64>& d) {
d = {0};
bytes v;
if (HexStrToUint8Vec(hex_input, v)) {
copy(v.begin(), v.begin() + min((int)v.size(), 64), d.begin());
return true;
}
LOG_GENERAL(WARNING, "Failed HexStrToStdArray conversion");
return false;
}

const string DataConversion::Uint8VecToHexStr(
const vector<unsigned char>& hex_vec) {
string str;
boost::algorithm::hex(hex_vec.begin(), hex_vec.end(), back_inserter(str));
return str;
bool DataConversion::Uint8VecToHexStr(const bytes& hex_vec, string& str) {
try {
str = "";
boost::algorithm::hex(hex_vec.begin(), hex_vec.end(), back_inserter(str));
} catch (exception& e) {
LOG_GENERAL(WARNING, "Failed Uint8VecToHexStr conversion");
return false;
}
return true;
}

const string DataConversion::Uint8VecToHexStr(
const vector<unsigned char>& hex_vec, unsigned int offset,
unsigned int len) {
string str;
boost::algorithm::hex(hex_vec.begin() + offset,
hex_vec.begin() + offset + len, back_inserter(str));
return str;
bool DataConversion::Uint8VecToHexStr(const bytes& hex_vec, unsigned int offset,
unsigned int len, string& str) {
try {
str = "";
boost::algorithm::hex(hex_vec.begin() + offset,
hex_vec.begin() + offset + len, back_inserter(str));
} catch (exception& e) {
LOG_GENERAL(WARNING, "Failed Uint8VecToHexStr conversion");
return false;
}
return true;
}

string DataConversion::SerializableToHexStr(const Serializable& input) {
vector<unsigned char> tmp;
bool DataConversion::SerializableToHexStr(const Serializable& input,
string& str) {
bytes tmp;
input.Serialize(tmp, 0);
string str;
boost::algorithm::hex(tmp.begin(), tmp.end(), back_inserter(str));
return str;
try {
str = "";
boost::algorithm::hex(tmp.begin(), tmp.end(), back_inserter(str));
} catch (exception& e) {
LOG_GENERAL(WARNING, "Failed SerializableToHexStr conversion");
return false;
}
return true;
}

uint16_t DataConversion::charArrTo16Bits(const vector<unsigned char>& hex_arr) {
uint16_t DataConversion::charArrTo16Bits(const bytes& hex_arr) {
if (hex_arr.size() == 0) {
return 0;
}
uint32_t lsb = hex_arr.size() - 1;

return (hex_arr.at(lsb - 1) << 8) | hex_arr.at(lsb);
}
}
Loading

0 comments on commit 6c95aaa

Please sign in to comment.