]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - doc/examples.rst
Test code human readable OIDs
[pyderasn.git] / doc / examples.rst
index 667f0ab90a6caf3791173e12ea8a2277a63ed01e..953001a36c9c6b98c16f1ff512595c9533da043e 100644 (file)
@@ -177,7 +177,7 @@ We are ready to decode PayPal's certificate from Go `encoding/asn1
 <https://golang.org/pkg/encoding/asn1/>`__ test suite (assuming that
 it's DER encoded representation is already in ``raw`` variable)::
 
-    >>> crt, tail = Certificate().decode(raw)
+    >>> crt = Certificate().decod(raw)
     >>> crt
     Certificate SEQUENCE[tbsCertificate: TBSCertificate SEQUENCE[
         version: [0] EXPLICIT Version INTEGER v3 OPTIONAL;
@@ -194,13 +194,13 @@ As command line utility
 You can decode DER/BER files using command line abilities and get the
 same picture as above by executing::
 
-    % python -m pyderasn --schema tests.test_crts:Certificate path/to/file
+    $ python -m pyderasn --schema tests.test_crts:Certificate path/to/file
 
 If there is no schema for you file, then you can try parsing it without,
 but of course IMPLICIT tags will often make it impossible. But result is
 good enough for the certificate above::
 
-    % python -m pyderasn path/to/file
+    $ python -m pyderasn path/to/file
         0   [1,3,1604]  . >: SEQUENCE OF
         4   [1,3,1453]  . . >: SEQUENCE OF
         8   [0,0,   5]  . . . . >: [0] ANY
@@ -235,7 +235,7 @@ ___________________
 If you have got dictionaries with ObjectIdentifiers, like example one
 from ``tests/test_crts.py``::
 
-    some_oids = {
+    stroid2name = {
         "1.2.840.113549.1.1.1": "id-rsaEncryption",
         "1.2.840.113549.1.1.5": "id-sha1WithRSAEncryption",
         [...]
@@ -245,7 +245,7 @@ from ``tests/test_crts.py``::
 
 then you can pass it to pretty printer to see human readable OIDs::
 
-    % python -m pyderasn --oids tests.test_crts:some_oids path/to/file
+    $ python -m pyderasn --oids tests.test_crts:stroid2name path/to/file
     [...]
        37   [1,1,  11]  . . . . . . >: SET OF
        39   [1,1,   9]  . . . . . . . . >: SEQUENCE OF
@@ -269,7 +269,7 @@ names it is passing during the decode process. Each element has its own
 unique path inside the whole ASN.1 tree. You can print it out with
 ``--print-decode-path`` option::
 
-    % python -m pyderasn --schema path.to:Certificate --print-decode-path path/to/file
+    $ python -m pyderasn --schema path.to:Certificate --print-decode-path path/to/file
        0    [1,3,1604]  Certificate SEQUENCE []
        4    [1,3,1453]   . tbsCertificate: TBSCertificate SEQUENCE [tbsCertificate]
       10-2  [1,1,   1]   . . version: [0] EXPLICIT Version INTEGER v3 OPTIONAL [tbsCertificate:version]
@@ -290,7 +290,7 @@ unique path inside the whole ASN.1 tree. You can print it out with
 
 Now you can print only the specified tree, for example signature algorithm::
 
-    % python -m pyderasn --schema path.to:Certificate --decode-path-only tbsCertificate:signature path/to/file
+    $ python -m pyderasn --schema path.to:Certificate --decode-path-only tbsCertificate:signature path/to/file
       18    [1,1,  13]  AlgorithmIdentifier SEQUENCE
       20    [1,1,   9]   . algorithm: OBJECT IDENTIFIER 1.2.840.113549.1.1.5
       31    [0,0,   2]   . parameters: [UNIV 5] ANY OPTIONAL
@@ -301,14 +301,14 @@ Descriptive errors
 
 If you have bad DER/BER, then errors will show you where error occurred::
 
-    % python -m pyderasn --schema tests.test_crts:Certificate path/to/bad/file
+    $ python -m pyderasn --schema tests.test_crts:Certificate path/to/bad/file
     Traceback (most recent call last):
     [...]
     pyderasn.DecodeError: UTCTime (tbsCertificate:validity:notAfter:utcTime) (at 328) invalid UTCTime format
 
 ::
 
-    % python -m pyderasn path/to/bad/file
+    $ python -m pyderasn path/to/bad/file
     [...]
     pyderasn.DecodeError: UTCTime (0:SequenceOf:4:SequenceOf:1:UTCTime) (at 328) invalid UTCTime format
 
@@ -362,7 +362,7 @@ Let's create some simple self-signed X.509 certificate from the ground::
     tbs["validity"] = validity
 
     spki = SubjectPublicKeyInfo()
-    spki_algo_id = sign_algo_id.copy()
+    spki_algo_id = copy(sign_algo_id)
     spki_algo_id["algorithm"] = ObjectIdentifier("1.2.840.113549.1.1.1")
     spki["algorithm"] = spki_algo_id
     spki["subjectPublicKey"] = BitString(hexdec("".join((