Skip to content
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

feat(kas): Partial implementation EC384 and EC521 support in KAS #883

Closed
wants to merge 43 commits into from

Commits on Jun 13, 2024

  1. Implement EC384 and EC521 support in KAS

    Enabled EC384 and EC521 support in KAS and added relevant unit tests. The config file now supports the new EC384 and EC521 key types. Also, test keys for both types have been generated and added.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    e450da6 View commit details
    Browse the repository at this point in the history
  2. Update error message and refactor key configurations

    Improved the clarity of an error message in the "NewOpenTDFServer" method. Refactored key configurations in the dev and example YAML files to differentiate between multiple elliptic curve securities. Also made updates to various scripts to generate and handle these keys suitably.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    5ea5c63 View commit details
    Browse the repository at this point in the history
  3. Refactor key generation and error handling in publicKey.go

    This commit includes the refactoring of the publicKey.go file for better error handling and support for different algorithms. The log messages have been updated to provide clearer context upon failure of key generation methods for both EC and RSA algorithms. Also, changes were made to the init-temp-keys.cmd script to correct the path of the generated keys.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    c4ff770 View commit details
    Browse the repository at this point in the history
  4. Update error handling for unknown key algorithm

    The code was updated to address an issue where an unknown key algorithm could be passed to the publicKey functions. It now properly catches this event and logs an error message. The additional condition checks if the algorithm is not RSA in addition to being non-empty, helping prevent potential configuration errors.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    c420ec2 View commit details
    Browse the repository at this point in the history
  5. Update init-temp-keys script execution in GitHub workflow

    This commit modifies the execution of the `init-temp-keys.sh` script in `.github/workflows/checks.yaml` file. The change includes passing '--output ./keys/' argument to the script to dictate where the keys will be stored. This specifies the directory for the keys and enhances organization.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    f3a1d72 View commit details
    Browse the repository at this point in the history
  6. Update paths for key files and init-temp-keys script

    Updated the paths for secp256r1, secp384r1, and secp521r1 key files in the opentdf-dev.yaml file, removing the '/keys/' prefix. Also modified the path in the init-temp-keys.sh command within checks.yaml. This adjustment accommodates a change in file structure and ensures consistent script execution.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    3c7533b View commit details
    Browse the repository at this point in the history
  7. Refactor symmetric key generation for improved security

    This commit includes modifications to symmetric key generation in the crypto provider. Now, GenerateNanoTDFSymmetricKey requires a keyID in addition to ephemeralPublicKeyBytes. This change allows for better security features as the encryption processes are enhanced. Minor changes such as comments added to the decrypt file and an adjustment to test output validation were also implemented.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    c15ea61 View commit details
    Browse the repository at this point in the history
  8. rollback

    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    2d51e2e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    f0ac2aa View commit details
    Browse the repository at this point in the history
  10. minor cleanup

    sujankota authored and pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    cd86859 View commit details
    Browse the repository at this point in the history
  11. Remove attributes.swagger.json from the policy docs

    The attributes.swagger.json file in the policy documentation was deleted. It was located in the docs/openapi/policy/attributes directory. This file contains the OpenAPI specification for attribute related services. The commit message should reflect the elimination of this detailed specification file.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    570a604 View commit details
    Browse the repository at this point in the history
  12. Refactor curve name retrieval in NanoTDFHeader

    The if-else constructs in the GetCurveName() method of the NanoTDFHeader struct in nanotdf.go have been refactored to a switch-case statement for better readability. Also, the invocation to retrieve the public key algorithm has been updated to use req.GetAlgorithm rather than directly accessing the property.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    87ef2c1 View commit details
    Browse the repository at this point in the history
  13. Add support for secp256k1 and modify logging level

    Added secp256k1 to the ECCMode in nanotdf.go. Also, the logging level for the 'kas public key algorithm' has been downgraded from Info to Debug to reflect its utilization better and reduce log volume in non-debug scenarios.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    0c9952e View commit details
    Browse the repository at this point in the history
  14. Remove unnecessary constants and refactor ECCurve

    The kNanoTDFGMACLength constant and ErrInternal error constant were removed as they were not being used. The unnecessary ECCurve fetching code was also removed, now ECCurve is fetched directly from the header. The CryptoProvider now generates keys based on this directly fetched ECCurve.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    c013d32 View commit details
    Browse the repository at this point in the history
  15. Update EC algorithms in public key handling

    The public key handling process has been updated to accommodate three different elliptic curve algorithms: EC256R1, EC384R1 and EC512R1. The tests have also been adjusted to ensure these changes function as expected. Algorithm constants in the crypto provider code file have also been updated to reflect these changes in public key handling.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    e03db4c View commit details
    Browse the repository at this point in the history
  16. Refactor cryptoProvider configuration in YAML files

    The cryptoProvider configuration in both opentdf-dev.yaml and opentdf-example.yaml files has been refactored. The rsa and ec field structure has now been replaced with a simpler, streamlined `keys` field, which should enhance readability and maintainability of these configurations.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    dab6073 View commit details
    Browse the repository at this point in the history
  17. Add EC key generation to init-temp-keys scripts

    Updated both the .cmd and .sh versions of the init-temp-keys scripts to include the generation of elliptic curve (EC) keys with prime256v1 curve. Now, alongside RSA and secp256r1 key pairs, the scripts also generate prime256v1 EC key pairs.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    6b1fc14 View commit details
    Browse the repository at this point in the history
  18. Update encryption functionality and refactor options

    The encryption functionality has been updated to allow for more options, such as the nano format and ability to disable storing key identifiers in TDF KAOs. The encrypt command has also been refactored for conciseness and clarity. Code for token endpoint during client creation is removed, and new options have been added to address the nanoTDF format and managing key identifiers.
    pflynn-virtru committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    b6cc539 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2024

  1. Add new encryption keys to YAML files

    New encryption keys have been added to both `opentdf-dev.yaml` and `opentdf-example.yaml` files. The keys are of elliptic curve cryptographic type with identifiers e2 and e3, corresponding to different security levels.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    6e44006 View commit details
    Browse the repository at this point in the history
  2. Correct algorithm name and simplify code

    The algorithm name was incorrectly spelled as 'AlgorithmECP512R1' instead of 'AlgorithmECP521R1'. This incorrect spelling was fixed across multiple files. Also, the redundant code in publicKey.go and standard_crypto.go where ecPublicKeyPem was retrieved separately for each algorithm was consolidated into one single case handling multiple algorithms, making the code more concise and readable.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    109968b View commit details
    Browse the repository at this point in the history
  3. Refactor crypto provider methods and tests

    Simplified the "publicKey.go" code by handling all elliptic curve digital signature algorithm cases together. Also, amended the ECCertificate and ECPublicKey methods in the crypto provider to take an additional 'curveName' parameter. These changes are reflected in the accompanying tests as well.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    41ffd92 View commit details
    Browse the repository at this point in the history
  4. Add new keys to opentdf-dev.yaml

    Three new keys, e2 with ec:secp384r1, e3 with ec:secp521r1, and a legacy e2 key, and a legacy e3 key have been added to the configuration file. These keys enhance the algorithm compatibility and secure communications with the legacy system.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    ae70bba View commit details
    Browse the repository at this point in the history
  5. Add new key ids and change ECCMode in encrypt.go

    Two new key ids have been added to the tdf-roundtrips.bats file. Also, in the encrypt.go file, the ECCMode was changed from ECCModeSecp521r1 to ECCModeSecp256r1. This commit introduces these modifications to improve security and performance.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    39eb5c3 View commit details
    Browse the repository at this point in the history
  6. Add new public key endpoint in service-start bats test

    A new endpoint for the ec384 public key has been added in the service-start bats test. This endpoint checks if the output is a public key, verifies it's an EC
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    d411aa8 View commit details
    Browse the repository at this point in the history
  7. Add support for secp384r1 and secp521r1 algorithms

    The code has been updated in the 'tdf-roundtrips.bats' test file to include support for secp384r1 and secp521r1 algorithms. New kids have been added along with their respective private key and cert file details. This should allow more flexibility for testing purposes.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    ad2f99c View commit details
    Browse the repository at this point in the history
  8. Disable decryption step in tdf-roundtrips test

    Temporarily disable the decrypt command in tdf-roundtrips test due to a bug reported in issue #900. This change also modifies the paths of the r2 key pair to match the kas-private.pem and kas-cert.pem paths, eliminating the previously separate r2 keys.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    43ff918 View commit details
    Browse the repository at this point in the history
  9. Refactor algorithm assignment in getECPublicKey function

    The selected encryption algorithm assignment has been changed from a bunch of if-else conditions to a switch case statement within the getECPublicKey function. This change contributes to more readable and maintainable code. Also, comments are included to indicate the corresponding algorithm.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    d631c68 View commit details
    Browse the repository at this point in the history
  10. Add support for ECCModeSecp256k1 in nanotdf.go

    This commit updates the case switch in the nanotdf.go file to include support for ocrypto.ECCModeSecp256k1. Although this encryption algorithm is currently not supported, it now has a corresponding switch case.
    pflynn-virtru committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    9c65c5c View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2024

  1. Add error handling for unsupported or unknown algorithms

    In the SDK, error logging and returning has been implemented for the cases when an unsupported algorithm (ec:secp256k1) or any unknown algorithm is used. This will aid in better fault detection and diagnosis.
    pflynn-virtru committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    a7bfe0e View commit details
    Browse the repository at this point in the history
  2. Enable decryption in tdf-roundtrips test

    The decryption steps in the tdf-roundtrips bats test were commented out, and have been enabled again. In addition, the decrypt function was updated to accommodate both TDF and Nano files. It now attempts to decrypt both file types instead of returning an error when the file is not a TDF file.
    pflynn-virtru committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    42ffcbe View commit details
    Browse the repository at this point in the history
  3. Remove specific message comparison from decrypt.go

    The change removes the specific comparison of the output buffer content with "Hello Virtru" in the decrypt command. Instead, it just prints the content of the output buffer directly, making it more universally applicable.
    pflynn-virtru committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    416ad7c View commit details
    Browse the repository at this point in the history
  4. Convert output buffer to string in decrypt command

    The decryption command previously printed output directly from the buffer. This commit changes that and converts the output buffer to a string before printing. This may improve readability and consistency across the application.
    pflynn-virtru committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    843cc8e View commit details
    Browse the repository at this point in the history
  5. Remove warning message and adjust print method in decrypt.go

    Removed the warning message in the 'tdf-roundtrips.bats' test file which is no longer relevant. Also, in 'decrypt.go', replaced the 'cmd.Println' method with the 'fmt.Println' method to print the output string. This change is meant to simplify and standardize the print methods across the codebase.
    pflynn-virtru committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    d96accc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e786271 View commit details
    Browse the repository at this point in the history

Commits on Jun 18, 2024

  1. Update function signatures in hsm.go

    The function signatures for GenerateEphemeralKasKeys, ECPublicKey, and ECCertificate in hsm.go have been updated. The functions now accept an additional parameter, though it's currently unused. This change provides better flexibility for future adjustments or enhancements of these functions.
    pflynn-virtru committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    a83cbc6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    544dd51 View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2024

  1. Update test/tdf-roundtrips.bats

    Co-authored-by: Dave Mihalcik <dmihalcik@virtru.com>
    pflynn-virtru and dmihalcik-virtru authored Jun 20, 2024
    Configuration menu
    Copy the full SHA
    a17ebbc View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2024

  1. Merge remote-tracking branch 'refs/remotes/origin/main' into 881-supp…

    …ort-additional-elliptic-curves
    
    # Conflicts:
    #	docs/openapi/policy/attributes/attributes.swagger.json
    #	docs/openapi/policy/namespaces/namespaces.swagger.json
    pflynn-virtru committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    389f220 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2024

  1. Configuration menu
    Copy the full SHA
    57e5f8e View commit details
    Browse the repository at this point in the history
  2. regen docs

    dmihalcik-virtru committed Jun 24, 2024
    Configuration menu
    Copy the full SHA
    71ecaf0 View commit details
    Browse the repository at this point in the history
  3. fixups

    dmihalcik-virtru committed Jun 24, 2024
    Configuration menu
    Copy the full SHA
    2f5d945 View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2024

  1. Configuration menu
    Copy the full SHA
    779ee2b View commit details
    Browse the repository at this point in the history

Commits on Jul 11, 2024

  1. fixup merge fail

    dmihalcik-virtru committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    3781f2e View commit details
    Browse the repository at this point in the history