-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
29 lines (23 loc) · 1.6 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package wskeyid
import (
"errors"
"github.com/sparkscience/wskeyid-golang/messages/clientmessage"
)
var (
ErrClientIdWasNotSupplied = errors.New("the client ID was not supplied by the client")
ErrBadClientIDFormat = errors.New("the client ID is of a bad format. Expected a string of format <format>$<base64-encoded buffer>, e.g. WebCrypto-raw.EC.P-256$JsxA+HaVosJsyVC/S")
ErrUnknownClientIDFormat = errors.New("unknown client ID format")
ErrUnknownNISTKeyFormat = errors.New("unknown NIST key format; expected the first byte to be exactly 0x04, and the remainder of the key to be a byte buffer of length divisible by 2")
ErrUnsuportedClientIdVersion = errors.New("the client ID version is unsupported. The first two bytes of the base64-encoded value of the client ID must be an int16 value equal exactly to 0x01")
ErrUnsupportedECDSAKeyType = errors.New("the ECDSA key must be of type 4, as represented by the first byte of the key itself (3rd byte in the buffer)")
ErrFailedToReadRandomNumbers = errors.New("in an attempt to generate the challenge, the server failed to read the adequate number bytes needed for our challenge")
ErrConnectionClosed = errors.New("the connection was closed, in the middle of the handshake")
ErrSignatureDoesNotMatch = errors.New("the signature provided by the client did not match the public key provided")
)
type NotAValidChallengeResponse struct {
Message clientmessage.Message `json:"message"`
}
func (n NotAValidChallengeResponse) Error() string {
return "the message received was not a challenge response"
}
var _ error = NotAValidChallengeResponse{}