Documentation
¶
Index ¶
- Variables
- func NewRandom(ctx context.Context, optFns ...OptionFunc) (io.Reader, error)
- type Key
- func (k *Key) Decrypt(_ io.Reader, msg []byte, opts crypto.DecrypterOpts) ([]byte, error)
- func (k *Key) Encrypt(hsh hash.Hash, rand io.Reader, msg []byte) ([]byte, error)
- func (k *Key) Equal(x crypto.PrivateKey) bool
- func (k *Key) KeyARN() string
- func (k *Key) KeySpec() kmsTypes.KeySpec
- func (k *Key) Public() crypto.PublicKey
- func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
- func (k *Key) SubjectPublicKeyInfo() []byte
- type OptionFunc
- func WithAwsClient(client kmsClienter) OptionFunc
- func WithAwsConfig(cfg aws.Config, fns ...func(*kms.Options)) OptionFunc
- func WithCustomKeyStoreId(v string) OptionFunc
- func WithGrantTokens(tokens []string) OptionFunc
- func WithMaxConcurrency(conc int) OptionFunc
- func WithSigningAlgorithm(alg kmsTypes.SigningAlgorithmSpec) OptionFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyNotSignVerifyError = errors.New("key usage is not SIGN_VERIFY") ErrKeyNotEncryptDecryptError = errors.New("key usage is not ENCRYPT_DECRYPT") ErrNoAwsClientError = errors.New("no aws client initialized, use WithAwsConfig or WithAwsClient") ErrInvalidSigningAlgorithmError = errors.New("invalid signing algorithm choice") ErrUnsupportedDecryptionError = errors.New("unsupported decryption options") )
Functions ¶
func NewRandom ¶
Example ¶
package main
import (
"context"
"crypto/rsa"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/webdestroya/go-kmskey"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion("us-fake-1"))
if err != nil {
panic(err)
}
kmsrand, err := kmskey.NewRandom(ctx, kmskey.WithAwsConfig(cfg))
if err != nil {
panic(err)
}
// Key Generation:
rsaKey, err := rsa.GenerateKey(kmsrand, 3072)
if err != nil {
panic(err)
}
// do something with the new key
_ = rsaKey
}
Output:
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func (*Key) SubjectPublicKeyInfo ¶
The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280
type OptionFunc ¶
type OptionFunc = func(*kcsOption) error
func WithAwsClient ¶
func WithAwsClient(client kmsClienter) OptionFunc
func WithAwsConfig ¶
func WithAwsConfig(cfg aws.Config, fns ...func(*kms.Options)) OptionFunc
func WithCustomKeyStoreId ¶
func WithCustomKeyStoreId(v string) OptionFunc
Specifies a Custom KeyStore to use to generate random data.
Only used with NewRandom
func WithGrantTokens ¶
func WithGrantTokens(tokens []string) OptionFunc
If you need to provide KMS grant tokens for your requests to GetPublicKey, Sign, Decrypt
func WithMaxConcurrency ¶
func WithMaxConcurrency(conc int) OptionFunc
Sets the maximum parallel requests that will be made to get random data.
Only used with NewRandom
func WithSigningAlgorithm ¶
func WithSigningAlgorithm(alg kmsTypes.SigningAlgorithmSpec) OptionFunc
Force the signing algorithm to use. You probably should not set this.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.