-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Adds AES-128-ECB to ossltest provider to be able to reenable DTLS 1.3 ACK tests #28926
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
base: feature/dtls-1.3
Are you sure you want to change the base?
Conversation
@nhorman I'm having some trouble porting the change that I did for the ossltest engine in https://github.com/openssl/openssl/pull/25119/files#diff-373f9ff409bc1e8eeb2d6335cccac16270dfa06ba39d1c3d49a4bdc318b23267 Since you've made the initial porting to the ossltest provider you might have some insight in where to look? |
@fwh-dc If you have specific questions, I'll be happy to try answer them. For now, I'll just give you some general guidance. The purpose of the ossltest provider is to provide the needed digests/ciphers/aead/rng methods for tls communication, but to do so in a way that "fake" or "known" data is returned as ciphertext and plaintext, so that the tests we have in place can validate that we receive the known data at various points during the handshake. aes128ecb is close enough to aes128cbc that you can likely just follow the pattern for the cbc algorithm in the provider. some notes about that:
Truthfully, to get this to work, you can probably just clone all the structures/functions referencing aes128cbc, rename them to aes128ecb, and fix up the internal implementations of your renamed symbols to reference the ECB cipher where needed. Hope that helps. |
@nhorman I tried that approach but somehow it fails and I was just thinking if you could spot something out of the ordinary. But it sounds like I'm on the right path. Do you test the provider somewhere? Because I couldn't find that anywhere and I think that might be the best way to debug the current implementation. |
The provider is used in all the tls tests (test/recipies/70-test_tls13*). Basically anything that uses TLSProxy.pm starts a client and server with the options --provider=p_ossltest -propquery ?provider=p_ossltest. So the provider is definitely getting used. Given the nature of the above tests (the fact that plaintext == ciphertext as an expectation for all the handshake and data frames), if the provider wasn't getting used, those tests would fail spectacularly. Running your dtlsack test locally from this branch, I think you're not getting to a point where the provider is being used however. Looking at one of the failed CI tests: All the messages starting at timestamp 2025-10-16T04:20:27.1563433Z show that the proxy is receiving only client messages, but the server is not responding. Taking a tcpdump here during the test: you can see that dtls client hellos are getting sent, but there is no response from the server. Why thats happening, I'm not sure, but it would seem the first order of business is to figure out why you're not getting connected. The ports change on every run, but using a test sample here, I see that in one run of the dtlsack test, The client is assigned port 64920, and the proxy 58890, with the server listening on 59435. Looking at the corresponding trace (not the one above), I see a dtls client hello geting forwarded from the client by the proxy to server port 59435 (which is good), but the server responds with a icmp dst port unreachable frame listing 59435 as the unreachable dst port. So that suggests to me that there is something wrong in the proxy code or the s_server setup that is causing udp frame reception to not work there. Thats the thing to look into first. This is an asside, but something to keep in mind as well for next steps once you figure out the above. In the trace above, looking at the client hello, specifically the listed cipher suites from the client, I only see AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, and AES_128_GCM_SHA256 listed. Given what you are doing in this PR, I would have expected to see an ECB cipher listed there as well, and its not, so once you get the connection issue sorted, I imagine you will have subsequent issues actually using the cipher, as its not getting advertised by the tls protocol as an available option to use. |
Thanks for the explanation! I think I need to add a bit of explaination: So this particular addition will be executed when DTLS 1.3 does sequence number encryption. And since tests are now failing by the addition of this piece of code I'm assuming that it gets called. I think the issue is that the client sends its client hello to the proxy and the proxy sends it to the server, but the server fails because of an issue with the implementation. So my question was really if there's something obvious in the implementation that does not look right. I will create a test case to check the ECB implementation. If you spot something unusual in the meantime then I'd be happy to hear from you. |
ah, you appear to be correct, if I attach a debugger to the server process it appears the connection gets accepted, but something happens during the setup that causes the connection to then be immediately closed while we're setting up for the handshake. What that is I can't tell at the moment, but a bit of tracing through the dtls code shows that dtls_crypt_sequence_number is returning 0 after calling EVP_CipherFinal_ex on the ecb cipher. |
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.
Fixing these issues should hopefully make it start working?
test/p_ossltest.c
Outdated
* handle that padding in ecb_update on our own, so intercept and | ||
* squash that here | ||
*/ | ||
return 1; |
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 needs to be properly wired up for this case. Unlike aes-128-cbc this is not being used for a TLS ciphersuite. This is just being used a standard EVP cipher. in particular we need to pass down the parameters to turn off padding.
return 1; | |
PROV_EVP_AES128_ECB_CTX *ctx = (PROV_EVP_AES128_ECB_CTX *)vprovctx; | |
return EVP_CIPHER_CTX_set_params(ctx->sub_ctx, params); |
int soutl; | ||
int ret; | ||
|
||
ret = EVP_CipherFinal_ex(ctx->sub_ctx, out, &soutl); |
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.
You need to update outl
here
test/p_ossltest.c
Outdated
|
||
memcpy(inbuf, in, inl); | ||
|
||
soutl = EVP_Cipher(ctx->sub_ctx, (unsigned char *)out, in, (unsigned int)inl); |
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.
Call actual EVP_CipherUpdate here.
…TLS 1.3 ACK tests.
Checklist