File: interface.go

package info (click to toggle)
golang-github-lestrrat-go-jwx 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,872 kB
  • sloc: sh: 222; makefile: 86; perl: 62
file content (72 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package keygen

import (
	"crypto/ecdsa"

	"github.com/lestrrat-go/jwx/v2/jwa"
	"github.com/lestrrat-go/jwx/v2/x25519"
)

type Generator interface {
	Size() int
	Generate() (ByteSource, error)
}

// RandomKeyGenerate generates random keys
type Random struct {
	keysize int
}

// EcdhesKeyGenerate generates keys using ECDH-ES algorithm / EC-DSA curve
type Ecdhes struct {
	pubkey    *ecdsa.PublicKey
	keysize   int
	algorithm jwa.KeyEncryptionAlgorithm
	enc       jwa.ContentEncryptionAlgorithm
	apu       []byte
	apv       []byte
}

// X25519KeyGenerate generates keys using ECDH-ES algorithm / X25519 curve
type X25519 struct {
	algorithm jwa.KeyEncryptionAlgorithm
	enc       jwa.ContentEncryptionAlgorithm
	keysize   int
	pubkey    x25519.PublicKey
}

// ByteKey is a generated key that only has the key's byte buffer
// as its instance data. If a key needs to do more, such as providing
// values to be set in a JWE header, that key type wraps a ByteKey
type ByteKey []byte

// ByteWithECPublicKey holds the EC private key that generated
// the key along with the key itself. This is required to set the
// proper values in the JWE headers
type ByteWithECPublicKey struct {
	ByteKey
	PublicKey interface{}
}

type ByteWithIVAndTag struct {
	ByteKey
	IV  []byte
	Tag []byte
}

type ByteWithSaltAndCount struct {
	ByteKey
	Salt  []byte
	Count int
}

// ByteSource is an interface for things that return a byte sequence.
// This is used for KeyGenerator so that the result of computations can
// carry more than just the generate byte sequence.
type ByteSource interface {
	Bytes() []byte
}

type Setter interface {
	Set(string, interface{}) error
}