14 #include "feature/control/control_hs.h"
36 SPLIT_IGNORE_BLANK, 0);
37 if (smartlist_len(key_args) != 2) {
42 const char *key_type = smartlist_get(key_args, 0);
43 const char *key_blob = smartlist_get(key_args, 1);
45 if (strcasecmp(key_type,
"x25519")) {
47 "Unrecognized key type \"%s\"", key_type);
51 if (
base64_decode((
char*)privkey->secret_key,
sizeof(privkey->secret_key),
53 strlen(key_blob)) !=
sizeof(privkey->secret_key)) {
59 sizeof(privkey->secret_key))) {
61 "Invalid private key \"%s\"", key_blob);
69 smartlist_free(key_args);
76 .accept_keywords =
true,
95 int argc = smartlist_len(args->
args);
99 "Incomplete ONION_CLIENT_AUTH_ADD command");
105 const char *hsaddress = smartlist_get(args->
args, 0);
113 const char *client_privkey = smartlist_get(args->
args, 1);
123 if (smartlist_len(flags) < 1) {
128 if (!strcasecmp(flag,
"Permanent")) {
135 } SMARTLIST_FOREACH_END(flag);
137 if (!strcasecmp(line->key,
"ClientName")) {
146 hs_client_register_auth_status_t register_status;
149 switch (register_status) {
150 case REGISTER_FAIL_BAD_ADDRESS:
154 case REGISTER_FAIL_PERMANENT_STORAGE:
158 case REGISTER_SUCCESS_ALREADY_EXISTS:
161 case REGISTER_SUCCESS_AND_DECRYPTED:
164 case REGISTER_SUCCESS:
175 client_service_authorization_free(creds);
179 smartlist_free(flags);
186 .accept_keywords =
true,
201 int argc = smartlist_len(args->
args);
204 "Incomplete ONION_CLIENT_AUTH_REMOVE command");
208 const char *hsaddress = smartlist_get(args->
args, 0);
214 hs_client_removal_auth_status_t removal_status;
216 switch (removal_status) {
217 case REMOVAL_BAD_ADDRESS:
221 case REMOVAL_SUCCESS_NOT_FOUND:
224 case REMOVAL_SUCCESS:
244 char x25519_b64[128];
245 char *msg_str = NULL;
251 sizeof(cred->
enc_seckey.secret_key), 0) < 0) {
274 smartlist_free(control_line);
282 .accept_keywords =
true,
294 const char *hsaddress = NULL;
301 int argc = smartlist_len(args->
args);
303 hsaddress = smartlist_get(args->
args, 0);
319 digest256map_iter_t *itr = digest256map_iter_init(
client_auths);
320 while (!digest256map_iter_done(itr)) {
321 const uint8_t *service_pubkey;
323 digest256map_iter_get(itr, &service_pubkey, &valp);
334 tor_assert_nonfatal(encoding_str);
344 } SMARTLIST_FOREACH_END(c);
352 smartlist_free(creds_str_list);
int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen, int flags)
Header file for control_cmd.c.
Definition for control_cmd_args_t.
int handle_control_onion_client_auth_view(control_connection_t *conn, const control_cmd_args_t *args)
static int parse_private_key_from_control_port(const char *client_privkey_str, curve25519_secret_key_t *privkey, control_connection_t *conn)
int handle_control_onion_client_auth_add(control_connection_t *conn, const control_cmd_args_t *args)
static char * encode_client_auth_cred_for_control_port(hs_client_service_authorization_t *cred)
const control_cmd_syntax_t onion_client_auth_add_syntax
const control_cmd_syntax_t onion_client_auth_remove_syntax
int handle_control_onion_client_auth_remove(control_connection_t *conn, const control_cmd_args_t *args)
const control_cmd_syntax_t onion_client_auth_view_syntax
void control_write_endreply(control_connection_t *conn, int code, const char *s)
void control_printf_midreply(control_connection_t *conn, int code, const char *fmt,...)
void send_control_done(control_connection_t *conn)
void control_printf_endreply(control_connection_t *conn, int code, const char *fmt,...)
Header file for control_proto.c.
const char * escaped(const char *s)
digest256map_t * get_hs_client_auths_map(void)
hs_client_register_auth_status_t hs_client_register_auth_credentials(hs_client_service_authorization_t *creds)
static digest256map_t * client_auths
hs_client_removal_auth_status_t hs_client_remove_auth_credentials(const char *hsaddress)
Header file containing client data for the HS subsystem.
#define CLIENT_AUTH_FLAG_IS_PERMANENT
int hs_address_is_valid(const char *address)
Master header file for Tor-specific functionality.
#define REND_CLIENTNAME_MAX_LEN
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
void smartlist_sort_strings(smartlist_t *sl)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
struct smartlist_t * args
struct config_line_t * kwargs
char onion_address[HS_SERVICE_ADDR_LEN_BASE32+1]
curve25519_secret_key_t enc_seckey
#define tor_assert_nonfatal_unreached()
int strcasecmpstart(const char *s1, const char *s2)
int fast_mem_is_zero(const char *mem, size_t len)