-
Notifications
You must be signed in to change notification settings - Fork 38
feat(tdf): implement tdf3 encrypt and decrypt #73
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1229f1d
feat(tdf): implement tdf3 encrypt and decrypt
sujankota e1bd214
minor cleanup
sujankota 6cffb4b
Minor cleanup
sujankota 3b2de0c
API to get metadata
sujankota 5bf4a80
Rename the GetMetaData to GetMetadata
sujankota 8cba6e8
Add API to get attributes from TDF
sujankota f703d66
CreatTDF and GetPayload return total bytes written
sujankota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package sdk | ||
|
|
||
| type Assertion struct { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package sdk | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "github.com/opentdf/opentdf-v2-poc/internal/crypto" | ||
| ) | ||
|
|
||
| type AuthConfig struct { | ||
| signingPublicKey string | ||
| signingPrivateKey string | ||
| authToken string | ||
| } | ||
|
|
||
| // NewAuthConfig Create a new instance of authConfig | ||
| func NewAuthConfig() (*AuthConfig, error) { | ||
| rsaKeyPair, err := crypto.NewRSAKeyPair(tdf3KeySize) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("crypto.NewRSAKeyPair failed: %w", err) | ||
| } | ||
|
|
||
| publicKey, err := rsaKeyPair.PublicKeyInPemFormat() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("crypto.PublicKeyInPemFormat failed: %w", err) | ||
| } | ||
|
|
||
| privateKey, err := rsaKeyPair.PublicKeyInPemFormat() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("crypto.PublicKeyInPemFormat failed: %w", err) | ||
| } | ||
|
|
||
| return &AuthConfig{signingPublicKey: publicKey, signingPrivateKey: privateKey}, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package sdk | ||
|
|
||
| type Segment struct { | ||
| Hash string `json:"hash"` | ||
| Size int64 `json:"segmentSize"` | ||
| EncryptedSize int64 `json:"encryptedSegmentSize"` | ||
| } | ||
|
|
||
| type RootSignature struct { | ||
| Algorithm string `json:"alg"` | ||
| Signature string `json:"sig"` | ||
| } | ||
|
|
||
| type IntegrityInformation struct { | ||
| RootSignature `json:"rootSignature"` | ||
| SegmentHashAlgorithm string `json:"segmentHashAlg"` | ||
| DefaultSegmentSize int64 `json:"segmentSizeDefault"` | ||
| DefaultEncryptedSegSize int64 `json:"encryptedSegmentSizeDefault"` | ||
| Segments []Segment `json:"segments"` | ||
| } | ||
|
|
||
| type KeyAccess struct { | ||
| KeyType string `json:"type"` | ||
| KasURL string `json:"url"` | ||
| Protocol string `json:"protocol"` | ||
| WrappedKey string `json:"wrappedKey"` | ||
| PolicyBinding string `json:"policyBinding"` | ||
| EncryptedMetadata string `json:"encryptedMetadata"` | ||
| } | ||
|
|
||
| type Method struct { | ||
| Algorithm string `json:"algorithm"` | ||
| IV string `json:"iv"` | ||
| IsStreamable bool `json:"isStreamable"` | ||
| } | ||
|
|
||
| type Payload struct { | ||
| Type string `json:"type"` | ||
| URL string `json:"url"` | ||
| Protocol string `json:"protocol"` | ||
| MimeType string `json:"mimeType"` | ||
| IsEncrypted bool `json:"isEncrypted"` | ||
| // IntegrityInformation IntegrityInformation `json:"integrityInformation"` | ||
| } | ||
|
|
||
| type EncryptionInformation struct { | ||
| KeyAccessType string `json:"type"` | ||
| Policy string `json:"policy"` | ||
| KeyAccessObjs []KeyAccess `json:"keyAccess"` | ||
| Method Method `json:"method"` | ||
| IntegrityInformation `json:"integrityInformation"` | ||
| } | ||
|
|
||
| type Manifest struct { | ||
| EncryptionInformation `json:"encryptionInformation"` | ||
| Payload `json:"payload"` | ||
| } | ||
|
|
||
| type attributeObject struct { | ||
| Attribute string `json:"attribute"` | ||
| DisplayName string `json:"displayName"` | ||
| IsDefault bool `json:"isDefault"` | ||
| PubKey string `json:"pubKey"` | ||
| KasURL string `json:"kasURL"` | ||
| } | ||
|
|
||
| type policyObject struct { | ||
| UUID string `json:"uuid"` | ||
| Body struct { | ||
| DataAttributes []attributeObject `json:"dataAttributes"` | ||
| Dissem []string `json:"dissem"` | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Place holder until auth configuration is implemented