Documentation
¶
Index ¶
- Constants
- func BuildMaskWithLeadingZeroes(numZeroes uint) uint64
- func DocIDToPathname(docID sserver1.DocumentID, keys []PathnameKeyType) (string, error)
- func GenerateSalts(numKeys, lenSalt int) (salts [][]byte, err error)
- func GetKeyGenFromDocID(docID sserver1.DocumentID) (int, error)
- func GetNumLeadingZeroes(num uint64) uint
- func GetRootCerts(serverAddr string) []byte
- func NormalizeKeyword(keyword string) string
- func PathnameToDocID(keyGen libkbfs.KeyGen, pathname string, key PathnameKeyType) (sserver1.DocumentID, error)
- func RandUint64() (uint64, error)
- func RandUint64n(n uint64) (uint64, error)
- func WriteFileAtomic(pathname string, content []byte) error
- func XorBytes(one, two []byte, len int) []byte
- type PathnameKeyType
- type SecureIndex
- type SecureIndexBuilder
Constants ¶
const RandomNumberGenerationFactor = 1.3
RandomNumberGenerationFactor is the ratio of the number of random numbers to generate to the number of which that we need. We generate extra random numbers to account for those that are out of range.
const TestRootCert = `` /* 4195-byte string literal not displayed */
TestRootCert is a CA cert which can be used for testing TLS support. 127.0.0.1 is the only supported address.
const TestRootKey = `` /* 1678-byte string literal not displayed */
TestRootKey can be used with the above cert+public key to test TLS support.
Variables ¶
This section is empty.
Functions ¶
func BuildMaskWithLeadingZeroes ¶
BuildMaskWithLeadingZeroes returns an uint64 with the first `numZeroes` bits being '0', and the rest being '1'.
func DocIDToPathname ¶
func DocIDToPathname(docID sserver1.DocumentID, keys []PathnameKeyType) (string, error)
DocIDToPathname decrypts a `docID` to get the actual pathname by using the `keys`.
func GenerateSalts ¶
GenerateSalts generates `numKeys` salts with length `lenSalt`. Returns an error if the salts cannot be properly generated.
func GetKeyGenFromDocID ¶
func GetKeyGenFromDocID(docID sserver1.DocumentID) (int, error)
GetKeyGenFromDocID extracts the key generation from the document ID and returns it as an int. Note that `docID` does not need to be a complete document ID. A prefix of a document ID would also work, as the key generation is written in the very beginning.
func GetNumLeadingZeroes ¶
GetNumLeadingZeroes returns the number of leading zeroes in `num` as an uint64. The algorithm is based upon the `__builtin_clz` function in C languages.
func GetRootCerts ¶
GetRootCerts returns a byte array with the appropriate root certs for the given host:port string. TODO: Add production cert.
func NormalizeKeyword ¶
NormalizeKeyword normalizes a keyword for adding into the index by converting it to lower case and keeping only the alphanumeric characters.
func PathnameToDocID ¶
func PathnameToDocID(keyGen libkbfs.KeyGen, pathname string, key PathnameKeyType) (sserver1.DocumentID, error)
PathnameToDocID encrypts a `pathname` to a document ID using `key`. NOTE: Instead of using random nonce and padding, we need to use deterministic ones, because we want the encryptions of the same pathname to always yield the same result.
func RandUint64 ¶
RandUint64 returns a random 64-bit unsigned integer.
func RandUint64n ¶
RandUint64n returns a random 64-bit unsigned integer in the range of [0, n). Panics if n <= 0.
func WriteFileAtomic ¶
WriteFileAtomic writes `content` to a file with `pathname`. First writes to a temporary file and then performs a rename so that the write is atomic.
Types ¶
type PathnameKeyType ¶
type PathnameKeyType [32]byte
PathnameKeyType is the type of key used to encrypt the pathnames into document IDs, and vice versa.
type SecureIndex ¶
type SecureIndex struct { BloomFilter bitarray.BitArray // The blinded bloom filter, which is the main part of the index. Nonce uint64 Size uint64 // The number of buckets in the bloom filter. Hash func() hash.Hash // The hash function to be used for HMAC. }
SecureIndex defines the elements in a secure index.
func (*SecureIndex) MarshalBinary ¶
func (si *SecureIndex) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*SecureIndex) UnmarshalBinary ¶
func (si *SecureIndex) UnmarshalBinary(input []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type SecureIndexBuilder ¶
type SecureIndexBuilder struct {
// contains filtered or unexported fields
}
SecureIndexBuilder stores the essential information needed to build the indexes for the documents.
func CreateSecureIndexBuilder ¶
func CreateSecureIndexBuilder(h func() hash.Hash, masterSecret []byte, salts [][]byte, size uint64) *SecureIndexBuilder
CreateSecureIndexBuilder instantiates a `SecureIndexBuilder`. Sets up the hash function, and derives the keys from the master secret and salts by using PBKDF2. Finally, sets up the trapdoor function for the words.
func (*SecureIndexBuilder) BuildSecureIndex ¶
func (sib *SecureIndexBuilder) BuildSecureIndex(document *os.File, fileLen int64) (SecureIndex, error)
BuildSecureIndex builds the index for `document` and an *encrypted* length of `fileLen`.
func (*SecureIndexBuilder) ComputeTrapdoors ¶
func (sib *SecureIndexBuilder) ComputeTrapdoors(word string) [][]byte
ComputeTrapdoors computes the trapdoor values for `word`. This acts as the public getter for the trapdoorFunc field of SecureIndexBuilder.