Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/generated/messages.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ The fix: As `+async_seal_xchacha+`: name a native backend, such as `+backends::s

|`+async_seal_removed+`
|native, wasip2, wasip3
|`+no member named 'async_seal' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_seal'?+`
|`+no member named 'async_seal' in namespace 'webcpp::crypto'+`

`+no member named 'async_open' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_open'?+`
`+no member named 'async_open' in namespace 'webcpp::crypto'+`

The fix: Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `+secret_key_encryption::async_seal+` and `+async_open+`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.
The fix: Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `+secret_key_encryption::async_seal+` and `+async_open+`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.

|`+async_seal_removed_declaration+`
|native, wasip2, wasip3
Expand Down Expand Up @@ -1908,7 +1908,7 @@ On MSVC, each case of `test/msvc` is proven to stop the build, at compile or at

|`+async_seal_removed+`
|the compile
|Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `+secret_key_encryption::async_seal+` and `+async_open+`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.
|Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `+secret_key_encryption::async_seal+` and `+async_open+`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.

|`+async_seal_removed_declaration+`
|the compile
Expand Down
2 changes: 1 addition & 1 deletion doc/tables/crypto.json
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@
"secretbox_removed": "Name `crypto::secret_key_encryption::secretbox` and `secretbox_xchacha20poly1305`, the secret boxes' namespace; `ciphers::secretbox` is gone, with no alias.",
"secretbox_removed_call": "As `secretbox_removed`: name `crypto::secret_key_encryption::secretbox<>` and `secretbox_xchacha20poly1305<>`, the names clang offers.",
"seal_removed_call": "As `seal_removed`: call crypto::secret_key_encryption::aead::seal and open, which the cipher's header brings.",
"async_seal_removed": "Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `secret_key_encryption::async_seal` and `async_open`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.",
"async_seal_removed": "Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `secret_key_encryption::async_seal` and `async_open`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.",
"async_seal_removed_declaration": "As `async_seal_removed`: call crypto::secret_key_encryption::aead::async_seal and async_open, in <webcpp/crypto/async.hpp>.",
"async_seal_box_asynchronous_backend": "Name a native backend, such as `backends::sodium`, for the secret box: WebCrypto has no secret box, so no form of it runs on the browser's backend, where only AES-GCM seals and opens.",
"async_open_box_asynchronous_backend": "Name a native backend, such as `backends::sodium`, for the crypto_box: WebCrypto has no crypto_box, so no form of it runs on the browser's backend, where only AES-GCM seals and opens.",
Expand Down
12 changes: 7 additions & 5 deletions doc/tables/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@
'webcpp.compile-diagnostic', 'webcpp.compile-fail', 'webcpp.link-fail',
'webcpp.example')
# A message test's text: clang's -verify directive, with the count it takes when two calls raise
# the same text (`expected-error@<file>:* 2 {{text}}`). A directive that ends with `(knock-on)`
# after its text pins an error clang adds because of another (an undeclared name the first error
# left, a call it corrected): the test checks it, and the page leaves it out. clang's -verify
# ignores the words after a directive.
EXPECTED_ERROR = re.compile(r'expected-error@\S+(?: \d+)? \{\{(.*)\}\}(\s*\(knock-on\))?')
# the same text (`expected-error@<file>:* 2 {{text}}`), or a range of counts (`1+`, or `0-1` for a
# knock-on error that one clang version reports and another does not). A directive that ends with
# `(knock-on)` after its text pins an error clang adds because of another (an undeclared name the
# first error left, a call it corrected): the test checks it, and the page leaves it out. clang's
# -verify ignores the words after a directive.
EXPECTED_ERROR = re.compile(
r'expected-error@\S+(?: \d+(?:\+|-\d+)?)? \{\{(.*)\}\}(\s*\(knock-on\))?')
SOURCE = re.compile(r'\{([a-z0-9-]+)\}')
# A comparison table's cell that the data writes: {speed:<family>}, the family's throughput from
# doc/performance.json, or {constant_time:<family>}, its measured constant time from crypto.json.
Expand Down
17 changes: 17 additions & 0 deletions doc/tables/generate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def test_a_message_test_s_first_error_is_its_message(scratch: Path) -> None:
assert found == {'alias': (["no template named 'old' in namespace 'n'"], ['native'])}, found


def test_a_directive_s_range_of_counts_is_read(scratch: Path) -> None:
# A text that a range of counts states is listed as any other (`1+`), and a knock-on error that
# one clang reports and another does not (`0-1`) is left out as any knock-on.
written(scratch, 'test/messages/ranges/Jamfile',
'webcpp.compile-diagnostic ranges : ranges.cpp : : native : alone ;\n')
written(scratch, 'test/messages/ranges/ranges.cpp', (
"// expected-error@+2 1+ {{no member named 'old' in namespace 'n'}}\n"
"// expected-error@+1 0-1 {{no matching function for call to 'old'}} (knock-on)\n"
'n::old(1);\n'))
found = generate.messages(scratch)
assert found == {'ranges': (["no member named 'old' in namespace 'n'"], ['native'])}, found


def test_a_test_of_several_removed_names_lists_each(scratch: Path) -> None:
# A test that pins several removed names lists every one, in the source's order, each once.
written(scratch, 'test/messages/names/Jamfile',
Expand Down Expand Up @@ -1824,6 +1837,10 @@ def test_a_namespace_table_is_split_into_its_parts(_: Path) -> None:
test_a_program_inside_an_if_is_a_fault,
test_the_memory_option_s_tests_are_declared,
test_a_message_expected_more_than_once_is_read,
test_a_message_test_s_first_error_is_its_message,
test_a_directive_s_range_of_counts_is_read,
test_a_test_of_several_removed_names_lists_each,
test_a_function_is_read_in_the_header_the_operation_maps_it_to,
test_a_backend_says_why_it_is_missing_elsewhere,
test_a_reason_elsewhere_is_openssl_s_alone,
test_an_outcome_reads_each_directive,
Expand Down
14 changes: 8 additions & 6 deletions test/messages/async_seal_removed/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ project : requirements <library>/webcpp/crypto//crypto ;

import webcpp ;

# alone: the two missing names and the corrected calls of the box forms are
# the compile's only errors, so a regression that puts another error before or
# after them fails the test.
# The pinned "did you mean" texts are clang's typo correction, which names the
# box forms and may drift with clang updates.
# alone: the two missing names, and on Clang 22 the corrected calls of the box
# forms, are the compile's only errors, so a regression that puts another error
# before or after them fails the test. clang's "did you mean" is its typo
# correction, which differs by version, and is not pinned. AES-GCM's default
# backend is linked, as a program that calls it links it: where clang corrects
# the calls to the AEAD forms (Clang 18, Apple Clang 17), they compile.
webcpp.compile-diagnostic async_seal_removed : async_seal_removed.cpp
: <library>/webcpp/asio//asio : native wasip2 wasip3 : alone ;
: <library>/webcpp/asio//asio <library>/webcpp/crypto//gcm-default
: native wasip2 wasip3 : alone ;
23 changes: 11 additions & 12 deletions test/messages/async_seal_removed/async_seal_removed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

// What a program that still calls crypto::async_seal and crypto::async_open as it did sees (design
// D11): each call stops the build, although async.hpp, which brings
// secret_key_encryption::aead::async_seal and async_open, is included. clang offers the box forms,
// secret_key_encryption::async_seal and async_open, whose arity is one less, and the corrected call
// adds its own error: those four errors alone. The object is a parameter: the calls are compiled,
// never run.
// secret_key_encryption::aead::async_seal and async_open, is included: those two errors alone.
// What clang offers after each is its typo correction, which differs by version and is not pinned:
// Clang 18 and Apple Clang 17 offer secret_key_encryption::aead::async_seal and async_open, the
// right forms, and the corrected calls compile; Clang 22 offers the box forms,
// secret_key_encryption::async_seal and async_open, whose arity is one less, and each corrected
// call adds its own error, which may be absent (0-1). The program links AES-GCM's default backend,
// as a program that calls it does. The object is a parameter: the calls are compiled, never run.

#include <webcpp/crypto/async.hpp>
#include <webcpp/crypto/ciphers/aes256_gcm.hpp>
Expand All @@ -32,16 +35,12 @@ void sealed_and_opened(webcpp::crypto::ciphers::aes256_gcm& cipher) {
std::array<std::uint8_t, 16> const tag{};
webcpp::asio::io_context context;
auto const executor = context.get_executor();
// clang-format off
// expected-error@+3 {{no member named 'async_seal' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_seal'?}}
// expected-error@+2 {{no matching function for call to 'async_seal'}} (knock-on)
// clang-format on
// expected-error@+2 {{no member named 'async_seal' in namespace 'webcpp::crypto'}}
// expected-error@+1 0-1 {{no matching function for call to 'async_seal'}} (knock-on)
webcpp::crypto::async_seal(executor, cipher, nonce, associated_data, data,
[](boost::system::error_code, boost::hash2::digest<16>) {});
// clang-format off
// expected-error@+3 {{no member named 'async_open' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_open'?}}
// expected-error@+2 {{no matching function for call to 'async_open'}} (knock-on)
// clang-format on
// expected-error@+2 {{no member named 'async_open' in namespace 'webcpp::crypto'}}
// expected-error@+1 0-1 {{no matching function for call to 'async_open'}} (knock-on)
webcpp::crypto::async_open(executor, cipher, nonce, associated_data, data, tag,
[](boost::system::error_code) {});
}
Expand Down
8 changes: 5 additions & 3 deletions test/messages/ph_removed/ph_removed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

int main() {
// With the name unknown, clang reads `<` as a comparison, the hash's type where a value goes
// and `::begin` as a global name: four errors for the line, as a program that still names it
// sees them, the first the missing name.
// and `::begin` as a global name: three errors for the line, as a program that still names it
// sees them, the first the missing name. Clang 22 also offers std::begin for the global name
// and adds the failed call of its correction, a fourth error that Clang 18 and Apple Clang 17
// do not report: that one may be absent (0-1).
// expected-error@+4 {{no member named 'ph' in namespace}}
// expected-error@+3 {{expected '(' for function-style cast or type construction}} (knock-on)
// expected-error@+2 {{no member named 'begin' in the global namespace}} (knock-on)
// expected-error@+1 {{no matching function for call to 'begin'}} (knock-on)
// expected-error@+1 0-1 {{no matching function for call to 'begin'}} (knock-on)
return webcpp::crypto::curves::ed25519::ph<webcpp::hash::sha2_512>::begin() ? 0 : 1;
}
6 changes: 4 additions & 2 deletions test/messages/seal_removed_call/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import webcpp ;

# alone: the two removed calls are the compile's only errors. Native only: on
# WASI clang offers fopen for open and adds an error, which
# seal_removed_call_wasi pins.
# seal_removed_call_wasi pins. ChaCha20-Poly1305's default backend is linked, as
# a program that calls it links it: Clang 18 and Apple Clang 17 correct the
# calls to the AEAD forms, which then compile.
webcpp.compile-diagnostic seal_removed_call : seal_removed_call.cpp
: : native : alone ;
: <library>/webcpp/crypto//chacha20_poly1305-default : native : alone ;
6 changes: 4 additions & 2 deletions test/messages/seal_removed_call/seal_removed_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

// What a program that still calls crypto::seal and crypto::open as it did sees, natively (design
// D11): each call stops the build, with those two errors alone, although the cipher's header,
// which brings secret_key_encryption::aead::seal and open, is included. On WASI clang offers the C
// library's fopen for open: seal_removed_call_wasi.
// which brings secret_key_encryption::aead::seal and open, is included. Clang 18 and Apple Clang 17
// offer those, and compile the corrected calls, which instantiate the cipher's engine: the program
// links ChaCha20-Poly1305's default backend, as a program that calls it does. On WASI clang offers
// the C library's fopen for open: seal_removed_call_wasi.

#include <webcpp/crypto/ciphers/chacha20_poly1305.hpp>

Expand Down
Loading