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): implement KAS nanotdf standard crypto #807

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

pflynn-virtru
Copy link
Member

Refactored the Key Access Service provider to use a pointer receiver and updated the cryptography system for better private-public key management. Enhanced the elliptic curve digital signature algorithm (ECDSA) methods, and included functions to generate a symmetric key, ephemeral keys, and a session key. Also fixed minor issues and commented out code blocks.

Refactored the Key Access Service provider to use a pointer receiver and updated the cryptography system for better private-public key management. Enhanced the elliptic curve digital signature algorithm (ECDSA) methods, and included functions to generate a symmetric key, ephemeral keys, and a session key. Also fixed minor issues and commented out code blocks.
@pflynn-virtru pflynn-virtru linked an issue May 14, 2024 that may be closed by this pull request
@pflynn-virtru pflynn-virtru changed the title Update KAS access provider and crypto system feat(service): implement KAS nanotdf standard crypto May 14, 2024
@pflynn-virtru pflynn-virtru changed the title feat(service): implement KAS nanotdf standard crypto feat(kas): implement KAS nanotdf standard crypto May 14, 2024
pflynn-virtru and others added 4 commits May 14, 2024 15:32
Removed commented-out code and the errNotImplemented variable from the standard_crypto.go file. Also replaced a panic scenario with a standard error message to improve error handling.
Added unit tests to test the functionality of different methods present in the standard crypto file. Additionally, handled an edge case where the code could break when the length of ecKeys is less than or equal to privateKeyHandle.
The commit refactors assertions in "standard_crypto_test.go" to use Require instead of Assert, as Require stops test execution once a failure is encountered. Moreover, dead code primarily containing key validation functions has been removed for better readability and maintenance.
@pflynn-virtru pflynn-virtru marked this pull request as ready for review May 14, 2024 21:26
@pflynn-virtru pflynn-virtru requested review from a team as code owners May 14, 2024 21:26
Removed unused variable in the function "expect" in the standard_crypto_test specifically within the "Success" test case. This clear unused variables and helps to improve the readability of the code.
}

// We have to ensure we have an ECDSA public key
pubKey, ok := pubKeyInterface.(*ecdsa.PublicKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should ECDH not ECDSA

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session key = KDF(ECDH(sdk-session-public-key, kas-ephemeral-private-key), 'L1L')

L1L is the salt

Copy link
Contributor

@sujankota sujankota May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ocrypto module should have this functionality. We can just call into it.

// ecPublicKey *ecdh.PublicKey
// ecPrivateKey *ecdh.PrivateKey
Identifier string
ecPrivateKey *ecdsa.PrivateKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ECDH

pflynn-virtru and others added 7 commits May 17, 2024 14:16
This commit introduces a new ECCertificate function in the HSMSession struct along with a corresponding method in the ICryptoProvider interface. It also updates the "eccertid" in various service configuration yaml files. At the same time, several Go dependencies have been updated to their newer versions.
This commit refines the error logging in `rewrap.go` file for better tracking and modifies the key generation process in `access/rewrap.go` for more efficiency. It has also corrected an error message in `server.go`. Updated dependencies in `go.work.sum` for synchronicity with new alterations.
Updated the code to support ECDH keys in addition to ECDSA keys. This includes changes in key generation, marshalling, and unmarshalling, as well as handling these keys within struct types. Also improved error handling and logging across multiple files for better debugging and traceability.
Updated the `nanoTDFRewrap` function in `rewrap.go` to now take a context argument. Refactored key variables for clarity and simplicity. Simplified the conversion of public keys to bytes. Modified logic of `GenerateNanoTDFSessionKey` function for a cleaner key generation approach.
This commit cleans up and optimizes key management and generation in nanoTDFRewrap. The unnecessary check of mismatched key access URL is removed to simplify the flow. Moreover, the generation and use of symmetric keys (now referred to as DEK) and session keys are clarified. Naming in the standard_crypto module is also improved to better reflect the purpose of the keys.
Modified the init-temp-keys.sh script to generate an ECDSA private key and certificate, and handled loading the EC certificate in the standard_crypto.go file. Also, updated publicKey.go to fetch the public key based on the EC certificate ID instead of a hardcoded value. Additionally, some debug log messages were inserted for detailed tracing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nanotdf kas standard crypto implementation
2 participants