/* * Show IKE algorithms for * - this connection (result from ike= string) * - newest SA */ void ike_alg_show_connection(struct connection *c, const char *instance) { struct state *st; if (c->alg_info_ike) { char buf[1024]; alg_info_snprint(buf, sizeof(buf) - 1, (struct alg_info *)c->alg_info_ike); whack_log(RC_COMMENT, "\"%s\"%s: IKE algorithms wanted: %s", c->name, instance, buf); alg_info_snprint_ike(buf, sizeof(buf), c->alg_info_ike); whack_log(RC_COMMENT, "\"%s\"%s: IKE algorithms found: %s", c->name, instance, buf); } st = state_with_serialno(c->newest_isakmp_sa); if (st != NULL) { static char encbuf[ENUM_SHOW_BUF_LEN]; static char prfbuf[ENUM_SHOW_BUF_LEN]; static char integbuf[ENUM_SHOW_BUF_LEN]; static char groupbuf[ENUM_SHOW_BUF_LEN]; if (!st->st_ikev2) { /* IKEv1 */ whack_log(RC_COMMENT, "\"%s\"%s: IKE algorithm newest: %s_%03d-%s-%s", c->name, instance, strip_prefix(enum_showb(&oakley_enc_names, st->st_oakley.encrypt, encbuf, sizeof(encbuf)), "OAKLEY_"), /* st->st_oakley.encrypter->keydeflen, */ st->st_oakley.enckeylen, strip_prefix(enum_showb(&oakley_hash_names, st->st_oakley.prf_hash, prfbuf, sizeof(prfbuf)), "OAKLEY_"), strip_prefix(enum_showb(&oakley_group_names, st->st_oakley.group->group, groupbuf, sizeof(groupbuf)), "OAKLEY_GROUP_")); } else { /* IKEv2 */ whack_log(RC_COMMENT, "\"%s\"%s: IKEv2 algorithm newest: %s_%03d-%s-%s-%s", c->name, instance, enum_showb(&ikev2_trans_type_encr_names, st->st_oakley.encrypt, encbuf, sizeof(encbuf)), /* st->st_oakley.encrypter->keydeflen, */ st->st_oakley.enckeylen, enum_showb(&ikev2_trans_type_integ_names, st->st_oakley.integ_hash, integbuf, sizeof(integbuf)), enum_showb(&ikev2_trans_type_prf_names, st->st_oakley.prf_hash, prfbuf, sizeof(prfbuf)), strip_prefix(enum_showb(&oakley_group_names, st->st_oakley.group->group, groupbuf, sizeof(groupbuf)), "OAKLEY_GROUP_")); } } }
static int snprint_esp_info(char *ptr, size_t buflen, const char *sep, const struct esp_info *esp_info) { unsigned eklen = esp_info->enckeylen; unsigned aklen = esp_info->authkeylen; return snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d", sep, strip_prefix(enum_name(&esp_transformid_names, esp_info->transid), "ESP_"), esp_info->transid, eklen, strip_prefix(strip_prefix(enum_name(&auth_alg_names, esp_info->auth), "AUTH_ALGORITHM_HMAC_"), "AUTH_ALGORITHM_"), esp_info->auth, aklen); }
static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep, LPWSTR *prefix_args, int *prefix_args_len, int *is_git_command, LPWSTR *working_directory, int *full_path, int *skip_arguments, int *allocate_console, int *show_console, int *append_quote_to_cmdline) { int i, id, minimal_search_path, needs_a_console, no_hide, wargc; int append_quote; LPWSTR *wargv; WCHAR *app_id; #define BUFSIZE 65536 static WCHAR buf[BUFSIZE]; LPWSTR buf2 = buf; int len; for (id = 0; ; id++) { minimal_search_path = 0; needs_a_console = 0; no_hide = 0; append_quote = 0; app_id = NULL; len = LoadString(NULL, id, buf, BUFSIZE); if (!len) { if (!id) return 0; /* no resources found */ fwprintf(stderr, L"Need a valid command-line; " L"Edit the string resources accordingly\n"); exit(1); } if (len >= BUFSIZE) { fwprintf(stderr, L"Could not read resource (too large)\n"); exit(1); } for (;;) { if (strip_prefix(buf, &len, L"MINIMAL_PATH=1 ")) minimal_search_path = 1; else if (strip_prefix(buf, &len, L"ALLOC_CONSOLE=1 ")) needs_a_console = 1; else if (strip_prefix(buf, &len, L"SHOW_CONSOLE=1 ")) no_hide = 1; else if (strip_prefix(buf, &len, L"APPEND_QUOTE=1 ")) append_quote = 1; else if (strip_prefix(buf, &len, L"APP_ID=")) { LPWSTR space = wcschr(buf, L' '); size_t app_id_len = space - buf; if (!space) { len -= 7; memmove(buf, buf + 7, len * sizeof(WCHAR)); break; } app_id = wcsdup(buf); app_id[app_id_len] = L'\0'; len -= app_id_len + 1; memmove(buf, buf + app_id_len + 1, len * sizeof(WCHAR)); } else break; } buf[len] = L'\0'; if (!id) SetEnvironmentVariable(L"EXEPATH", exepath); buf2 = expand_variables(buf, BUFSIZE); extract_first_arg(buf2, exepath, exep); if (_waccess(exep, 0) != -1) break; fwprintf(stderr, L"Skipping command-line '%s'\n('%s' not found)\n", buf2, exep); if (app_id) free(app_id); } *prefix_args = buf2; *prefix_args_len = wcslen(buf2); *is_git_command = 0; wargv = CommandLineToArgvW(GetCommandLine(), &wargc); for (i = 1; i < wargc; i++) { if (!wcscmp(L"--no-cd", wargv[i])) *working_directory = NULL; else if (!wcscmp(L"--cd-to-home", wargv[i])) *working_directory = (LPWSTR) 1; else if (!wcsncmp(L"--cd=", wargv[i], 5)) *working_directory = wcsdup(wargv[i] + 5); else if (!wcscmp(L"--minimal-search-path", wargv[i])) minimal_search_path = 1; else if (!wcscmp(L"--no-minimal-search-path", wargv[i])) minimal_search_path = 0; else if (!wcscmp(L"--needs-console", wargv[i])) needs_a_console = 1; else if (!wcscmp(L"--no-needs-console", wargv[i])) needs_a_console = 0; else if (!wcscmp(L"--hide", wargv[i])) no_hide = 0; else if (!wcscmp(L"--no-hide", wargv[i])) no_hide = 1; else if (!wcscmp(L"--append-quote", wargv[i])) append_quote = 1; else if (!wcscmp(L"--no-append-quote", wargv[i])) append_quote = -1; else if (!wcsncmp(L"--command=", wargv[i], 10)) { LPWSTR expanded; wargv[i] += 10; expanded = expand_variables(wargv[i], wcslen(wargv[i])); if (expanded == wargv[i]) expanded = wcsdup(expanded); extract_first_arg(expanded, exepath, exep); *prefix_args = expanded; *prefix_args_len = wcslen(*prefix_args); *skip_arguments = i; break; } else if (!wcsncmp(L"--app-id=", wargv[i], 9)) { free(app_id); app_id = wcsdup(wargv[i] + 9); } else break; *skip_arguments = i; } if (minimal_search_path) *full_path = 0; if (needs_a_console) *allocate_console = 1; if (no_hide) *show_console = 1; if (append_quote) *append_quote_to_cmdline = append_quote == 1; if (app_id) set_app_id(app_id); LocalFree(wargv); return 1; }