Commit 6dce2b6d authored by Lukas Matt's avatar Lukas Matt

Remove obsolete code and reduce logging

parent 6538947a
......@@ -30,14 +30,6 @@ import (
"strings"
)
func ParseBase64RSAPubKey(encodedKey string) (pubkey *rsa.PublicKey, err error) {
decodedKey, err := base64.StdEncoding.DecodeString(encodedKey)
if err != nil {
return
}
return ParseRSAPubKey(decodedKey)
}
func ParseRSAPubKey(decodedKey []byte) (pubkey *rsa.PublicKey, err error) {
block, _ := pem.Decode(decodedKey)
if block == nil {
......@@ -70,37 +62,6 @@ func ParseRSAPrivKey(decodedKey []byte) (privkey *rsa.PrivateKey, err error) {
return
}
func (request *DiasporaUnmarshal) VerifySignature(serialized []byte) error {
pubkey, err := ParseRSAPubKey(serialized)
if err != nil {
warn(err)
return err
}
type64 := base64.StdEncoding.EncodeToString(
[]byte(request.Env.Data.Type),
)
encoding64 := base64.StdEncoding.EncodeToString(
[]byte(request.Env.Encoding),
)
alg64 := base64.StdEncoding.EncodeToString(
[]byte(request.Env.Alg),
)
text := request.Env.Data.Data + "." + type64 + "." + encoding64 + "." + alg64
h := sha256.New()
h.Write([]byte(text))
digest := h.Sum(nil)
ds, err := base64.URLEncoding.DecodeString(request.Env.Sig.Sig)
if err != nil {
return err
}
return rsa.VerifyPKCS1v15(pubkey, crypto.SHA256, digest, ds)
}
func AuthorSignature(data interface{}, order, privKey string) (string, error) {
var text string
var r = reflect.TypeOf(data)
......
......@@ -32,7 +32,6 @@ const (
PROTO_HTTPS = "https://"
CONTENT_TYPE_ENVELOPE = "application/magic-envelope+xml"
CONTENT_TYPE_JSON = "application/json"
CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
)
var timeout = time.Duration(10 * time.Second)
......@@ -45,10 +44,6 @@ func PushXmlToPublic(host string, body io.Reader) error {
return push(host, "/receive/public", PROTO_HTTPS, CONTENT_TYPE_ENVELOPE, body)
}
func PushFormToPrivate(host, guid string, body io.Reader) error {
return push(host, "/receive/users/" + guid, PROTO_HTTPS, CONTENT_TYPE_FORM, body)
}
func push(host, endpoint, proto, contentType string, body io.Reader) error {
req, err := http.NewRequest("POST", proto + host + endpoint, body)
if err != nil {
......@@ -68,7 +63,7 @@ func push(host, endpoint, proto, contentType string, body io.Reader) error {
defer resp.Body.Close()
if !(resp.StatusCode == 200 || resp.StatusCode == 202) {
return errors.New("pushXml results in: " + resp.Status)
return errors.New("push results in: " + resp.Status)
}
return nil
}
......@@ -92,7 +87,6 @@ func FetchJson(method, url string, body io.Reader, result interface{}) error {
if err != nil {
return err
}
info(result)
return nil
}
......@@ -121,7 +115,6 @@ func FetchXml(method, url string, body io.Reader, result interface{}) error {
if err != nil {
return err
}
info(result)
return nil
}
......
Markdown is supported
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