diff options
author | Ilya Etingof <etingof@gmail.com> | 2017-01-23 10:26:16 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2017-01-23 10:26:16 +0100 |
commit | ebb8da508c25a6523bd684e4ee2e76ddcc6cde4d (patch) | |
tree | 9e0610e644f45bdb9988b5caf8ddf98c46ee9842 | |
parent | e5da7182b23c6152945d391dfa2c7fe2b80f12a8 (diff) | |
download | pyasn1-git-ebb8da508c25a6523bd684e4ee2e76ddcc6cde4d.tar.gz |
docstrings for encoders
-rw-r--r-- | doc/source/docs/api-reference.rst | 10 | ||||
-rw-r--r-- | doc/source/docs/codec/ber/contents.rst | 5 | ||||
-rw-r--r-- | doc/source/docs/codec/cer/contents.rst | 5 | ||||
-rw-r--r-- | doc/source/docs/codec/der/contents.rst | 5 | ||||
-rw-r--r-- | pyasn1/codec/ber/encoder.py | 18 | ||||
-rw-r--r-- | pyasn1/codec/cer/encoder.py | 15 | ||||
-rw-r--r-- | pyasn1/codec/der/encoder.py | 16 |
7 files changed, 71 insertions, 3 deletions
diff --git a/doc/source/docs/api-reference.rst b/doc/source/docs/api-reference.rst index 239aed6..1a9466b 100644 --- a/doc/source/docs/api-reference.rst +++ b/doc/source/docs/api-reference.rst @@ -12,3 +12,13 @@ ASN.1 types :maxdepth: 2 /docs/type/univ/contents + +Serialization codecs +-------------------- + +.. toctree:: + :maxdepth: 2 + + /docs/codec/ber/contents + /docs/codec/cer/contents + /docs/codec/der/contents diff --git a/doc/source/docs/codec/ber/contents.rst b/doc/source/docs/codec/ber/contents.rst new file mode 100644 index 0000000..cd434b6 --- /dev/null +++ b/doc/source/docs/codec/ber/contents.rst @@ -0,0 +1,5 @@ + +Basic Encoding Rules +-------------------- + +.. autofunction:: pyasn1.codec.ber.encoder.encode(value, defMode=True, maxChunkSize=0) diff --git a/doc/source/docs/codec/cer/contents.rst b/doc/source/docs/codec/cer/contents.rst new file mode 100644 index 0000000..599b9ae --- /dev/null +++ b/doc/source/docs/codec/cer/contents.rst @@ -0,0 +1,5 @@ + +Canonical Encoding Rules +------------------------ + +.. autofunction:: pyasn1.codec.cer.encoder.encode(value, defMode=True, maxChunkSize=0) diff --git a/doc/source/docs/codec/der/contents.rst b/doc/source/docs/codec/der/contents.rst new file mode 100644 index 0000000..a80a116 --- /dev/null +++ b/doc/source/docs/codec/der/contents.rst @@ -0,0 +1,5 @@ + +Distinguished Encoding Rules +---------------------------- + +.. autofunction:: pyasn1.codec.der.encoder.encode(value, defMode=True, maxChunkSize=0) diff --git a/pyasn1/codec/ber/encoder.py b/pyasn1/codec/ber/encoder.py index 0e5cf8d..905bdb1 100644 --- a/pyasn1/codec/ber/encoder.py +++ b/pyasn1/codec/ber/encoder.py @@ -168,7 +168,7 @@ class OctetStringEncoder(AbstractItemEncoder): if not v: break substrate = substrate + encodeFun(v, defMode, maxChunkSize) - pos = pos + maxChunkSize + pos += maxChunkSize return substrate, 1 @@ -475,5 +475,19 @@ class Encoder(object): 'built %s octets of substrate: %s\nencoder completed' % (len(substrate), debug.hexdump(substrate))) return substrate - +#: Turns ASN.1 object into BER octet stream. +#: +#: Takes any ASN.1 object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: walks all its components recursively and produces a BER octet stream. +#: +#: Parameters +#: ---------- +# value: any pyasn1 type object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: A pyasn1 type object to encode +#: +#: defMode: :py:class:`bool` +#: If `False`, produces indefinite length encoding +#: +#: maxChunkSize: :py:class:`int` +#: Maximum chunk size in chunked encoding mode (0 denotes unlimited chunk size) encode = Encoder(tagMap, typeMap) diff --git a/pyasn1/codec/cer/encoder.py b/pyasn1/codec/cer/encoder.py index 92fbb0f..70b7570 100644 --- a/pyasn1/codec/cer/encoder.py +++ b/pyasn1/codec/cer/encoder.py @@ -142,6 +142,21 @@ class Encoder(encoder.Encoder): return encoder.Encoder.__call__(self, client, defMode, maxChunkSize) +#: Turns ASN.1 object into CER octet stream. +#: +#: Takes any ASN.1 object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: walks all its components recursively and produces a CER octet stream. +#: +#: Parameters +#: ---------- +# value: any pyasn1 type object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: A pyasn1 type object to encode +#: +#: defMode: :py:class:`bool` +#: If `False`, produces indefinite length encoding +#: +#: maxChunkSize: :py:class:`int` +#: Maximum chunk size in chunked encoding mode (0 denotes unlimited chunk size) encode = Encoder(tagMap, typeMap) # EncoderFactory queries class instance and builds a map of tags -> encoders diff --git a/pyasn1/codec/der/encoder.py b/pyasn1/codec/der/encoder.py index 3316bc9..552206d 100644 --- a/pyasn1/codec/der/encoder.py +++ b/pyasn1/codec/der/encoder.py @@ -37,5 +37,19 @@ class Encoder(encoder.Encoder): raise error.PyAsn1Error('DER forbids indefinite length mode') return encoder.Encoder.__call__(self, client, defMode, maxChunkSize) - +#: Turns ASN.1 object into DER octet stream. +#: +#: Takes any ASN.1 object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: walks all its components recursively and produces a DER octet stream. +#: +#: Parameters +#: ---------- +# value: any pyasn1 type object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) +#: A pyasn1 type object to encode +#: +#: defMode: :py:class:`bool` +#: If `False`, produces indefinite length encoding +#: +#: maxChunkSize: :py:class:`int` +#: Maximum chunk size in chunked encoding mode (0 denotes unlimited chunk size) encode = Encoder(tagMap, typeMap) |