@@ -71,7 +71,7 @@ func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSes
7171
7272 cardPublic , ok := gen .Unmarshal (keyData )
7373 if ! ok {
74- return nil , fmt .Errorf ("Could not unmarshal public key from card" )
74+ return nil , fmt .Errorf ("could not unmarshal public key from card" )
7575 }
7676
7777 secret , err := gen .GenerateSharedSecret (private , cardPublic )
@@ -109,7 +109,7 @@ func (s *SecureChannelSession) Pair(pairingPassword []byte) error {
109109 cardChallenge := response .Data [32 :64 ]
110110
111111 if ! bytes .Equal (expectedCryptogram , cardCryptogram ) {
112- return fmt .Errorf ("Invalid card cryptogram %v != %v" , expectedCryptogram , cardCryptogram )
112+ return fmt .Errorf ("invalid card cryptogram %v != %v" , expectedCryptogram , cardCryptogram )
113113 }
114114
115115 md .Reset ()
@@ -132,7 +132,7 @@ func (s *SecureChannelSession) Pair(pairingPassword []byte) error {
132132// Unpair disestablishes an existing pairing.
133133func (s * SecureChannelSession ) Unpair () error {
134134 if s .PairingKey == nil {
135- return fmt .Errorf ("Cannot unpair: not paired" )
135+ return fmt .Errorf ("cannot unpair: not paired" )
136136 }
137137
138138 _ , err := s .transmitEncrypted (claSCWallet , insUnpair , s .PairingIndex , 0 , []byte {})
@@ -148,7 +148,7 @@ func (s *SecureChannelSession) Unpair() error {
148148// Open initializes the secure channel.
149149func (s * SecureChannelSession ) Open () error {
150150 if s .iv != nil {
151- return fmt .Errorf ("Session already opened" )
151+ return fmt .Errorf ("session already opened" )
152152 }
153153
154154 response , err := s .open ()
@@ -185,11 +185,11 @@ func (s *SecureChannelSession) mutuallyAuthenticate() error {
185185 return err
186186 }
187187 if response .Sw1 != 0x90 || response .Sw2 != 0x00 {
188- return fmt .Errorf ("Got unexpected response from MUTUALLY_AUTHENTICATE: 0x%x%x" , response .Sw1 , response .Sw2 )
188+ return fmt .Errorf ("got unexpected response from MUTUALLY_AUTHENTICATE: 0x%x%x" , response .Sw1 , response .Sw2 )
189189 }
190190
191191 if len (response .Data ) != scSecretLength {
192- return fmt .Errorf ("Response from MUTUALLY_AUTHENTICATE was %d bytes, expected %d" , len (response .Data ), scSecretLength )
192+ return fmt .Errorf ("response from MUTUALLY_AUTHENTICATE was %d bytes, expected %d" , len (response .Data ), scSecretLength )
193193 }
194194
195195 return nil
@@ -222,7 +222,7 @@ func (s *SecureChannelSession) pair(p1 uint8, data []byte) (*responseAPDU, error
222222// transmitEncrypted sends an encrypted message, and decrypts and returns the response.
223223func (s * SecureChannelSession ) transmitEncrypted (cla , ins , p1 , p2 byte , data []byte ) (* responseAPDU , error ) {
224224 if s .iv == nil {
225- return nil , fmt .Errorf ("Channel not open" )
225+ return nil , fmt .Errorf ("channel not open" )
226226 }
227227
228228 data , err := s .encryptAPDU (data )
@@ -261,14 +261,14 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
261261 return nil , err
262262 }
263263 if ! bytes .Equal (s .iv , rmac ) {
264- return nil , fmt .Errorf ("Invalid MAC in response" )
264+ return nil , fmt .Errorf ("invalid MAC in response" )
265265 }
266266
267267 rapdu := & responseAPDU {}
268268 rapdu .deserialize (plainData )
269269
270270 if rapdu .Sw1 != sw1Ok {
271- return nil , fmt .Errorf ("Unexpected response status Cla=0x%x, Ins=0x%x, Sw=0x%x%x" , cla , ins , rapdu .Sw1 , rapdu .Sw2 )
271+ return nil , fmt .Errorf ("unexpected response status Cla=0x%x, Ins=0x%x, Sw=0x%x%x" , cla , ins , rapdu .Sw1 , rapdu .Sw2 )
272272 }
273273
274274 return rapdu , nil
@@ -277,7 +277,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
277277// encryptAPDU is an internal method that serializes and encrypts an APDU.
278278func (s * SecureChannelSession ) encryptAPDU (data []byte ) ([]byte , error ) {
279279 if len (data ) > maxPayloadSize {
280- return nil , fmt .Errorf ("Payload of %d bytes exceeds maximum of %d" , len (data ), maxPayloadSize )
280+ return nil , fmt .Errorf ("payload of %d bytes exceeds maximum of %d" , len (data ), maxPayloadSize )
281281 }
282282 data = pad (data , 0x80 )
283283
@@ -323,10 +323,10 @@ func unpad(data []byte, terminator byte) ([]byte, error) {
323323 case terminator :
324324 return data [:len (data )- i ], nil
325325 default :
326- return nil , fmt .Errorf ("Expected end of padding, got %d" , data [len (data )- i ])
326+ return nil , fmt .Errorf ("expected end of padding, got %d" , data [len (data )- i ])
327327 }
328328 }
329- return nil , fmt .Errorf ("Expected end of padding, got 0" )
329+ return nil , fmt .Errorf ("expected end of padding, got 0" )
330330}
331331
332332// updateIV is an internal method that updates the initialization vector after
0 commit comments