Skip to content

Commit

Permalink
Merge pull request #1 from teserakt-io/fb/openclient
Browse files Browse the repository at this point in the history
Open source preparations
  • Loading branch information
diagprov committed Sep 25, 2019
2 parents 2efcd70 + 6fe8be7 commit bf3ca86
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 55 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/go.yml
@@ -0,0 +1,29 @@
name: Go
on: [push]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: 1.12

- name: Install dependencies
run: |
go get honnef.co/go/tools/cmd/staticcheck
go get golang.org/x/lint/golint
- name: Lint
run: /home/runner/go/bin/golint -set_exit_status ./...

- name: Static check
run: /home/runner/go/bin/staticcheck ./...

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: teserakt-io/gh-actions/go-test@master
1 change: 0 additions & 1 deletion .gitignore
@@ -1,3 +1,2 @@
cover.out.tmp
cover.out
test/data
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -4,11 +4,11 @@ Although E4 is an in-house-developed product by Teserakt.io, it is still open-so

## Bugs, issues, feature requests

Please let us know by creating a [Github issues](https://github.com/Teserakt-io/e4common/issues) if you stumble upon a bug, have an issue or a feature request.
Please let us know by creating a [Github issues](https://github.com/Teserakt-io/e4go/issues) if you stumble upon a bug, have an issue or a feature request.

## Development

* We use golang version >= 1.12 for developing e4common.
* We use golang version >= 1.12 for developing e4go.
* Makes sure to create new unit tests covering your code additions.
* Please create pull requests targeting the `develop` branch

Expand Down
8 changes: 3 additions & 5 deletions README.md
@@ -1,7 +1,5 @@

# e4common

Copyright (C) Teserakt AG 2018-2019. All Rights Reserved.
# e4go

This repository implements E4 in Go, Teserakt's Secure machine-to-machine
communication protocol.
Expand All @@ -15,7 +13,7 @@ communication protocol.
Client instances can be created with either the `NewSymKeyClient` or
`NewSymKeyClientPretty` commands, for example you might call:
```go
import e4 "gitlab.com/teserakt/e4common"
import e4 "github.com/teserakt-io/e4go"

var id []byte
var key []byte
Expand All @@ -25,7 +23,7 @@ Client instances can be created with either the `NewSymKeyClient` or

If you know your id and key already; alternatively you might do:
```go
import e4 "gitlab.com/teserakt/e4common"
import e4 "github.com/teserakt-io/e4go"

name := "some client name"
pwd := "some random password"
Expand Down
8 changes: 4 additions & 4 deletions client.go
@@ -1,5 +1,5 @@
//
// Package e4common provides a e4 client implementation and libraries.
// Package e4go provides a e4 client implementation and libraries.
//
// It aims to be quick and easy to integrate in IoT devices applications
// enabling to secure their communications, as well as exposing a way to manage the various keys required.
Expand Down Expand Up @@ -28,7 +28,7 @@
// There is nothing particular to be done when receiving a command, just passing its protected form to the Unprotect() method
// and the client will automatically unprotect and process it (thus returning no unprotected message).
// See commands.go for the list of available commands and their respective parameters.
package e4common
package e4go

import (
"encoding/hex"
Expand All @@ -41,8 +41,8 @@ import (

"golang.org/x/crypto/ed25519"

e4crypto "gitlab.com/teserakt/e4common/crypto"
"gitlab.com/teserakt/e4common/keys"
e4crypto "github.com/teserakt-io/e4go/crypto"
"github.com/teserakt-io/e4go/keys"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions client_test.go
@@ -1,4 +1,4 @@
package e4common
package e4go

import (
"bytes"
Expand All @@ -10,8 +10,8 @@ import (
"time"

"github.com/agl/ed25519/extra25519"
e4crypto "gitlab.com/teserakt/e4common/crypto"
"gitlab.com/teserakt/e4common/keys"
e4crypto "github.com/teserakt-io/e4go/crypto"
"github.com/teserakt-io/e4go/keys"
"golang.org/x/crypto/ed25519"
)

Expand Down
5 changes: 3 additions & 2 deletions commands.go
@@ -1,10 +1,11 @@
package e4common
package e4go

import (
"errors"

e4crypto "gitlab.com/teserakt/e4common/crypto"
"golang.org/x/crypto/ed25519"

e4crypto "github.com/teserakt-io/e4go/crypto"
)

// Command is a command sent by C2 to a client. This is a sequence of bytes, starting from a Command, followed by the command arguments.
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/curve25519"

miscreant "github.com/miscreant/miscreant/go"
miscreant "github.com/miscreant/miscreant.go"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions example_test.go
@@ -1,12 +1,12 @@
package e4common
package e4go

import (
"log"

"github.com/agl/ed25519/extra25519"
"golang.org/x/crypto/ed25519"

"gitlab.com/teserakt/e4common/crypto"
"github.com/teserakt-io/e4go/crypto"
)

func ExampleNewSymKeyClient() {
Expand Down
7 changes: 2 additions & 5 deletions go.mod
@@ -1,12 +1,9 @@
module gitlab.com/teserakt/e4common
module github.com/teserakt-io/e4go

go 1.12

require (
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
github.com/golang/protobuf v1.3.1
github.com/miscreant/miscreant v0.3.0
github.com/miscreant/miscreant.go v0.0.0-20190903041724-6bebe170cbaf
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
google.golang.org/grpc v1.21.1
)
28 changes: 2 additions & 26 deletions go.sum
@@ -1,38 +1,14 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/miscreant/miscreant v0.3.0 h1:bCn4zQMvNeeFBE3PWrG9ePFLPZyttBPhJ/WDqyqWrLQ=
github.com/miscreant/miscreant v0.3.0/go.mod h1:ZKWeIKfbJej2zjb1OUXJaaP1DnCb4yoTtcR90O7BOD4=
github.com/miscreant/miscreant.go v0.0.0-20190903041724-6bebe170cbaf h1:WHuYoA2VHEGYtfIaV2oBwa8csNWuUpCKAnDf3Jz2D1o=
github.com/miscreant/miscreant.go v0.0.0-20190903041724-6bebe170cbaf/go.mod h1:pBbZyGwC5i16IBkjVKoy/sznA8jPD/K9iedwe1ESE6w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 h1:8dUaAV7K4uHsF56JQWkprecIQKdPHtR9jCHF5nB8uzc=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
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/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/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/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
2 changes: 1 addition & 1 deletion keys/publickey.go
Expand Up @@ -8,7 +8,7 @@ import (
"sync"
"time"

e4crypto "gitlab.com/teserakt/e4common/crypto"
e4crypto "github.com/teserakt-io/e4go/crypto"

"github.com/agl/ed25519/extra25519"
"golang.org/x/crypto/curve25519"
Expand Down
14 changes: 13 additions & 1 deletion keys/publickey_test.go
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/agl/ed25519/extra25519"

e4crypto "gitlab.com/teserakt/e4common/crypto"
e4crypto "github.com/teserakt-io/e4go/crypto"
"golang.org/x/crypto/ed25519"
)

Expand Down Expand Up @@ -352,6 +352,10 @@ func TestPubKeyMaterialPubKeys(t *testing.T) {

func TestPubKeyMaterialSetKey(t *testing.T) {
_, privateKey, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatalf("Failed to generate key: %v", err)
}

clientID := e4crypto.HashIDAlias("test")

k, err := NewPubKeyMaterial(clientID, privateKey, getTestC2PubKey(t))
Expand All @@ -369,6 +373,10 @@ func TestPubKeyMaterialSetKey(t *testing.T) {
}

_, privateKey2, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatalf("Failed to generate key: %v", err)
}

if err := typedKey.SetKey(privateKey2); err != nil {
t.Fatalf("Failed to set key: %v", err)
}
Expand All @@ -389,6 +397,10 @@ func TestPubKeyMaterialSetKey(t *testing.T) {

func TestPubKeyMaterialMarshalJSON(t *testing.T) {
_, privateKey, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatalf("Failed to generate key: %v", err)
}

clientID := e4crypto.HashIDAlias("test")
c2Pk := getTestC2PubKey(t)

Expand Down
2 changes: 1 addition & 1 deletion keys/symmetric.go
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

e4crypto "gitlab.com/teserakt/e4common/crypto"
e4crypto "github.com/teserakt-io/e4go/crypto"
)

// SymKeyMaterial extends the KeyMaterial interface for symmetric key implementations
Expand Down
2 changes: 1 addition & 1 deletion keys/symmetric_test.go
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"testing"

e4crypto "gitlab.com/teserakt/e4common/crypto"
e4crypto "github.com/teserakt-io/e4go/crypto"
)

func TestNewSymKeyFromPassword(t *testing.T) {
Expand Down

0 comments on commit bf3ca86

Please sign in to comment.