aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'account.go')
-rw-r--r--account.go22
1 files changed, 2 insertions, 20 deletions
diff --git a/account.go b/account.go
index 38121f6..a74f2d0 100644
--- a/account.go
+++ b/account.go
@@ -4,7 +4,6 @@ import (
"crypto/rand"
"crypto/rsa"
"fmt"
- "net/http"
"net/mail"
"github.com/square/go-jose"
@@ -32,7 +31,6 @@ func NewAccount(email string, bits int) (*Account, error) {
return &Account{
Contact: []string{"mailto:" + m.Address},
PrivKey: key,
- nonce: make(chan string, 10), // shall be enough
}, nil
}
@@ -40,14 +38,14 @@ func LoadAccount(email string) (*Account, error) {
return nil, nil
}
-func (a *Account) Sign(msg []byte) ([]byte, error) {
+func (a *Account) Sign(msg []byte, n jose.NonceSource) ([]byte, error) {
if a.signer == nil {
var err error
a.signer, err = jose.NewSigner(jose.RS256, a.PrivKey)
if err != nil {
return nil, err
}
- a.signer.SetNonceSource(a)
+ a.signer.SetNonceSource(n)
}
obj, err := a.signer.Sign(msg)
return []byte(obj.FullSerialize()), err
@@ -61,19 +59,3 @@ func (a *Account) ParseSigned(msg []byte) ([]byte, error) {
}
return obj.Verify(&a.PrivKey.PublicKey)
}
-
-// Nonce implements jose nonce provider
-func (a Account) Nonce() (string, error) {
- select {
- case nonce := <-a.nonce:
- return nonce, nil
- default:
- return "", errNoNonces
- }
-}
-
-func (a Account) parseNonce(r *http.Response) {
- if nonce := replyNonce(r); nonce != "" {
- a.nonce <- nonce
- }
-}