/*
webid-oidc, implementation of the Solid specification
Copyright (C) 2020, 2021 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
#ifdef HAVE_CONFIG_H
#include
#endif /* HAVE_CONFIG_H */
#include
#include
#include
#include
#define _(s) gettext (s)
SCM webidoidc_generate_key_g (SCM args);
SCM webidoidc_strip_key_g (SCM key);
SCM webidoidc_jkt_g (SCM key);
extern int init_webidoidc (void);
static void
run (void *params, int argc, char *argv[])
{
SCM data;
char *end;
size_t n_size = 0;
(void) params;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (argc != 2
|| (strcmp (argv[1], "P-256") != 0
&& strcmp (argv[1], "P-384") != 0
&& strcmp (argv[1], "P-521") != 0
&& ((n_size = strtoull (argv[1], &end, 10)) == 0 || *end != '\0')))
{
fprintf (stderr, _("Usage: generate-key [NUMBER OF BITS | CURVE]\n"));
exit (1);
}
init_webidoidc ();
if (strcmp (argv[1], "P-256") == 0
|| strcmp (argv[1], "P-384") == 0 || strcmp (argv[1], "P-521") == 0)
{
data =
webidoidc_generate_key_g (scm_list_2
(scm_from_utf8_keyword ("crv"),
scm_from_utf8_symbol (argv[1])));
}
else
{
data =
webidoidc_generate_key_g (scm_list_2
(scm_from_utf8_keyword ("n-size"),
scm_from_size_t (n_size)));
}
scm_display (webidoidc_jkt_g (data), scm_current_error_port ());
fprintf (stderr, "\n");
scm_display (data, scm_current_output_port ());
}
int
main (int argc, char *argv[])
{
scm_boot_guile (argc, argv, run, NULL);
return 0;
}