-
Notifications
You must be signed in to change notification settings - Fork 5
Add rules for stdlib, rustls, and stdio #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b04d154
Add rules for stdlib, rustls, and stdio
lucic71 cd8713a
Add support for typedef'ed rules
lucic71 d03fe07
Delete vendored rustls.h
lucic71 17df753
Use the rustls vendored by the rustls_ffi crate
lucic71 90536a1
Use using in C++ and typedef in C for type rules
lucic71 d5f2e00
cargo fmt
lucic71 60b98d8
Replace GetNameOfScalarTypedef with kPreserve flag in ToString
lucic71 6d7ea1b
Add rustls_result test
lucic71 aeb392e
The test should compile in refcount
lucic71 406e2a6
Zero initialize enum using rule initializer
lucic71 7a32ac8
Drop as u32 casts from rustls_result
lucic71 78f667e
Delete rustls test because it depends on an external crate
lucic71 f587c82
cargo-fmt
lucic71 dfb5e19
Delete rebase artifacts
lucic71 9d712f6
Add back the rules build command
lucic71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ build/ | |
| # Cargo | ||
| target/ | ||
| Cargo.lock | ||
| rules/rustls/rustls.h | ||
|
|
||
| # Python | ||
| *.pyc | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,248 @@ | ||
| // Copyright (c) 2022-present INESC-ID. | ||
| // Distributed under the MIT license that can be found in the LICENSE file. | ||
|
|
||
| #include "rustls.h" | ||
|
|
||
| typedef rustls_connection *t1; | ||
| typedef const rustls_connection *t2; | ||
| typedef const rustls_certificate *t3; | ||
| typedef rustls_str t4; | ||
| typedef rustls_result t5; | ||
| typedef rustls_io_result t6; | ||
| typedef rustls_tls_version t7; | ||
|
|
||
| rustls_result f1() { return RUSTLS_RESULT_OK; } | ||
| rustls_result f2() { return RUSTLS_RESULT_NULL_PARAMETER; } | ||
| rustls_result f3() { return RUSTLS_RESULT_PLAINTEXT_EMPTY; } | ||
| rustls_result f4() { return RUSTLS_RESULT_UNEXPECTED_EOF; } | ||
|
|
||
| rustls_tls_version f5() { return RUSTLS_TLS_VERSION_TLSV1_2; } | ||
| rustls_tls_version f6() { return RUSTLS_TLS_VERSION_TLSV1_3; } | ||
|
|
||
| rustls_result f7(rustls_connection *conn, uint8_t *buf, size_t count, | ||
| size_t *out_n) { | ||
| return rustls_connection_read(conn, buf, count, out_n); | ||
| } | ||
| rustls_result f8(rustls_connection *conn, const uint8_t *buf, size_t count, | ||
| size_t *out_n) { | ||
| return rustls_connection_write(conn, buf, count, out_n); | ||
| } | ||
| rustls_result f9(rustls_connection *conn) { | ||
| return rustls_connection_process_new_packets(conn); | ||
| } | ||
| bool f10(const rustls_connection *conn) { | ||
| return rustls_connection_wants_read(conn); | ||
| } | ||
| bool f11(const rustls_connection *conn) { | ||
| return rustls_connection_wants_write(conn); | ||
| } | ||
| bool f12(const rustls_connection *conn) { | ||
| return rustls_connection_is_handshaking(conn); | ||
| } | ||
| void f13(rustls_connection *conn) { | ||
| return rustls_connection_send_close_notify(conn); | ||
| } | ||
| void f14(rustls_connection *conn, void *userdata) { | ||
| return rustls_connection_set_userdata(conn, userdata); | ||
| } | ||
| void f15(const rustls_connection *conn, const uint8_t **protocol_out, | ||
| size_t *protocol_out_len) { | ||
| return rustls_connection_get_alpn_protocol(conn, protocol_out, | ||
| protocol_out_len); | ||
| } | ||
| uint16_t f16(const rustls_connection *conn) { | ||
| return rustls_connection_get_protocol_version(conn); | ||
| } | ||
| rustls_str f17(const rustls_connection *conn) { | ||
| return rustls_connection_get_negotiated_ciphersuite_name(conn); | ||
| } | ||
| rustls_str f18(const rustls_connection *conn) { | ||
| return rustls_connection_get_negotiated_key_exchange_group_name(conn); | ||
| } | ||
| const rustls_certificate *f19(const rustls_connection *conn, size_t i) { | ||
| return rustls_connection_get_peer_certificate(conn, i); | ||
| } | ||
| void f20(rustls_connection *conn) { return rustls_connection_free(conn); } | ||
|
|
||
| typedef rustls_client_config *t8; | ||
| typedef const rustls_client_config *t9; | ||
| typedef rustls_client_config_builder *t10; | ||
| typedef const rustls_client_config_builder *t11; | ||
| typedef rustls_certified_key *t12; | ||
| typedef const rustls_certified_key *t13; | ||
| typedef rustls_crypto_provider *t14; | ||
| typedef const rustls_crypto_provider *t15; | ||
| typedef rustls_crypto_provider_builder *t16; | ||
| typedef const rustls_crypto_provider_builder *t17; | ||
| typedef rustls_root_cert_store *t18; | ||
| typedef const rustls_root_cert_store *t19; | ||
| typedef rustls_root_cert_store_builder *t20; | ||
| typedef const rustls_root_cert_store_builder *t21; | ||
| typedef rustls_server_cert_verifier *t22; | ||
| typedef const rustls_server_cert_verifier *t23; | ||
| typedef rustls_web_pki_server_cert_verifier_builder *t24; | ||
| typedef const rustls_web_pki_server_cert_verifier_builder *t25; | ||
| typedef rustls_supported_ciphersuite *t26; | ||
| typedef const rustls_supported_ciphersuite *t27; | ||
| typedef rustls_slice_bytes t28; | ||
| typedef rustls_verify_server_cert_params t29; | ||
|
|
||
| rustls_result f21(rustls_client_config_builder *builder, | ||
| const rustls_client_config **config_out) { | ||
| return rustls_client_config_builder_build(builder, config_out); | ||
| } | ||
| void f22(rustls_client_config_builder *config) { | ||
| return rustls_client_config_builder_free(config); | ||
| } | ||
| rustls_result f23(const rustls_crypto_provider *provider, | ||
| const uint16_t *tls_versions, size_t tls_versions_len, | ||
| rustls_client_config_builder **builder_out) { | ||
| return rustls_client_config_builder_new_custom(provider, tls_versions, | ||
| tls_versions_len, builder_out); | ||
| } | ||
| rustls_result f24(rustls_client_config_builder *builder, | ||
| const rustls_slice_bytes *protocols, size_t len) { | ||
| return rustls_client_config_builder_set_alpn_protocols(builder, protocols, | ||
| len); | ||
| } | ||
| rustls_result f25(rustls_client_config_builder *builder, | ||
| const rustls_certified_key *const *certified_keys, | ||
| size_t certified_keys_len) { | ||
| return rustls_client_config_builder_set_certified_key(builder, certified_keys, | ||
| certified_keys_len); | ||
| } | ||
| void f26(rustls_client_config_builder *builder, | ||
| const rustls_server_cert_verifier *verifier) { | ||
| return rustls_client_config_builder_set_server_verifier(builder, verifier); | ||
| } | ||
| void f27(const rustls_client_config *config) { | ||
| return rustls_client_config_free(config); | ||
| } | ||
| rustls_result f28(const rustls_client_config *config, const char *server_name, | ||
| rustls_connection **conn_out) { | ||
| return rustls_client_connection_new(config, server_name, conn_out); | ||
| } | ||
|
|
||
| rustls_result f29(const rustls_certificate *cert, const uint8_t **out_der_data, | ||
| size_t *out_der_len) { | ||
| return rustls_certificate_get_der(cert, out_der_data, out_der_len); | ||
| } | ||
| rustls_result f30(const uint8_t *cert_chain, size_t cert_chain_len, | ||
| const uint8_t *private_key, size_t private_key_len, | ||
| const rustls_certified_key **certified_key_out) { | ||
| return rustls_certified_key_build(cert_chain, cert_chain_len, private_key, | ||
| private_key_len, certified_key_out); | ||
| } | ||
| void f31(const rustls_certified_key *key) { | ||
| return rustls_certified_key_free(key); | ||
| } | ||
| rustls_result f32(const rustls_certified_key *key) { | ||
| return rustls_certified_key_keys_match(key); | ||
| } | ||
| rustls_result f33(rustls_root_cert_store_builder *builder, const uint8_t *pem, | ||
| size_t pem_len, bool strict) { | ||
| return rustls_root_cert_store_builder_add_pem(builder, pem, pem_len, strict); | ||
| } | ||
| rustls_result f34(rustls_root_cert_store_builder *builder, | ||
| const rustls_root_cert_store **root_cert_store_out) { | ||
| return rustls_root_cert_store_builder_build(builder, root_cert_store_out); | ||
| } | ||
| void f35(rustls_root_cert_store_builder *builder) { | ||
| return rustls_root_cert_store_builder_free(builder); | ||
| } | ||
| rustls_result f36(rustls_root_cert_store_builder *builder, const char *filename, | ||
| bool strict) { | ||
| return rustls_root_cert_store_builder_load_roots_from_file(builder, filename, | ||
| strict); | ||
| } | ||
| rustls_root_cert_store_builder *f37() { | ||
| return rustls_root_cert_store_builder_new(); | ||
| } | ||
| void f38(const rustls_root_cert_store *store) { | ||
| return rustls_root_cert_store_free(store); | ||
| } | ||
|
|
||
| rustls_result f39(rustls_crypto_provider_builder *builder, | ||
| const rustls_crypto_provider **provider_out) { | ||
| return rustls_crypto_provider_builder_build(builder, provider_out); | ||
| } | ||
| void f40(rustls_crypto_provider_builder *builder) { | ||
| return rustls_crypto_provider_builder_free(builder); | ||
| } | ||
| rustls_result f41(rustls_crypto_provider_builder **builder_out) { | ||
| return rustls_crypto_provider_builder_new_from_default(builder_out); | ||
| } | ||
| rustls_result f42(rustls_crypto_provider_builder *builder, | ||
| const rustls_supported_ciphersuite *const *cipher_suites, | ||
| size_t cipher_suites_len) { | ||
| return rustls_crypto_provider_builder_set_cipher_suites(builder, cipher_suites, | ||
| cipher_suites_len); | ||
| } | ||
| void f43(const rustls_crypto_provider *provider) { | ||
| return rustls_crypto_provider_free(provider); | ||
| } | ||
| const rustls_supported_ciphersuite *f44(size_t index) { | ||
| return rustls_default_crypto_provider_ciphersuites_get(index); | ||
| } | ||
| size_t f45() { return rustls_default_crypto_provider_ciphersuites_len(); } | ||
| rustls_result f46(uint8_t *buff, size_t len) { | ||
| return rustls_default_crypto_provider_random(buff, len); | ||
| } | ||
|
|
||
| rustls_result f47(rustls_server_cert_verifier **verifier_out) { | ||
| return rustls_platform_server_cert_verifier(verifier_out); | ||
| } | ||
| void f48(rustls_server_cert_verifier *verifier) { | ||
| return rustls_server_cert_verifier_free(verifier); | ||
| } | ||
| rustls_result f49(rustls_web_pki_server_cert_verifier_builder *builder, | ||
| const uint8_t *crl_pem, size_t crl_pem_len) { | ||
| return rustls_web_pki_server_cert_verifier_builder_add_crl(builder, crl_pem, | ||
| crl_pem_len); | ||
| } | ||
| rustls_result f50(rustls_web_pki_server_cert_verifier_builder *builder, | ||
| rustls_server_cert_verifier **verifier_out) { | ||
| return rustls_web_pki_server_cert_verifier_builder_build(builder, | ||
| verifier_out); | ||
| } | ||
| void f51(rustls_web_pki_server_cert_verifier_builder *builder) { | ||
| return rustls_web_pki_server_cert_verifier_builder_free(builder); | ||
| } | ||
| rustls_web_pki_server_cert_verifier_builder * | ||
| f52(const rustls_root_cert_store *store) { | ||
| return rustls_web_pki_server_cert_verifier_builder_new(store); | ||
| } | ||
|
|
||
| uint16_t f53(const rustls_supported_ciphersuite *supported_ciphersuite) { | ||
| return rustls_supported_ciphersuite_get_suite(supported_ciphersuite); | ||
| } | ||
| rustls_tls_version | ||
| f54(const rustls_supported_ciphersuite *supported_ciphersuite) { | ||
| return rustls_supported_ciphersuite_protocol_version(supported_ciphersuite); | ||
| } | ||
|
|
||
| rustls_str f55() { return rustls_version(); } | ||
|
|
||
| void f56(unsigned int result, char *buf, size_t len, size_t *out_n) { | ||
| return rustls_error(result, buf, len, out_n); | ||
| } | ||
| bool f57(unsigned int result) { return rustls_result_is_cert_error(result); } | ||
|
|
||
| rustls_io_result f58(rustls_connection *conn, rustls_read_callback callback, | ||
| void *userdata, size_t *out_n) { | ||
| return rustls_connection_read_tls(conn, callback, userdata, out_n); | ||
| } | ||
| rustls_io_result f59(rustls_connection *conn, rustls_write_callback callback, | ||
| void *userdata, size_t *out_n) { | ||
| return rustls_connection_write_tls(conn, callback, userdata, out_n); | ||
| } | ||
| rustls_result f60(rustls_client_config_builder *builder, | ||
| rustls_keylog_log_callback log_cb, | ||
| rustls_keylog_will_log_callback will_log_cb) { | ||
| return rustls_client_config_builder_set_key_log(builder, log_cb, will_log_cb); | ||
| } | ||
| rustls_result f61(rustls_client_config_builder *config_builder, | ||
| rustls_verify_server_cert_callback callback) { | ||
| return rustls_client_config_builder_dangerous_set_certificate_verifier( | ||
| config_builder, callback); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change doesn't look intended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was a mistake. It was asymptomatic because I already had rustls.h generated on my machine