Skip to content

Commit

Permalink
implement jws (#30)
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>

Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
Co-authored-by: Junjie Gao <junjiegao@microsoft.com>
  • Loading branch information
JeyJeyGao and JeyJeyGao committed Aug 11, 2022
1 parent b64ffd6 commit bb1fc31
Show file tree
Hide file tree
Showing 8 changed files with 835 additions and 6 deletions.
45 changes: 44 additions & 1 deletion signature/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package signature

import "fmt"
import (
"fmt"
)

// MalformedSignatureError is used when Signature envelope is malformed.
type MalformedSignatureError struct {
Expand Down Expand Up @@ -46,3 +48,44 @@ func (e *MalformedArgumentError) Error() string {
func (e *MalformedArgumentError) Unwrap() error {
return e.Err
}

// MalformedSignRequestError is used when SignRequest is malformed.
type MalformedSignRequestError struct {
Msg string
}

func (e *MalformedSignRequestError) Error() string {
if e.Msg != "" {
return e.Msg
}
return "SignRequest is malformed"
}

// SignatureAlgoNotSupportedError is used when signing algo is not supported.
type SignatureAlgoNotSupportedError struct {
Alg string
}

func (e *SignatureAlgoNotSupportedError) Error() string {
return fmt.Sprintf("signature algorithm %q is not supported", e.Alg)
}

// SignatureIntegrityError is used when the Signature associated is no longer valid.
type SignatureIntegrityError struct {
Err error
}

func (e *SignatureIntegrityError) Error() string {
return fmt.Sprintf("signature is invalid. Error: %s", e.Err.Error())
}

func (e *SignatureIntegrityError) Unwrap() error {
return e.Err
}

// SignatureNotFoundError is used when signature envelope is not present.
type SignatureNotFoundError struct{}

func (e *SignatureNotFoundError) Error() string {
return "signature envelope is not present"
}
Loading

0 comments on commit bb1fc31

Please sign in to comment.