lpa

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GSMAISDRApplicationAID = []byte{0xA0, 0x00, 0x00, 0x05, 0x59, 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x89, 0x00, 0x00, 0x01, 0x00}

GSMAISDRApplicationAID is the AID of the GSMA SGP.02 ISD-R application. See https://www.gsma.com/solutions-and-impact/technologies/esim/wp-content/uploads/2020/07/SGP.02-v4.2.pdf#page=26 (Section 2.2.3 Identification of Security Domains: AID and TAR)

Functions

This section is empty.

Types

type ActivationCode

type ActivationCode struct {
	SMDP             *url.URL
	MatchingID       string
	IMEI             string
	OID              string
	ConfirmationCode string
}

type Client

type Client struct {
	HTTP *http.Client
	APDU sgp22.Transmitter
	// contains filtered or unexported fields
}

Client is the main structure for the LPA client.

func New added in v0.0.10

func New(opt *Option) (*Client, error)

New creates a new LPA client with the given options.

func (*Client) AuthenticateClient

func (c *Client) AuthenticateClient(address *url.URL, request *sgp22.AuthenticateServerRequest) (*sgp22.ES9AuthenticateClientResponse, error)

AuthenticateClient authenticates the client to the eUICC.

See https://aka.pw/sgp22/v2.5#page=195 (Section 5.7.13, ES10b.AuthenticateClient)

func (*Client) Close added in v0.0.10

func (c *Client) Close() error

Close closes the LPA client and the underlying APDU transmitter. You should call this method when you are done using the client to release resources.

func (*Client) DeleteProfile

func (c *Client) DeleteProfile(identifier any) error

DeleteProfile deletes a profile. The profile is identified by the ICCID or ISD-P AID.

ProfileInfo Identifier: - sgp22.ICCID: The ICCID of the profile. - sgp22.ISDPAID: The ISD-P AID of the profile.

See https://aka.pw/sgp22/v2.5#page=206 (Section 5.7.18, ES10c.DeleteProfile)

func (*Client) DisableProfile

func (c *Client) DisableProfile(identifier any, refresh bool) error

DisableProfile disables a profile. The profile is identified by the ICCID or ISD-P AID.

ProfileInfo Identifier: - sgp22.ICCID: The ICCID of the profile. - sgp22.ISDPAID: The ISD-P AID of the profile.

See https://aka.pw/sgp22/v2.5#page=204 (Section 5.7.17, ES10c.DisableProfile)

func (*Client) Discovery

func (c *Client) Discovery(address *url.URL, IMEI []byte) ([]*sgp22.EventEntry, error)

Discovery discovers the downloadable profiles from SM-DS.

See https://aka.pw/sgp22/v2.5#page=212 (Section 5.8.2, ES11.AuthenticateClient)

func (*Client) DownloadProfile

func (*Client) EID

func (c *Client) EID() ([]byte, error)

EID returns the EID of the eUICC. The EID is a unique identifier of the eUICC.

See https://aka.pw/sgp22/v2.5#page=209 (Section 5.7.20, ES10c.GetEID)

func (*Client) EUICCChallenge

func (c *Client) EUICCChallenge() ([]byte, error)

func (*Client) EUICCConfiguredAddresses

func (c *Client) EUICCConfiguredAddresses() (*EUICCConfiguredAddresses, error)

EUICCConfiguredAddresses returns the default SM-DP+ address and the root SM-DS address.

See https://aka.pw/sgp22/v2.5#page=183 (Section 5.7.3, ES10a.GetEuiccConfiguredAddresses)

func (*Client) EUICCInfo1

func (c *Client) EUICCInfo1() (*bertlv.TLV, error)

EUICCInfo1 retrieves the eUICC information (version 1).

See https://aka.pw/sgp22/v2.5#page=187 (Section 5.7.8, ES10b.GetEUICCInfo)

func (*Client) EUICCInfo2

func (c *Client) EUICCInfo2() (*bertlv.TLV, error)

EUICCInfo2 retrieves the eUICC information (version 2).

See https://aka.pw/sgp22/v2.5#page=187 (Section 5.7.8, ES10b.GetEUICCInfo)

func (*Client) EnableProfile

func (c *Client) EnableProfile(identifier any, refresh bool) error

EnableProfile enables a profile. The profile is identified by the ICCID or ISD-P AID.

ProfileInfo Identifier: - sgp22.ICCID: The ICCID of the profile. - sgp22.ISDPAID: The ISD-P AID of the profile.

See https://aka.pw/sgp22/v2.5#page=201 (Section 5.7.16, ES10c.EnableProfile)

func (*Client) HandleNotification

func (c *Client) HandleNotification(pendingNotification *sgp22.PendingNotification) error

HandleNotification handles the pending notification.

See https://aka.pw/sgp22/v2.5#page=177 (Section 5.6.4, ES9p.HandleNotification)

func (*Client) InitiateAuthentication

func (c *Client) InitiateAuthentication(address *url.URL) (*sgp22.ES9InitiateAuthenticationResponse, error)

InitiateAuthentication initiates the authentication process.

See https://aka.pw/sgp22/v2.5#page=170 (Section 5.6.1, ES9p.InitiateAuthentication)

func (*Client) ListNotification

func (c *Client) ListNotification(filters ...sgp22.NotificationEvent) ([]*sgp22.NotificationMetadata, error)

ListNotification retrieves a list of notifications from the eUICC.

See https://aka.pw/sgp22/v2.5#page=191 (Section 5.7.9, ES10b.ListNotification)

func (*Client) ListProfile

func (c *Client) ListProfile(searchCriteria any, tags []bertlv.Tag) ([]*sgp22.ProfileInfo, error)

ListProfile returns a list of profiles that match the search criteria. If the search criteria is empty, all profiles are returned. The tags specify which additional data objects should be returned for each profile.

Search Criteria: - sgp22.ICCID: The ICCID of the profile. - sgp22.ISDPAID: The ISD-P AID of the profile. - sgp22.ProfileClass: The profile class of the profile.

See https://aka.pw/sgp22/v2.5#page=199 (Section 5.7.15, ES10c.GetProfilesInfo)

func (*Client) MemoryReset

func (c *Client) MemoryReset() error

MemoryReset resets the eUICC memory. This operation deletes all operational profiles, field-loaded test profiles, and resets the default SM-DP+ address.

See https://aka.pw/sgp22/v2.5#page=207 (Section 5.7.19, ES10c.eUICCMemoryReset)

func (*Client) PrepareDownload

func (c *Client) PrepareDownload(address *url.URL, request *sgp22.PrepareDownloadRequest) (*sgp22.ES9BoundProfilePackageResponse, error)

PrepareDownload prepares the eUICC for a profile download.

See https://aka.pw/sgp22/v2.5#page=184 (Section 5.7.13, ES10b.PrepareDownload)

func (*Client) RemoveNotificationFromList

func (c *Client) RemoveNotificationFromList(sequenceNumber sgp22.SequenceNumber) error

func (*Client) RetrieveNotificationList

func (c *Client) RetrieveNotificationList(searchCriteria any) ([]*sgp22.PendingNotification, error)

RetrieveNotificationList retrieves a list of notifications from the eUICC.

Search Criteria: - sgp22.SequenceNumber: The sequence number of the notification. - sgp22.NotificationEvent: The event type of the notification.

func (*Client) SetDefaultDPAddress

func (c *Client) SetDefaultDPAddress(address string) error

SetDefaultDPAddress sets the default SM-DP+ address.

See https://aka.pw/sgp22/v2.5#page=183 (Section 5.7.4, ES10a.SetDefaultDpAddress)

func (*Client) SetNickname

func (c *Client) SetNickname(iccid sgp22.ICCID, nickname string) error

SetNickname sets the nickname of the profile.

See https://aka.pw/sgp22/v2.5#page=209 (Section 5.7.21, ES10c.SetNickname)

type DownloadHandler

type DownloadHandler interface {
	Progress(process DownloadProgress)
	Confirm(metadata *sgp22.ProfileInfo) chan bool
	ConfirmationCode() chan string
}

type DownloadProgress

type DownloadProgress uint8
const (
	DownloadProgressAuthenticateClient DownloadProgress = iota
	DownloadProgressAuthenticateServer
	DownloadProgressLoadBPP
)

type EUICCConfiguredAddresses

type EUICCConfiguredAddresses struct {
	DefaultSMDPAddress string
	RootSMDSAddress    string
}

type Option added in v0.0.10

type Option struct {
	// Channel is the channel for APDU communication. It is required for APDU communication.
	Channel apdu.SmartCardChannel
	// AID is the application identifier for the GSMA ISD-R application. It defaults to GSMA ISD-R Application AID.
	AID []byte
	// MSS is the maximum APDU size. It defaults to 240.
	MSS int
	// AdminProtocolVersion is the version of the admin protocol. It defaults to "v2.2.0".
	AdminProtocolVersion string
	// Logger is the logger for the LPA client. It defaults to slog.Default().
	Logger *slog.Logger
	// Timeout is the timeout for the HTTP client. It defaults to 30 seconds.
	Timeout time.Duration
}

Option is the configuration for the LPA client. It includes the channel for APDU communication, logger, AID, maximum APDU size (MSS), admin protocol version, and timeout.

func (*Option) Validate added in v0.0.10

func (opt *Option) Validate() error

Jump to

Keyboard shortcuts

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