Skip to content

Commit

Permalink
add support for base64 variants
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Nov 7, 2024
1 parent 749ccf3 commit 1e74527
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func init() {
uploadCmd.Flags().StringVar(&uploadOpts.Arch, "arch", "", "arch for the artifact")
uploadCmd.Flags().StringVar(&uploadOpts.Checksum, "checksum", "", "pre-calculated checksum for the artifact (defaults using sha-512)")
uploadCmd.Flags().StringVar(&uploadOpts.ChecksumAlgorithm, "checksum-algorithm", "sha-512", "the checksum algorithm to use, one of: sha-512, sha-256, sha-1")
uploadCmd.Flags().StringVar(&uploadOpts.ChecksumEncoding, "checksum-encoding", "base64", "the checksum encoding to use, one of: base64, hex")
uploadCmd.Flags().StringVar(&uploadOpts.ChecksumEncoding, "checksum-encoding", "base64raw", "the checksum encoding to use, one of: base64, base64raw, base64url, hex")
uploadCmd.Flags().StringVar(&uploadOpts.Signature, "signature", "", "pre-calculated signature for the artifact (defaults using ed25519ph)")
uploadCmd.Flags().StringVar(&uploadOpts.SigningAlgorithm, "signing-algorithm", "ed25519ph", "the signing algorithm to use, one of: ed25519ph, ed25519")
uploadCmd.Flags().StringVar(&uploadOpts.SignatureEncoding, "signature-encoding", "base64", "the signature encoding to use, one of: base64, hex")
uploadCmd.Flags().StringVar(&uploadOpts.SignatureEncoding, "signature-encoding", "base64raw", "the signature encoding to use, one of: base64, base64raw, base64url, hex")
uploadCmd.Flags().StringVar(&uploadOpts.SigningKeyPath, "signing-key", "", "path to ed25519 private key for signing the artifact [$KEYGEN_SIGNING_KEY_PATH=<path>, $KEYGEN_SIGNING_KEY=<key>]")
uploadCmd.Flags().BoolVar(&uploadOpts.NoAutoUpgrade, "no-auto-upgrade", false, "disable automatic upgrade checks [$KEYGEN_NO_AUTO_UPGRADE=1]")
uploadCmd.Flags().StringVar(&uploadOpts.Metadata, "metadata", "", "JSON string of metadata key-value pairs")
Expand Down Expand Up @@ -379,7 +379,11 @@ func calculateChecksum(file *os.File) (string, error) {

switch uploadOpts.ChecksumEncoding {
case "base64":
return base64.StdEncoding.EncodeToString(digest), nil
case "base64raw":
return base64.RawStdEncoding.EncodeToString(digest), nil
case "base64url":
return base64.URLEncoding.EncodeToString(digest), nil
case "hex":
return hex.EncodeToString(digest), nil
default:
Expand Down Expand Up @@ -436,7 +440,11 @@ func calculateSignature(encSigningKey string, file *os.File) (string, error) {

switch uploadOpts.SignatureEncoding {
case "base64":
return base64.StdEncoding.EncodeToString(sig), nil
case "base64raw":
return base64.RawStdEncoding.EncodeToString(sig), nil
case "base64url":
return base64.URLEncoding.EncodeToString(sig), nil
case "hex":
return hex.EncodeToString(sig), nil
default:
Expand Down

0 comments on commit 1e74527

Please sign in to comment.