applecrypto

package module
v0.0.0-...-202802a Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2016 License: MIT Imports: 14 Imported by: 0

README

AppleCrypto: library for working with ApplePay

AppleCrypto is a simple library for decrypting ApplePay tokens using elliptic cryptography as described by Apple written in GO.

Library provides only methods for decrypting and encrypting token as well as datatypes neccesery for working with Apple Paymnet Token.

Implementation seems to be a little bit naive and you probably shouldn't be using it in prodcution

Basic Usage

First initialise Token with Apple's paymentData. Token type is responsible for cryptographic operations

t, err := applecrypto.MakeToken(token)

Error is thrown if provided token is not base64 encoded or cannot be unmarshaled in Token struct

Then simply call t.Decrypt() and pass it path to file which contains certificate with private key and its password.

Decrypt implements steps 3-4 in Apple reference documentation

Library provides Card type for Unmarshalling decrypted data into.

Author: Nikita Evdokimov

Documentation

Overview

Package applecrypto provides necseessray tools for working with ApplePay tokens

Package applecrypto provides necseessray tools for working with ApplePay tokens

Package applecrypto provides necseessray tools for working with ApplePay tokens

Package applecrypto provides necseessray tools for working with ApplePay tokens

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	AccountNumber string            `json:"applicationPrimaryAccountNumber"`
	ExpDate       string            `json:"applicationExpirationDate"` //Card expiration date in the format YYMMDD.
	Currency      string            `json:"currencyCode"`
	Amount        int               `json:"transactionAmount"`
	CardHolder    string            `json:"cardholderName"`
	DeviceManID   string            `json:"deviceManufacturerIdentifier"` //hex encoded
	PayDataType   string            `json:"paymentDataType"`              //Either 3DSecure or EMV.
	PayData       map[string]string `json:"paymentData"`
}

Card represents Payment Data Keys as described by apple

type Token

type Token struct {
	Header    headerToken
	Version   string
	Data      string
	Signature string
}

Token represents base64 decoded ApplePay string

func MakeToken

func MakeToken(token string) (Token, error)

MakeToken creates applePay token instance

func (Token) Decrypt

func (at Token) Decrypt(filename, password string) ([]byte, error)

Decrypt tries do decrypt ApplePay Data field with provided certificate. Assumes certificate and privatekey are in the same file. Return decrypted data

func (Token) Encrypt

func (at Token) Encrypt(filename, password string, in []byte) (string, string, error)

Encrypt encrypts data using provided cerificate. Returns base 64 encrypted data and ephemeral public key

Jump to

Keyboard shortcuts

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