Moves all test files from the `tdd/` directory to their corresponding `pkg/` subdirectories. This aligns with standard Go project structure and simplifies the test coverage workflow.
- Moves `tdd/crypt/crypt_test.go` to `pkg/crypt/`
- Moves `tdd/enchantrix/enchantrix_test.go` to `pkg/enchantrix/`
- Moves `tdd/trix/trix_test.go` to `pkg/trix/`
- Simplifies the `Taskfile.yml` to use a standard `go test` command.
- Removes the now-obsolete `tdd/` directory.
- Adds generated coverage files to `.gitignore`.
Adds `_internal_test.go` files to test unexported functions in the `crypt` and `lthn` packages, improving overall test coverage.
- Adds tests for the `ensureRSA` private function in `pkg/crypt/crypt.go`.
- Adds tests for the `createSalt` private function in `pkg/crypt/std/lthn/lthn.go`.
These changes align with the project's TDD methodology and follow the `_Good`, `_Bad`, `_Ugly` testing structure.
This commit addresses feedback from the code review:
- Updates the `TestChecksum_Bad` test in `tdd/trix/trix_test.go` to use `assert.ErrorIs` for consistent error handling.
- Reverts the breaking API change to `EncryptRSA` and `DecryptRSA` in `pkg/crypt/crypt.go` by re-introducing the `label` parameter to the public-facing functions.
- Updates the tests and examples to match the reverted API.
- Fixes a build error in `tdd/crypt/crypt_test.go` by re-introducing a necessary variable.
This commit addresses feedback from the code review:
- Updates the `HeaderTooLarge` test in `tdd/trix/trix_test.go` to correctly verify that `trix.Decode` returns `trix.ErrHeaderTooLarge`.
- Removes local `service` variable shadowing in `tdd/crypt/crypt_test.go` to use the package-level variable.
- Reverts the breaking API change to `EncryptRSA` and `DecryptRSA` in `pkg/crypt/crypt.go` by removing the `label` parameter from the public-facing functions.
- Updates the tests and examples to match the reverted API.
This commit introduces a new `tdd/` directory and adds a comprehensive test suite for the `crypt` package, covering hashing, checksums, and RSA functions.
- Adds a new `tdd/crypt_test.go` file with tests for all functions in the `crypt` package, following the "Good, Bad, Ugly" methodology.
- Deletes the old `pkg/crypt/crypt_test.go` to avoid redundancy.
- Fixes a build error in `examples/main.go` related to an updated function signature.
This commit introduces several improvements to the RSA implementation:
- Preserves zero-value service safety by lazily initializing the RSA service in `pkg/crypt/crypt.go`.
- Enforces a minimum RSA key size of 2048 bits in `pkg/crypt/std/rsa/rsa.go` to prevent the generation of insecure keys.
- Exposes the OAEP label parameter in `Encrypt` and `Decrypt` functions, allowing for more advanced use cases.
- Adds a test case to verify that `GenerateKeyPair` correctly rejects key sizes below the new minimum.
This commit introduces a standard RSA implementation in `pkg/crypt/std/rsa`.
The new `rsa.Service` provides a clean API for RSA operations, including:
- Key pair generation
- Encryption and decryption of data
The implementation uses the standard `crypto/rsa` package and follows best practices, including OAEP padding. The main `crypt.Service` has been updated to integrate and expose this new functionality.
This work was done to validate the build environment, and the tests for this implementation pass successfully, confirming that the previous testing issues were isolated to the OpenPGP library.
This commit introduces a full OpenPGP implementation in `pkg/crypt/std/openpgp`, using the ProtonMail `go-crypto` library.
The new `openpgp.Service` provides a clean, Web3-friendly API for PGP operations, including:
- Key pair generation
- Subkey management
- Encryption and decryption of messages
- Signing and verification of messages
The implementation is based on the user's `Core` repository and uses file-based key management. The main `crypt.Service` has been updated to integrate and expose this new functionality.
This commit refactors the test suites for the `crypt` and `trix` packages to follow the Good, Bad, and Ugly testing strategy.
- `_Good` tests cover the ideal "happy path" scenarios.
- `_Bad` tests cover expected failure scenarios with well-formed but invalid inputs.
- `_Ugly` tests cover malicious or malformed inputs designed to cause crashes or panics.
This new testing structure makes the test suite more organized, comprehensive, and robust.
Additionally, this commit includes a bug fix for the `Luhn` function, which now correctly handles empty and single-digit strings.