openpgp

package
v0.0.0-...-50fbe42 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package openpgp implements the interface to the OpenPGP application on ISO Smart Card Operating Systems v3.4.1 See: https://gnupg.org/ftp/specs/OpenPGP-smart-card-application-3.4.1.pdf

Index

Constants

View Source
const (
	PW1 byte = 0x81
	PW2 byte = 0x82
	PW3 byte = 0x83
)
View Source
const (
	AppIDOpenPGP = 0x01
)

Variables

View Source
var RidFSFE = [5]byte{0xD2, 0x76, 0x00, 0x01, 0x24}

Functions

This section is empty.

Types

type Algorithm

type Algorithm byte
const (
	AlgRSAEncSign Algorithm = 1
	AlgRSAEnc     Algorithm = 2
	AlgRSASign    Algorithm = 3
	AlgElgamal    Algorithm = 16
	AlgDSA        Algorithm = 17
	AlgECDH       Algorithm = 18
	AlgECDSA      Algorithm = 19
)

func (Algorithm) String

func (a Algorithm) String() string

type AlgorithmAttributes

type AlgorithmAttributes struct {
	Algorithm
	// contains filtered or unexported fields
}

func (*AlgorithmAttributes) Decode

func (a *AlgorithmAttributes) Decode(b []byte) error

func (*AlgorithmAttributes) String

func (a *AlgorithmAttributes) String() string

type ApplicationIdentifier

type ApplicationIdentifier struct {
	RID          RID
	Application  byte
	Version      [2]byte
	Serial       [4]byte
	Manufacturer uint16
	RFU          [2]byte
	SerialGPG    uint64
}

func (*ApplicationIdentifier) Decode

func (aid *ApplicationIdentifier) Decode(b []byte) error

func (*ApplicationIdentifier) ManufacturerName

func (aid *ApplicationIdentifier) ManufacturerName() string

type ApplicationRelated

type ApplicationRelated struct {
	AID             ApplicationIdentifier
	HistoricalBytes HistoricalBytes

	LengthInfo     ExtendedLengthInfo
	Capabilities   ExtendedCapabilities
	Features       GeneralFeatures
	PasswordStatus PasswordStatus

	Keys [4]KeyInfo
}

func (*ApplicationRelated) Decode

func (ar *ApplicationRelated) Decode(b []byte) (err error)

type Card

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

func NewCard

func NewCard(sc *scard.Card) (c *Card, err error)

func (*Card) CalculateSharedSecret

func (c *Card) CalculateSharedSecret(pk []byte) ([]byte, error)

See: OpenPGP Smart Card Application - Section 7.2.11 PSO: DECIPHER

func (*Card) ChangePassword

func (c *Card) ChangePassword(pwType byte, pwActual, pwNew string) error

See: OpenPGP Smart Card Application - Section 7.2.3 CHANGE REFERENCE DATA

func (*Card) Decipher

func (c *Card) Decipher(_ []byte) ([]byte, error)

See: OpenPGP Smart Card Application - Section 7.2.11 PSO: DECIPHER

func (*Card) Encipher

func (c *Card) Encipher(_ []byte) ([]byte, error)

See: OpenPGP Smart Card Application - Section 7.2.12 PSO: ENCIPHER

func (*Card) FactoryReset

func (c *Card) FactoryReset() error

See: OpenPGP Smart Card Application - Section

func (*Card) GenerateKeyPair

func (c *Card) GenerateKeyPair() error

See: OpenPGP Smart Card Application - Section 7.2.14 GENERATE ASYMMETRIC KEY PAIR

func (*Card) GetApplicationRelatedData

func (c *Card) GetApplicationRelatedData() (ar ApplicationRelated, err error)

func (*Card) GetCardholder

func (c *Card) GetCardholder() (ch Cardholder, err error)

func (*Card) GetChallenge

func (c *Card) GetChallenge(cnt int) ([]byte, error)

See: OpenPGP Smart Card Application - Section 7.2.15 GET CHALLENGE

func (*Card) GetSecuritySupportTemplate

func (c *Card) GetSecuritySupportTemplate() (sst SecuritySupportTemplate, err error)

func (*Card) ManageSecurityEnvironment

func (c *Card) ManageSecurityEnvironment(crt byte, slot Slot) error

See: OpenPGP Smart Card Application - Section 7.2.18 MANAGE SECURITY ENVIRONMENT

func (*Card) ResetRetryCounter

func (c *Card) ResetRetryCounter(pw string) error

See: OpenPGP Smart Card Application - Section 7.2.4 RESET RETRY COUNTER

func (*Card) ResetRetryCounterWithResetCode

func (c *Card) ResetRetryCounterWithResetCode(pw, rc string) error

See: OpenPGP Smart Card Application - Section 7.2.4 RESET RETRY COUNTER

func (*Card) Select

func (c *Card) Select() error

See: OpenPGP Smart Card Application - Section 7.2.1 SELECT

func (*Card) Sign

func (c *Card) Sign(_ []byte) ([]byte, error)

See: OpenPGP Smart Card Application - Section 7.2.10 PSO: COMPUTE DIGITAL SIGNATURE

func (*Card) VerifyPassword

func (c *Card) VerifyPassword(pwType byte, pw string) (err error)

See: OpenPGP Smart Card Application - Section 7.2.2 VERIFY

type Cardholder

type Cardholder struct {
	Name     string
	Language string
	Sex      Sex
}

func (*Cardholder) Decode

func (ch *Cardholder) Decode(b []byte) (err error)

type Error

type Error uint16

func (Error) Error

func (e Error) Error() string

type ExtendedCapabilities

type ExtendedCapabilities struct {
	SecureMessaging          bool
	GetChallenge             bool
	KeyImport                bool
	PasswordStatusChangeable bool
	PrivateDO                bool
	AlgAttrsChangeable       bool
	EncDecAES                bool
	KdfDO                    bool
	AlgSecureMessaging       byte
	MaxLenChallenge          uint16
	MaxLenCardholderCert     uint16
	MaxLenSpecialDO          uint16
	Pin2BlockFormat          byte
	CommandMSE               byte
}

func (*ExtendedCapabilities) Decode

func (ec *ExtendedCapabilities) Decode(b []byte) error

type ExtendedLengthInfo

type ExtendedLengthInfo struct {
	MaxCommandLength  uint16
	MaxResponseLength uint16
}

func (*ExtendedLengthInfo) Decode

func (li *ExtendedLengthInfo) Decode(b []byte) error

type Fingerprint

type Fingerprint [20]byte

type GeneralFeatures

type GeneralFeatures struct {
	Display     bool
	Bio         bool
	Button      bool
	KeyPad      bool
	LED         bool
	Speaker     bool
	Mic         bool
	Touchscreen bool
}

func (*GeneralFeatures) Decode

func (f *GeneralFeatures) Decode(b []byte) error

type HistoricalBytes

type HistoricalBytes struct {
	CategoryIndicator byte
	StatusIndicator   []byte

	Caps struct {
		CmdChaining       bool // Command chaining
		ExtLen            bool // Extended Lc and Le fields
		ExtLenInfoinEFATR bool // Extended Length Information in EF.ATR/INFO
		LogicalChanNum    bool
	}

	CardService struct {
		AppSelectionFullDF bool // Application Selection by full DF name (AID)
		AppSelectPartialDF bool // Application Selection by partial DF name
		EfDirDOsAvailable  bool // DOs available in EF.DIR

		MF bool // Card with MF
	}
}

func (*HistoricalBytes) Decode

func (h *HistoricalBytes) Decode(b []byte) (err error)

type KeyInfo

type KeyInfo struct {
	Reference      byte
	Status         byte
	AlgAttrs       AlgorithmAttributes
	Fingerprint    []byte
	FingerprintCA  []byte
	GenerationTime time.Time
	UIF            UserInteractionFlag
}

type PasswordStatus

type PasswordStatus struct {
	ValidityPW1 uint8

	LengthPW1 uint8
	LengthRC  uint8
	LengthPW3 uint8

	AttemptsPW1 uint8
	AttemptsRC  uint8
	AttemptsPW3 uint8
}

func (*PasswordStatus) Decode

func (ps *PasswordStatus) Decode(b []byte) error

type RID

type RID [5]byte

type SecuritySupportTemplate

type SecuritySupportTemplate struct {
	SignatureCounter [3]byte
	CardHolderCerts  [3][]byte
}

func (*SecuritySupportTemplate) Decode

func (sst *SecuritySupportTemplate) Decode(b []byte) (err error)

type Sex

type Sex byte
const (
	SexUnknown       Sex = '0'
	SexMale          Sex = '1'
	SexFemale        Sex = '2'
	SexNotApplicable Sex = '9'
)

func (Sex) String

func (s Sex) String() string

type Slot

type Slot byte
const (
	SlotSign Slot = iota
	SlotDecrypt
	SlotAuthn
	SlotAttest
)

type UserInteractionFlag

type UserInteractionFlag struct {
	Requirement byte
	Feature     byte
}

func (*UserInteractionFlag) Decode

func (uif *UserInteractionFlag) Decode(b []byte) error

Jump to

Keyboard shortcuts

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