From da2b3b6031e417a207216306f7fa0f1158ba5f5e Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Wed, 21 Feb 2024 18:11:51 +0200 Subject: [PATCH 1/3] remove dead code for OpenSSL keys --- keys/keys.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/keys/keys.go b/keys/keys.go index 524dff9..a2958d5 100644 --- a/keys/keys.go +++ b/keys/keys.go @@ -92,33 +92,13 @@ func ReadPrivateKey(reader io.Reader, passPhrase []byte) (privateKey [chacha20po return } - // Not OpenSSH private key, assuming OpenSSL private key, trying to figure out type (Ed25519 or X25519) block, _ := pem.Decode(allBytes) if block == nil { - return [chacha20poly1305.KeySize]byte{}, fmt.Errorf("Read of unrecognized private key format failed; " + + return [chacha20poly1305.KeySize]byte{}, fmt.Errorf("read of unrecognized private key format failed; " + "expected PEM encoded key") } - var openSSLPrivateKey openSSLPrivateKey - if _, err = asn1.Unmarshal(block.Bytes, &openSSLPrivateKey); err == nil { - // Trying to read OpenSSL Ed25519 private key and convert to X25519 private key - if openSSLPrivateKey.Algorithm.Algorithm.Equal(ed25519Algorithm) { - var edKeyBytes ed25519.PrivateKey - copy(edKeyBytes[:], block.Bytes[len(block.Bytes)-chacha20poly1305.KeySize:]) - PrivateKeyToCurve25519(&privateKey, edKeyBytes) - - return - } - - // Trying to read OpenSSL X25519 private key - if openSSLPrivateKey.Algorithm.Algorithm.Equal(x25519Algorithm) { - copy(privateKey[:], block.Bytes[len(block.Bytes)-chacha20poly1305.KeySize:]) - - return - } - } - // Interpreting bytes as Crypt4GH private key bytes (https://crypt4gh.readthedocs.io/en/latest/keys.html) if len(block.Bytes) > 8 && string(block.Bytes[:7]) == magic { return readCrypt4GHPrivateKey(block.Bytes, passPhrase) From f46988f527892e92e5f04523b62eba92f2bc6f07 Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Wed, 21 Feb 2024 18:11:55 +0200 Subject: [PATCH 2/3] exclude examples folder from testing --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc570f5..7887242 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: fi - name: Test - run: go test -v -coverprofile=coverage.txt -covermode=atomic ./... + run: go test -v -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v /examples/) - name: Codecov uses: codecov/codecov-action@v4.0.1 From 39e61770ee15ed05a225ee5f6377acff5f5411bc Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Wed, 21 Feb 2024 18:20:49 +0200 Subject: [PATCH 3/3] use latest golangci-lint --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c1d97f6..2fac5b5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,5 +20,5 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v4.0.0 with: - version: v1.51.1 + version: latest args: -E bodyclose,gocritic,gofmt,gosec,govet,nestif,nlreturn,revive,rowserrcheck --exclude G401,G501,G107