c3

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 10 Imported by: 0

README

c3-go

Golang port of the C3 project.

  • Currently verification-only. Use python C3 for signing etc.
  • Text fields are currently ignored instead of being inspected/cross-checked.

Documentation

Index

Constants

View Source
const (
	// --- Top-level tag values ---
	PUB_CSR         = 10
	DUALBLOCK       = 11
	PUB_PAYLOAD     = 12 // cert chain with a payload as the first entry
	BARE_PAYLOAD    = 13 // literally just payload bytes but tagged with a header tag.
	PUB_CERTCHAIN   = 14 // cert chain with a cert as the first entry
	PRIV_CRCWRAPPED = 15 // "priv data with a crc32 integrity check"
	// --- Public-part chain-level ---
	HDR_DAS = 0x19 // "data_part and sig_part structure"
)

Variables

View Source
var (
	TextStructureError = errors.New("File text vertical structure is invalid")
	StructureError     = errors.New("Binary structure is invalid")
	NoLinkError        = errors.New("Chain does not link to trusted certs")
	VerifyError        = errors.New("Signature failed to verify")
)

Functions

func AddTrusted

func AddTrusted(block []byte) error

func Blankify

func Blankify(in string) string

func ChainMetadata

func ChainMetadata(chain []DasCertPayload, FieldEx func(*Cert) string) []string

func ExpectKeyHeader

func ExpectKeyHeader(wantKeys []int, wantType int, buf []byte) (int, int, error)

func InIntList

func InIntList(itm int, intList []int) bool

func KeypairsVerify

func KeypairsVerify(cert Cert, dataBytes []byte, sigBytes []byte) error

func SplitLines

func SplitLines(input string) []string

func TextToBinaryBlock

func TextToBinaryBlock(textPart string) ([]byte, []string, error)

func VNames

func VNames(chain []DasCertPayload) []string

func VTypes

func VTypes(chain []DasCertPayload) []string

func Verify

func Verify(chain []DasCertPayload) error

Types

type Cert

type Cert struct {
	CertID      []byte    `b3.type:"BYTES"     b3.tag:"0"  b3.req:"y"`
	SubjectName string    `b3.type:"UTF8"      b3.tag:"1"  b3.req:"y"`
	KeyType     int       `b3.type:"UVARINT"   b3.tag:"2"  b3.req:"y"`
	PublicKey   []byte    `b3.type:"BYTES"     b3.tag:"3"  b3.req:"y"`
	ExpiryDate  time.Time `b3.type:"BASICDATE" b3.tag:"4"  b3.req:"y"` //    (this is for b3.BASICDATE so it's ONLY date-values)
	IssuedDate  time.Time `b3.type:"BASICDATE" b3.tag:"5"  b3.req:"y"`
	CertType    string    `b3.type:"UTF8"      b3.tag:"6"  b3.req:"n"` //    // optional (zero value ok here)
}

type DasBytes

type DasBytes struct {
	DataPart []byte `b3.type:"BYTES"     b3.tag:"0"  b3.req:"y"`
	SigPart  []byte `b3.type:"BYTES"     b3.tag:"1"  b3.req:"y"`
}

This is a DAS (data-and-sig) with the data & sig bytes (made for us by B3)

type DasCertPayload

type DasCertPayload struct {
	DataPart []byte
	SigPart  []byte
	Payload  []byte
	Cert     Cert
	Sig      Signature
}

This is a DAS with everything unpacked (certs & payloads etc) made by Load for Verify to use

func LoadPubBlock

func LoadPubBlock(publicPart []byte) (ppkey int, chain []DasCertPayload, err error)

type Signature

type Signature struct {
	Signature     []byte `b3.type:"BYTES"     b3.tag:"0"   b3.req:"y"`
	SigningCertID []byte `b3.type:"BYTES"     b3.tag:"1"   b3.req:"n"` // optional
}

Jump to

Keyboard shortcuts

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