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 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 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)