|
1 | 1 | rules: |
2 | 2 | - name: no-void-functions |
3 | 3 | trigger: >- |
4 | | - All functions must return a value. Avoid using void return types to ensure |
5 | | - error values can be propagated upstream. |
| 4 | + When implementing new public functions (WOLFSSL_API) avoid using "void" |
| 5 | + return type to ensure error values can be propagated upstream. Does not |
| 6 | + apply to "doc/" directory. |
6 | 7 | solution: >- |
7 | 8 | Change the function to return an appropriate error code or result instead |
8 | 9 | of void. Ensure all return paths provide a meaningful value. |
@@ -51,12 +52,17 @@ rules: |
51 | 52 | variables to minimize stack usage within the function. |
52 | 53 | - name: prefer-constant-time |
53 | 54 | trigger: >- |
54 | | - Implement algorithms in constant time to prevent timing attacks and ensure |
55 | | - security. |
56 | | - solution: >- |
57 | | - Review and refactor algorithms to ensure their execution time does not |
58 | | - depend on input values. Use constant-time libraries or functions where |
59 | | - applicable. |
| 55 | + Any code handling secret or private key data (symmetric or asymmetric) |
| 56 | + must be implemented in constant time. This includes cryptographic |
| 57 | + operations, key comparisons, and encoding/decoding operations (base64, |
| 58 | + hex, etc.) when processing secrets. Use constant-time implementations |
| 59 | + by default for all secret data since tracking when timing attacks are |
| 60 | + strictly possible is error-prone. |
| 61 | + solution: >- |
| 62 | + Review and refactor code to ensure execution time does not depend on |
| 63 | + secret values. Use constant-time functions such as ConstantCompare() |
| 64 | + for comparisons and avoid early-exit conditions based on secret data. |
| 65 | + When in doubt, assume constant-time handling is required. |
60 | 66 | - name: use-sizeof |
61 | 67 | trigger: >- |
62 | 68 | Avoid hard-coded numeric values for sizes. Use `sizeof()` to ensure |
@@ -143,3 +149,13 @@ rules: |
143 | 149 |
|
144 | 150 | ensure ephemeral structures are freed once no longer needed, and avoid |
145 | 151 | reusing pointers after free |
| 152 | + - name: use-proper-function-visibility |
| 153 | + trigger: >- |
| 154 | + functions must use appropriate visibility modifiers. Public functions |
| 155 | + should use WOLFSSL_API, local functions should use WOLFSSL_LOCAL, and |
| 156 | + non-static local functions should have a wolfssl_local_ or wc_local_ prefix. |
| 157 | + solution: >- |
| 158 | + for public functions that are part of the external API, declare them with |
| 159 | + WOLFSSL_API. For functions local to the library but not static, use |
| 160 | + WOLFSSL_LOCAL and prefix the function name with wolfssl_local_ or wc_local_ |
| 161 | + to clearly indicate internal usage. |
0 commit comments