diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-10-12 14:10:08 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-10-13 10:57:59 +0200 |
commit | 988e2af4b7a0c1bc70188674cfde2bf8b2838bd7 (patch) | |
tree | 6cc10692587c0a92cb02d89e19573723051808f0 /backport/compat/verification/rsapubkey-asn1.c | |
parent | f82274f97829d7f9e11a9793546ba88b084e1199 (diff) |
backports: add signature verification code
Uh, this was awful. Because the crypto/ things are completely
impossible to backport, I've actually implemented this by using
mbedtls and embedding the relevant functions it has...
The mbedtls code is taken from mbedtls version 2.6.0 and only
minimally modified (mostly to remove <string.h> and similar).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport/compat/verification/rsapubkey-asn1.c')
-rw-r--r-- | backport/compat/verification/rsapubkey-asn1.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/backport/compat/verification/rsapubkey-asn1.c b/backport/compat/verification/rsapubkey-asn1.c new file mode 100644 index 00000000..84ab7f4e --- /dev/null +++ b/backport/compat/verification/rsapubkey-asn1.c @@ -0,0 +1,38 @@ +/* + * Automatically generated by asn1_compiler. Do not edit + * + * ASN.1 parser for rsapubkey + */ +#include <linux/asn1_ber_bytecode.h> +#include "rsapubkey-asn1.h" + +enum rsapubkey_actions { + ACT_rsa_get_e = 0, + ACT_rsa_get_n = 1, + NR__rsapubkey_actions = 2 +}; + +static const asn1_action_t rsapubkey_action_table[NR__rsapubkey_actions] = { + [ 0] = rsa_get_e, + [ 1] = rsa_get_n, +}; + +static const unsigned char rsapubkey_machine[] = { + // RsaPubKey + [ 0] = ASN1_OP_MATCH, + [ 1] = _tag(UNIV, CONS, SEQ), + [ 2] = ASN1_OP_MATCH_ACT, // n + [ 3] = _tag(UNIV, PRIM, INT), + [ 4] = _action(ACT_rsa_get_n), + [ 5] = ASN1_OP_MATCH_ACT, // e + [ 6] = _tag(UNIV, PRIM, INT), + [ 7] = _action(ACT_rsa_get_e), + [ 8] = ASN1_OP_END_SEQ, + [ 9] = ASN1_OP_COMPLETE, +}; + +const struct asn1_decoder rsapubkey_decoder = { + .machine = rsapubkey_machine, + .machlen = sizeof(rsapubkey_machine), + .actions = rsapubkey_action_table, +}; |