common

package
v0.0.0-...-64dd8ac Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CombinedFormatSeparator = "~"

	SDAlgorithmKey        = "_sd_alg"
	SDKey                 = "_sd"
	CNFKey                = "cnf"
	ArrayElementDigestKey = "..."
)

CombinedFormatSeparator is disclosure separator.

View Source
const (
	// SDJWTVersionDefault default SD-JWT version for compatibility purposes.
	SDJWTVersionDefault = SDJWTVersionV2
	// SDJWTVersionV2 SD-JWT v2 spec.
	SDJWTVersionV2 = SDJWTVersion(2)
	// SDJWTVersionV5 SD-JWT v5 spec.
	SDJWTVersionV5 = SDJWTVersion(5)
)
View Source
const (
	// DisclosureClaimTypeUnknown default type for disclosure claim.
	DisclosureClaimTypeUnknown = DisclosureClaimType(0)
	// DisclosureClaimTypeArrayElement array element.
	DisclosureClaimTypeArrayElement = DisclosureClaimType(2)
	// DisclosureClaimTypeObject object.
	DisclosureClaimTypeObject = DisclosureClaimType(3)
	// DisclosureClaimTypePlainText object.
	DisclosureClaimTypePlainText = DisclosureClaimType(3)
)

Variables

This section is empty.

Functions

func GetCNF

func GetCNF(claims map[string]interface{}) (map[string]interface{}, error)

GetCNF returns confirmation claim 'cnf'.

func GetCryptoHash

func GetCryptoHash(sdAlg string) (crypto.Hash, error)

GetCryptoHash returns crypto hash from SD algorithm.

func GetCryptoHashFromClaims

func GetCryptoHashFromClaims(claims map[string]interface{}) (crypto.Hash, error)

GetCryptoHashFromClaims returns crypto hash from claims.

func GetDisclosedClaims

func GetDisclosedClaims(disclosureClaims []*DisclosureClaim, claims map[string]interface{}) (map[string]interface{}, error)

GetDisclosedClaims returns disclosed claims only.

func GetDisclosureDigests

func GetDisclosureDigests(claims map[string]interface{}) (map[string]bool, error)

GetDisclosureDigests returns digests from claims map considering either SDKey and array elements that are objects with one key, that key being ... and referring to a string.

func GetHash

func GetHash(hash crypto.Hash, value string) (string, error)

GetHash calculates hash of data using hash function identified by hash.

func GetKeyFromVC

func GetKeyFromVC(key string, claims map[string]interface{}) (interface{}, bool)

GetKeyFromVC returns key value from VC.

func GetSDAlg

func GetSDAlg(claims map[string]interface{}) (string, error)

GetSDAlg returns SD algorithm from claims.

func KeyExistsInMap

func KeyExistsInMap(key string, m map[string]interface{}) bool

KeyExistsInMap checks if key exists in map.

func SliceToMap

func SliceToMap(ids []string) map[string]bool

SliceToMap converts slice to map.

func VerifyDisclosuresInSDJWT

func VerifyDisclosuresInSDJWT(
	disclosures []string,
	signedJWT *afgjwt.JSONWebToken,
) error

VerifyDisclosuresInSDJWT checks for disclosure inclusion in SD-JWT.

func VerifyJWT

func VerifyJWT(signedJWT *afgjwt.JSONWebToken, leeway time.Duration) error

VerifyJWT checks that the JWT is valid using nbf, iat, and exp claims (if provided in the JWT).

func VerifySigningAlg

func VerifySigningAlg(joseHeaders jose.Headers, secureAlgs []string) error

VerifySigningAlg ensures that a signing algorithm was used that was deemed secure for the application. The none algorithm MUST NOT be accepted.

func VerifyTyp

func VerifyTyp(joseHeaders jose.Headers, expectedTyp string) error

VerifyTyp checks JWT header parameters for the SD-JWT component.

Types

type CombinedFormatForIssuance

type CombinedFormatForIssuance struct {
	SDJWT       string
	Disclosures []string
}

CombinedFormatForIssuance holds SD-JWT and disclosures.

func ParseCombinedFormatForIssuance

func ParseCombinedFormatForIssuance(combinedFormatForIssuance string) *CombinedFormatForIssuance

ParseCombinedFormatForIssuance parses combined format for issuance into CombinedFormatForIssuance parts.

func (*CombinedFormatForIssuance) Serialize

func (cf *CombinedFormatForIssuance) Serialize() string

Serialize will assemble combined format for issuance.

type CombinedFormatForPresentation

type CombinedFormatForPresentation struct {
	SDJWT       string
	Disclosures []string

	// Holder Verification JWT.
	// For SD JWT V2 field contains Holder Binding JWT data.
	// For SD JWT V5 field contains Key Binding JWT data.
	HolderVerification string
}

CombinedFormatForPresentation holds SD-JWT, disclosures and optional holder binding info.

func ParseCombinedFormatForPresentation

func ParseCombinedFormatForPresentation(combinedFormatForPresentation string) *CombinedFormatForPresentation

ParseCombinedFormatForPresentation parses combined format for presentation into CombinedFormatForPresentation parts.

func (*CombinedFormatForPresentation) Serialize

func (cf *CombinedFormatForPresentation) Serialize() string

Serialize will assemble combined format for presentation.

type DisclosureClaim

type DisclosureClaim struct {
	Digest        string
	Disclosure    string
	Salt          string
	Elements      int
	Type          DisclosureClaimType
	Version       SDJWTVersion
	Name          string
	Value         interface{}
	IsValueParsed bool
}

DisclosureClaim defines claim.

func GetDisclosureClaims

func GetDisclosureClaims(
	disclosures []string,
	hash crypto.Hash,
) ([]*DisclosureClaim, error)

GetDisclosureClaims de-codes disclosures.

type DisclosureClaimType

type DisclosureClaimType int

DisclosureClaimType disclosure claim type, used for sd-jwt v5+.

type SDJWTVersion

type SDJWTVersion int

SDJWTVersion represents version SD-JWT according to spec version.

Jump to

Keyboard shortcuts

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