Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bindings
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
katzenpost
bindings
Commits
57e0b45b
Unverified
Commit
57e0b45b
authored
Feb 01, 2018
by
Ruben Pollan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: add key discovery
parent
8b8178c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
17 deletions
+73
-17
python/client.go
python/client.go
+64
-6
python/config.go
python/config.go
+9
-11
No files found.
python/client.go
View file @
57e0b45b
...
...
@@ -18,10 +18,15 @@
package
katzenpost
import
(
"encoding/json"
"errors"
"net/http"
"net/url"
"strings"
"time"
"github.com/katzenpost/core/crypto/ecdh"
"github.com/katzenpost/core/pki"
"github.com/katzenpost/mailproxy"
"github.com/katzenpost/mailproxy/config"
"github.com/katzenpost/mailproxy/event"
...
...
@@ -31,8 +36,6 @@ const (
pkiName
=
"default"
)
var
identityKeyBytes
=
[]
byte
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
// TimeoutError is returned on timeouts
type
TimeoutError
struct
{}
...
...
@@ -98,7 +101,16 @@ func (c Client) WaitToConnect() error {
// ListProviders returns the provider list
func
(
c
Client
)
ListProviders
()
([]
string
,
error
)
{
return
c
.
proxy
.
ListProviders
(
pkiName
)
providers
,
err
:=
c
.
proxy
.
ListProviders
(
pkiName
)
if
err
!=
nil
{
return
nil
,
err
}
names
:=
make
([]
string
,
len
(
providers
))
for
i
,
provider
:=
range
providers
{
names
[
i
]
=
provider
.
Name
}
return
names
,
nil
}
// Shutdown the client
...
...
@@ -108,12 +120,58 @@ func (c Client) Shutdown() {
// Send a message into katzenpost
func
(
c
Client
)
Send
(
recipient
,
msg
string
)
error
{
var
identityKey
ecdh
.
PrivateKey
identityKey
.
FromBytes
(
identityKeyBytes
)
c
.
proxy
.
SetRecipient
(
recipient
,
identityKey
.
PublicKey
())
err
:=
c
.
fetchKey
(
recipient
)
if
err
!=
nil
{
return
err
}
return
c
.
proxy
.
SendMessage
(
c
.
address
,
recipient
,
[]
byte
(
msg
))
}
func
(
c
Client
)
fetchKey
(
address
string
)
error
{
parts
:=
strings
.
Split
(
address
,
"@"
)
if
len
(
parts
)
!=
2
{
return
errors
.
New
(
"Not valid address address: "
+
address
)
}
user
:=
strings
.
ToLower
(
parts
[
0
])
providerName
:=
parts
[
1
]
providers
,
err
:=
c
.
proxy
.
ListProviders
(
pkiName
)
if
err
!=
nil
{
return
err
}
providerAddress
:=
""
for
_
,
provider
:=
range
providers
{
if
provider
.
Name
==
providerName
{
addr
:=
provider
.
Addresses
[
pki
.
TransportTCPv4
][
0
]
providerAddress
=
strings
.
Split
(
addr
,
":"
)[
0
]
break
}
}
if
providerAddress
==
""
{
return
errors
.
New
(
"Recipient provider doesn't exist in the authority document: "
+
providerName
)
}
resp
,
err
:=
http
.
PostForm
(
"http://"
+
providerAddress
+
":7900/getidkey"
,
url
.
Values
{
"user"
:
{
user
}})
if
err
!=
nil
{
return
errors
.
New
(
"Can't fetch key for address: "
+
err
.
Error
())
}
defer
resp
.
Body
.
Close
()
decoder
:=
json
.
NewDecoder
(
resp
.
Body
)
var
response
struct
{
Getidkey
string
}
err
=
decoder
.
Decode
(
&
response
)
if
err
!=
nil
{
return
errors
.
New
(
"There was a problem reading the key fetch response: "
+
err
.
Error
())
}
var
key
ecdh
.
PublicKey
key
.
FromString
(
response
.
Getidkey
)
c
.
proxy
.
SetRecipient
(
address
,
&
key
)
return
nil
}
// Message received from katzenpost
type
Message
struct
{
Sender
string
...
...
python/config.go
View file @
57e0b45b
...
...
@@ -22,20 +22,20 @@ import (
"os"
"path"
"github.com/katzenpost/core/crypto/ecdh"
"github.com/katzenpost/core/crypto/eddsa"
"github.com/katzenpost/mailproxy/config"
)
// Config has the client configuration
type
Config
struct
{
PkiAddress
string
PkiKey
string
User
string
Provider
string
LinkKey
Key
Log
LogConfig
DataDir
string
PkiAddress
string
PkiKey
string
User
string
Provider
string
IdentityKey
Key
LinkKey
Key
Log
LogConfig
DataDir
string
}
// LogConfig keeps the configuration of the loger
...
...
@@ -55,14 +55,12 @@ func (c Config) getAuthority() *config.NonvotingAuthority {
}
func
(
c
Config
)
getAccount
()
*
config
.
Account
{
var
identityKey
ecdh
.
PrivateKey
identityKey
.
FromBytes
(
identityKeyBytes
)
return
&
config
.
Account
{
User
:
c
.
User
,
Provider
:
c
.
Provider
,
Authority
:
pkiName
,
IdentityKey
:
c
.
IdentityKey
.
priv
,
LinkKey
:
c
.
LinkKey
.
priv
,
IdentityKey
:
&
identityKey
,
StorageKey
:
nil
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment