/
crypt.go
27 lines (23 loc) · 964 Bytes
/
crypt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package storage
import (
"github.com/keybase/client/go/encrypteddb"
"github.com/keybase/client/go/libkb"
"github.com/keybase/client/go/protocol/gregor1"
"github.com/keybase/client/go/protocol/keybase1"
"golang.org/x/net/context"
)
// ***
// If we change this, make sure to update libkb.EncryptionReasonChatLocalStorage as well!
// Also see the encrypteddb package's cryptoVersion.
// ***
const cryptoVersion = 1
func GetSecretBoxKey(ctx context.Context, g *libkb.GlobalContext) (fkey [32]byte, err error) {
return encrypteddb.GetSecretBoxKey(ctx, g, libkb.EncryptionReasonChatLocalStorage, "encrypt chat message")
}
func GetSecretBoxKeyWithUID(ctx context.Context, g *libkb.GlobalContext, uid gregor1.UID) (fkey [32]byte, err error) {
uid2, err := keybase1.UIDFromString(uid.String())
if err != nil {
return [32]byte{}, err
}
return encrypteddb.GetSecretBoxKeyWithUID(ctx, g, uid2, libkb.EncryptionReasonChatLocalStorage, "encrypt chat message")
}