diff --git a/cellframe-sdk b/cellframe-sdk index 828a6b42ed4ec9f6cfdf33a01cf6c6bc573ed03b..8cdb1a3cc280386ef982943ed14fe266c11aad57 160000 --- a/cellframe-sdk +++ b/cellframe-sdk @@ -1 +1 @@ -Subproject commit 828a6b42ed4ec9f6cfdf33a01cf6c6bc573ed03b +Subproject commit 8cdb1a3cc280386ef982943ed14fe266c11aad57 diff --git a/python-cellframe b/python-cellframe index 6a774f3a8f73ff8bf5c29d802728799f7a616c48..37c95060177e9d6822756ed9667c24f240a0208a 160000 --- a/python-cellframe +++ b/python-cellframe @@ -1 +1 @@ -Subproject commit 6a774f3a8f73ff8bf5c29d802728799f7a616c48 +Subproject commit 37c95060177e9d6822756ed9667c24f240a0208a diff --git a/sources/main_node_tool.c b/sources/main_node_tool.c index 7cb35eb7788df3b8066a0da45411217ccefe1ded..0eed2f74682755b87ad14051bfa12c4c8d0bf369 100644 --- a/sources/main_node_tool.c +++ b/sources/main_node_tool.c @@ -217,29 +217,26 @@ int main(int argc, const char **argv) }*/ } // wallet else if (strcmp (argv[1],"cert") == 0 ) { - if (argc == 3) { - if (strcmp (argv[2], "create_pkey_hash") == 0) { - dap_config_t *l_config = dap_config_open("network/private"); - if (!l_config) { - log_it(L_ERROR, "Not found a private config - private.cfg"); - exit(-111); - } - uint16_t ui_acl_list_len; - dap_cert_t *l_cert = NULL; - - l_cert = dap_cert_find_by_name(dap_config_get_item_str(l_config, "general", "auth_cert")); - - size_t st_size = sizeof(dap_hash_fast_t); - unsigned char *l_data = DAP_NEW_Z_SIZE(unsigned char, st_size + 1); - s_fill_hash_key_for_data(l_cert->enc_key, l_data); - for (int i = 0; i < st_size; i++) { - printf("%02x", l_data[i]); - } - printf("\n"); - exit(0); - } - } if ( argc >=3 ) { + if (argc >= 5) { + if (strcmp (argv[2], "pkey") == 0 && strcmp (argv[3], "show") == 0) { + dap_cert_t *l_cert = dap_cert_find_by_name(argv[4]); + if (!l_cert) { + printf("Not found cert: %s\n", argv[4]); + exit(-134); + } + + size_t l_buf_len; + uint8_t *l_pub_enc_key = dap_enc_key_serealize_pub_key(l_cert->enc_key, &l_buf_len); + + dap_hash_fast_t l_hash; + dap_hash_fast (l_pub_enc_key, l_buf_len, &l_hash); + + char *l_hash_str = dap_chain_hash_fast_to_str_new(&l_hash); + printf("%s\n", l_hash_str); + exit(0); + } + } if ( strcmp( argv[2],"dump") == 0 ){ if (argc>=4) { const char * l_cert_name = argv[3]; @@ -586,4 +583,6 @@ static void s_help() printf(" * Add metadata item to <cert name>\n"); printf("\t%s cert add_metadata <cert name> <key:type:length:value>\n\n",dap_get_appname()); + printf(" * Print hash of cert <cert name>\n"); + printf("\t%s cert pkey show <cert name>\n\n",dap_get_appname()); }