-
Notifications
You must be signed in to change notification settings - Fork 17
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
Autogenerate cgo wrappers #230
Conversation
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.
Copilot reviewed 31 out of 46 changed files in this pull request and generated 3 suggestions.
Files not reviewed (15)
- goopenssl.c: Language not supported
- goopenssl.h: Language not supported
- export_test.go: Evaluated as low risk
- ed25519.go: Evaluated as low risk
- ecdsa.go: Evaluated as low risk
- ec.go: Evaluated as low risk
- ecdh.go: Evaluated as low risk
- aes.go: Evaluated as low risk
- des.go: Evaluated as low risk
- evp.go: Evaluated as low risk
- hkdf.go: Evaluated as low risk
- hash.go: Evaluated as low risk
- cipher.go: Evaluated as low risk
- hmac.go: Evaluated as low risk
- init.go: Evaluated as low risk
Comments skipped due to low confidence (8)
internal/mkcgo/parse.go:191
- The extractSection function does not handle cases where the start or end strings are not found properly. It might return incorrect results.
func extractSection(s string, start, end string) (prefix, body, suffix string, found bool) {
internal/mkcgo/parse.go:137
- The newFn function has a lot of string manipulation which could be error-prone. Ensure that it handles edge cases properly.
func newFn(s string, opts fnOptions) (*fn, error) {
internal/mkcgo/mkcgo.go:62
- Handle the case where fileName is empty to avoid unexpected behavior.
err = os.WriteFile(*fileName, data, 0644)
internal/mkcgo/mkcgo.go:64
- Ensure fileName ends with .go before using TrimSuffix to avoid incorrect file naming.
cfileName := strings.TrimSuffix(*fileName, ".go") + ".c"
internal/mkcgo/mkcgo.go:132
- [nitpick] Simplify the error handling for better readability.
if closeErr := f.Close(); err == nil { err = closeErr }
internal/mkcgo/generate.go:244
- The function
libArgList
in theparam
struct returns a slice with a single string element, which is unnecessary. It should return a string directly.
return []string{s}
dsa.go:58
- The function signature for withKey has been changed from func(C.GO_EVP_PKEY_PTR) C.int to func(ossl.EVP_PKEY_PTR) error. Ensure that the functions passed to withKey are updated to handle errors correctly.
func (k *PrivateKeyDSA) withKey(f func(ossl.EVP_PKEY_PTR) error) error {
ecdsa_test.go:25
- The removal of
t.Parallel()
should be justified. If there were no issues with parallel execution, consider adding it back to improve test performance.
t.Parallel()
044ae27
to
13e70e5
Compare
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.
PR Overview
This PoC PR demonstrates an initial migration from direct C function calls to the internal ossl package, while also updating the build tags to require cgo. Key changes include:
- Updating build tags (e.g. added "&& cgo") across multiple files.
- Replacing direct C calls (via “C.” functions) with equivalent calls to the ossl package.
- Adjustments to provider name strings and minor logic changes in test and cryptographic functions.
Reviewed Changes
File | Description |
---|---|
ecdsa_test.go | Removed t.Parallel() from test runner to run tests serially. |
init.go, dsa.go, ed25519.go etc. | Replaced C function calls with ossl package functions. |
export_test.go | Modified provider string literals to include a null terminator. |
.github/workflows/test.yml | Commented out header check step. |
ec.go, ecdsa.go, ecdh.go, etc. | Updated build tags and migrated C types to ossl types. |
Copilot reviewed 49 out of 49 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
ecdsa_test.go:25
- The removal of t.Parallel() may affect test execution time by running tests sequentially. Please confirm that this change is intentional or add a comment explaining the rationale.
// t.Parallel() removed here
export_test.go:8
- The provider strings now include a null terminator (\x00). Please verify that this change is intentional and that all consuming functions correctly handle the null-terminated strings.
return isProviderAvailable("symcryptprovider\x00")
init.go:1
- The build tag update to include '&& cgo' is applied across many files. Please ensure that this change aligns with the project’s intended build environment and that non-cgo builds are either deprecated or handled appropriately.
//go:build !cmd_go_bootstrap && cgo
Tip: Turn on automatic Copilot reviews for this repository to get quick feedback on every pull request. Learn more
PoC, do not review yet.