Commit 3df3d95e authored by David Venhoek's avatar David Venhoek Committed by Sietse Ringers
Browse files

Moved keyshareserver and keysharecore to better places in the irmago directory structure.

parent 42d5b1f1
package keyshareCore
package keysharecore
import (
"crypto/rsa"
......
package keyshareCore
package keysharecore
import (
"crypto/hmac"
......
package keyshareCore
package keysharecore
import (
"crypto/rand"
......
package keyshareCore
package keysharecore
import (
"crypto/aes"
......
package keyshareCore
package keysharecore
import (
"crypto/rand"
......
package keyshareServerCore
package keyshareserver
import (
"encoding/binary"
......@@ -7,7 +7,7 @@ import (
"strings"
"github.com/privacybydesign/irmago/internal/common"
"github.com/privacybydesign/irmago/keyshareCore"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/dgrijalva/jwt-go"
"github.com/go-errors/errors"
......@@ -81,18 +81,18 @@ type Configuration struct {
Production bool `json:"production" mapstructure:"production"`
}
func readAESKey(filename string) (uint32, keyshareCore.AesKey, error) {
func readAESKey(filename string) (uint32, keysharecore.AesKey, error) {
keyFile, err := os.Open(filename)
if err != nil {
return 0, keyshareCore.AesKey{}, err
return 0, keysharecore.AesKey{}, err
}
defer keyFile.Close()
keyData, err := ioutil.ReadAll(keyFile)
if err != nil {
return 0, keyshareCore.AesKey{}, err
return 0, keysharecore.AesKey{}, err
}
if len(keyData) != 32+4 {
return 0, keyshareCore.AesKey{}, errors.New("Invalid aes key")
return 0, keysharecore.AesKey{}, errors.New("Invalid aes key")
}
var key [32]byte
copy(key[:], keyData[4:36])
......@@ -101,7 +101,7 @@ func readAESKey(filename string) (uint32, keyshareCore.AesKey, error) {
// Process a passed configuration to ensure all field values are valid and initialized
// as required by the rest of this keyshare server component.
func processConfiguration(conf *Configuration) (*keyshareCore.KeyshareCore, error) {
func processConfiguration(conf *Configuration) (*keysharecore.KeyshareCore, error) {
// Setup log
if conf.Logger == nil {
conf.Logger = server.NewLogger(conf.Verbose, conf.Quiet, conf.LogJSON)
......@@ -190,8 +190,8 @@ func processConfiguration(conf *Configuration) (*keyshareCore.KeyshareCore, erro
conf.ServerConfiguration.DisableTLS = conf.DisableTLS // ensure matching checks
}
// Parse keyshareCore private keys and create a valid keyshare core
core := keyshareCore.NewKeyshareCore()
// Parse keysharecore private keys and create a valid keyshare core
core := keysharecore.NewKeyshareCore()
if conf.JwtPrivateKey == "" && conf.JwtPrivateKeyFile == "" {
return nil, server.LogError(errors.Errorf("Missing keyshare server jwt key"))
}
......
package keyshareServerCore
package keyshareserver
import (
"database/sql"
......@@ -6,7 +6,7 @@ import (
"sync"
"time"
"github.com/privacybydesign/irmago/keyshareCore"
"github.com/privacybydesign/irmago/internal/keysharecore"
_ "github.com/jackc/pgx/stdlib"
)
......@@ -36,12 +36,12 @@ type KeyshareUser interface {
type KeyshareUserData struct {
Username string
Coredata keyshareCore.EncryptedKeysharePacket
Coredata keysharecore.EncryptedKeysharePacket
}
type keyshareMemoryDB struct {
lock sync.Mutex
users map[string]keyshareCore.EncryptedKeysharePacket
users map[string]keysharecore.EncryptedKeysharePacket
}
type keyshareMemoryUser struct {
......@@ -53,7 +53,7 @@ func (m *keyshareMemoryUser) Data() *KeyshareUserData {
}
func NewMemoryDatabase() KeyshareDB {
return &keyshareMemoryDB{users: map[string]keyshareCore.EncryptedKeysharePacket{}}
return &keyshareMemoryDB{users: map[string]keysharecore.EncryptedKeysharePacket{}}
}
func (db *keyshareMemoryDB) User(username string) (KeyshareUser, error) {
......
package keyshareServerCore
package keyshareserver
import (
"github.com/privacybydesign/gabi"
......
package keyshareServerCore
package keyshareserver
import (
"crypto/rand"
......@@ -15,7 +15,7 @@ import (
irma "github.com/privacybydesign/irmago"
"github.com/sirupsen/logrus"
"github.com/privacybydesign/irmago/keyshareCore"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/irmaserver"
......@@ -31,7 +31,7 @@ type SessionData struct {
type Server struct {
conf *Configuration
core *keyshareCore.KeyshareCore
core *keysharecore.KeyshareCore
sessionserver *irmaserver.Server
db KeyshareDB
......@@ -289,7 +289,7 @@ func (s *Server) handleVerifyPin(w http.ResponseWriter, r *http.Request) {
return
}
jwtt, err := s.core.ValidatePin(user.Data().Coredata, msg.Pin, msg.Username)
if err == keyshareCore.ErrInvalidPin {
if err == keysharecore.ErrInvalidPin {
if tries == 0 {
server.WriteJson(w, keysharePinStatus{Status: "error", Message: fmt.Sprintf("%v", wait)})
} else {
......@@ -352,7 +352,7 @@ func (s *Server) handleChangePin(w http.ResponseWriter, r *http.Request) {
return
}
user.Data().Coredata, err = s.core.ChangePin(user.Data().Coredata, msg.OldPin, msg.NewPin)
if err == keyshareCore.ErrInvalidPin {
if err == keysharecore.ErrInvalidPin {
if tries == 0 {
server.WriteJson(w, keysharePinStatus{Status: "error", Message: fmt.Sprintf("%v", wait)})
} else {
......
......@@ -3,14 +3,14 @@ package main
import (
"net/http"
"github.com/privacybydesign/irmago/keyshareServerCore"
"github.com/privacybydesign/irmago/server/keyshareserver"
)
func main() {
s, err := keyshareServerCore.New(&keyshareServerCore.Configuration{
s, err := keyshareserver.New(&keyshareserver.Configuration{
SchemesPath: "schemes/",
URL: "http://10.0.2.2:8080/",
DbType: keyshareServerCore.DatabaseTypePostgres,
DbType: keyshareserver.DatabaseTypePostgres,
DbConnstring: "postgresql://localhost:5432/test",
JwtKeyId: 0,
JwtPrivateKeyFile: "schemes/test/kss-0.private.pem",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment