Commit 4d1feabc authored by Lukas Matt's avatar Lukas Matt

Use URLEncoding instead of StdEncoding for signature creation

see https://diaspora.github.io/diaspora_federation/federation/magicsig.html
parent 9abcf5ee
...@@ -29,7 +29,7 @@ var TEST_MAGIC_PAYLOAD = []byte(`<me:env xmlns:me="http://salmon-protocol.org/ns ...@@ -29,7 +29,7 @@ var TEST_MAGIC_PAYLOAD = []byte(`<me:env xmlns:me="http://salmon-protocol.org/ns
<me:data type="application/xml">PHg-PC94Pg==</me:data> <me:data type="application/xml">PHg-PC94Pg==</me:data>
<me:encoding>base64url</me:encoding> <me:encoding>base64url</me:encoding>
<me:alg>RSA-SHA256</me:alg> <me:alg>RSA-SHA256</me:alg>
<me:sig key_id="ZGlhc3BvcmFfMm5kQGxvY2FsaG9zdDozMDAx">PIlS0XhUHGqSsoGKP2efeitDKv7uO0ekNoDQPm5lk844muzMPk7iK9t6T3ageqIsl14xmnInDGKlbrM49JiuYB4aFKEwqHAIEj2axCjdm6HRF5mv+2nhVjKISx+AcuKY1Rav9pKQoQqphRm8p9CQr632TK5mkFfBAeGpyJE8I3WNwguy9AozR+ym0b3MrbDhHxpzGxcRAvjyzbRMfvLhOlVKauaIEGDVN6nbBXVSY4hSBYu38+02PyGuyPjjlBJHNIPQXUL9dcSq/LXs/ElwQA2JBLwF6+opQvIBDbjUVkX4spKo/uRNEAlFuR4Ul+bi/Y7+ssoD3DrMHN4Fg2hx5w==</me:sig> <me:sig key_id="ZGlhc3BvcmFfMm5kQGxvY2FsaG9zdDozMDAx">PIlS0XhUHGqSsoGKP2efeitDKv7uO0ekNoDQPm5lk844muzMPk7iK9t6T3ageqIsl14xmnInDGKlbrM49JiuYB4aFKEwqHAIEj2axCjdm6HRF5mv-2nhVjKISx-AcuKY1Rav9pKQoQqphRm8p9CQr632TK5mkFfBAeGpyJE8I3WNwguy9AozR-ym0b3MrbDhHxpzGxcRAvjyzbRMfvLhOlVKauaIEGDVN6nbBXVSY4hSBYu38-02PyGuyPjjlBJHNIPQXUL9dcSq_LXs_ElwQA2JBLwF6-opQvIBDbjUVkX4spKo_uRNEAlFuR4Ul-bi_Y7-ssoD3DrMHN4Fg2hx5w==</me:sig>
</me:env>`) </me:env>`)
func TestMagicEnvelope(t *testing.T) { func TestMagicEnvelope(t *testing.T) {
......
...@@ -59,14 +59,14 @@ func (signature *Signature) Sign(privKey *rsa.PrivateKey, sig *string) error { ...@@ -59,14 +59,14 @@ func (signature *Signature) Sign(privKey *rsa.PrivateKey, sig *string) error {
signature.Err = err signature.Err = err
return err return err
} }
*sig = base64.StdEncoding.EncodeToString(bytes) *sig = base64.URLEncoding.EncodeToString(bytes)
return nil return nil
} }
func (signature *Signature) Verify(order string, pubKey *rsa.PublicKey) bool { func (signature *Signature) Verify(order string, pubKey *rsa.PublicKey) bool {
sig, err := base64.StdEncoding.DecodeString(signature.entity.Signature()) sig, err := base64.URLEncoding.DecodeString(signature.entity.Signature())
if err != nil { if err != nil {
sig, err = base64.URLEncoding.DecodeString(signature.entity.Signature()) sig, err = base64.StdEncoding.DecodeString(signature.entity.Signature())
if err != nil { if err != nil {
signature.Err = err signature.Err = err
return false return false
......
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