kbcrypto

package
v0.0.0-...-a8b6a46 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: BSD-3-Clause, BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDSuffixKID = 0x0a
)
View Source
const (
	KeybaseKIDV1 = 1 // Uses SHA-256
)
View Source
const (
	SCSigCannotVerify = int(keybase1.StatusCode_SCSigCannotVerify)
)
View Source
const SHA256Code = 8

Variables

This section is empty.

Functions

func CodecHandle

func CodecHandle() *codec.MsgpackHandle

func ComputeSigIDFromSigBody

func ComputeSigIDFromSigBody(body []byte) keybase1.SigID

func DecodePacket

func DecodePacket(decoder *codec.Decoder, body Packetable) error

func DecodePacketFromBytes

func DecodePacketFromBytes(data []byte, body Packetable) error

func EncodePacket

func EncodePacket(p Packetable, encoder *codec.Encoder) error

func EncodePacketToArmoredString

func EncodePacketToArmoredString(p Packetable) (string, error)

func EncodePacketToBytes

func EncodePacketToBytes(p Packetable) ([]byte, error)

func FastByteArrayEq

func FastByteArrayEq(a, b []byte) bool

func SecureByteArrayEq

func SecureByteArrayEq(a, b []byte) bool

Types

type AlgoType

type AlgoType int
const (
	KIDPGPBase    AlgoType = 0x00
	KIDPGPRsa     AlgoType = 0x1
	KIDPGPElgamal AlgoType = 0x10
	KIDPGPDsa     AlgoType = 0x11
	KIDPGPEcdh    AlgoType = 0x12
	KIDPGPEcdsa   AlgoType = 0x13
	KIDPGPEddsa   AlgoType = 0x16
	KIDNaclEddsa  AlgoType = 0x20
	KIDNaclDH     AlgoType = 0x21

	SigKbEddsa AlgoType = KIDNaclEddsa
)

type BadKeyError

type BadKeyError struct {
	Msg string
}

func (BadKeyError) Error

func (p BadKeyError) Error() string

type BadSignaturePrefixError

type BadSignaturePrefixError struct{}

func (BadSignaturePrefixError) Error

func (e BadSignaturePrefixError) Error() string

type FishyMsgpackError

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

func (FishyMsgpackError) Error

func (e FishyMsgpackError) Error() string

type HashType

type HashType int
const (
	HashPGPMd5       HashType = 1
	HashPGPSha1      HashType = 2
	HashPGPRipemd160 HashType = 3
	HashPGPSha256    HashType = 8
	HashPGPSha384    HashType = 9
	HashPGPSha512    HashType = 10
	HashPGPSha224    HashType = 11
)

OpenPGP hash IDs, taken from http://tools.ietf.org/html/rfc4880#section-9.4

type NaclSigInfo

type NaclSigInfo struct {
	Kid      keybase1.BinaryKID `codec:"key"`
	Payload  []byte             `codec:"payload,omitempty"`
	Sig      NaclSignature      `codec:"sig"`
	SigType  AlgoType           `codec:"sig_type"`
	HashType HashType           `codec:"hash_type"`
	Detached bool               `codec:"detached"`
	Version  int                `codec:"version,omitempty"`
	Prefix   SignaturePrefix    `codec:"prefix,omitempty"`
}

func DecodeArmoredNaclSigInfoPacket

func DecodeArmoredNaclSigInfoPacket(s string) (NaclSigInfo, error)

func DecodeNaclSigInfoPacket

func DecodeNaclSigInfoPacket(data []byte) (NaclSigInfo, error)

func (*NaclSigInfo) ArmoredEncode

func (s *NaclSigInfo) ArmoredEncode() (ret string, err error)

func (*NaclSigInfo) GetTagAndVersion

func (s *NaclSigInfo) GetTagAndVersion() (PacketTag, PacketVersion)

func (NaclSigInfo) Verify

func (s NaclSigInfo) Verify() (*NaclSigningKeyPublic, error)

type NaclSignature

type NaclSignature [ed25519.SignatureSize]byte

type NaclSigningKeyPrivate

type NaclSigningKeyPrivate [ed25519.PrivateKeySize]byte

func (NaclSigningKeyPrivate) Sign

func (NaclSigningKeyPrivate) SignInfoV0

func (k NaclSigningKeyPrivate) SignInfoV0(msg []byte, public NaclSigningKeyPublic) NaclSigInfo

func (NaclSigningKeyPrivate) SignInfoV2

func (k NaclSigningKeyPrivate) SignInfoV2(msg []byte, public NaclSigningKeyPublic, prefix SignaturePrefix) (NaclSigInfo, error)

func (NaclSigningKeyPrivate) SignToStringV0

func (k NaclSigningKeyPrivate) SignToStringV0(msg []byte, public NaclSigningKeyPublic) (string, keybase1.SigID, error)

type NaclSigningKeyPublic

type NaclSigningKeyPublic [ed25519.PublicKeySize]byte

func KIDToNaclSigningKeyPublic

func KIDToNaclSigningKeyPublic(bk []byte) *NaclSigningKeyPublic

func NaclVerifyAndExtract

func NaclVerifyAndExtract(s string) (nk *NaclSigningKeyPublic, payload []byte, fullBody []byte, err error)

NaclVerifyAndExtract interprets the given string as a NaCl-signed messaged, in the keybase NaclSigInfo (v1) format. It will check that the signature verified, and if so, will return the public key that was used for the verification, the payload of the signature, the full body of the decoded SignInfo, and an error

func (NaclSigningKeyPublic) GetBinaryKID

func (k NaclSigningKeyPublic) GetBinaryKID() keybase1.BinaryKID

func (NaclSigningKeyPublic) GetKID

func (k NaclSigningKeyPublic) GetKID() keybase1.KID

func (NaclSigningKeyPublic) Verify

func (k NaclSigningKeyPublic) Verify(msg []byte, sig NaclSignature) bool

type PacketTag

type PacketTag uint

PacketTag are tags for OpenPGP and Keybase packets. It is a uint to be backwards compatible with older versions of codec that encoded positive ints as uints.

const (
	TagP3skb      PacketTag = 513
	TagSignature  PacketTag = 514
	TagEncryption PacketTag = 515
)

func (PacketTag) String

func (t PacketTag) String() string

type PacketVersion

type PacketVersion int
const (
	KeybasePacketV1 PacketVersion = 1
)

type Packetable

type Packetable interface {
	GetTagAndVersion() (PacketTag, PacketVersion)
}

type SignaturePrefix

type SignaturePrefix string
const (
	SignaturePrefixKBFS           SignaturePrefix = "Keybase-KBFS-1"
	SignaturePrefixSigchain       SignaturePrefix = "Keybase-Sigchain-1"
	SignaturePrefixChatAttachment SignaturePrefix = "Keybase-Chat-Attachment-1"
	SignaturePrefixTesting        SignaturePrefix = "Keybase-Testing-1"
	SignaturePrefixNIST           SignaturePrefix = "Keybase-Auth-NIST-1"
	// Chat prefixes for each MessageBoxedVersion.
	SignaturePrefixChatMBv1 SignaturePrefix = "Keybase-Chat-1"
	SignaturePrefixChatMBv2 SignaturePrefix = "Keybase-Chat-2"
)

func (SignaturePrefix) HasNullByte

func (p SignaturePrefix) HasNullByte() bool

func (SignaturePrefix) Prefix

func (p SignaturePrefix) Prefix(msg []byte) []byte

type UnhandledSignatureError

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

func (UnhandledSignatureError) Error

func (e UnhandledSignatureError) Error() string

type UnmarshalError

type UnmarshalError struct {
	ExpectedTag PacketTag
	Tag         PacketTag
}

func (UnmarshalError) Error

func (u UnmarshalError) Error() string

type VerificationError

type VerificationError struct {
	Cause error
}

func (VerificationError) Error

func (e VerificationError) Error() string

func (VerificationError) ToStatus

func (e VerificationError) ToStatus() keybase1.Status

Jump to

Keyboard shortcuts

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