Documentation
¶
Overview ¶
Package dataencryption provides the MSEH envelope format and DataEncryptionService.
Wire format (Java-compatible):
[4 bytes: 0x4D 0x53 0x45 0x48] "MSEH" magic [varint32: proto byte length] [EncryptionHeader proto bytes] see dataencryption/v1/encryption_header.proto [ciphertext bytes]
Index ¶
- Constants
- func EncodeHeader(h Header) ([]byte, error)
- func FieldAAD(headerPrefix []byte, domain, identity string) []byte
- func HasMagic(b []byte) bool
- func WithContext(ctx context.Context, svc *Service) context.Context
- func WriteHeader(w io.Writer, h Header) error
- type Header
- type Service
- func (s *Service) AttachmentSigningKeys(ctx context.Context) ([][]byte, error)
- func (s *Service) DecryptField(ciphertext []byte, domain, identity string) ([]byte, error)
- func (s *Service) DecryptStream(src io.Reader) (io.Reader, error)
- func (s *Service) EncryptField(plaintext []byte, domain, identity string) ([]byte, error)
- func (s *Service) EncryptStream(dst io.Writer) (io.WriteCloser, error)
- func (s *Service) IsPrimaryReal() bool
Constants ¶
const ( // VersionAttachmentStreamAESGCM is the authenticated record stream format used for attachments. VersionAttachmentStreamAESGCM uint32 = 3 // VersionFieldAESGCM is the authenticated field format using domain/identity AAD. VersionFieldAESGCM uint32 = 4 )
Variables ¶
This section is empty.
Functions ¶
func EncodeHeader ¶ added in v0.0.4
EncodeHeader encodes h as an MSEH envelope prefix.
func FieldAAD ¶ added in v0.0.4
FieldAAD returns the canonical associated data for an MSEH v4 persisted field.
func WithContext ¶
WithContext returns a new context carrying the given Service.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service orchestrates encryption providers. The primary provider is used for new encryptions; all registered providers are available for decryption routing via the MSEH ProviderID field.
func FromContext ¶
FromContext retrieves the Service from the context. Returns nil if none was set.
func New ¶
New constructs a Service from cfg.EncryptionProviders (comma-separated list). The first named provider becomes the primary (used for encryption).
func (*Service) AttachmentSigningKeys ¶
AttachmentSigningKeys returns signing keys from the primary provider for attachment download URL HMAC signing. Returns nil when the primary provider does not support signed URLs (e.g. "plain" with no key configured).
func (*Service) DecryptField ¶ added in v0.0.4
DecryptField decrypts a persisted field. Encrypted values must use MSEH v4 and are authenticated with the supplied domain and identity. Headerless values are accepted only when plain is the primary provider.
func (*Service) DecryptStream ¶
DecryptStream routes current MSEH v3 streams by provider. Headerless streams are accepted only when plain is the primary provider.
func (*Service) EncryptField ¶ added in v0.0.4
EncryptField encrypts a persisted field with MSEH v4 domain/identity AAD binding.
func (*Service) EncryptStream ¶
EncryptStream delegates to the primary provider.
func (*Service) IsPrimaryReal ¶
IsPrimaryReal returns true when the primary provider performs actual encryption (i.e. is not the "plain" no-op provider).