-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Consider naming structs so it is possible to forward declare them #1215
Comments
HI @randombit Thank you for your suggestion. As an open source project, we welcome contributions from the community, as long as the contributor followed our coding standards and signed the CLA. |
ARM Internal Ref: IOTSSL-1951 |
Just did a grep on typedef struct
{
uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */
uint32_t S[4][256]; /*!< key dependent S-boxes */
}
mbedtls_blowfish_context; to typedef struct mbedtls_blowfish_context
{
uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */
uint32_t S[4][256]; /*!< key dependent S-boxes */
}
mbedtls_blowfish_context; |
I have same problem now. What I found that there is I will prepare PR |
This is by design. If you can implement an alternative functionality of blowfish on your platform, such as HW acceleration, you should define |
Thanks to forward declare we can declare `struct` in our header file instead making #include
PR #1861 merged so this issue can now be closed. |
Currently in ecp.h the
mbedtls_ecp_keypair
struct is defined asThe problem arises, I am currently working on a codebase that supports both OpenSSL and mbedtls. For the OpenSSL case I have something like
typedef struct ec_key_st MY_ECC_KEY
and then useMY_ECC_KEY*
as parameters to various functions. But there is afaict no way to provide a similar forward declaration formbedtls_ecp_keypair
, because thestruct
has no name! Instead I must actually include the mbedtls header in order to get the typedef.It would be nice if this could be fixed in a future release. I believe all that is required is to grep for "typedef struct {" and for each case insert the same name as the typedef. Then my code would not have to include mbedtls in the header, and I could use
typedef struct mbedtls_ecp_keypair MY_ECC_KEY
.(This already works for some structs, like
mbedtls_x509_crt
)I think this would be useful outside my case as I imagine there are many applications that support mbedtls as well as another implementation, and being able to forward declare types allows making the implementation more opaque to the larger codebase.
The text was updated successfully, but these errors were encountered: