Decrypt decrypts the provided data using provided blobID to derive initialization vector.
(c Crypter, payload gather.Bytes, blobID blob.ID, output *gather.WriteBuffer)
| 67 | |
| 68 | // Decrypt decrypts the provided data using provided blobID to derive initialization vector. |
| 69 | func Decrypt(c Crypter, payload gather.Bytes, blobID blob.ID, output *gather.WriteBuffer) error { |
| 70 | iv, err := getIndexBlobIV(blobID) |
| 71 | if err != nil { |
| 72 | return errors.Wrap(err, "unable to get index blob IV") |
| 73 | } |
| 74 | |
| 75 | output.Reset() |
| 76 | |
| 77 | // Decrypt will verify the payload. |
| 78 | if err := c.Encryptor().Decrypt(payload, iv, output); err != nil { |
| 79 | return errors.Wrapf(err, "error decrypting BLOB %v", blobID) |
| 80 | } |
| 81 | |
| 82 | return nil |
| 83 | } |