...

Package mongocrypt

import "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt"
Overview
Index
Subdirectories

Overview ▾

Index ▾

func Version() string
type Context
    func (c *Context) AddOperationResult(bsoncore.Document) error
    func (c *Context) Close()
    func (c *Context) CompleteOperation() error
    func (c *Context) Finish() (bsoncore.Document, error)
    func (c *Context) FinishKmsContexts() error
    func (c *Context) NextKmsContext() *KmsContext
    func (c *Context) NextOperation() (bsoncore.Document, error)
    func (c *Context) ProvideKmsProviders(bsoncore.Document) error
    func (c *Context) State() State
type Error
    func (Error) Error() string
type KmsContext
    func (kc *KmsContext) BytesNeeded() int32
    func (kc *KmsContext) FeedResponse([]byte) error
    func (kc *KmsContext) HostName() (string, error)
    func (kc *KmsContext) KMSProvider() string
    func (kc *KmsContext) Message() ([]byte, error)
type MongoCrypt
    func NewMongoCrypt(*options.MongoCryptOptions) (*MongoCrypt, error)
    func (m *MongoCrypt) Close()
    func (m *MongoCrypt) CreateDataKeyContext(string, *options.DataKeyOptions) (*Context, error)
    func (m *MongoCrypt) CreateDecryptionContext(bsoncore.Document) (*Context, error)
    func (m *MongoCrypt) CreateEncryptionContext(string, bsoncore.Document) (*Context, error)
    func (m *MongoCrypt) CreateExplicitDecryptionContext(bsoncore.Document) (*Context, error)
    func (m *MongoCrypt) CreateExplicitEncryptionContext(bsoncore.Document, *options.ExplicitEncryptionOptions) (*Context, error)
    func (m *MongoCrypt) CreateExplicitEncryptionExpressionContext(bsoncore.Document, *options.ExplicitEncryptionOptions) (*Context, error)
    func (m *MongoCrypt) CryptSharedLibVersion() uint64
    func (m *MongoCrypt) CryptSharedLibVersionString() string
    func (m *MongoCrypt) GetKmsProviders(context.Context) (bsoncore.Document, error)
    func (m *MongoCrypt) RewrapDataKeyContext([]byte, *options.RewrapManyDataKeyOptions) (*Context, error)
type State
    func (s State) String() string

Package files

errors_not_enabled.go mongocrypt_context_not_enabled.go mongocrypt_kms_context_not_enabled.go mongocrypt_not_enabled.go state.go

func Version

func Version() string

Version returns the version string for the loaded libmongocrypt, or an empty string if libmongocrypt was not loaded.

type Context

Context represents a mongocrypt_ctx_t handle

type Context struct{}

func (*Context) AddOperationResult

func (c *Context) AddOperationResult(bsoncore.Document) error

AddOperationResult feeds the result of a database operation to mongocrypt.

func (*Context) Close

func (c *Context) Close()

Close cleans up any resources associated with the given Context instance.

func (*Context) CompleteOperation

func (c *Context) CompleteOperation() error

CompleteOperation signals a database operation has been completed.

func (*Context) Finish

func (c *Context) Finish() (bsoncore.Document, error)

Finish performs the final operations for the context and returns the resulting document.

func (*Context) FinishKmsContexts

func (c *Context) FinishKmsContexts() error

FinishKmsContexts signals that all KMS contexts have been completed.

func (*Context) NextKmsContext

func (c *Context) NextKmsContext() *KmsContext

NextKmsContext returns the next KmsContext, or nil if there are no more.

func (*Context) NextOperation

func (c *Context) NextOperation() (bsoncore.Document, error)

NextOperation gets the document for the next database operation to run.

func (*Context) ProvideKmsProviders

func (c *Context) ProvideKmsProviders(bsoncore.Document) error

ProvideKmsProviders provides the KMS providers when in the NeedKmsCredentials state.

func (*Context) State

func (c *Context) State() State

State returns the current State of the Context.

type Error

Error represents an error from an operation on a MongoCrypt instance.

type Error struct {
    Code    int32
    Message string
}

func (Error) Error

func (Error) Error() string

Error implements the error interface

type KmsContext

KmsContext represents a mongocrypt_kms_ctx_t handle.

type KmsContext struct{}

func (*KmsContext) BytesNeeded

func (kc *KmsContext) BytesNeeded() int32

BytesNeeded returns the number of bytes that should be received from the KMS. After sending the message to the KMS, this message should be called in a loop until the number returned is 0.

func (*KmsContext) FeedResponse

func (kc *KmsContext) FeedResponse([]byte) error

FeedResponse feeds the bytes received from the KMS to mongocrypt.

func (*KmsContext) HostName

func (kc *KmsContext) HostName() (string, error)

HostName gets the host name of the KMS.

func (*KmsContext) KMSProvider

func (kc *KmsContext) KMSProvider() string

KMSProvider gets the KMS provider of the KMS context.

func (*KmsContext) Message

func (kc *KmsContext) Message() ([]byte, error)

Message returns the message to send to the KMS.

type MongoCrypt

MongoCrypt represents a mongocrypt_t handle.

type MongoCrypt struct{}

func NewMongoCrypt

func NewMongoCrypt(*options.MongoCryptOptions) (*MongoCrypt, error)

NewMongoCrypt constructs a new MongoCrypt instance configured using the provided MongoCryptOptions.

func (*MongoCrypt) Close

func (m *MongoCrypt) Close()

Close cleans up any resources associated with the given MongoCrypt instance.

func (*MongoCrypt) CreateDataKeyContext

func (m *MongoCrypt) CreateDataKeyContext(string, *options.DataKeyOptions) (*Context, error)

CreateDataKeyContext creates a Context to use for creating a data key.

func (*MongoCrypt) CreateDecryptionContext

func (m *MongoCrypt) CreateDecryptionContext(bsoncore.Document) (*Context, error)

CreateDecryptionContext creates a Context to use for decryption.

func (*MongoCrypt) CreateEncryptionContext

func (m *MongoCrypt) CreateEncryptionContext(string, bsoncore.Document) (*Context, error)

CreateEncryptionContext creates a Context to use for encryption.

func (*MongoCrypt) CreateExplicitDecryptionContext

func (m *MongoCrypt) CreateExplicitDecryptionContext(bsoncore.Document) (*Context, error)

CreateExplicitDecryptionContext creates a Context to use for explicit decryption.

func (*MongoCrypt) CreateExplicitEncryptionContext

func (m *MongoCrypt) CreateExplicitEncryptionContext(bsoncore.Document, *options.ExplicitEncryptionOptions) (*Context, error)

CreateExplicitEncryptionContext creates a Context to use for explicit encryption.

func (*MongoCrypt) CreateExplicitEncryptionExpressionContext

func (m *MongoCrypt) CreateExplicitEncryptionExpressionContext(bsoncore.Document, *options.ExplicitEncryptionOptions) (*Context, error)

CreateExplicitEncryptionExpressionContext creates a Context to use for explicit encryption of an expression.

func (*MongoCrypt) CryptSharedLibVersion

func (m *MongoCrypt) CryptSharedLibVersion() uint64

CryptSharedLibVersion returns the version number for the loaded crypt_shared library, or 0 if the crypt_shared library was not loaded.

func (*MongoCrypt) CryptSharedLibVersionString

func (m *MongoCrypt) CryptSharedLibVersionString() string

CryptSharedLibVersionString returns the version string for the loaded crypt_shared library, or an empty string if the crypt_shared library was not loaded.

func (*MongoCrypt) GetKmsProviders

func (m *MongoCrypt) GetKmsProviders(context.Context) (bsoncore.Document, error)

GetKmsProviders returns the originally configured KMS providers.

func (*MongoCrypt) RewrapDataKeyContext

func (m *MongoCrypt) RewrapDataKeyContext([]byte, *options.RewrapManyDataKeyOptions) (*Context, error)

RewrapDataKeyContext creates a Context to use for rewrapping a data key.

type State

State represents a state that a MongocryptContext can be in.

type State int

These constants are valid values for the State type. The values must match the values defined in the mongocrypt_ctx_state_t enum in libmongocrypt.

const (
    StateError         State = 0
    NeedMongoCollInfo  State = 1
    NeedMongoMarkings  State = 2
    NeedMongoKeys      State = 3
    NeedKms            State = 4
    Ready              State = 5
    Done               State = 6
    NeedKmsCredentials State = 7
)

func (State) String

func (s State) String() string

String implements the Stringer interface.

Subdirectories

Name Synopsis
..
options