...

Source file src/github.com/lestrrat-go/jwx/jwe/internal/keygen/interface.go

Documentation: github.com/lestrrat-go/jwx/jwe/internal/keygen

     1  package keygen
     2  
     3  import (
     4  	"crypto/ecdsa"
     5  
     6  	"github.com/lestrrat-go/jwx/jwa"
     7  	"github.com/lestrrat-go/jwx/x25519"
     8  )
     9  
    10  type Generator interface {
    11  	Size() int
    12  	Generate() (ByteSource, error)
    13  }
    14  
    15  // StaticKeyGenerate uses a static byte buffer to provide keys.
    16  type Static []byte
    17  
    18  // RandomKeyGenerate generates random keys
    19  type Random struct {
    20  	keysize int
    21  }
    22  
    23  // EcdhesKeyGenerate generates keys using ECDH-ES algorithm / EC-DSA curve
    24  type Ecdhes struct {
    25  	pubkey    *ecdsa.PublicKey
    26  	keysize   int
    27  	algorithm jwa.KeyEncryptionAlgorithm
    28  	enc       jwa.ContentEncryptionAlgorithm
    29  }
    30  
    31  // X25519KeyGenerate generates keys using ECDH-ES algorithm / X25519 curve
    32  type X25519 struct {
    33  	algorithm jwa.KeyEncryptionAlgorithm
    34  	enc       jwa.ContentEncryptionAlgorithm
    35  	keysize   int
    36  	pubkey    x25519.PublicKey
    37  }
    38  
    39  // ByteKey is a generated key that only has the key's byte buffer
    40  // as its instance data. If a key needs to do more, such as providing
    41  // values to be set in a JWE header, that key type wraps a ByteKey
    42  type ByteKey []byte
    43  
    44  // ByteWithECPublicKey holds the EC private key that generated
    45  // the key along with the key itself. This is required to set the
    46  // proper values in the JWE headers
    47  type ByteWithECPublicKey struct {
    48  	ByteKey
    49  	PublicKey interface{}
    50  }
    51  
    52  type ByteWithIVAndTag struct {
    53  	ByteKey
    54  	IV  []byte
    55  	Tag []byte
    56  }
    57  
    58  type ByteWithSaltAndCount struct {
    59  	ByteKey
    60  	Salt  []byte
    61  	Count int
    62  }
    63  
    64  // ByteSource is an interface for things that return a byte sequence.
    65  // This is used for KeyGenerator so that the result of computations can
    66  // carry more than just the generate byte sequence.
    67  type ByteSource interface {
    68  	Bytes() []byte
    69  }
    70  
    71  type Setter interface {
    72  	Set(string, interface{}) error
    73  }
    74  

View as plain text