Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sujankota committed Mar 3, 2025
1 parent 572f819 commit a312242
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
25 changes: 9 additions & 16 deletions cmd/tdf-decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ import (
"github.com/spf13/cobra"
)

const (
RSA2048 = "rsa:2048"
ECSECP256R1 = "ec:secp256r1"
ECSECP384R1 = "ec:secp384r1"
ECSECP521R1 = "ec:secp521r1"
)

var TDF = "tdf"

var assertionVerification string
Expand All @@ -35,16 +28,16 @@ func dev_tdfDecryptCmd(cmd *cobra.Command, args []string) {
sessionKeyAlgStr := c.Flags.GetOptionalString("session-key-algorithm")
var sessionKeyAlgorithm ocrypto.KeyType
switch sessionKeyAlgStr {
case RSA2048:
sessionKeyAlgorithm = RSA2048
case ECSECP256R1:
sessionKeyAlgorithm = ECSECP256R1
case ECSECP384R1:
sessionKeyAlgorithm = ECSECP384R1
case ECSECP521R1:
sessionKeyAlgorithm = ECSECP521R1
case string(ocrypto.RSA2048Key):
sessionKeyAlgorithm = ocrypto.RSA2048Key
case string(ocrypto.EC256Key):
sessionKeyAlgorithm = ocrypto.EC256Key
case string(ocrypto.EC384Key):
sessionKeyAlgorithm = ocrypto.EC384Key
case string(ocrypto.EC521Key):
sessionKeyAlgorithm = ocrypto.EC521Key
default:
sessionKeyAlgorithm = RSA2048
sessionKeyAlgorithm = ocrypto.RSA2048Key
}

// check for piped input
Expand Down
18 changes: 9 additions & 9 deletions cmd/tdf-encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ func dev_tdfEncryptCmd(cmd *cobra.Command, args []string) {
wrappingKeyAlgStr := c.Flags.GetOptionalString("wrapping-key-algorithm")
var wrappingKeyAlgorithm ocrypto.KeyType
switch wrappingKeyAlgStr {
case RSA2048:
wrappingKeyAlgorithm = RSA2048
case ECSECP256R1:
wrappingKeyAlgorithm = ECSECP256R1
case ECSECP384R1:
wrappingKeyAlgorithm = ECSECP384R1
case ECSECP521R1:
wrappingKeyAlgorithm = ECSECP521R1
case string(ocrypto.RSA2048Key):
wrappingKeyAlgorithm = ocrypto.RSA2048Key
case string(ocrypto.EC256Key):
wrappingKeyAlgorithm = ocrypto.EC256Key
case string(ocrypto.EC384Key):
wrappingKeyAlgorithm = ocrypto.EC384Key
case string(ocrypto.EC521Key):
wrappingKeyAlgorithm = ocrypto.EC521Key
default:
wrappingKeyAlgorithm = RSA2048
wrappingKeyAlgorithm = ocrypto.RSA2048Key
}

piped := readPipedStdin()
Expand Down

0 comments on commit a312242

Please sign in to comment.