Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_actividentity.doctest
blob: 734b028de28778b2a68c7cbe062462116bb5ae52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
test_actividentity.doctest - tests for ActivIdentity PSKC files

Copyright (C) 2017 Arthur de Jong

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA


>>> from binascii import a2b_hex, b2a_hex
>>> def tostr(x):
...     return str(x.decode())
>>> def decode(f):
...     return lambda x: tostr(f(x))
>>> b2a_hex = decode(b2a_hex)

>>> from pskc import PSKC


This tests an ActivIdentity PSKC file that was found in the wild. It does not
follow the RFC 6030 spec but is handled nonetheless.

>>> pskc = PSKC('tests/actividentity/test.pskc')
>>> pskc.encryption.algorithm
'http://www.w3.org/2001/04/xmlenc#aes128-cbc'
>>> b2a_hex(pskc.encryption.iv)
'5eeb3496c73eac92e2d2773f00d1345e'
>>> pskc.encryption.key = a2b_hex('fe0de6b806c09b762c4b49a666a27b72')
>>> pskc.mac.algorithm
'http://www.w3.org/2000/09/xmldsig#hmac-sha1'
>>> key = pskc.keys[0]
>>> key.manufacturer
'ActivIdentity'
>>> key.serial
'0950380269'
>>> key.algorithm
'http://www.ietf.org/keyprov/pskc#hotp'
>>> key.id
'0950380269'
>>> key.issuer
'ActivIdentity'
>>> key.policy.key_usage
['OTP']
>>> key.response_encoding
'DECIMAL'
>>> key.response_length
8
>>> b2a_hex(key.secret)
'dce70c2a0c1f5806f316ca8d09456eb4765ad053'
>>> key.counter
837830147