crypto

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EC  = 16
	RRC = 28
)

Variables

View Source
var (
	CFXFlagSendByAcceptor = uint8(0x01)
	CFXFlagSealed         = uint8(0x02)
	CFXFlagAcceptorSubKey = uint8(0x04)
)
View Source
var (
	KRB5OID = asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}
)

Functions

func DecodeASN1Header added in v1.2.0

func DecodeASN1Header(b []byte) ([]byte, uint32, bool)

DecodeASN1Header function decodes the given byte slice as an ASN.1 header and returns the remaining data, the size and a boolean value indicating if the header is valid.

func EncodeASN1Header added in v1.2.0

func EncodeASN1Header(sz uint32) ([]byte, error)

EncodeASN1Header function encodes the given size into an ASN.1 header and returns the encoded byte slice. The function returns an error if any.

func EncodeASN1HeaderTo added in v1.2.0

func EncodeASN1HeaderTo(b []byte, sz uint32) (int, error)

EncodeASN1HeaderTo function encodes the given size into an ASN.1 header and writes it to the given byte slice. The function returns the number of bytes written and an error if any.

func EncodeASN1Value added in v1.2.0

func EncodeASN1Value(b []byte, oid asn1.ObjectIdentifier, dceStyle bool, extra [][]byte) ([]byte, error)

EncodeASN1Value function encodes the given byte slice into an ASN.1 value with the given object identifier. If dceStyle is true, the function will encode the value in DCE style, else it will encode the extra value size into the header.

func EncodeASN1ValueWithExtraSize added in v1.2.0

func EncodeASN1ValueWithExtraSize(b []byte, oid asn1.ObjectIdentifier, extra ...[]byte) ([]byte, error)

EncodeASN1ValueWithExtraSize function encodes the given byte slice into an ASN.1 value with the given object identifier. The function will encode the extra value size into the header.

func IsASN1Value added in v1.2.0

func IsASN1Value(b []byte) bool

IsASN1Value function returns true if the given byte slice is an ASN.1 value with application tag.

func ParseASN1Value added in v1.2.0

func ParseASN1Value(b []byte, extra [][]byte) ([]byte, asn1.ObjectIdentifier, error)

ParseASN1Value function parses the given byte slice as an ASN.1 value. The function returns the remaining data, the object identifier and an error if any.

func Rotate

func Rotate(b []byte, rc int) []byte

Rotate function rotates the buffer over rotation point `rc`, ie out = in[rc:] + in[:rc].

Types

type AESCTSHMACSHA1

type AESCTSHMACSHA1 struct {
	// contains filtered or unexported fields
}

AESCTSHMACSHA1 represents the integrity/confidentiality routines for the aes128-cts-hmac-sha1 and aes256-cts-hmac-sha1.

func (*AESCTSHMACSHA1) ChecksumHash

func (c *AESCTSHMACSHA1) ChecksumHash() (hash.Hash, error)

func (*AESCTSHMACSHA1) DeriveEncryptionKey added in v1.2.0

func (c *AESCTSHMACSHA1) DeriveEncryptionKey() ([]byte, error)

func (*AESCTSHMACSHA1) IntegrityHash

func (c *AESCTSHMACSHA1) IntegrityHash() (hash.Hash, error)

func (*AESCTSHMACSHA1) MICHeader

func (c *AESCTSHMACSHA1) MICHeader(ctx context.Context, seqNum uint64) []byte

func (*AESCTSHMACSHA1) MakeSignature

func (c *AESCTSHMACSHA1) MakeSignature(ctx context.Context, seqNum uint64, forSgn [][]byte) ([]byte, error)

func (*AESCTSHMACSHA1) Size

func (c *AESCTSHMACSHA1) Size(ctx context.Context, conf bool) int

func (*AESCTSHMACSHA1) Unwrap

func (c *AESCTSHMACSHA1) Unwrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte, sgn []byte) (bool, error)

func (*AESCTSHMACSHA1) Wrap

func (c *AESCTSHMACSHA1) Wrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte) ([]byte, error)

func (*AESCTSHMACSHA1) WrapHeader

func (c *AESCTSHMACSHA1) WrapHeader(ctx context.Context, seqNum uint64) []byte

type Cipher

type Cipher interface {
	Wrap(context.Context, uint64, [][]byte, [][]byte) ([]byte, error)
	Unwrap(context.Context, uint64, [][]byte, [][]byte, []byte) (bool, error)
	MakeSignature(context.Context, uint64, [][]byte) ([]byte, error)
	Size(context.Context, bool) int
}

func NewAESCipher

func NewAESCipher(ctx context.Context, setting CipherSetting) (Cipher, error)

func NewCipher

func NewCipher(ctx context.Context, setting CipherSetting) (Cipher, error)

func NewDESCipher added in v1.2.0

func NewDESCipher(ctx context.Context, setting CipherSetting) (Cipher, error)

func NewRC4Cipher

func NewRC4Cipher(ctx context.Context, setting CipherSetting) (Cipher, error)

type CipherSetting added in v1.2.0

type CipherSetting struct {
	// Key is an encryption key for the cipher.
	Key types.EncryptionKey
	// Type is an encryption type for the cipher.
	Type etype.EType
	// IsSubKey is true if the key is a subkey.
	IsSubKey bool
	// IsLocal is true if cipher is an initiator's cipher.
	IsLocal bool
	// DCEStyle is true if the cipher is DCE style.
	DCEStyle bool
}

type DES added in v1.2.0

type DES struct {
	// contains filtered or unexported fields
}

func (*DES) MakeSignature added in v1.2.0

func (c *DES) MakeSignature(ctx context.Context, seqNum uint64, forSign [][]byte) ([]byte, error)

func (*DES) Size added in v1.2.0

func (c *DES) Size(ctx context.Context, conf bool) int

func (*DES) Unwrap added in v1.2.0

func (c *DES) Unwrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte, sgn []byte) (bool, error)

func (*DES) Wrap added in v1.2.0

func (c *DES) Wrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte) ([]byte, error)

type RC4HMAC

type RC4HMAC struct {
	// contains filtered or unexported fields
}

func (*RC4HMAC) MakeSignature

func (c *RC4HMAC) MakeSignature(ctx context.Context, seqNum uint64, forSign [][]byte) ([]byte, error)

func (*RC4HMAC) Size

func (c *RC4HMAC) Size(ctx context.Context, conf bool) int

func (*RC4HMAC) Unwrap

func (c *RC4HMAC) Unwrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte, sgn []byte) (bool, error)

func (*RC4HMAC) Wrap

func (c *RC4HMAC) Wrap(ctx context.Context, seqNum uint64, forSign, forSeal [][]byte) ([]byte, error)

type SizedHash

type SizedHash struct {
	hash.Hash
	// contains filtered or unexported fields
}

func (*SizedHash) Sum

func (h *SizedHash) Sum(b []byte) []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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