Skip to content
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

Treat base64 as null-terminated strings #533

Closed
XavierChanth opened this issue Jan 24, 2025 · 2 comments
Closed

Treat base64 as null-terminated strings #533

XavierChanth opened this issue Jan 24, 2025 · 2 comments
Assignees

Comments

@XavierChanth
Copy link
Member

XavierChanth commented Jan 24, 2025

@JeremyTubongbanua would love your thoughts on this.

My overall reasoning is that in the atPlatform and at_c:

  • We represent byte buffers as unsigned char* and we don't null-terminate buffers
  • String are char* and they are null-terminated
  • base64 has becomes some hybrid of these two styles because:
    • We use them like strings
    • mbedtls treats them as byte buffers

I think because of the fact that we use base64 to serialize raw keys into strings, the best approach going forward would be to treat them like strings. It would make usage patterns elsewhere easier to identify.

The main places we would need this change are (there may be more, but these are the ones I've encountered):

  • atchops_base64_encode - not null-terminated but are correct type (char *)
  • atchops_rsa_key_generate_base64 - null-terminated but wrong type (unsigned char*)
@JeremyTubongbanua
Copy link
Member

I agree that we should treat base64 as char*

Let's go ahead with the changes of the two functions mentioned :)

@XavierChanth
Copy link
Member Author

I've made these changes in a non-breaking way, see #534 for the behavioral explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants