From c1bb07e65f550e043d9a387d3978e651a1b7a15d Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 2 Jul 2019 03:00:31 -0400 Subject: enable TLS for replica-replica connections --- src/hotstuff_tls_keygen.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/hotstuff_tls_keygen.cpp (limited to 'src/hotstuff_tls_keygen.cpp') diff --git a/src/hotstuff_tls_keygen.cpp b/src/hotstuff_tls_keygen.cpp new file mode 100644 index 0000000..1ce80f2 --- /dev/null +++ b/src/hotstuff_tls_keygen.cpp @@ -0,0 +1,46 @@ +/** + * Copyright 2018 VMware + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "salticidae/util.h" +#include "salticidae/crypto.h" +#include "hotstuff/type.h" + +using salticidae::Config; +using hotstuff::tls_pkey_bt; +using hotstuff::tls_x509_bt; + +int main(int argc, char **argv) { + Config config("hotstuff.conf"); + tls_pkey_bt priv_key; + tls_x509_bt pub_key; + auto opt_n = Config::OptValInt::create(1); + config.add_opt("num", opt_n, Config::SET_VAL); + config.parse(argc, argv); + int n = opt_n->get(); + if (n < 1) + error(1, 0, "n must be >0"); + while (n--) + { + priv_key = new salticidae::PKey(salticidae::PKey::create_privkey_rsa()); + pub_key = new salticidae::X509(salticidae::X509::create_self_signed_from_pubkey(*priv_key)); + printf("crt:%s sec:%s cid:%s\n", + salticidae::get_hex(pub_key->get_der()).c_str(), + salticidae::get_hex(priv_key->get_privkey_der()).c_str(), + salticidae::get_hex(salticidae::get_hash(pub_key->get_der())).c_str()); + } + return 0; +} -- cgit v1.2.3-70-g09d2