aboutsummaryrefslogtreecommitdiff
path: root/src/hotstuff_tls_keygen.cpp
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-07-02 03:00:31 -0400
committerDeterminant <[email protected]>2019-07-02 03:00:31 -0400
commitc1bb07e65f550e043d9a387d3978e651a1b7a15d (patch)
tree610d501e893c1eead667e558fb58ee85109fd82f /src/hotstuff_tls_keygen.cpp
parent7e91de67703a3a3eb292d1a2422acb15a10d4b95 (diff)
enable TLS for replica-replica connections
Diffstat (limited to 'src/hotstuff_tls_keygen.cpp')
-rw-r--r--src/hotstuff_tls_keygen.cpp46
1 files changed, 46 insertions, 0 deletions
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 <error.h>
+#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;
+}