From 87b59747bc1654279eeb347e86926cf2b0c41b67 Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter <10532077+lubux@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:17:21 +0100 Subject: [PATCH] Remove Name field from profile (#305) * feat: Remove Name field from profile * ci: Update interop-test-docker to v1.1.12 --- .github/workflows/sop-test-suite.yml | 2 +- crypto/base_test.go | 3 ++- crypto/encrypt_decrypt_test.go | 8 ++++---- profile/preset.go | 3 --- profile/profile.go | 2 -- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sop-test-suite.yml b/.github/workflows/sop-test-suite.yml index 96e75206..6037a6aa 100644 --- a/.github/workflows/sop-test-suite.yml +++ b/.github/workflows/sop-test-suite.yml @@ -46,7 +46,7 @@ jobs: name: Run interoperability test suite runs-on: ubuntu-latest container: - image: ghcr.io/protonmail/openpgp-interop-test-docker:v1.1.9 + image: ghcr.io/protonmail/openpgp-interop-test-docker:v1.1.12 credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} diff --git a/crypto/base_test.go b/crypto/base_test.go index 454f885e..a4b88636 100644 --- a/crypto/base_test.go +++ b/crypto/base_test.go @@ -19,6 +19,7 @@ const testMessage = "Hello world!" var testPGP *PGPHandle var testProfiles []*profile.Custom +var testProfileNames []string func readTestFile(name string, trimNewlines bool) string { data, err := os.ReadFile("testdata/" + name) //nolint @@ -35,7 +36,7 @@ func init() { testPGP = PGP() testPGP.defaultTime = NewConstantClock(testTime) // 2019-05-13T13:37:07+00:00 testProfiles = []*profile.Custom{profile.Default(), profile.RFC4880(), profile.RFC9580()} - + testProfileNames = []string{"Default", "RFC4880", "RFC9580"} initEncDecTest() initGenerateKeys() initArmoredKeys() diff --git a/crypto/encrypt_decrypt_test.go b/crypto/encrypt_decrypt_test.go index 5eae4c6c..23adc2ac 100644 --- a/crypto/encrypt_decrypt_test.go +++ b/crypto/encrypt_decrypt_test.go @@ -23,7 +23,7 @@ var password = []byte("password") var decPasswords = [][]byte{[]byte("wrongPassword"), password} var testMaterialForProfiles []*testMaterial -func generateTestKeyMaterial(profile *profile.Custom) *testMaterial { +func generateTestKeyMaterial(name string, profile *profile.Custom) *testMaterial { handle := PGPWithProfile(profile) testSessionKey, err := handle.GenerateSessionKey() if err != nil { @@ -57,7 +57,7 @@ func generateTestKeyMaterial(profile *profile.Custom) *testMaterial { panic("Cannot generate key:" + err.Error()) } return &testMaterial{ - profileName: profile.Name, + profileName: name, pgp: handle, keyRingTestPublic: keyRingTestPublic, keyRingTestPrivate: keyRingTestPrivate, @@ -67,8 +67,8 @@ func generateTestKeyMaterial(profile *profile.Custom) *testMaterial { } func initEncDecTest() { - for _, profile := range testProfiles { - material := generateTestKeyMaterial(profile) + for ind, profile := range testProfiles { + material := generateTestKeyMaterial(testProfileNames[ind], profile) testMaterialForProfiles = append(testMaterialForProfiles, material) } if len(testMaterialForProfiles) < 2 { diff --git a/profile/preset.go b/profile/preset.go index ac95f0e6..7ae284a3 100644 --- a/profile/preset.go +++ b/profile/preset.go @@ -21,7 +21,6 @@ func Default() *Custom { } } return &Custom{ - Name: "default", SetKeyAlgorithm: setKeyAlgorithm, Hash: crypto.SHA256, CipherEncryption: packet.CipherAES256, @@ -45,7 +44,6 @@ func RFC4880() *Custom { } } return &Custom{ - Name: "rfc4880", SetKeyAlgorithm: setKeyAlgorithm, Hash: crypto.SHA256, CipherEncryption: packet.CipherAES256, @@ -65,7 +63,6 @@ func RFC9580() *Custom { } } return &Custom{ - Name: "rfc9580", SetKeyAlgorithm: setKeyAlgorithm, Hash: crypto.SHA512, CipherEncryption: packet.CipherAES256, diff --git a/profile/profile.go b/profile/profile.go index d86930b3..c2e88c14 100644 --- a/profile/profile.go +++ b/profile/profile.go @@ -16,8 +16,6 @@ const weakMinRSABits = 1023 // Use one of the pre-defined profiles if possible. // i.e., profile.Default(), profile.RFC4880(). type Custom struct { - // Name defines the name of the custom profile. - Name string // SetKeyAlgorithm is a function that sets public key encryption // algorithm in the config bases on the int8 security level. SetKeyAlgorithm func(*packet.Config, int8)