jwa

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2017 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurvePoint

type CurvePoint struct {
	R *big.Int
	S *big.Int
}

CurvePoint represents the parameters for a ECDSA Curve

type ECDSASignerVerifier

type ECDSASignerVerifier struct {
	// contains filtered or unexported fields
}

ECDSASignerVerifier implements a Signer-Verifier after JWA RFC 7518 Section 3.4

func NewECDSASignerVerifier

func NewECDSASignerVerifier(hashtype crypto.Hash) (*ECDSASignerVerifier, error)

NewECDSASignerVerifier creates a New ECDSASignerVerifier and selects a curve based on the given Hash Function

func NewECDSASignerVerifierWithKey

func NewECDSASignerVerifierWithKey(key *ecdsa.PrivateKey) (*ECDSASignerVerifier, error)

NewECDSASignerVerifierWithKey create a new ECDSASignerVerifier and selects a hash based on the given ECDSA private key

func (*ECDSASignerVerifier) Alg

func (sv *ECDSASignerVerifier) Alg() string

Alg returns the the Algorithm used for Signing after JWA 3.1

func (*ECDSASignerVerifier) Sign

func (sv *ECDSASignerVerifier) Sign(message []byte) ([]byte, error)

Sign returns the signature for the message

func (*ECDSASignerVerifier) Verify

func (sv *ECDSASignerVerifier) Verify(message []byte, messageMac []byte) (bool, error)

Verify returns true if the message verifies against the messageMac

type HSSignerVerifier

type HSSignerVerifier struct {
	// contains filtered or unexported fields
}

HSSignerVerifier implements the HMAC SHA-2 Signer (JWA RFC 7518 Section 3.2)

func NewHSSignerVerifier

func NewHSSignerVerifier(hashtype crypto.Hash) (*HSSignerVerifier, error)

NewHSSignerVerifier returns a new SignerVerifier using HMAC and a SHA2 function crypto.SHA256, crypto.SHA384, crypto.SHA512 are supported

func NewHSSignerVerifierWithKey

func NewHSSignerVerifierWithKey(key []byte, hashtype crypto.Hash) (*HSSignerVerifier, error)

NewHSSignerVerifierWithKey returns a new HSSignerVerifier given a key They key length should be larger than the output length of the Hash Function and at least the block size of the hash function (Recommendation from RFC 4868) The absolute minimum recommended Keylength is 128 bits, smaller keys will be rejected

func (*HSSignerVerifier) Alg

func (sv *HSSignerVerifier) Alg() string

Alg returns the the Algorithm used for Signing after JWA 3.1

func (*HSSignerVerifier) Sign

func (sv *HSSignerVerifier) Sign(message []byte) ([]byte, error)

Sign returns the signature for the message

func (*HSSignerVerifier) Verify

func (sv *HSSignerVerifier) Verify(message []byte, messageMac []byte) (bool, error)

Verify returns true if the message verifies against the messageMac

type NoneSignerVerifier

type NoneSignerVerifier struct {
}

NoneSignerVerifier implements a Signer-Verifier after (JWA RFC 7518 Section 3.6)

func (*NoneSignerVerifier) Alg

func (sv *NoneSignerVerifier) Alg() string

Alg returns the the Algorithm used for Signing after JWA 3.1

func (*NoneSignerVerifier) Sign

func (sv *NoneSignerVerifier) Sign(message []byte) ([]byte, error)

Sign returns the signature for the message

func (*NoneSignerVerifier) Verify

func (sv *NoneSignerVerifier) Verify(message []byte, messageMac []byte) (bool, error)

Verify returns true if the message verifies against the messageMac

type RSAPSSSignerVerifier

type RSAPSSSignerVerifier struct {
	// contains filtered or unexported fields
}

RSAPSSSignerVerifier implements a Signer-Verifier after (JWA RFC 7518 Section 3.5)

func NewRSAPSSSignerVerifier

func NewRSAPSSSignerVerifier(hashtype crypto.Hash) (*RSAPSSSignerVerifier, error)

NewRSAPSSSignerVerifier creates a new RSAPSSSignerVerifier and creates a 4096 bit RSA key

func NewRSAPSSSignerVerifierWithKey

func NewRSAPSSSignerVerifierWithKey(hashtype crypto.Hash, key *rsa.PrivateKey) (*RSAPSSSignerVerifier, error)

NewRSAPSSSignerVerifierWithKey createss a new RSAPSSSignerVerifier using the given hashtype and the given RSA private key

func (*RSAPSSSignerVerifier) Alg

func (sv *RSAPSSSignerVerifier) Alg() string

Alg returns the the Algorithm used for Signing after JWA 3.1

func (*RSAPSSSignerVerifier) Sign

func (sv *RSAPSSSignerVerifier) Sign(message []byte) ([]byte, error)

Sign returns the signature for the message

func (*RSAPSSSignerVerifier) Verify

func (sv *RSAPSSSignerVerifier) Verify(message []byte, messageMac []byte) (bool, error)

Verify returns true if the message verifies against the messageMac

type RSASSASignerVerifier

type RSASSASignerVerifier struct {
	// contains filtered or unexported fields
}

RSASSASignerVerifier implements a Signer-Verifier after (JWA RFC 7518 Section 3.3)

func NewRSASSASignerVerifier

func NewRSASSASignerVerifier(hashtype crypto.Hash) (*RSASSASignerVerifier, error)

NewRSASSASignerVerifier creates a new RSASSASignerVerifier with the given hash function and a generated 4096 bit RSA key

func NewRSASSASignerVerifierWithKey

func NewRSASSASignerVerifierWithKey(hashtype crypto.Hash, key *rsa.PrivateKey) (*RSASSASignerVerifier, error)

NewRSASSASignerVerifierWithKey creates as new RSASSASignerVerifier According to RFC 7518 Section 3.3 the Key has to have a length of 2048 bits or more

func (*RSASSASignerVerifier) Alg

func (sv *RSASSASignerVerifier) Alg() string

Alg returns the the Algorithm used for Signing after JWA 3.1

func (*RSASSASignerVerifier) Sign

func (sv *RSASSASignerVerifier) Sign(message []byte) ([]byte, error)

Sign returns the signature for the message

func (*RSASSASignerVerifier) Verify

func (sv *RSASSASignerVerifier) Verify(message []byte, messageMac []byte) (bool, error)

Verify returns true if the message verifies against the messageMac

type SignerVerifier

type SignerVerifier interface {
	Sign(payload []byte) ([]byte, error)
	Verify(payload []byte, messageMac []byte) (bool, error)
	Alg() string
}

SignerVerifier is the interface for implementing the Cryptographics Algorithms for Digital Signatures and MACs according to RFC 7518 JWA Chapter 3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL