FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
smartcard-interpreter.ApplicationPIV Class Reference
Inheritance diagram for smartcard-interpreter.ApplicationPIV:
Collaboration diagram for smartcard-interpreter.ApplicationPIV:

Public Member Functions

 __init__ (self, aid)
 
 getAID (self)
 
 selectResult (self, selectT, status, body)
 
 getData (self, fileId, bytes)
 
 getDataResult (self, status, body)
 
 getResponse (self, status, body)
 
 getResponseResult (self, status, body)
 
 mse (self, body)
 
 mseResult (self, status, body)
 
 pso (self, body)
 
 psoResult (self, status, body)
 
 verify (self, status, body)
 
 verifyResult (self, status, body)
 

Data Fields

 lastGet
 
 aid
 

Detailed Description

PIV application

Definition at line 225 of file smartcard-interpreter.py.

Constructor & Destructor Documentation

◆ __init__()

smartcard-interpreter.ApplicationPIV.__init__ (   self,
  aid 
)

Definition at line 228 of file smartcard-interpreter.py.

228 def __init__(self, aid):
229 self.lastGet = None
230 self.aid = aid
231

Member Function Documentation

◆ getAID()

smartcard-interpreter.ApplicationPIV.getAID (   self)

Definition at line 232 of file smartcard-interpreter.py.

232 def getAID(self):
233 return self.aid
234

◆ getData()

smartcard-interpreter.ApplicationPIV.getData (   self,
  fileId,
  bytes 
)

Definition at line 276 of file smartcard-interpreter.py.

276 def getData(self, fileId, bytes):
277 ret = "\tfileId=%s(%0.4x)\n" % (FIDs.get(fileId, ""), fileId)
278
279 if len(bytes) < 7:
280 return ret + "\t/!\\ too short !!!!"
281
282 lc = bytes[4]
283 tag = bytes[5]
284 tagLen = bytes[6]
285
286 if lc == 4:
287 ret += "\tdoId=%0.4x\n"% (bytes[7] * 256 + bytes[8])
288
289 elif lc == 0xa:
290 keyStr = ''
291 # TLV
292 i = 7
293 tag = bytes[i]
294 tagLen = bytes[i+1]
295 keyRef = bytes[i+3]
296 keyStr = "key(tag=0x%x len=%d ref=0x%x)=" % (tag, tagLen, keyRef)
297 i = i + 2 + tagLen
298
299 tag = bytes[i]
300 tagLen = bytes[i+1]
301 keyStr += "value(tag=0x%x len=%d)"
302 elif lc == 3:
303 ret += "\tDiscovery Object\n"
304 elif lc == 4:
305 ret += "\tBiometric Information Templates (BIT) Group Template\n"
306 elif lc == 5:
307 if tag == 0x5C:
308 tagStr = bytes[7:10].hex()
309 ret += '\ttag: %s(%s)\n' % (tagStr, PIV_OIDs.get(tagStr, '<unknown>'))
310 self.lastGet = tagStr
311 else:
312 ret += "\tunknown key access(lc=0x%x)\n" % lc
313
314 return ret
315

◆ getDataResult()

smartcard-interpreter.ApplicationPIV.getDataResult (   self,
  status,
  body 
)

Definition at line 316 of file smartcard-interpreter.py.

316 def getDataResult(self, status, body):
317 ret = ''
318 if not len(body):
319 return ''
320 appTag = body[0]
321 appLen = body[1]
322
323 body = body[2:2+appLen]
324 while len(body) > 2:
325 tag = body[0]
326 tagLen = body[1]
327 tagBody = body[2:2+tagLen]
328
329 if self.lastGet in ('5fc102',):
330 # Card holder Unique Identifier
331 if tag == 0x30:
332 ret += '\tFASC-N: %s\n' % tagBody.hex()
333 elif tag == 0x34:
334 ret += '\tGUID: %s\n' % tagBody.hex()
335 elif tag == 0x35:
336 ret += '\texpirationDate: %s\n' % tagBody.decode('utf8')
337 elif tag == 0x3e:
338 ret += '\tIssuer Asymmetric Signature: %s\n' % tagBody.hex()
339 else:
340 ret += "\tunknown tag=0x%x len=%d content=%s\n" % (tag, tagLen, tagBody.hex())
341
342 elif self.lastGet in ('5fc107',):
343 # Card Capability Container
344 capas = {
345 0xf0: "Card Identifier",
346 0xf1: "Capability Container version number",
347 0xf2: "Capability Grammar version number",
348 0xf3: "Applications CardURL",
349 0xf4: "PKCS#15",
350 0xf5: "Registered Data Model number",
351 0xf6: "Access Control Rule Table",
352 0xf7: "Card APDUs",
353 0xfa: "Redirection Tag",
354 0xfb: "Capability Tuples (CTs)",
355 0xfc: "Status Tuples (STs)",
356 0xfd: "Next CCC",
357 0xe3: "Extended Application CardURL",
358 0xb4: "Security Object Buffer",
359 0xfe: "Error Detection Code"
360 }
361
362 if tag in capas.keys():
363 if tagLen:
364 ret += "\t%s: len=%d %s\n" % (capas[tag], tagLen, tagBody.hex())
365 else:
366 ret += "\tunknown capa tag 0x%x: %s\n" % (tag, tagBody.hex())
367
368 elif self.lastGet == '5fc105':
369 # X.509 Certificate for PIV Authentication
370 pass
371
372 else:
373 ret += "\t%s: unimplemented tag=0x%x len=%d content=%s\n" % (self.lastGet, tag, tagLen, tagBody.hex())
374
375 body = body[2+tagLen:]
376
377 return ret
378

◆ getResponse()

smartcard-interpreter.ApplicationPIV.getResponse (   self,
  status,
  body 
)

Definition at line 379 of file smartcard-interpreter.py.

379 def getResponse(self, status, body):
380 return body.hex()
381

◆ getResponseResult()

smartcard-interpreter.ApplicationPIV.getResponseResult (   self,
  status,
  body 
)

Definition at line 382 of file smartcard-interpreter.py.

382 def getResponseResult(self, status, body):
383 return body.hex()
384

◆ mse()

smartcard-interpreter.ApplicationPIV.mse (   self,
  body 
)

Definition at line 385 of file smartcard-interpreter.py.

385 def mse(self, body):
386 return body.hex()
387

◆ mseResult()

smartcard-interpreter.ApplicationPIV.mseResult (   self,
  status,
  body 
)

Definition at line 388 of file smartcard-interpreter.py.

388 def mseResult(self, status, body):
389 return body.hex()
390

◆ pso()

smartcard-interpreter.ApplicationPIV.pso (   self,
  body 
)

Definition at line 391 of file smartcard-interpreter.py.

391 def pso(self, body):
392 return body.hex()
393

◆ psoResult()

smartcard-interpreter.ApplicationPIV.psoResult (   self,
  status,
  body 
)

Definition at line 394 of file smartcard-interpreter.py.

394 def psoResult(self, status, body):
395 return body.hex()
396

◆ selectResult()

smartcard-interpreter.ApplicationPIV.selectResult (   self,
  selectT,
  status,
  body 
)

Definition at line 235 of file smartcard-interpreter.py.

235 def selectResult(self, selectT, status, body):
236 ret = ''
237 appTag = body[0]
238 appLen = body[1]
239
240 body = body[2:2+appLen]
241 while len(body) > 2:
242 tag = body[0]
243 tagLen = body[1]
244 if tagLen != 1:
245 pass
246 if selectT == "FCI":
247 if tag == 0x4f:
248 ret += "\tpiv version: %s\n" % body[2:2 + tagLen].hex()
249 elif tag == 0x79:
250 subBody = body[2:2 + tagLen]
251
252 subTag = subBody[0]
253 subLen = subBody[1]
254
255 content = subBody.hex()
256 if subTag == 0x4f:
257 v = content[4:]
258 if v.startswith('a000000308'):
259 content = 'NIST RID'
260 ret += '\tCoexistent tag allocation authority: %s\n' % content
261
262 elif tag == 0x50:
263 ret += '\tapplication label: %s\n' % body[2:2+tagLen].decode('utf8')
264 elif tag == 0xac:
265 ret += '\tCryptographic algorithms supported: %s\n' % body[2:2+tagLen].hex()
266 else:
267 rety += '\tunknown tag 0x%x\n' % tag
268
269 else:
270 ret += "\tTODO: selectType %s\n" % selectT
271
272 body = body[2+tagLen:]
273
274 return ret
275

◆ verify()

smartcard-interpreter.ApplicationPIV.verify (   self,
  status,
  body 
)

Definition at line 397 of file smartcard-interpreter.py.

397 def verify(self, status, body):
398 return "verify(%s)" % body.hex()
399

◆ verifyResult()

smartcard-interpreter.ApplicationPIV.verifyResult (   self,
  status,
  body 
)

Definition at line 400 of file smartcard-interpreter.py.

400 def verifyResult(self, status, body):
401 return "verify(%s)" % body.hex()
402
403
404
405

Field Documentation

◆ aid

smartcard-interpreter.ApplicationPIV.aid

Definition at line 230 of file smartcard-interpreter.py.

◆ lastGet

smartcard-interpreter.ApplicationPIV.lastGet

Definition at line 229 of file smartcard-interpreter.py.


The documentation for this class was generated from the following file: