cap

package module
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 6 Imported by: 0

README

cap

Golang implementation of parsing Java Card converted applets (CAP)

Documentation

Overview

Package cap implements the parsing of Java Card converted applets (CAP) and providing them in an installable format.

Index

Constants

View Source
const (
	ComponentHeader            = 1  // ComponentHeader is the tag of the Header component.
	ComponentDirectory         = 2  // ComponentDirectory is the tag of the Directory component.
	ComponentApplet            = 3  // ComponentApplet is the tag of the Applet component.
	ComponentImport            = 4  // ComponentImport is the tag of the Import component.
	ComponentConstantPool      = 5  // ComponentConstantPool is the tag of the ConstantPool component.
	ComponentClass             = 6  // ComponentClass is the tag of the Class component.
	ComponentMethod            = 7  // ComponentMethod is the tag of the Method component.
	ComponentStaticField       = 8  // ComponentStaticField is the tag of the StaticField component.
	ComponentReferenceLocation = 9  // ComponentReferenceLocation is the tag of the ReferenceLocation component.
	ComponentExport            = 10 // ComponentExport is the tag of the Export component.
	ComponentDescriptor        = 11 // ComponentDescriptor is the tag of the Descriptor component.
	ComponentDebug             = 12 // ComponentDebug is the tag of the Debug component.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CAP

type CAP struct {
	Header           Header     // Header is the representation of the Header component.
	Imports          []Package  // Imports is a list of imported packages contained in the the Import component.
	Applets          [][]byte   // Applets is a list of AIDs of applets that are contained in the Applet component.
	JavaCardVersion  MMPVersion // JavaCardVersion is the targeted JavaCard Version of the CAP.
	GPCardAPIVersion *MMVersion // Optional imported GlobalPlatform Card API Version.
	// contains filtered or unexported fields
}

CAP is a Converted Applet that contains a package with optional applets that can be loaded onto a JavaCard.

func Parse

func Parse(reader *zip.Reader) (*CAP, error)

Parse takes a pointer to zip.Reader for a '.cap' file, reads its contents and parses its cap components and returns a CAP.

func (*CAP) LoadBytes

func (cap *CAP) LoadBytes(includeDescriptor bool) []byte

LoadBytes returns the loadable form of a CAP file. It encodes the contained components (tag, size, info) as bytes and returns the appended results.

type Component

type Component struct {
	Tag  uint8  // Tag indicates the kind of component.
	Size uint16 // Size indicates the number of bytes in the info field of the component, not including tag and size.
	Info []byte // Info and its contents vary with the type of component.
}

Component is the general format of a CAP file component.

func (*Component) Bytes

func (c *Component) Bytes() []byte

Bytes encodes a Component as TLV encoded bytes.

type Header struct {
	// The minor_version and major_version items are the minor and major version numbers of this CAP file.
	CapFileVersion MMVersion
	// Indicates if the Java int type is used in this package.
	UsesInteger bool
	// Indicates if a CAP file contains an Export Component.
	ContainsExport bool
	// Indicates if a CAP file contains an Applet Component.
	ContainsApplet bool
	// Package describes the package defined in this CAP file.
	Package Package
	// Optional name of the package defined in this CAP file.
	PackageName string
}

The Header Component contains general information about this CAP file and the package it defines.

type MMPVersion

type MMPVersion struct {
	Major uint8
	Minor uint8
	Patch uint8
}

MMPVersion is a version that consists of a major, minor and version number.

type MMVersion

type MMVersion struct {
	Major uint8
	Minor uint8
}

MMVersion is a version that consists of a major and minor version number.

type Package

type Package struct {
	// The minor_version and major_version items are the minor and major version numbers of this package.
	// These values uniquely identify the particular implementation of this package and indicate the binary
	//compatibility between packages.
	Version MMVersion
	// The AID represents the Java Card platform name of the package.
	AID []byte
}

Package is a JavaCard package identified by an AID with a version.

Jump to

Keyboard shortcuts

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