databroker: add encryption for records (#1168)

This commit is contained in:
Caleb Doxsey 2020-07-30 14:04:31 -06:00 committed by GitHub
parent 8cae3f27bb
commit 29fb96a955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 332 additions and 7 deletions

View file

@ -4,6 +4,8 @@ import (
"encoding/base64"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestEncodeAndDecodeAccessToken(t *testing.T) {
@ -61,6 +63,22 @@ func TestNewAEADCipher(t *testing.T) {
}
}
func BenchmarkAEADCipher(b *testing.B) {
plaintext := []byte("my plain text value")
key := NewKey()
c, err := NewAEADCipher(key)
if !assert.NoError(b, err) {
return
}
ciphertext := Encrypt(c, plaintext, nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
Decrypt(c, ciphertext, nil)
}
}
func TestNewAEADCipherFromBase64(t *testing.T) {
t.Parallel()
tests := []struct {