Documentation ¶
Index ¶
Constants ¶
View Source
const ProtocolVersion uint8 = 2
ProtocolVersion specifies the default version of the protocol
Variables ¶
View Source
var ( // MagicNumber is prepended to the container to identify its format MagicNumber = []byte{95, 219, 76} // ErrSaltInvalid is returned when a salt is the wrong length ErrSaltInvalid = errors.New("invalid salt must be 32 bytes long") // ErrCurveSupport is returned when a curve is not supported for ECIES ErrCurveSupport = errors.New("curve is not supported") // ErrCurveMissmatch is returned if you have a different container curve ID to the public key's curve ID ErrCurveMissmatch = errors.New("curve of public key does not match curve of container") // ErrHashUnsupported is returned when trying to obtain a HKDF with a hash which isn't supported ErrHashUnsupported = errors.New("hash is unsupported") )
View Source
var ( // ErrNotContainer is returned if the content trying to be decoded is not // a container ErrNotContainer = errors.New("stream is not a container") // ErrProtocolVersionSupport is returned if the version of the protocol // in the container is not a supported version and can not be decoded ErrProtocolVersionSupport = errors.New("protocol version is not supported") // ErrCipherTextShort is returned when ciphertext is too short to be valid ErrCipherTextShort = errors.New("ciphertext is too short to be valid") )
Functions ¶
func HashIDToFunc ¶ added in v1.2.0
HashIDToFunc takes a HashID and returns a hash.Hash
Types ¶
type Container ¶
type Container struct { // Curve specifies which curve to use for the ECIES on the metadata section Curve CurveID // HashID is used with HKDF on the metadata section HashID HashID MetaData *SectionMetaData CipherText *SectionCipherText // contains filtered or unexported fields }
Container is used to hold the metadata and ciphertext section together and communicate some configuration and protocol version information to the decoder
func DecodeContainer ¶
DecodeContainer will decode a container and decrypt it
func NewContainer ¶
NewContainer will create a new container to store the secret content
func UnmarshalContainer ¶
func UnmarshalContainer(container []byte, priv rome.PrivateKey, masterKey []byte) (*Container, error)
UnmarshalContainer will decode the provided bytes into a container
type CurveID ¶
type CurveID uint8
CurveID represents a Elliptic or Edwards curve
const ( // CurveP224 is a nist curve CurveP224 CurveID = 1 + iota // CurveP256 is a nist curve CurveP256 // CurveP384 is a nist curve CurveP384 // CurveP521 is a nist curve CurveP521 // Brain pool curves CurveP160t1 CurveP192r1 CurveP192t1 CurveP224r1 CurveP224t1 CurveP256r1 CurveP256t1 CurveP320r1 CurveP320t1 CurveP384r1 CurveP384t1 CurveP512r1 CurveP512t1 )
type SectionCipherText ¶
SectionCipherText is used to store the secret content
func (*SectionCipherText) Encode ¶
func (c *SectionCipherText) Encode(w io.Writer, m *SectionMetaData, masterKey []byte) error
Encode encrypts and marshales the plaintext
Source Files ¶
Click to show internal directories.
Click to hide internal directories.