 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
const TokenValidity = time.Hour
    Validity period of tokens created with D1.CreateToken.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access struct {
	// The set of groups that have access to the associated object. The format of the key strings
	// depends on how the ID Provider implements group identifiers.
	Groups map[string]struct{}
	// The wrapped encryption key for the associated object.
	WrappedOEK []byte
}
    Access is used to manage access to encrypted objects. Note: All member fields need to be exported in order to serialize them.
func NewAccess ¶
NewAccess creates a new access object which contains the provided wrapped key and no groups.
func (*Access) ContainsGroups ¶
ContainsGroups returns true if all provided group IDs are contained in the access object, and false otherwise.
func (*Access) RemoveGroups ¶
RemoveGroups removes the provided group IDs from the access object.
func (*Access) Seal ¶
func (a *Access) Seal(oid uuid.UUID, cryptor crypto.CryptorInterface) (SealedAccess, error)
Seal encrypts the access object.
type Node ¶
Node contains an identifier (e.g. a document ID) and the counter used to compute the next label.
func (*Node) NextLabel ¶
func (n *Node) NextLabel(tagger crypto.TaggerInterface) ([]byte, error)
NextLabel computes the next label based on the value of NextCounter.
func (*Node) Seal ¶
func (n *Node) Seal(label []byte, cryptor crypto.CryptorInterface) (SealedNode, error)
Seal encrypts the plaintext Node.
type Object ¶
type Object struct {
	// Sensitive plaintext data that will be encrypted.
	Plaintext []byte
	// Associated data that will not be encrypted but will be authenticated.
	AssociatedData []byte
}
    Object contains plaintext data provided to D1 for encryption.
func (*Object) Seal ¶
func (o *Object) Seal(oid uuid.UUID, cryptor crypto.CryptorInterface) ([]byte, SealedObject, error)
Seal encrypts the object and returns the wrapped encryption key and the sealed object.
type SealedAccess ¶
type SealedAccess struct {
	// The ID of the object this access object provides access to.
	OID uuid.UUID
	Ciphertext []byte
	WrappedKey []byte
}
    SealedAccess is an encrypted structure which is used to manage access to encrypted objects.
func (*SealedAccess) Unseal ¶
func (a *SealedAccess) Unseal(cryptor crypto.CryptorInterface) (Access, error)
Unseal decrypts the sealed object.
type SealedNode ¶
SealedNode is an encrypted structure which defines an occurrence of a specific keyword in a specific identifier.
func (*SealedNode) Unseal ¶
func (n *SealedNode) Unseal(label []byte, cryptor crypto.CryptorInterface) (Node, error)
Unseal decrypts the sealed Node.
type SealedObject ¶
type SealedObject struct {
	// The encrypted contents of the object.
	Ciphertext []byte
	// Associated data in plaintext. This data is authenticated upon decryption, and can be used as
	// metadata about the ciphertext.
	AssociatedData []byte
	// A unique ID which identifies the object. The ID is authenticated upon decryption.
	OID uuid.UUID
}
    SealedObject contains encrypted and authenticated data.
func (*SealedObject) Unseal ¶
func (o *SealedObject) Unseal(wrappedKey []byte, cryptor crypto.CryptorInterface) (Object, error)
Unseal uses the wrapped key to decrypt the sealed object.
type SealedToken ¶
type SealedToken struct {
	// The tokens expiry time. After this time, it can no longer be decrypted.
	ExpiryTime time.Time
	Ciphertext []byte
	WrappedKey []byte
}
    SealedToken contains encrypted data which has an expiry time.
func TokenFromString ¶
func TokenFromString(tokenString string) (SealedToken, error)
TokenFromString takes a raw base 64 URL encoded token and deserializes it.
func (*SealedToken) String ¶
func (t *SealedToken) String() (string, error)
String serializes the sealed token into a raw base 64 URL encoded format.
func (*SealedToken) Unseal ¶
func (t *SealedToken) Unseal(cryptor crypto.CryptorInterface) (Token, error)
Unseal decrypts the sealed token.
type Token ¶
type Token struct {
	// Arbitrary plaintext data.
	Plaintext []byte
	// Expiry time at which point the data is no longer valid.
	ExpiryTime time.Time
}
    Token contains arbitrary data along with an expiry time. Note: All fields need to be exported in order to serialize them.
func NewToken ¶
NewToken creates a new token which contains the provided plaintext and has the given validity period.
func (*Token) Seal ¶
func (t *Token) Seal(cryptor crypto.CryptorInterface) (SealedToken, error)
Seal encrypts the token.