atca

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ConfigSize     = 128
	KeySize        = 32
	PrivateKeySize = 32
	PublicKeySize  = 64
	SignatureSize  = 64
)
View Source
const (
	KeyTypeECC    KeyType = "ECC"
	KeyTypeAES            = "AES"
	KeyTypeOther          = "Other"
	KeyTypeNonECC         = "NonECC" // For backward compatibility only.
)
View Source
const (
	KeyFilePrefix = "ATCA:"
)

Variables

This section is empty.

Functions

func GenKey

func GenKey(ctx context.Context, slot int, dryRun bool, dc dev.DevConn) (*ecdsa.PublicKey, error)

func GetPubKey

func GetPubKey(ctx context.Context, slot int, dc dev.DevConn) (*ecdsa.PublicKey, error)

func JSONStr

func JSONStr(v interface{}) string

func NewSigner

func NewSigner(ctx context.Context, dc dev.DevConn, slot int) crypto.Signer

func ReadHex

func ReadHex(data []byte) []byte

func WriteBinaryConfig

func WriteBinaryConfig(c *Config) ([]byte, error)

func WriteHex

func WriteHex(data []byte, numPerLine int) []byte

Types

type ChipMode

type ChipMode struct {
	SelectorWriteOnce bool
	TTLEnable         bool
	WatchDogDuration  WatchdogDuration
}

type Config

type Config struct {
	SerialNum   []byte
	Revision    uint32
	Reserved13  uint8
	I2CEnable   bool
	Reserved15  uint8
	I2CAddress  uint8
	Reserved17  uint8
	OTPMode     uint8
	ChipMode    ChipMode
	SlotInfo    []SlotInfo
	Counter0    uint64
	Counter1    uint64
	LastKeyUse0 uint64
	LastKeyUse1 uint64
	UserExtra   uint8
	Selector    uint8
	LockValue   LockMode
	LockConfig  LockMode
	SlotLocked  uint16
	Reserved90  uint8
	Reserved91  uint8
	X509Format  []X509Format
}

func Connect

func Connect(ctx context.Context, dc dev.DevConn) ([]byte, *Config, error)

func ParseBinaryConfig

func ParseBinaryConfig(cd []byte) (*Config, error)

type GenKeyArgs

type GenKeyArgs struct {
	Slot int64 `json:"slot"`
}

type GenKeyResult

type GenKeyResult struct {
	Pubkey *string `json:"pubkey,omitempty"`
}

type GetConfigResult

type GetConfigResult struct {
	Config *string `json:"config,omitempty"`
}

type GetPubKeyArgs

type GetPubKeyArgs struct {
	Slot int64 `json:"slot"`
}

type GetPubKeyResult

type GetPubKeyResult struct {
	Pubkey *string `json:"pubkey,omitempty"`
}

type KeyConfig

type KeyConfig struct {
	Private          bool    // 0
	PubInfo          bool    // 1
	KeyType          KeyType // 2, 3, 4
	Lockable         bool    // 5
	ReqRandom        bool    // 6
	ReqAuth          bool    // 7
	AuthKey          uint8   // 8,9,10,11
	IntrusionDisable bool    // 12
	// 13 - Reserved
	X509ID uint8 // 14,15
}

type KeyType

type KeyType string

type LockMode

type LockMode string
const (
	LockModeLocked   LockMode = "Locked"
	LockModeUnlocked          = "Unlocked"
)

type LockZone

type LockZone int
const (
	LockZoneConfig LockZone = 0
	LockZoneData            = 1
)

type LockZoneArgs

type LockZoneArgs struct {
	Zone *int64 `json:"zone,omitempty"`
}

type PrivateKeySlotConfig

type PrivateKeySlotConfig struct {
	ExtSignEnable  bool
	IntSignEnable  bool
	ECDHEnable     bool
	ECDHToNextSlot bool
}

type SetConfigArgs

type SetConfigArgs struct {
	Config *string `json:"config,omitempty"`
}

type SetKeyArgs

type SetKeyArgs struct {
	Ecc    bool   `json:"ecc,omitempty"`
	Key    string `json:"key,omitempty"`
	Slot   int    `json:"slot"`
	Block  int    `json:"block,omitempty"`
	Wkey   string `json:"wkey,omitempty"`
	Wkslot int    `json:"wkslot,omitempty"`
}

type SignArgs

type SignArgs struct {
	Digest *string `json:"digest,omitempty"`
	Slot   int64   `json:"slot"`
}

type SignResult

type SignResult struct {
	Signature *string `json:"signature,omitempty"`
}

type Signer

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

Implements crypto.Signer interface using ATCA.

func (*Signer) Public

func (s *Signer) Public() crypto.PublicKey

func (*Signer) Sign

func (s *Signer) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

type SlotConfig

type SlotConfig struct {
	PrivateKeySlotConfig *PrivateKeySlotConfig `json:",omitempty" yaml:",omitempty"` // For slots 0-7
	ReadKey              *uint8                `json:",omitempty" yaml:",omitempty"` // For slots 8-15
	NoMAC                bool
	LimitedUse           bool
	EncryptRead          bool
	IsSecret             bool
	WriteKey             uint8
	WriteConfig          uint8
}

type SlotInfo

type SlotInfo struct {
	Num        uint8
	SlotConfig SlotConfig
	KeyConfig  KeyConfig
}

This struct is not stored in the chip and simply contains both SlotConfig and KeyConfig together, for convenience and readability.

type WatchdogDuration

type WatchdogDuration string
const (
	Watchdog1  WatchdogDuration = "1s"
	Watchdog10                  = "10s"
)

type X509Format

type X509Format struct {
	PublicPosition uint8
	TemplateLength uint8
}

Jump to

Keyboard shortcuts

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