forked from TrueCloudLab/restic
Update vendored library github.com/minio/minio-go
This commit is contained in:
parent
7e6fff324c
commit
31e156c666
44 changed files with 1612 additions and 1583 deletions
34
vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go
generated
vendored
34
vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go
generated
vendored
|
@ -42,35 +42,15 @@ func main() {
|
|||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
//// Build an asymmetric key from private and public files
|
||||
//
|
||||
// privateKey, err := ioutil.ReadFile("private.key")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// publicKey, err := ioutil.ReadFile("public.key")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// asymmetricKey, err := NewAsymmetricKey(privateKey, publicKey)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
////
|
||||
bucketname := "my-bucketname" // Specify a bucket name - the bucket must already exist
|
||||
objectName := "my-objectname" // Specify a object name - the object must already exist
|
||||
password := "correct horse battery staple" // Specify your password. DO NOT USE THIS ONE - USE YOUR OWN.
|
||||
|
||||
// Build a symmetric key
|
||||
symmetricKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
|
||||
// New SSE-C where the cryptographic key is derived from a password and the objectname + bucketname as salt
|
||||
encryption := encrypt.DefaultPBKDF([]byte(password), []byte(bucketname+objectName))
|
||||
|
||||
// Build encryption materials which will encrypt uploaded data
|
||||
cbcMaterials, err := encrypt.NewCBCSecureMaterials(symmetricKey)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Get a deciphered data from the server, deciphering is assured by cbcMaterials
|
||||
reader, err := s3Client.GetEncryptedObject("my-bucketname", "my-objectname", cbcMaterials)
|
||||
// Get the encrypted object
|
||||
reader, err := s3Client.GetObject(bucketname, objectName, minio.GetObjectOptions{ServerSideEncryption: encryption})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue