Documentation
¶
Overview ¶
Package sdk is the Unofficial Go SDK implementation of the AWS Encryption SDK.
Getting started ¶
To install the AWS Encryption SDK for Go, use the following command:
go get github.com/chainifynet/aws-encryption-sdk-go@latest
Usage ¶
The following example demonstrates how to use SDK to encrypt and decrypt data using a static key.
package main
import (
"context"
"fmt"
"github.com/chainifynet/aws-encryption-sdk-go/pkg/client"
"github.com/chainifynet/aws-encryption-sdk-go/pkg/materials"
"github.com/chainifynet/aws-encryption-sdk-go/pkg/providers/rawprovider"
)
func main() {
// static key to use for encryption and decryption
staticKey1 := []byte("superSecureKeySecureKey32bytes32")
// data to encrypt
secretData := []byte("secret data to encrypt")
// setup Encryption SDK client with default configuration
sdkClient := client.NewClient()
// setup Raw Key provider
rawKeyProvider, err := rawprovider.NewWithOpts(
"raw",
rawprovider.WithStaticKey("static1", staticKey1),
)
if err != nil {
panic(err) // handle error
}
// setup crypto materials manager
cmm, err := materials.NewDefault(rawKeyProvider)
if err != nil {
panic(err) // handle error
}
// encrypt data without encryption context passing nil as the third argument
encrypted, header, err := sdkClient.Encrypt(context.TODO(), secretData, nil, cmm)
if err != nil {
panic(err) // handle error
}
fmt.Printf("encrypted encryption context: %v\n", header.AADData().EncryptionContext())
// decrypt "encrypted" data
decrypted, _, err := sdkClient.Decrypt(context.TODO(), encrypted, cmm)
if err != nil {
panic(err) // handle error
}
fmt.Printf("decrypted data: %s\n", decrypted)
// verify that "decrypted" plaintext is identical to the original secret data
if string(decrypted) != string(secretData) {
panic("decrypted data does not match with the original data")
}
}
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
basicEncryption
module
|
|
|
customAwsKmsConfig
module
|
|
|
discoveryFilterKmsProvider
module
|
|
|
discoveryKmsProvider
module
|
|
|
mrkAwareKmsProvider
module
|
|
|
multipleKeyProvider
module
|
|
|
multipleKmsKey
module
|
|
|
oneKmsKey
module
|
|
|
oneKmsKeyUnsigned
module
|
|
|
Package pkg provides the core SDK packages.
|
Package pkg provides the core SDK packages. |
|
client
Package client provides the entrypoint for using AWS Encryption SDK for Go.
|
Package client provides the entrypoint for using AWS Encryption SDK for Go. |
|
clientconfig
Package clientconfig provides a way to configure SDK client.
|
Package clientconfig provides a way to configure SDK client. |
|
crypto
Package crypto provides common errors and encryption configuration.
|
Package crypto provides common errors and encryption configuration. |
|
internal/crypto/hasher
Package hasher provides a Hasher interface for hashing data with a given elliptic.Curve.
|
Package hasher provides a Hasher interface for hashing data with a given elliptic.Curve. |
|
internal/utils/conv
Package conv provides utilities for converting types to big endian and vice versa.
|
Package conv provides utilities for converting types to big endian and vice versa. |
|
internal/utils/encryption
Package encryption provides a way to encrypt and decrypt with AES-GCM.
|
Package encryption provides a way to encrypt and decrypt with AES-GCM. |
|
internal/utils/itertools
Package itertools provides a method to generate all combinations out of a given generic type array.
|
Package itertools provides a method to generate all combinations out of a given generic type array. |
|
internal/utils/keyderivation
Package keyderivation provides a set of functions for deriving cryptographic keys.
|
Package keyderivation provides a set of functions for deriving cryptographic keys. |
|
internal/utils/structs
Package structs provides utility functions for working with structs.
|
Package structs provides utility functions for working with structs. |
|
keys
Package keys contains implementations of Master Keys and generic key errors.
|
Package keys contains implementations of Master Keys and generic key errors. |
|
keys/kms
Package kms contains KMS and KMS MRK Master Key implementations.
|
Package kms contains KMS and KMS MRK Master Key implementations. |
|
keys/raw
Package raw contains Raw Master Key implementation.
|
Package raw contains Raw Master Key implementation. |
|
materials
Package materials provides CryptoMaterialsManager implementations.
|
Package materials provides CryptoMaterialsManager implementations. |
|
model
Package model contains SDK data model.
|
Package model contains SDK data model. |
|
model/format
Package format provides set of interfaces for SDK message format.
|
Package format provides set of interfaces for SDK message format. |
|
model/types
Package types contains a basic types used in SDK.
|
Package types contains a basic types used in SDK. |
|
providers
Package providers contains a generic provider errors.
|
Package providers contains a generic provider errors. |
|
providers/keyprovider
Package keyprovider provides a way to create KeyProvider via alias.
|
Package keyprovider provides a way to create KeyProvider via alias. |
|
providers/kmsprovider
Package kmsprovider contains KMS Master Key Provider implementation.
|
Package kmsprovider contains KMS Master Key Provider implementation. |
|
providers/rawprovider
Package rawprovider contains Raw Master Key Provider implementation.
|
Package rawprovider contains Raw Master Key Provider implementation. |
|
suite
Package suite provides the algorithm suites.
|
Package suite provides the algorithm suites. |
|
utils/arn
Package arn provides a set of utilities for working with Amazon Resource Names (ARNs).
|
Package arn provides a set of utilities for working with Amazon Resource Names (ARNs). |
|
test
|
|
|
e2e
command
|
|
Click to show internal directories.
Click to hide internal directories.