libsearch

package
v0.0.0-...-1fd911f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2016 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
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.

View Source
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

func BuildMaskWithLeadingZeroes(numZeroes uint) uint64

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

func GenerateSalts(numKeys, lenSalt int) (salts [][]byte, err error)

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

func GetNumLeadingZeroes(num uint64) uint

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

func GetRootCerts(serverAddr string) []byte

GetRootCerts returns a byte array with the appropriate root certs for the given host:port string. TODO: Add production cert.

func NormalizeKeyword

func NormalizeKeyword(keyword string) string

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

func RandUint64() (uint64, error)

RandUint64 returns a random 64-bit unsigned integer.

func RandUint64n

func RandUint64n(n uint64) (uint64, error)

RandUint64n returns a random 64-bit unsigned integer in the range of [0, n). Panics if n <= 0.

func WriteFileAtomic

func WriteFileAtomic(pathname string, content []byte) error

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.

func XorBytes

func XorBytes(one, two []byte, len int) []byte

XorBytes performs an xor operation on the first `len` bytes of the two input byte slices and returns the result as a byte slice. Behavior is undefined if one or more of the input slices is shorter than `len`. TODO: Probably not needed, delete.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL