gq

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GQ256 = jwa.SignatureAlgorithm("GQ256")

Functions

func GQ256SignJWT

func GQ256SignJWT(rsaPublicKey *rsa.PublicKey, jwt []byte, opts ...Opts) ([]byte, error)

GQ256SignJWT takes a rsaPublicKey and signed JWT and computes a GQ1 signature on the JWT. It returns a JWT whose RSA signature has been replaced by the GQ signature. It is wrapper around SignerVerifier.SignJWT an additional check that the correct rsa public key has been supplied. Use this instead of SignerVerifier.SignJWT.

func GQ256VerifyJWT

func GQ256VerifyJWT(rsaPublicKey *rsa.PublicKey, gqToken []byte) (bool, error)

GQ256VerifyJWT verifies a GQ1 signature over GQ signed JWT

func OriginalJWTHeaders

func OriginalJWTHeaders(jwt []byte) ([]byte, error)

Types

type Opts

type Opts func(a *OptsStruct)

func WithExtraClaim

func WithExtraClaim(k string, v string) Opts

WithExtraClaim specifies additional values to be included in the GQ signed JWT. These claims will be included in the protected header of the JWT Example use:

WithExtraClaim("claimKey", "claimValue")

type OptsStruct

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

type Signer

type Signer interface {
	// Sign creates a GQ1 signature over the given message with the given GQ1 private number.
	Sign(private []byte, message []byte) ([]byte, error)
	// SignJWT creates a GQ1 signature over the JWT token's header/payload with a GQ1 private number derived from the JWT signature.
	//
	// This works because a GQ1 private number can be calculated as the inverse mod n of an RSA signature, where n is the public RSA modulus.
	SignJWT(jwt []byte, opts ...Opts) ([]byte, error)
}

Signer allows for creating GQ1 signatures messages.

type SignerVerifier

type SignerVerifier interface {
	Signer
	Verifier
}

SignerVerifier combines the Signer and Verifier interfaces.

func New256SignerVerifier

func New256SignerVerifier(publicKey *rsa.PublicKey) (SignerVerifier, error)

Creates a new SignerVerifier specifically for GQ256, meaning the security parameter is 256.

func NewSignerVerifier

func NewSignerVerifier(publicKey *rsa.PublicKey, securityParameter int) (SignerVerifier, error)

NewSignerVerifier creates a SignerVerifier from the RSA public key of the trusted third-party which creates the GQ1 private numbers.

The securityParameter parameter is the level of desired security in bits. 256 is recommended.

type Verifier

type Verifier interface {
	// Verify verifies a GQ1 signature over a message, using the public identity of the signer.
	Verify(signature []byte, identity []byte, message []byte) bool

	// Compatible with SignJWT, this function verifies the GQ1 signature of the presented JSON Web Token.
	VerifyJWT(jwt []byte) bool
}

Signer allows for verifying GQ1 signatures.

Jump to

Keyboard shortcuts

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