diff options
Diffstat (limited to 'src/extern.h')
-rw-r--r-- | src/extern.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/extern.h b/src/extern.h new file mode 100644 index 0000000..c35af58 --- /dev/null +++ b/src/extern.h | |||
@@ -0,0 +1,132 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018 Yubico AB. All rights reserved. | ||
3 | * Use of this source code is governed by a BSD-style | ||
4 | * license that can be found in the LICENSE file. | ||
5 | */ | ||
6 | |||
7 | #ifndef _EXTERN_H | ||
8 | #define _EXTERN_H | ||
9 | |||
10 | /* aes256 */ | ||
11 | int aes256_cbc_dec(const fido_blob_t *, const fido_blob_t *, fido_blob_t *); | ||
12 | int aes256_cbc_enc(const fido_blob_t *, const fido_blob_t *, fido_blob_t *); | ||
13 | |||
14 | /* cbor encoding functions */ | ||
15 | cbor_item_t *cbor_flatten_vector(cbor_item_t **, size_t); | ||
16 | cbor_item_t *cbor_encode_assert_options(fido_opt_t, fido_opt_t); | ||
17 | cbor_item_t *cbor_encode_change_pin_auth(const fido_blob_t *, | ||
18 | const fido_blob_t *, const fido_blob_t *); | ||
19 | cbor_item_t *cbor_encode_extensions(int); | ||
20 | cbor_item_t *cbor_encode_hmac_secret_param(const fido_blob_t *, | ||
21 | const es256_pk_t *, const fido_blob_t *); | ||
22 | cbor_item_t *cbor_encode_options(fido_opt_t, fido_opt_t); | ||
23 | cbor_item_t *cbor_encode_pin_auth(const fido_blob_t *, const fido_blob_t *); | ||
24 | cbor_item_t *cbor_encode_pin_enc(const fido_blob_t *, const fido_blob_t *); | ||
25 | cbor_item_t *cbor_encode_pin_hash_enc(const fido_blob_t *, const fido_blob_t *); | ||
26 | cbor_item_t *cbor_encode_pin_opt(void); | ||
27 | cbor_item_t *cbor_encode_pubkey(const fido_blob_t *); | ||
28 | cbor_item_t *cbor_encode_pubkey_list(const fido_blob_array_t *); | ||
29 | cbor_item_t *cbor_encode_pubkey_param(int); | ||
30 | cbor_item_t *cbor_encode_rp_entity(const fido_rp_t *); | ||
31 | cbor_item_t *cbor_encode_set_pin_auth(const fido_blob_t *, const fido_blob_t *); | ||
32 | cbor_item_t *cbor_encode_user_entity(const fido_user_t *); | ||
33 | cbor_item_t *es256_pk_encode(const es256_pk_t *, int); | ||
34 | |||
35 | /* cbor decoding functions */ | ||
36 | int cbor_decode_attstmt(const cbor_item_t *, fido_attstmt_t *); | ||
37 | int cbor_decode_cred_authdata(const cbor_item_t *, int, fido_blob_t *, | ||
38 | fido_authdata_t *, fido_attcred_t *, int *); | ||
39 | int cbor_decode_assert_authdata(const cbor_item_t *, fido_blob_t *, | ||
40 | fido_authdata_t *, int *, fido_blob_t *); | ||
41 | int cbor_decode_cred_id(const cbor_item_t *, fido_blob_t *); | ||
42 | int cbor_decode_fmt(const cbor_item_t *, char **); | ||
43 | int cbor_decode_pubkey(const cbor_item_t *, int *, void *); | ||
44 | int cbor_decode_rp_entity(const cbor_item_t *, fido_rp_t *); | ||
45 | int cbor_decode_uint64(const cbor_item_t *, uint64_t *); | ||
46 | int cbor_decode_user(const cbor_item_t *, fido_user_t *); | ||
47 | int es256_pk_decode(const cbor_item_t *, es256_pk_t *); | ||
48 | int rs256_pk_decode(const cbor_item_t *, rs256_pk_t *); | ||
49 | int eddsa_pk_decode(const cbor_item_t *, eddsa_pk_t *); | ||
50 | |||
51 | /* auxiliary cbor routines */ | ||
52 | int cbor_add_bool(cbor_item_t *, const char *, fido_opt_t); | ||
53 | int cbor_add_bytestring(cbor_item_t *, const char *, const unsigned char *, | ||
54 | size_t); | ||
55 | int cbor_add_string(cbor_item_t *, const char *, const char *); | ||
56 | int cbor_array_iter(const cbor_item_t *, void *, int(*)(const cbor_item_t *, | ||
57 | void *)); | ||
58 | int cbor_build_frame(uint8_t, cbor_item_t *[], size_t, fido_blob_t *); | ||
59 | int cbor_bytestring_copy(const cbor_item_t *, unsigned char **, size_t *); | ||
60 | int cbor_map_iter(const cbor_item_t *, void *, int(*)(const cbor_item_t *, | ||
61 | const cbor_item_t *, void *)); | ||
62 | int cbor_string_copy(const cbor_item_t *, char **); | ||
63 | int cbor_parse_reply(const unsigned char *, size_t, void *, | ||
64 | int(*)(const cbor_item_t *, const cbor_item_t *, void *)); | ||
65 | int cbor_add_pin_params(fido_dev_t *, const fido_blob_t *, const es256_pk_t *, | ||
66 | const fido_blob_t *,const char *, cbor_item_t **, cbor_item_t **); | ||
67 | void cbor_vector_free(cbor_item_t **, size_t); | ||
68 | |||
69 | #ifndef nitems | ||
70 | #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) | ||
71 | #endif | ||
72 | |||
73 | /* buf */ | ||
74 | int fido_buf_read(const unsigned char **, size_t *, void *, size_t); | ||
75 | int fido_buf_write(unsigned char **, size_t *, const void *, size_t); | ||
76 | |||
77 | /* hid i/o */ | ||
78 | void *fido_hid_open(const char *); | ||
79 | void fido_hid_close(void *); | ||
80 | int fido_hid_read(void *, unsigned char *, size_t, int); | ||
81 | int fido_hid_write(void *, const unsigned char *, size_t); | ||
82 | |||
83 | /* generic i/o */ | ||
84 | int fido_rx_cbor_status(fido_dev_t *, int); | ||
85 | int fido_rx(fido_dev_t *, uint8_t, void *, size_t, int); | ||
86 | int fido_tx(fido_dev_t *, uint8_t, const void *, size_t); | ||
87 | |||
88 | /* log */ | ||
89 | #ifdef FIDO_NO_DIAGNOSTIC | ||
90 | #define fido_log_init(...) do { /* nothing */ } while (0) | ||
91 | #define fido_log_debug(...) do { /* nothing */ } while (0) | ||
92 | #define fido_log_xxd(...) do { /* nothing */ } while (0) | ||
93 | #else | ||
94 | #ifdef __GNUC__ | ||
95 | void fido_log_init(void); | ||
96 | void fido_log_debug(const char *, ...) | ||
97 | __attribute__((__format__ (printf, 1, 2))); | ||
98 | void fido_log_xxd(const void *, size_t); | ||
99 | #else | ||
100 | void fido_log_init(void); | ||
101 | void fido_log_debug(const char *, ...); | ||
102 | void fido_log_xxd(const void *, size_t); | ||
103 | #endif /* __GNUC__ */ | ||
104 | #endif /* FIDO_NO_DIAGNOSTIC */ | ||
105 | |||
106 | /* u2f */ | ||
107 | int u2f_register(fido_dev_t *, fido_cred_t *, int); | ||
108 | int u2f_authenticate(fido_dev_t *, fido_assert_t *, int); | ||
109 | |||
110 | /* unexposed fido ops */ | ||
111 | int fido_dev_authkey(fido_dev_t *, es256_pk_t *); | ||
112 | int fido_dev_get_pin_token(fido_dev_t *, const char *, const fido_blob_t *, | ||
113 | const es256_pk_t *, fido_blob_t *); | ||
114 | int fido_do_ecdh(fido_dev_t *, es256_pk_t **, fido_blob_t **); | ||
115 | |||
116 | /* misc */ | ||
117 | void fido_assert_reset_rx(fido_assert_t *); | ||
118 | void fido_assert_reset_tx(fido_assert_t *); | ||
119 | void fido_cred_reset_rx(fido_cred_t *); | ||
120 | void fido_cred_reset_tx(fido_cred_t *); | ||
121 | int fido_check_rp_id(const char *, const unsigned char *); | ||
122 | int fido_check_flags(uint8_t, fido_opt_t, fido_opt_t); | ||
123 | |||
124 | /* crypto */ | ||
125 | int fido_verify_sig_es256(const fido_blob_t *, const es256_pk_t *, | ||
126 | const fido_blob_t *); | ||
127 | int fido_verify_sig_rs256(const fido_blob_t *, const rs256_pk_t *, | ||
128 | const fido_blob_t *); | ||
129 | int fido_verify_sig_eddsa(const fido_blob_t *, const eddsa_pk_t *, | ||
130 | const fido_blob_t *); | ||
131 | |||
132 | #endif /* !_EXTERN_H */ | ||