https://github.com/infinityworks/aws-decryption-go
Decrypt AWS Encryption SDK formatted blobs using a custom private key
https://github.com/infinityworks/aws-decryption-go
Last synced: 5 months ago
JSON representation
Decrypt AWS Encryption SDK formatted blobs using a custom private key
- Host: GitHub
- URL: https://github.com/infinityworks/aws-decryption-go
- Owner: infinityworks
- Created: 2020-05-20T16:53:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-02T15:06:37.000Z (about 6 years ago)
- Last Synced: 2024-06-20T16:49:58.253Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aws-decryption-go
Decrypt AWS Encryption SDK formatted blobs using a custom private key.
This repo implements part of the [AWS Encryption SDK spec](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html) in go. It is presently limitted in scope:
* Decryption only
* Framed data body only
* Algorithm Suite 0x0378 only (see [this spec page](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/algorithms-reference.html))
This is sufficient to decrypt encrypted customer input generated by the Amazon Connect platform.
## Usage
```go
package main
import (
decrypt "github.com/infinityworks/aws-decryption-go"
)
func main () {
key, err := ioutil.ReadFile("./private.key")
if err != nil {
log.Fatalf("error reading key file: %s", err)
}
ciphertext, err := ioutil.ReadFile("./ciphertext_base64")
if err != nil {
log.Fatalf("error reading key file: %s", err)
}
dataBytes, err := base64.StdEncoding.DecodeString(ciphertext)
if err != nil {
log.Fatalf("error decoding base64 ciphertext: %s", err)
}
decrypter, err := decrypt.New(key)
if err != nil {
log.Fatalf("error creating decrypter: %s", err)
}
result, err := decrypter.Decrypt(dataBytes)
if err != nil {
log.Fatalf("error decrypting data: %s", err)
}
fmt.Println("decrypted data: %s", string(result))
}
```