forked from openssh/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply upstream refactor to sshkey.c (#160)
Signed-off-by: Gerardo Ravago <[email protected]>
- Loading branch information
Showing
25 changed files
with
841 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{%- for kex in config['kexs'] %} | ||
"{{ kex['pretty_name'] }}", | ||
{%- for curve in kex['mix_with'] %} | ||
"{{ curve['pretty_name'] }}", | ||
# "{{ curve['pretty_name'] }}", | ||
{%- endfor -%} | ||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{%- for sig in config['sigs'] %} | ||
"ssh-{{ sig['name']|replace('_','') }}", | ||
{%- for alg in sig['mix_with'] %} | ||
"ssh-{{ alg['name']|replace('_','-') }}-{{ sig['name']|replace('_','') }}", | ||
# "ssh-{{ alg['name']|replace('_','-') }}-{{ sig['name']|replace('_','') }}", | ||
{%- endfor -%} | ||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{%- for sig in config['sigs'] %} | ||
n += do_print_resource_record(pw, | ||
_PATH_HOST_{{ sig['name']|upper }}_KEY_FILE, rr_hostname, | ||
print_generic); | ||
print_generic, opts, nopts); | ||
{%- for alg in sig['mix_with'] %} | ||
n += do_print_resource_record(pw, | ||
_PATH_HOST_{{ alg['name']|upper }}_{{ sig['name']|upper }}_KEY_FILE, rr_hostname, | ||
print_generic); | ||
print_generic, opts, nopts); | ||
{%- endfor %} | ||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,116 @@ | ||
{%- for sig in config['sigs'] %} | ||
{%- set symbol_base_name = sig['name']|replace('_','') %} | ||
/*--------------------------------------------------- | ||
* {{ sig['name']|upper }} METHODS | ||
*--------------------------------------------------- | ||
*/ | ||
int ssh_{{ sig['name']|replace('_','') }}_sign(const struct sshkey *key, | ||
static int ssh_{{ symbol_base_name }}_generate(struct sshkey *k, int bits) | ||
{ | ||
k->oqs_pk_len = oqs_sig_pk_len(k->type); | ||
k->oqs_sk_len = oqs_sig_sk_len(k->type); | ||
if ((k->oqs_pk = malloc(k->oqs_pk_len)) == NULL || | ||
(k->oqs_sk = malloc(k->oqs_sk_len)) == NULL) { | ||
return SSH_ERR_ALLOC_FAIL; | ||
} | ||
return OQS_SIG_{{ sig['name'] }}_keypair(k->oqs_pk, k->oqs_sk); | ||
} | ||
|
||
int ssh_{{ symbol_base_name }}_sign(const struct sshkey *key, | ||
u_char **sigp, | ||
size_t *lenp, | ||
const u_char *data, | ||
size_t datalen, | ||
const char *alg, | ||
const char *sk_provider, | ||
const char *sk_pin, | ||
u_int compat) | ||
{ | ||
OQS_SIG *sig = OQS_SIG_new(OQS_SIG_alg_{{ sig['name'] }}); | ||
if (sig == NULL) { | ||
return SSH_ERR_ALLOC_FAIL; | ||
} | ||
int r = ssh_generic_sign(sig, "{{ sig['name']|replace('_','') }}", key, sigp, lenp, data, datalen, compat); | ||
int r = ssh_generic_sign(sig, "{{ symbol_base_name }}", key, sigp, lenp, data, datalen, compat); | ||
OQS_SIG_free(sig); | ||
return r; | ||
} | ||
int ssh_{{ sig['name']|replace('_','') }}_verify(const struct sshkey *key, | ||
|
||
int ssh_{{ symbol_base_name }}_verify(const struct sshkey *key, | ||
const u_char *signature, | ||
size_t signaturelen, | ||
const u_char *data, | ||
size_t datalen, | ||
const char *alg, | ||
u_int compat) | ||
{ | ||
OQS_SIG *sig = OQS_SIG_new(OQS_SIG_alg_{{ sig['name'] }}); | ||
if (sig == NULL) { | ||
return SSH_ERR_ALLOC_FAIL; | ||
} | ||
int r = ssh_generic_verify(sig, "{{ sig['name']|replace('_','') }}", key, signature, signaturelen, data, datalen, compat); | ||
int r = ssh_generic_verify(sig, "{{ symbol_base_name }}", key, signature, signaturelen, data, datalen, compat); | ||
OQS_SIG_free(sig); | ||
return r; | ||
} | ||
|
||
static const struct sshkey_impl_funcs sshkey_{{ symbol_base_name }}_funcs = { | ||
/* .size = */ ssh_generic_size, | ||
/* .alloc = */ ssh_generic_alloc, | ||
/* .cleanup = */ ssh_generic_cleanup, | ||
/* .equal = */ ssh_generic_equal, | ||
/* .ssh_serialize_public = */ ssh_generic_serialize_public, | ||
/* .ssh_deserialize_public = */ ssh_generic_deserialize_public, | ||
/* .ssh_serialize_private = */ ssh_generic_serialize_private, | ||
/* .ssh_deserialize_private = */ ssh_generic_deserialize_private, | ||
/* .generate = */ ssh_{{ symbol_base_name }}_generate, | ||
/* .copy_public = */ ssh_generic_copy_public, | ||
/* .sign = */ ssh_{{ symbol_base_name }}_sign, | ||
/* .verify = */ ssh_{{ symbol_base_name }}_verify, | ||
}; | ||
|
||
const struct sshkey_impl sshkey_{{ symbol_base_name }}_impl = { | ||
/* .name = */ "ssh-{{ symbol_base_name }}", | ||
/* .shortname = */ "{{ symbol_base_name|upper }}", | ||
/* .sigalg = */ NULL, | ||
/* .type = */ KEY_{{ sig['name']|upper }}, | ||
/* .nid = */ 0, | ||
/* .cert = */ 0, | ||
/* .sigonly = */ 0, | ||
/* .keybits = */ 256, // TODO - What should be here? | ||
/* .funcs = */ &sshkey_{{ symbol_base_name }}_funcs, | ||
}; | ||
{%- endfor %} | ||
|
||
#ifdef HYBRID_IMPLEMENTATION_EXISTS | ||
// #ifdef WITH_OPENSSL | ||
{%- for sig in config['sigs'] %} | ||
{%- for alg in sig['mix_with'] if alg['rsa'] %} | ||
{%- set symbol_base_name = alg['name']|replace('_','') + '_' + sig['name']|replace('_','') %} | ||
static const struct sshkey_impl_funcs sshkey_{{ symbol_base_name }}_funcs = { | ||
/* .size = */ ssh_generic_size, | ||
/* .alloc = */ ssh_generic_alloc, | ||
/* .cleanup = */ ssh_generic_cleanup, | ||
/* .equal = */ ssh_generic_equal, | ||
/* .ssh_serialize_public = */ ssh_generic_serialize_public, | ||
/* .ssh_deserialize_public = */ ssh_generic_deserialize_public, | ||
/* .ssh_serialize_private = */ ssh_generic_serialize_private, | ||
/* .ssh_deserialize_private = */ ssh_generic_deserialize_private, | ||
/* .generate = */ ssh_{{ symbol_base_name }}_generate, | ||
/* .copy_public = */ ssh_generic_copy_public, | ||
/* .sign = */ ssh_{{ symbol_base_name }}_sign, | ||
/* .verify = */ ssh_{{ symbol_base_name }}_verify, | ||
}; | ||
|
||
const struct sshkey_impl sshkey_{{ symbol_base_name }}_impl = { | ||
/* .name = */ "ssh-{{ symbol_base_name }}", | ||
/* .shortname = */ "{{ symbol_base_name|upper }}", | ||
/* .sigalg = */ NULL, | ||
/* .type = */ KEY_{{ sig['name']|upper }}, | ||
/* .nid = */ 0, | ||
/* .cert = */ 0, | ||
/* .sigonly = */ 0, | ||
/* .keybits = */ 256, // TODO - What should be here? | ||
/* .funcs = */ &sshkey_{{ symbol_base_name }}_funcs, | ||
}; | ||
{%- endfor %} | ||
{%- endfor %} | ||
#endif /* WITH_OPENSSL */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- for sig in config['sigs'] %} | ||
case KEY_{{ sig['name']|upper }}: | ||
{%- for alg in sig['mix_with'] %} | ||
case KEY_{{ alg['name']|upper }}_{{ sig['name']|upper }}: | ||
{%- endfor -%} | ||
return OQS_SIG_{{ sig['name'] }}_length_public_key; | ||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- for sig in config['sigs'] %} | ||
case KEY_{{ sig['name']|upper }}: | ||
{%- for alg in sig['mix_with'] %} | ||
case KEY_{{ alg['name']|upper }}_{{ sig['name']|upper }}: | ||
{%- endfor %} | ||
return OQS_SIG_{{ sig['name'] }}_length_secret_key; | ||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{%- for sig in config['sigs'] %} | ||
extern const struct sshkey_impl sshkey_{{ sig['name']|replace('_','') }}_impl; | ||
{%- endfor %} | ||
|
||
#ifdef HYBRID_IMPLEMENTATION_EXISTS | ||
// #ifdef WITH_OPENSSL | ||
{%- for sig in config['sigs'] %} | ||
{%- for alg in sig['mix_with'] if alg['rsa'] %} | ||
extern const struct sshkey_impl sshkey_{{ alg['name']|replace('_','') }}_{{ sig['name']|replace('_','') }}_impl; | ||
{%- endfor %} | ||
{%- endfor %} | ||
#ifdef OPENSSL_HAS_ECC | ||
{%- for sig in config['sigs'] %} | ||
{%- for alg in sig['mix_with'] if not alg['rsa'] %} | ||
extern const struct sshkey_impl sshkey_{{ alg['name']|replace('_','') }}_{{ sig['name']|replace('_','') }}_impl; | ||
{%- endfor %} | ||
{%- endfor %} | ||
#endif /* OPENSSL_HAS_ECC */ | ||
#endif /* WITH_OPENSSL */ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
oqs-template/sshkey.c/sshkey_generate_switch_keytype.fragment
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
oqs-template/sshkey.c/sshkey_verify_switch_keytype.fragment
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.