This commit is contained in:
parent
7f6d7cc0c4
commit
139f5f6d9c
3 changed files with 19 additions and 19 deletions
|
@ -215,14 +215,14 @@ func (r *TorRelayIdentityEd25519Resource) encodeTorPrivateKey(privateKey ed25519
|
|||
// Tor Ed25519 private key format:
|
||||
// "== ed25519v1-secret: type0 ==" + null bytes + 64 bytes key data
|
||||
header := "== ed25519v1-secret: type0 =="
|
||||
|
||||
|
||||
// Create 96-byte buffer: 32 bytes header + null padding + 64 bytes key
|
||||
torKey := make([]byte, 96)
|
||||
copy(torKey, header)
|
||||
|
||||
|
||||
// Copy the private key (64 bytes) starting at offset 32
|
||||
copy(torKey[32:], privateKey)
|
||||
|
||||
|
||||
return base64.StdEncoding.EncodeToString(torKey)
|
||||
}
|
||||
|
||||
|
@ -230,13 +230,13 @@ func (r *TorRelayIdentityEd25519Resource) encodeTorPublicKey(publicKey ed25519.P
|
|||
// Tor Ed25519 public key format:
|
||||
// "== ed25519v1-public: type0 ==" + null bytes + 32 bytes key data
|
||||
header := "== ed25519v1-public: type0 =="
|
||||
|
||||
|
||||
// Create 64-byte buffer: 32 bytes header + null padding + 32 bytes key
|
||||
torKey := make([]byte, 64)
|
||||
copy(torKey, header)
|
||||
|
||||
|
||||
// Copy the public key (32 bytes) starting at offset 32
|
||||
copy(torKey[32:], publicKey)
|
||||
|
||||
|
||||
return base64.StdEncoding.EncodeToString(torKey)
|
||||
}
|
||||
|
|
|
@ -38,15 +38,15 @@ func TestAccTorRelayIdentityEd25519Resource(t *testing.T) {
|
|||
func TestTorEd25519FingerprintGeneration(t *testing.T) {
|
||||
testPubKeyBase64 := "PT0gZWQyNTUxOXYxLXB1YmxpYzogdHlwZTAgPT0AAAB6UEqfT3OvqdpNfw/rbOucsc5AXRUw4lcy/SaWxruoYA=="
|
||||
expectedFingerprint := "elBKn09zr6naTX8P62zrnLHOQF0VMOJXMv0mlsa7qGA"
|
||||
|
||||
|
||||
pubKeyBytes, err := base64.StdEncoding.DecodeString(testPubKeyBase64)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode test public key: %v", err)
|
||||
}
|
||||
|
||||
|
||||
actualFingerprint := base64.StdEncoding.EncodeToString(pubKeyBytes[32:])
|
||||
actualFingerprint = regexp.MustCompile(`=*$`).ReplaceAllString(actualFingerprint, "")
|
||||
|
||||
|
||||
if actualFingerprint != expectedFingerprint {
|
||||
t.Errorf("Expected fingerprint %s, got %s", expectedFingerprint, actualFingerprint)
|
||||
}
|
||||
|
@ -72,16 +72,16 @@ func TestAccTorRelayIdentityEd25519TorFormat(t *testing.T) {
|
|||
|
||||
func TestTorEd25519FormatEncoding(t *testing.T) {
|
||||
testPubKeyBase64 := "PT0gZWQyNTUxOXYxLXB1YmxpYzogdHlwZTAgPT0AAAB6UEqfT3OvqdpNfw/rbOucsc5AXRUw4lcy/SaWxruoYA=="
|
||||
|
||||
|
||||
pubKeyBytes, err := base64.StdEncoding.DecodeString(testPubKeyBase64)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode test public key: %v", err)
|
||||
}
|
||||
|
||||
|
||||
if len(pubKeyBytes) != 64 {
|
||||
t.Errorf("Expected public key to be 64 bytes, got %d", len(pubKeyBytes))
|
||||
}
|
||||
|
||||
|
||||
expectedHeader := "== ed25519v1-public: type0 =="
|
||||
actualHeader := string(pubKeyBytes[:len(expectedHeader)])
|
||||
if actualHeader != expectedHeader {
|
||||
|
|
|
@ -31,13 +31,13 @@ func NewTorRelayIdentityRsaResource() resource.Resource {
|
|||
type TorRelayIdentityRsaResource struct{}
|
||||
|
||||
type TorRelayIdentityRsaResourceModel struct {
|
||||
Id types.String `tfsdk:"id"`
|
||||
Algorithm types.String `tfsdk:"algorithm"`
|
||||
PrivateKeyPem types.String `tfsdk:"private_key_pem"`
|
||||
PublicKeyPem types.String `tfsdk:"public_key_pem"`
|
||||
PublicKeyFingerprintSha1 types.String `tfsdk:"public_key_fingerprint_sha1"`
|
||||
PublicKeyFingerprintSha256 types.String `tfsdk:"public_key_fingerprint_sha256"`
|
||||
PublicKeyFingerprintSha1Hashed types.String `tfsdk:"public_key_fingerprint_sha1_hashed"`
|
||||
Id types.String `tfsdk:"id"`
|
||||
Algorithm types.String `tfsdk:"algorithm"`
|
||||
PrivateKeyPem types.String `tfsdk:"private_key_pem"`
|
||||
PublicKeyPem types.String `tfsdk:"public_key_pem"`
|
||||
PublicKeyFingerprintSha1 types.String `tfsdk:"public_key_fingerprint_sha1"`
|
||||
PublicKeyFingerprintSha256 types.String `tfsdk:"public_key_fingerprint_sha256"`
|
||||
PublicKeyFingerprintSha1Hashed types.String `tfsdk:"public_key_fingerprint_sha1_hashed"`
|
||||
}
|
||||
|
||||
func (r *TorRelayIdentityRsaResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue