Skip to content

Conversation

@facchinm
Copy link
Member

@facchinm facchinm commented Aug 8, 2019

With certificates handling done in filesystem for persistency, need to be tested though

struct stat st;
stat(key_filename, &st);
size_t client_key_buf_size = st.st_size;
uint8_t* client_key_buf = (uint8_t*)malloc(st.st_size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is stored in RAM anyways, do we need to store it in a file?

Also, should the buffer be freed if the API is called twice in a row?

size_t client_crt_buf_size = (command[3] << 8 | command[4]);
size_t client_key_buf_size = (command[5] << 8 | command[6]);
uint8_t* client_crt_buf = (uint8_t*)malloc(client_crt_buf_size + 1);
uint8_t* client_key_buf = (uint8_t*)malloc(client_key_buf_size + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this RAM be free'ed somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our use case is somehow particular since the certificates are usually in flash; after a successful connection is established they should not be useful but I'm not 100% sure.
Since our library resets the module upon attempting the first communication with it I think we can avoid freeing them probably.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm still wondering if we should use realloc instead of malloc here, in case the sketch calls the lib side API twice in a row for whatever reason.

@sandeepmistry
Copy link
Contributor

Closing in favour of #43.

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

Successfully merging this pull request may close these issues.

2 participants