Documentation
¶
Index ¶
- Variables
- type DataRequest
- type DataResponse
- type InitRequest
- type InitResponse
- type LoginRequest
- type LoginResponse
- type NameRequest
- type NameResponse
- type PingRequest
- type PingResponse
- type RequestProcessor
- func (s *RequestProcessor) Decrypt(req DataRequest, response *DataResponse) error
- func (s *RequestProcessor) Encrypt(req DataRequest, response *DataResponse) error
- func (s *RequestProcessor) GetName(req NameRequest, response *NameResponse) error
- func (s *RequestProcessor) Init(req InitRequest, response *InitResponse) error
- func (s *RequestProcessor) Login(req LoginRequest, response *LoginResponse) error
- func (s *RequestProcessor) Ping(req PingRequest, response *PingResponse) error
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAuthKey = errors.New("Invalid authKey") ErrInvalidPassword = errors.New("Invalid password") )
Encrypt/decrypt errors
Functions ¶
This section is empty.
Types ¶
type DataRequest ¶
type DataRequest struct {
Data string `json:"data"`
}
DataRequest contains data to be encrypted/decrypted
type DataResponse ¶
type DataResponse struct {
Data string `json:"data"`
}
DataResponse contains the encrypted/decrypted data
type InitRequest ¶
InitRequest initializes the decryption server with the given password
type InitResponse ¶
type InitResponse struct {
AuthKey string `json:"auth"`
}
InitResponse returns the AuthKey. This is a string to validate the decryption password
type LoginRequest ¶
type LoginRequest struct { Password string `json:"pwd"` AuthKey string `json:"auth"` Name string `json:"name"` }
LoginRequest sends the password and the authkey to the serevr to validate
type LoginResponse ¶
type LoginResponse struct {
Ok bool `json:"ok"`
}
LoginResponse returns the result of login password validation
type NameResponse ¶
type NameResponse struct {
Name string `json:"name"`
}
NameResponse contains the name of the server
type PingRequest ¶
type PingRequest struct{}
PingRequest is ti check connection status and extend idle timeout
type RequestProcessor ¶
type RequestProcessor struct { Name string // contains filtered or unexported fields }
RequestProcessor is created after a successful login. It implements a simple RPC protocol betwee the agent and a client using the agent to encrypt/decrypt data
func NewRequestProcessor ¶
func NewRequestProcessor(server Server, pingFunc func(), name string) RequestProcessor
NewRequestProcessor return a new RequestProcessor object using the given server
func (*RequestProcessor) Decrypt ¶
func (s *RequestProcessor) Decrypt(req DataRequest, response *DataResponse) error
Decrypt a block of data
func (*RequestProcessor) Encrypt ¶
func (s *RequestProcessor) Encrypt(req DataRequest, response *DataResponse) error
Encrypt a block of data
func (*RequestProcessor) GetName ¶
func (s *RequestProcessor) GetName(req NameRequest, response *NameResponse) error
GetName returns the name of the server
func (*RequestProcessor) Init ¶
func (s *RequestProcessor) Init(req InitRequest, response *InitResponse) error
Init initializes the processor with a password
func (*RequestProcessor) Login ¶
func (s *RequestProcessor) Login(req LoginRequest, response *LoginResponse) error
Login validates the password and sets up the encryption server
func (*RequestProcessor) Ping ¶
func (s *RequestProcessor) Ping(req PingRequest, response *PingResponse) error
Ping calls the ping function
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server keeps all the information necessary to encrypt/decrypt data
func InitServer ¶
InitServer creates a new encrypt/decrypt server using the given password. It returns the server containing a key and salt
func NewServer ¶
NewServer returns a new server with the given password and authorization key. If the password does not validate, returns error
func (Server) GetAuthKey ¶
GetAuthKey returns a string that can be used for password validation. It is:
salt iv enc(randombytes hmac)