From 139f5f6d9cda9070ee0a6a7d67d5a9ca41c84ed1 Mon Sep 17 00:00:00 2001 From: Abel Luck Date: Wed, 10 Sep 2025 14:14:13 +0200 Subject: [PATCH] run nix fmt --- .../tor_relay_identity_ed25519_resource.go | 12 ++++++------ .../tor_relay_identity_ed25519_resource_test.go | 12 ++++++------ .../provider/tor_relay_identity_rsa_resource.go | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/provider/tor_relay_identity_ed25519_resource.go b/internal/provider/tor_relay_identity_ed25519_resource.go index f513097..fdec904 100644 --- a/internal/provider/tor_relay_identity_ed25519_resource.go +++ b/internal/provider/tor_relay_identity_ed25519_resource.go @@ -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) } diff --git a/internal/provider/tor_relay_identity_ed25519_resource_test.go b/internal/provider/tor_relay_identity_ed25519_resource_test.go index f293060..ea2638e 100644 --- a/internal/provider/tor_relay_identity_ed25519_resource_test.go +++ b/internal/provider/tor_relay_identity_ed25519_resource_test.go @@ -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 { diff --git a/internal/provider/tor_relay_identity_rsa_resource.go b/internal/provider/tor_relay_identity_rsa_resource.go index 7cc1e8b..bf8ccb6 100644 --- a/internal/provider/tor_relay_identity_rsa_resource.go +++ b/internal/provider/tor_relay_identity_rsa_resource.go @@ -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) {