~ubuntu-branches/ubuntu/wily/python-pskc/wily

« back to all changes in this revision

Viewing changes to tests/test_draft_keyprov.doctest

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2014-06-20 14:50:59 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140620145059-cf3iwj9rnwagig43
Tags: 0.2-1
* New upstream release:
  - raise exceptions on parsing, decryption and other problems
  - support more encryption algorithms (AES128-CBC, AES192-CBC, AES256-CBC,
    TripleDES-CBC, KW-AES128, KW-AES192, KW-AES256 and KW-TripleDES) and be
    more lenient in accepting algorithm URIs
  - support all HMAC algorithms that Python's hashlib module has hash
    functions for (HMAC-MD5, HMAC-SHA1, HMAC-SHA224, HMAC-SHA256,
    HMAC-SHA384 and HMAC-SHA512)
  - support PRF attribute of PBKDF2 algorithm
* Build and install Sphinx documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
test_draft_keyprov.doctest - test for examples from
 
2
                             draft-hoyer-keyprov-pskc-algorithm-profiles-01
 
3
 
 
4
Copyright (C) 2014 Arthur de Jong
 
5
 
 
6
This library is free software; you can redistribute it and/or
 
7
modify it under the terms of the GNU Lesser General Public
 
8
License as published by the Free Software Foundation; either
 
9
version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
This library is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
Lesser General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU Lesser General Public
 
17
License along with this library; if not, write to the Free Software
 
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
02110-1301 USA
 
20
 
 
21
 
 
22
>>> from pskc import PSKC
 
23
 
 
24
 
 
25
This tests an OCRA (OATH Challenge Response Algorithm) key contained within
 
26
a PSKC file as described in section 3 of
 
27
draft-hoyer-keyprov-pskc-algorithm-profiles-01.
 
28
 
 
29
>>> pskc = PSKC('tests/draft-keyprov-ocra.pskcxml')
 
30
>>> pskc.version
 
31
'1.0'
 
32
>>> key = pskc.keys[0]
 
33
>>> key.manufacturer
 
34
'TokenVendorAcme'
 
35
>>> key.serial
 
36
'987654322'
 
37
>>> key.id
 
38
'12345678'
 
39
>>> key.algorithm
 
40
'urn:ietf:params:xml:ns:keyprov:pskc#OCRA-1:HOTP-SHA512-8:C-QN08'
 
41
>>> key.issuer
 
42
'Issuer'
 
43
>>> key.challenge_encoding
 
44
'DECIMAL'
 
45
>>> key.challenge_min_length
 
46
8
 
47
>>> key.challenge_max_length
 
48
8
 
49
>>> key.response_encoding
 
50
'DECIMAL'
 
51
>>> key.response_length
 
52
8
 
53
>>> key.secret
 
54
'12345678901234567890'
 
55
>>> key.counter
 
56
0
 
57
>>> key.policy.key_usage
 
58
['CR']
 
59
 
 
60
 
 
61
This tests an TOTP (OATH Time based OTP) key contained within a PSKC file as
 
62
described in section 4 of draft-hoyer-keyprov-pskc-algorithm-profiles-01.
 
63
 
 
64
>>> pskc = PSKC('tests/draft-keyprov-totp.pskcxml')
 
65
>>> pskc.version
 
66
'1.0'
 
67
>>> key = pskc.keys[0]
 
68
>>> key.manufacturer
 
69
'TokenVendorAcme'
 
70
>>> key.serial
 
71
'987654323'
 
72
>>> key.id
 
73
'987654323'
 
74
>>> key.algorithm
 
75
'urn:ietf:params:xml:ns:keyprov:pskc#totp'
 
76
>>> key.issuer
 
77
'Issuer'
 
78
>>> key.response_encoding
 
79
'DECIMAL'
 
80
>>> key.response_length
 
81
6
 
82
>>> key.secret
 
83
'12345678901234567890'
 
84
>>> key.time_offset
 
85
0
 
86
>>> key.time_interval
 
87
30
 
88
>>> key.time_drift
 
89
4
 
90
>>> key.policy.key_usage
 
91
['OTP']
 
92
 
 
93
 
 
94
This tests an SecurID-AES-Counter key contained within a PSKC file as
 
95
described in section 6 of draft-hoyer-keyprov-pskc-algorithm-profiles-01.
 
96
 
 
97
>>> pskc = PSKC('tests/draft-keyprov-securid-aes-counter.pskcxml')
 
98
>>> pskc.version
 
99
'1.0'
 
100
>>> key = pskc.keys[0]
 
101
>>> key.manufacturer
 
102
'RSA, The Security Division of EMC'
 
103
>>> key.serial
 
104
'123456798'
 
105
>>> key.id
 
106
'23456789'
 
107
>>> key.algorithm
 
108
'http://www.rsa.com/names/2008/04/algorithms/SecurID/SecurID-AES128-Counter'
 
109
>>> key.issuer
 
110
'Issuer'
 
111
>>> key.response_encoding
 
112
'DECIMAL'
 
113
>>> key.response_length
 
114
6
 
115
>>> key.secret
 
116
'12345678901234567890'
 
117
>>> key.counter
 
118
0
 
119
>>> key.policy.key_usage
 
120
['OTP']
 
121
>>> key.policy.start_date
 
122
datetime.datetime(2006, 4, 14, 0, 0, tzinfo=tzutc())
 
123
>>> key.policy.expiry_date
 
124
datetime.datetime(2010, 9, 30, 0, 0, tzinfo=tzutc())
 
125
 
 
126
 
 
127
This tests an ActivIdentity-3DES key contained within a PSKC file as
 
128
described in section 8 of draft-hoyer-keyprov-pskc-algorithm-profiles-01.
 
129
 
 
130
>>> pskc = PSKC('tests/draft-keyprov-actividentity-3des.pskcxml')
 
131
>>> pskc.version
 
132
'1.0'
 
133
>>> key = pskc.keys[0]
 
134
>>> key.manufacturer
 
135
'ActivIdentity'
 
136
>>> key.serial
 
137
'34567890'
 
138
>>> key.id
 
139
'12345677'
 
140
>>> key.algorithm
 
141
'http://www.actividentity.com/2008/04/algorithms/algorithms#ActivIdentity-3DES'
 
142
>>> key.issuer
 
143
'Issuer'
 
144
>>> key.response_encoding
 
145
'DECIMAL'
 
146
>>> key.response_length
 
147
8
 
148
>>> key.secret
 
149
'12345678901234567890'
 
150
>>> key.counter
 
151
0
 
152
>>> key.time_offset
 
153
0
 
154
>>> key.time_interval
 
155
32
 
156
>>> key.time_drift
 
157
0
 
158
>>> key.policy.key_usage
 
159
['OTP']