Preferable way is to :ref:`download <download>` tarball with the
signature from `official website <http://pyderasn.cypherpunks.ru/>`__::
- $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.7.tar.xz
- $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-7.7.tar.xz.sig
- $ gpg --verify pyderasn-7.7.tar.xz.sig pyderasn-7.7.tar.xz
- $ xz --decompress --stdout pyderasn-7.7.tar.xz | tar xf -
- $ cd pyderasn-7.7
+ $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.0.tar.xz
+ $ [fetch|wget] http://pyderasn.cypherpunks.ru/pyderasn-8.0.tar.xz.sig
+ $ gpg --verify pyderasn-8.0.tar.xz.sig pyderasn-8.0.tar.xz
+ $ xz --decompress --stdout pyderasn-8.0.tar.xz | tar xf -
+ $ cd pyderasn-8.0
$ python setup.py install
# or copy pyderasn.py (+six.py, possibly termcolor.py) to your PYTHONPATH
You could use pip (**no** OpenPGP authentication is performed!) with PyPI::
$ cat > requirements.txt <<EOF
- pyderasn==7.7 --hash=sha256:TO-BE-FILLED
+ pyderasn==8.0 --hash=sha256:TO-BE-FILLED
six==1.14.0 --hash=sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a
EOF
$ pip install --requirement requirements.txt
def colored(what, *args, **kwargs):
return what
-__version__ = "7.7"
+__version__ = "8.0"
__all__ = (
"agg_octet_string",
.. warning::
- Pay attention that UTCTime can not hold full year, so all years
- having < 50 years are treated as 20xx, 19xx otherwise, according
- to X.509 recommendation.
+ Only **naive** ``datetime`` objects are supported.
+ Library assumes that all work is done in UTC.
.. warning::
- No strict validation of UTC offsets are made, but very crude:
+ Pay attention that ``UTCTime`` can not hold full year, so all years
+ having < 50 years are treated as 20xx, 19xx otherwise, according to
+ X.509 recommendation. Use ``GeneralizedTime`` instead for
+ removing ambiguity.
+
+ .. warning::
+
+ No strict validation of UTC offsets are made (only applicable to
+ **BER**), but very crude:
* minutes are not exceeding 60
* offset value is not exceeding 14 hours
if isinstance(value, self.__class__):
return value._value, None
if value.__class__ == datetime:
+ if value.tzinfo is not None:
+ raise ValueError("only naive datetime supported")
return self._dt_sanitize(value), None
raise InvalidValueType((self.__class__, datetime))
.. warning::
- Only microsecond fractions are supported in DER encoding.
- :py:exc:`pyderasn.DecodeError` will be raised during decoding of
- higher precision values.
+ Only **naive** datetime objects are supported.
+ Library assumes that all work is done in UTC.
.. warning::
- BER encoded data can loss information (accuracy) during decoding
- because of float transformations.
+ Only **microsecond** fractions are supported in DER encoding.
+ :py:exc:`pyderasn.DecodeError` will be raised during decoding of
+ higher precision values.
.. warning::
- Local times (without explicit timezone specification) are treated
- as UTC one, no transformations are made.
+ **BER** encoded data can loss information (accuracy) during
+ decoding because of float transformations.
.. warning::
- Zero year is unsupported.
+ **Zero** year is unsupported.
"""
__slots__ = ()
tag_default = tag_encode(24)
from time import time
from unittest import TestCase
+from dateutil.tz import UTC
from hypothesis import assume
from hypothesis import given
from hypothesis import settings
with self.assertRaises(DecodeError):
GeneralizedTime(data)
+ def test_aware(self):
+ with assertRaisesRegex(self, ValueError, "only naive"):
+ GeneralizedTime(datetime(2000, 1, 1, 1, tzinfo=UTC))
+
class TestUTCTime(TimeMixin, CommonMixin, TestCase):
base_klass = UTCTime
junk
)
+ def test_aware(self):
+ with assertRaisesRegex(self, ValueError, "only naive"):
+ UTCTime(datetime(2000, 1, 1, 1, tzinfo=UTC))
+
@composite
def tlv_value_strategy(draw):