Skip to content

Commit

Permalink
fix: pad ecdsa key with 00 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur authored Apr 6, 2024
1 parent f856877 commit f24d7c1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/operator/keys/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,21 @@ func saveEcdsaKey(
return displayWithLess(privateKeyHex, KeyTypeECDSA)
}

func padLeft(str string, length int) string {
for len(str) < length {
str = "0" + str
}
return str
}

func displayWithLess(privateKeyHex string, keyType string) error {
var message, border, keyLine string
tabSpace := " "

// Pad with 0 to match size of 64 bytes
if keyType == KeyTypeECDSA {
privateKeyHex = padLeft(privateKeyHex, 64)
}
keyContent := tabSpace + privateKeyHex + tabSpace
borderLength := len(keyContent) + 4
border = strings.Repeat("/", borderLength)
Expand Down

0 comments on commit f24d7c1

Please sign in to comment.