X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=pyderasn.py;fp=pyderasn.py;h=516715a7f2e419a6d1070c03eee7f2c07bb1b895;hp=505f3baafac8516084242256bb12f2633f02ace0;hb=44e10c60d857ea5e631927ac4b23365cc3b80698;hpb=bba84f2f3b5fbc860f51cf76f2f504cb2aa8d899 diff --git a/pyderasn.py b/pyderasn.py index 505f3ba..516715a 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -1201,7 +1201,7 @@ except ImportError: # pragma: no cover def colored(what, *args, **kwargs): return what -__version__ = "7.7" +__version__ = "8.0" __all__ = ( "agg_octet_string", @@ -5080,13 +5080,20 @@ class UTCTime(VisibleString): .. 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 @@ -5213,6 +5220,8 @@ class UTCTime(VisibleString): 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)) @@ -5323,23 +5332,23 @@ class GeneralizedTime(UTCTime): .. 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)