Skip to content

Commit cf0c9e6

Browse files
committed
Update documentation
This updates the documentation with the new features (writing PSKC files) as well as many editorial improvements, some rewording and a few typo fixes. Some things were moved around a little in order to be more easily readable and easier to find.
1 parent 671b6e2 commit cf0c9e6

File tree

8 files changed

+150
-87
lines changed

8 files changed

+150
-87
lines changed

README

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ types of crypto modules. The format is commonly used for one-time password
88
tokens or other authentication devices.
99

1010
The goal of this module is mainly to provide parsing of PSKC files in order
11-
to extract secret keys for use in an OTP authentication system. At a later
12-
time support for writing files may be added.
11+
to extract secret keys for use in an OTP authentication system.
1312

1413
http://arthurdejong.org/python-pskc/
1514

@@ -20,7 +19,7 @@ API
2019
The module provides a straightforward API that is mostly geared towards
2120
parsing existing PSKC files.
2221

23-
Extracting key matarial from PSKC files is as simple as.
22+
Extracting key matarial from encrypted PSKC files is as simple as.
2423

2524
>>> from pskc import PSKC
2625
>>> pskc = PSKC('tests/rfc6030-figure7.pskcxml')
@@ -45,7 +44,7 @@ private key material.
4544
Copyright
4645
---------
4746

48-
Copyright (C) 2014 Arthur de Jong
47+
Copyright (C) 2014-2015 Arthur de Jong
4948

5049
This library is free software; you can redistribute it and/or
5150
modify it under the terms of the GNU Lesser General Public

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# General information about the project.
4848
project = u'python-pskc'
49-
copyright = u'2014, Arthur de Jong'
49+
copyright = u'2014-2015 Arthur de Jong'
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the

docs/encryption.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,30 @@ pre-shared keys, passphrase-based keys or asymmetric keys (asymmetric keys
88
are currently unimplemented).
99

1010
Embedded PSKC encryption is handled inside the :class:`Encryption` class that
11-
defines encryption key and means of deriving keys. It is accessed from the
11+
defines encryption key or means of deriving keys. It is accessed from the
1212
:attr:`~pskc.PSKC.encryption` attribute of a :class:`~pskc.PSKC` instance::
1313

14+
>>> rom binascii import a2b_hex
1415
>>> from pskc import PSKC
1516
>>> pskc = PSKC('somefile.pskcxml')
16-
>>> pskc.encryption.key = '12345678901234567890123456789012'.decode('hex')
17+
>>> pskc.encryption.key = a2b_hex('12345678901234567890123456789012')
1718

1819
or::
1920

2021
>>> pskc.encryption.derive_key('qwerty')
2122

22-
Once the encryption key has been set up any encrypted key values from the
23+
Once the encryption key has been set up, any encrypted key values from the
2324
PSKC file are available transparently.
2425

25-
If an incorrect key has been set up, only upon accessing encrypted
26+
If an incorrect key has been set up, upon accessing encrypted
2627
information (e.g. the :attr:`~pskc.key.Key.secret` attribute of a
2728
:class:`~pskc.key.Key` instance) a :exc:`~pskc.exceptions.DecryptionError`
2829
exception will be raised.
2930

3031

32+
The Encryption class
33+
--------------------
34+
3135
.. class:: Encryption
3236

3337
.. attribute:: id

docs/exceptions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Exceptions
2222
2323
.. exception:: DecryptionError
2424

25-
Raised when decrypting the embedded encrypted value fails due to missing
26-
or incorrect key, unsupported decryption or MAC algorithm, failed message
27-
authentication check or other error.
25+
Raised when decrypting a value fails due to missing or incorrect key,
26+
unsupported decryption or MAC algorithm, failed message authentication
27+
check or other error.
2828

2929
This exception is generally raised when accessing encrypted information
3030
(i.e. the :attr:`~pskc.key.Key.secret`, :attr:`~pskc.key.Key.counter`,

docs/mac.rst

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ The PSKC format allows for `message authentication and integrity checking
77
<https://tools.ietf.org/html/rfc6030#section-6.1.1>`_ for some of the values
88
stored within the PSKC file.
99

10+
Integrity checking is done transparently when accessing attributes that
11+
are encrypted and contain a ValueMAC.
12+
13+
Once the PSKC encryption key has been set up, key values can be explicitly
14+
checked using the :func:`~pskc.key.Key.check` method::
15+
16+
>>> pskc = PSKC('somefile.pskcxml')
17+
>>> pskc.encryption.derive_key('qwerty')
18+
>>> pskc.mac.algorithm
19+
'http://www.w3.org/2000/09/xmldsig#hmac-sha1'
20+
>>> all(key.check() for key in pskc.keys)
21+
True
22+
23+
24+
The MAC class
25+
-------------
26+
1027
.. class:: MAC
1128

1229
.. attribute:: algorithm
@@ -21,14 +38,3 @@ stored within the PSKC file.
2138
MAC key is generated specifically for each PSKC file and encrypted with
2239
the PSKC encryption key, so the PSKC file should be decrypted first
2340
(see :doc:`encryption`).
24-
25-
26-
Once the PSKC encryption key has been set up key values can be explicitly
27-
checked using the :func:`~pskc.key.Key.check` method::
28-
29-
>>> pskc = PSKC('somefile.pskcxml')
30-
>>> pskc.encryption.derive_key('qwerty')
31-
>>> pskc.mac.algorithm
32-
'http://www.w3.org/2000/09/xmldsig#hmac-sha1'
33-
>>> all(key.check() for key in pskc.keys)
34-
True

docs/policy.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Key usage policy
33

44
.. module:: pskc.policy
55

6-
The PSKC format allows for specifying `key and pin usage policy <https://tools.ietf.org/html/rfc6030#section-5>`__.
6+
The PSKC format allows for specifying `key and pin usage policy <https://tools.ietf.org/html/rfc6030#section-5>`__
7+
per key.
78

89
Instances of the :class:`Policy` class provide attributes that describe
910
limits that are placed on key usage and requirements for key PIN protection::
@@ -13,6 +14,9 @@ limits that are placed on key usage and requirements for key PIN protection::
1314
True
1415

1516

17+
The Policy class
18+
----------------
19+
1620
.. class:: Policy
1721

1822
.. attribute:: start_date
@@ -38,13 +42,12 @@ limits that are placed on key usage and requirements for key PIN protection::
3842
A list of `valid usage scenarios
3943
<https://www.iana.org/assignments/pskc/#key-usage>`__ for the
4044
key that the recipient should check against the intended usage of the
41-
key. Also see :func:`may_use` and :ref:`the list of key usage constants
42-
below <key-use-constants>`.
45+
key. Also see :func:`may_use` and :ref:`key-use-constants` below.
4346

4447
.. attribute:: pin_key_id
4548

46-
The unique `id` value used to reference the key within the PSKC file
47-
that contains the value of the PIN that protects this key.
49+
The unique `id` of the key within the PSKC file that contains the value
50+
of the PIN that protects this key.
4851

4952
.. attribute:: pin_key
5053

@@ -58,8 +61,8 @@ limits that are placed on key usage and requirements for key PIN protection::
5861

5962
.. attribute:: pin_usage
6063

61-
Describe how the PIN is used during the usage of the key. See :ref:`the
62-
list of pin usage constants below <pin-use-constants>`.
64+
Describe how the PIN is used during the usage of the key. See
65+
:ref:`pin-use-constants` below.
6366

6467
.. attribute:: pin_max_failed_attemtps
6568

@@ -92,10 +95,14 @@ limits that are placed on key usage and requirements for key PIN protection::
9295
.. function:: may_use(usage)
9396

9497
Check whether the key may be used for the provided purpose. See
95-
:ref:`the list of key usage constants below <key-use-constants>`.
98+
:ref:`key-use-constants` below.
99+
96100

97101
.. _key-use-constants:
98102

103+
Key usage constants
104+
-------------------
105+
99106
The :class:`Policy` class provides the following key use constants (see
100107
:attr:`~Policy.key_usage` and :func:`~Policy.may_use`):
101108

@@ -149,8 +156,12 @@ The :class:`Policy` class provides the following key use constants (see
149156
The key is used to generate a new key based on a random number and the
150157
previous value of the key.
151158

159+
152160
.. _pin-use-constants:
153161

162+
Pin usage constants
163+
-------------------
164+
154165
The following constants for PIN use are defined in the :class:`Policy`
155166
class (see :attr:`~Policy.pin_usage`):
156167

0 commit comments

Comments
 (0)