Skip to content
Open
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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Go Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: '>= 1.19.2'
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest

- name: Test
run: go test -v -race ./...

- name: Upload Code Coverage
if: runner.os == 'Linux'
run: bash <(curl -s https://codecov.io/bash)
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ciphers/hmac/hmac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestEncrypt(t *testing.T) {

text := []byte("foobar")

k, err := symmecrypt.NewRandomKey(CipherName)
Expand Down
4 changes: 2 additions & 2 deletions cmd/symmecrypt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"strings"
Expand Down Expand Up @@ -172,7 +172,7 @@ func main() {
}

func readSecret() string {
b, err := ioutil.ReadAll(os.Stdin)
b, err := io.ReadAll(os.Stdin)
if len(b) == 0 {
os.Exit(0)
}
Expand Down
2 changes: 1 addition & 1 deletion convergent/convergent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package convergent

import (
"crypto/sha1"
"crypto/sha1" //nolint:gosec
"crypto/sha512"
"encoding/hex"
"errors"
Expand Down
10 changes: 5 additions & 5 deletions convergent/convergent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func TestKeyFromHash(t *testing.T) {
// Create a new content that we want to encrypt
clearContent := make([]byte, 10*1024*1024)
rand.Read(clearContent) // nolint
rand.Read(clearContent)

// Get the hash to know if the content is already known and encrypted
h, err := convergent.NewHash(bytes.NewReader(clearContent))
Expand Down Expand Up @@ -78,7 +78,7 @@ func runTest(t *testing.T, cipherName string) {

// Create a new content that we want to encrypt
clearContent := make([]byte, 10*1024*1024)
rand.Read(clearContent) // nolint
rand.Read(clearContent)

// Get the hash to know if the content is already known and encrypted
h, err := convergent.NewHash(bytes.NewReader(clearContent))
Expand All @@ -87,7 +87,7 @@ func runTest(t *testing.T, cipherName string) {
t.Logf("hash=%s", h)

_, has := mapHash[h]
require.False(t, has) // At this point the content is unkonwn
require.False(t, has) // At this point the content is unknown

k, err := convergent.NewKey(h, cfgs...)
require.NoError(t, err)
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestDecryptFromHTTP(t *testing.T) {

// Encrypt a random content
clearContent := make([]byte, 10*1024)
rand.Read(clearContent) // nolint
rand.Read(clearContent)

h, err := convergent.NewHash(bytes.NewReader(clearContent))
require.NoError(t, err)
Expand All @@ -292,7 +292,7 @@ func TestDecryptFromHTTP(t *testing.T) {
// Serve the encrypted content
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(1 * time.Second)
io.WriteString(w, encryptedContent) //nolint
io.WriteString(w, encryptedContent)
}))
defer ts.Close()

Expand Down
22 changes: 15 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
module github.com/ovh/symmecrypt

go 1.13
go 1.19

require (
github.com/SSSaaS/sssa-golang v0.0.0-20170502204618-d37d7782d752
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75
github.com/ovh/configstore v0.3.3-0.20200701085609-a539fcf61db5
github.com/ovh/configstore v0.6.1
github.com/pelletier/go-toml v1.8.0
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c // indirect
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
33 changes: 15 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,42 @@ github.com/SSSaaS/sssa-golang v0.0.0-20170502204618-d37d7782d752 h1:NMpC6M+PtNND
github.com/SSSaaS/sssa-golang v0.0.0-20170502204618-d37d7782d752/go.mod h1:PbJ8S5YaSYAvDPTiEuUsBHQwTUlPs6VM+Av8Oi3v570=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75 h1:cUVxyR+UfmdEAZGJ8IiKld1O0dbGotEnkMolG5hfMSY=
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75/go.mod h1:pBbZyGwC5i16IBkjVKoy/sznA8jPD/K9iedwe1ESE6w=
github.com/ovh/configstore v0.3.3-0.20200701085609-a539fcf61db5 h1:E5fS/QLKUEcInoJFtM3K5+6pVVTqKxwR5boVb5oZ02c=
github.com/ovh/configstore v0.3.3-0.20200701085609-a539fcf61db5/go.mod h1:IXY5qFC5mqMIFPXZjeZiAz/qIt+mO6F6SmsOCf/yits=
github.com/ovh/configstore v0.6.1 h1:EZg9Bgw6gm8zXkCjFxVqi4STE4spExkI1Nx0T2yMXwM=
github.com/ovh/configstore v0.6.1/go.mod h1:DU19o06umHsivDXqUXBGXiw/vTiLpADXBxkksoSz+Kc=
github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw=
github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c h1:UIcGWL6/wpCfyGuJnRFJRurA+yj8RrW7Q6x2YMCXt6c=
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A=
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2 h1:+j1SppRob9bAgoYmsdW9NNBdKZfgYuWpqnYHv78Qt8w=
gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions keyloader/keyloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ var (
)

// KeyConfig is the representation of an encryption key in the configuration.
// - Identifier is a free name to uniquely reference this key (and its revisions). It is used when loading the key.
// - Cipher controls which cipher is used (aes-gcm, ...)
// - Timestamp dictates priority between encryption keys, and is useful to identify new versions of a key
// - Sealed controls whether the key should be used as-is, or decrypted using symmecrypt/seal
// See RegisterCipher() to register a factory. The cipher field should be the same as the factory name.
// - Identifier is a free name to uniquely reference this key (and its revisions). It is used when loading the key.
// - Cipher controls which cipher is used (aes-gcm, ...)
// - Timestamp dictates priority between encryption keys, and is useful to identify new versions of a key
// - Sealed controls whether the key should be used as-is, or decrypted using symmecrypt/seal
// See RegisterCipher() to register a factory. The cipher field should be the same as the factory name.
type KeyConfig struct {
Identifier string `json:"identifier,omitempty"`
Cipher string `json:"cipher"`
Expand Down
2 changes: 1 addition & 1 deletion stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestMain(m *testing.M) {

func TestIncompleteRead(t *testing.T) {
clearContent := make([]byte, 32*1024+10)
rand.Read(clearContent) // nolint
rand.Read(clearContent)

k, err := keyloader.LoadKey("test")
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion symutils/symutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,6 @@ func (k *KeyMutex) String() (string, error) {

func RandomSalt() string {
var buff = make([]byte, 8)
rand.Read(buff) // nolint
rand.Read(buff)
return string(buff)
}