Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump golang to 1.23 #8

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Golangci-lint
on:
push:
branches:
- master
pull_request:

jobs:
golangci-lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Checkout
uses: actions/checkout@v4

- name: Golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: 'v1.62'
109 changes: 109 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
run:
deadline: 5m

linters-settings:
staticcheck:
go: '1.23'
stylecheck:
go: '1.23'
gci:
local-prefixes: github.com/kayrus
goimports:
local-prefixes: github.com/kayrus
depguard:
rules:
prevent_unmaintained_packages:
list-mode: lax
files:
- $all
- "!$test"
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"

linters:
fast: false
disable-all: true
enable:
- asciicheck
- bodyclose
- depguard
- dogsled
- errcheck
- copyloopvar
- gci
- gofmt
- goheader
- goimports
- gomodguard
- goprintffuncname
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- whitespace
# - exhaustive
# - godot
# - cyclop
# - dupl
# - durationcheck
# - errname
# - errorlint
# - exhaustivestruct
# - forbidigo
# - forcetypeassert
# - funlen
# - gochecknoglobals
# - gochecknoinits
# - gocognit
# - goconst
# - gocritic
# - gocyclo
# - godox
# - goerr113
# - gofumpt
# - golint
# - gomnd
# - gomoddirectives
# - gosec (gas)
# - gosimple (megacheck)
# - ifshort
# - importas
# - interfacer
# - lll
# - makezero
# - maligned
# - nestif
# - nilerr
# - nlreturn
# - noctx
# - paralleltest
# - predeclared
# - promlinter
# - revive
# - scopelint
# - sqlclosecheck
# - tagliatelle
# - testpackage
# - thelper
# - tparallel
# - unparam
# - wastedassign
# - wrapcheck
# - wsl

issues:
exclude-rules:
- linters:
- staticcheck
text: "SA1019:"
- linters:
- stylecheck
text: "ST1005:"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# putty

Go package to parse PuTTY private key formats. Go 1.22 or above is required.
Go package to parse PuTTY private key formats. Go 1.23 or above is required.

## Example

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/kayrus/putty

go 1.22
go 1.23

require golang.org/x/crypto v0.25.0
require golang.org/x/crypto v0.31.0

require golang.org/x/sys v0.22.0 // indirect
require golang.org/x/sys v0.28.0 // indirect
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
50 changes: 40 additions & 10 deletions putty.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,46 @@ func decryptCBC(cipherKey, cipherIV, macKey, ciphertext []byte) error {

// validateHMAC validates PuTTY key HMAC with a hash function
func (k Key) validateHMAC(hashFunc hash.Hash) error {
binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Algo)))
hashFunc.Write([]byte(k.Algo))
binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Encryption)))
hashFunc.Write([]byte(k.Encryption))
binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Comment)))
hashFunc.Write([]byte(k.Comment))
binary.Write(hashFunc, binary.BigEndian, uint32(len(k.PublicKey)))
hashFunc.Write(k.PublicKey)
binary.Write(hashFunc, binary.BigEndian, uint32(len(k.PrivateKey)))
hashFunc.Write(k.PrivateKey)
err := binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Algo)))
if err != nil {
return err
}
_, err = hashFunc.Write([]byte(k.Algo))
if err != nil {
return err
}
err = binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Encryption)))
if err != nil {
return err
}
_, err = hashFunc.Write([]byte(k.Encryption))
if err != nil {
return err
}
err = binary.Write(hashFunc, binary.BigEndian, uint32(len(k.Comment)))
if err != nil {
return err
}
_, err = hashFunc.Write([]byte(k.Comment))
if err != nil {
return err
}
err = binary.Write(hashFunc, binary.BigEndian, uint32(len(k.PublicKey)))
if err != nil {
return err
}
_, err = hashFunc.Write(k.PublicKey)
if err != nil {
return err
}
err = binary.Write(hashFunc, binary.BigEndian, uint32(len(k.PrivateKey)))
if err != nil {
return err
}
_, err = hashFunc.Write(k.PrivateKey)
if err != nil {
return err
}

mac := hashFunc.Sum(nil)
if !bytes.Equal(mac, k.PrivateMac) {
Expand Down
1 change: 0 additions & 1 deletion putty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ Comment: a@b`
if err == nil {
t.Errorf("Invalid key algorithm")
}

}

func TestKey_Load(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func parseField(v reflect.Value, src *bytes.Reader) error {
}
}
return nil
default:
}

switch fieldType {
Expand Down
Loading