1JOSEPY(1)                           josepy                           JOSEPY(1)
2
3
4

NAME

6       josepy - josepy Documentation
7
8       Javascript Object Signing and Encryption (JOSE).
9
10       This  package  is a Python implementation of the standards developed by
11       IETF Javascript Object Signing and Encryption (Active WG), in  particu‐
12       lar the following RFCs:
13
14       · JSON Web Algorithms (JWA)
15
16       · JSON Web Key (JWK)
17
18       · JSON Web Signature (JWS)
19
20       Originally developed as part of the ACME protocol implementation.
21

JOSE BASE64

23       JOSE Base64 is defined as:
24
25          · URL-safe Base64
26
27          · padding stripped
28
29       josepy.b64.b64decode(data)
30              JOSE Base64 decode.
31
32              Parameters
33                     data  (bytes  or unicode) -- Base64 string to be decoded.
34                     If it's unicode, then only ASCII characters are allowed.
35
36              Returns
37                     Decoded data.
38
39              Return type
40                     bytes
41
42              Raises
43
44                     · TypeError -- if input is of incorrect type
45
46                     · ValueError -- if input is unicode with non-ASCII  char‐
47                       acters
48
49       josepy.b64.b64encode(data)
50              JOSE Base64 encode.
51
52              Parameters
53                     data (bytes) -- Data to be encoded.
54
55              Returns
56                     JOSE Base64 string.
57
58              Return type
59                     bytes
60
61              Raises TypeError -- if data is of incorrect type
62

ERRORS

64       JOSE errors.
65
66       exception josepy.errors.DeserializationError
67              Bases: josepy.errors.Error
68
69              JSON deserialization error.
70
71       exception josepy.errors.Error
72              Bases: Exception
73
74              Generic JOSE Error.
75
76       exception josepy.errors.SerializationError
77              Bases: josepy.errors.Error
78
79              JSON serialization error.
80
81       exception josepy.errors.UnrecognizedTypeError(typ, jobj)
82              Bases: josepy.errors.DeserializationError
83
84              Unrecognized type error.
85
86              Variables
87
88                     · typ (str) -- The unrecognized type of the JSON object.
89
90                     · jobj -- Full JSON object.
91

INTERFACES

93       JOSE interfaces.
94
95       class josepy.interfaces.JSONDeSerializable
96              Bases: object
97
98              Interface for (de)serializable JSON objects.
99
100              Please recall, that standard Python library implements json.JSO‐
101              NEncoder and json.JSONDecoder that perform translations based on
102              respective  conversion tables that look pretty much like the one
103              below (for complete tables see relevant Python documentation):
104
105                                     ┌───────┬────────┐
106                                     │JSON   │ Python │
107                                     ├───────┼────────┤
108                                     │object │ dict   │
109                                     ├───────┼────────┤
110                                     │...    │ ...    │
111                                     └───────┴────────┘
112
113              While the above conversion table is about  translation  of  JSON
114              documents    to/from    the    basic    Python    types    only,
115              JSONDeSerializable introduces the following two concepts:
116
117                 serialization
118                        Turning an arbitrary Python object into Python  object
119                        that can be encoded into a JSON document. Full serial‐
120                        ization produces a  Python  object  composed  of  only
121                        basic  types as required by the conversion table. Par‐
122                        tial serialization (accomplished by to_partial_json())
123                        produces a Python object that might also be built from
124                        other JSONDeSerializable objects.
125
126                 deserialization
127                        Turning a decoded Python object  (necessarily  one  of
128                        the  basic  types as required by the conversion table)
129                        into an arbitrary Python object.
130
131              Serialization produces serialized object ("partially  serialized
132              object"  or "fully serialized object" for partial and full seri‐
133              alization respectively) and deserialization  produces  deserial‐
134              ized object, both usually denoted in the source code as jobj.
135
136              Wording  in the official Python documentation might be confusing
137              after reading the above, but in the light of those  definitions,
138              one  can view json.JSONDecoder.decode() as decoder and deserial‐
139              izer of basic types, json.JSONEncoder.default() as serializer of
140              basic   types,   json.JSONEncoder.encode()   as  serializer  and
141              encoder of basic types.
142
143              One could extend json to support arbitrary object (de)serializa‐
144              tion either by:
145
146                 · overriding   json.JSONDecoder.decode()   and   json.JSONEn‐
147                   coder.default() in subclasses
148
149                 · or passing object_hook argument (or  object_hook_pairs)  to
150                   json.load()/json.loads()    or    default    argument   for
151                   json.dump()/json.dumps().
152
153              Interestingly, default is required to perform only partial seri‐
154              alization,  as json.dumps() applies default recursively. This is
155              the idea behind making to_partial_json()  produce  only  partial
156              serialization,  while  providing  custom json_dumps() that dumps
157              with default set to json_dump_default().
158
159              To make further documentation a bit more concrete, please,  con‐
160              sider the following imaginatory implementation example:
161
162                 class Foo(JSONDeSerializable):
163                     def to_partial_json(self):
164                         return 'foo'
165
166                     @classmethod
167                     def from_json(cls, jobj):
168                         return Foo()
169
170                 class Bar(JSONDeSerializable):
171                     def to_partial_json(self):
172                         return [Foo(), Foo()]
173
174                     @classmethod
175                     def from_json(cls, jobj):
176                         return Bar()
177
178              classmethod from_json(jobj)
179                     Deserialize a decoded JSON document.
180
181                     Parameters
182                            jobj  --  Python  object,  composed  of only other
183                            basic data types, as decoded from  JSON  document.
184                            Not   necessarily  dict  (as  decoded  from  "JSON
185                            object" document).
186
187                     Raises josepy.errors.DeserializationError -- if  decoding
188                            was unsuccessful, e.g. in case of unparseable X509
189                            certificate,  or  wrong  padding  in  JOSE  base64
190                            encoded string, etc.
191
192              classmethod json_dump_default(python_object)
193                     Serialize Python object.
194
195                     This  function  is  meant  to  be  passed  as  default to
196                     json.dump()     or      json.dumps().      They      call
197                     default(python_object)  only  for non-basic Python types,
198                     so  this  function  necessarily   raises   TypeError   if
199                     python_object is not an instance of IJSONSerializable.
200
201                     Please read the class docstring for more information.
202
203              json_dumps(**kwargs)
204                     Dump to JSON string using proper serializer.
205
206                     Returns
207                            JSON document string.
208
209                     Return type
210                            str
211
212              json_dumps_pretty()
213                     Dump the object to pretty JSON document string.
214
215                     Return type
216                            str
217
218              classmethod json_loads(json_string)
219                     Deserialize from JSON document string.
220
221              to_json()
222                     Fully serialize.
223
224                     Again, following the example from before, full serializa‐
225                     tion means the following:
226
227                        assert Bar().to_json() == ['foo', 'foo']
228
229                     Raises josepy.errors.SerializationError -- in case of any
230                            serialization error.
231
232                     Returns
233                            Fully serialized object.
234
235              to_partial_json()
236                     Partially serialize.
237
238                     Following  the  example,  partial serialization means the
239                     following:
240
241                        assert isinstance(Bar().to_partial_json()[0], Foo)
242                        assert isinstance(Bar().to_partial_json()[1], Foo)
243
244                        # in particular...
245                        assert Bar().to_partial_json() != ['foo', 'foo']
246
247                     Raises josepy.errors.SerializationError -- in case of any
248                            serialization error.
249
250                     Returns
251                            Partially serializable object.
252

JSON UTILITIES

254       JSON (de)serialization framework.
255
256       The  framework  presented here is somewhat based on Go's "json" package
257       (especially the omitempty functionality).
258
259       class josepy.json_util.Field(json_name, default=None,  omitempty=False,
260       decoder=None, encoder=None)
261              Bases: object
262
263              JSON object field.
264
265              Field is meant to be used together with JSONObjectWithFields.
266
267              encoder (decoder) is a callable that accepts a single parameter,
268              i.e. a value to be encoded (decoded), and returns the serialized
269              (deserialized)  value. In case of errors it should raise Serial‐
270              izationError (DeserializationError).
271
272              Note, that decoder should perform partial serialization only.
273
274              Variables
275
276                     · json_name (str) -- Name of the field  when  encoded  to
277                       JSON.
278
279                     · default -- Default value (used when not present in JSON
280                       object).
281
282                     · omitempty (bool) -- If True  and  the  field  value  is
283                       empty,  then  it will not be included in the serialized
284                       JSON object, and default will be used for  deserializa‐
285                       tion.  Otherwise,  if  False,  field  is  considered as
286                       required, value will always be included in the  serial‐
287                       ized  JSON  objected,  and it must also be present when
288                       deserializing.
289
290              classmethod _empty(value)
291                     Is the provided value considered "empty" for this field?
292
293                     This is useful for subclasses that might want to override
294                     the  definition of being empty, e.g. for some more exotic
295                     data types.
296
297              decode(value)
298                     Decode a value, optionally with context JSON object.
299
300              decoder(fdec)
301                     Descriptor to change the decoder on JSON object field.
302
303              classmethod default_decoder(value)
304                     Default decoder.
305
306                     Recursively   deserialize   into   immutable   types    (
307                     josepy.util.frozendict instead of dict(), tuple() instead
308                     of list()).
309
310              classmethod default_encoder(value)
311                     Default (passthrough) encoder.
312
313              encode(value)
314                     Encode a value, optionally with context JSON object.
315
316              encoder(fenc)
317                     Descriptor to change the encoder on JSON object field.
318
319              omit(value)
320                     Omit the value in output?
321
322       class josepy.json_util.JSONObjectWithFields(**kwargs)
323              Bases: josepy.util.ImmutableMap, josepy.interfaces.JSONDeSerial‐
324              izable
325
326              JSON object with fields.
327
328              Example:
329
330                 class Foo(JSONObjectWithFields):
331                     bar = Field('Bar')
332                     empty = Field('Empty', omitempty=True)
333
334                     @bar.encoder
335                     def bar(value):
336                         return value + 'bar'
337
338                     @bar.decoder
339                     def bar(value):
340                         if not value.endswith('bar'):
341                             raise errors.DeserializationError('No bar suffix!')
342                         return value[:-3]
343
344                 assert Foo(bar='baz').to_partial_json() == {'Bar': 'bazbar'}
345                 assert Foo.from_json({'Bar': 'bazbar'}) == Foo(bar='baz')
346                 assert (Foo.from_json({'Bar': 'bazbar', 'Empty': '!'})
347                         == Foo(bar='baz', empty='!'))
348                 assert Foo(bar='baz').bar == 'baz'
349
350              classmethod _defaults()
351                     Get default fields values.
352
353              encode(name)
354                     Encode a single field.
355
356                     Parameters
357                            name (str) -- Name of the field to be encoded.
358
359                     Raises
360
361                            · errors.SerializationError  -- if field cannot be
362                              serialized
363
364                            · errors.Error -- if field could not be found
365
366              classmethod fields_from_json(jobj)
367                     Deserialize fields from JSON.
368
369              fields_to_partial_json()
370                     Serialize fields to JSON.
371
372              classmethod from_json(jobj)
373                     Deserialize a decoded JSON document.
374
375                     Parameters
376                            jobj -- Python  object,  composed  of  only  other
377                            basic  data  types, as decoded from JSON document.
378                            Not  necessarily  dict  (as  decoded  from   "JSON
379                            object" document).
380
381                     Raises josepy.errors.DeserializationError  -- if decoding
382                            was unsuccessful, e.g. in case of unparseable X509
383                            certificate,  or  wrong  padding  in  JOSE  base64
384                            encoded string, etc.
385
386              to_partial_json()
387                     Partially serialize.
388
389                     Following the example, partial  serialization  means  the
390                     following:
391
392                        assert isinstance(Bar().to_partial_json()[0], Foo)
393                        assert isinstance(Bar().to_partial_json()[1], Foo)
394
395                        # in particular...
396                        assert Bar().to_partial_json() != ['foo', 'foo']
397
398                     Raises josepy.errors.SerializationError -- in case of any
399                            serialization error.
400
401                     Returns
402                            Partially serializable object.
403
404       class josepy.json_util.JSONObjectWithFieldsMeta
405              Bases: abc.ABCMeta
406
407              Metaclass for JSONObjectWithFields and its subclasses.
408
409              It makes sure that, for any class cls with __metaclass__ set  to
410              JSONObjectWithFieldsMeta:
411
412              1. All fields (attributes of type Field) in the class definition
413                 are moved to the cls._fields dictionary, where keys are field
414                 attribute names and values are fields themselves.
415
416              2. cls.__slots__  is extended by all field attribute names (i.e.
417                 not Field.json_name). Original cls.__slots__  are  stored  in
418                 cls._orig_slots.
419
420              In  a  consequence,  for  a  field  attribute  name  some_field,
421              cls.some_field will be a slot descriptor and not an instance  of
422              Field. For example:
423
424                 some_field = Field('someField', default=())
425
426                 class Foo(object):
427                     __metaclass__ = JSONObjectWithFieldsMeta
428                     __slots__ = ('baz',)
429                     some_field = some_field
430
431                 assert Foo.__slots__ == ('some_field', 'baz')
432                 assert Foo._orig_slots == ()
433                 assert Foo.some_field is not Field
434
435                 assert Foo._fields.keys() == ['some_field']
436                 assert Foo._fields['some_field'] is some_field
437
438              As   an   implementation  note,  this  metaclass  inherits  from
439              abc.ABCMeta (and not the usual type) to mitigate  the  metaclass
440              conflict   (ImmutableMap   and  JSONDeSerializable,  parents  of
441              JSONObjectWithFields, use abc.ABCMeta as its metaclass).
442
443       class josepy.json_util.TypedJSONObjectWithFields(**kwargs)
444              Bases: josepy.json_util.JSONObjectWithFields
445
446              JSON object with type.
447
448              classmethod from_json(jobj)
449                     Deserialize ACME object from valid JSON object.
450
451                     Raises josepy.errors.UnrecognizedTypeError -- if type  of
452                            the ACME object has not been registered.
453
454              classmethod get_type_cls(jobj)
455                     Get the registered class for jobj.
456
457              classmethod register(type_cls, typ=None)
458                     Register class for JSON deserialization.
459
460              to_partial_json()
461                     Get JSON serializable object.
462
463                     Returns
464                            Serializable  JSON  object representing ACME typed
465                            object.   validate()  will  almost  certainly  not
466                            work,  due  to  reasons explained in josepy.inter‐
467                            faces.IJSONSerializable.
468
469                     Return type
470                            dict
471
472       josepy.json_util.decode_b64jose(data, size=None, minimum=False)
473              Decode JOSE Base-64 field.
474
475              Parameters
476
477                     · data (unicode) --
478
479                     · size (int) -- Required length (after decoding).
480
481                     · minimum (bool) -- If True, then size will be treated as
482                       minimum required length, as opposed to exact equality.
483
484              Return type
485                     bytes
486
487       josepy.json_util.decode_cert(b64der)
488              Decode JOSE Base-64 DER-encoded certificate.
489
490              Parameters
491                     b64der (unicode) --
492
493              Return type
494                     OpenSSL.crypto.X509 wrapped in ComparableX509
495
496       josepy.json_util.decode_csr(b64der)
497              Decode JOSE Base-64 DER-encoded CSR.
498
499              Parameters
500                     b64der (unicode) --
501
502              Return type
503                     OpenSSL.crypto.X509Req wrapped in ComparableX509
504
505       josepy.json_util.decode_hex16(value, size=None, minimum=False)
506              Decode hexlified field.
507
508              Parameters
509
510                     · value (unicode) --
511
512                     · size (int) -- Required length (after decoding).
513
514                     · minimum (bool) -- If True, then size will be treated as
515                       minimum required length, as opposed to exact equality.
516
517              Return type
518                     bytes
519
520       josepy.json_util.encode_b64jose(data)
521              Encode JOSE Base-64 field.
522
523              Parameters
524                     data (bytes) --
525
526              Return type
527                     unicode
528
529       josepy.json_util.encode_cert(cert)
530              Encode certificate as JOSE Base-64 DER.
531
532              Return type
533                     unicode
534
535       josepy.json_util.encode_csr(csr)
536              Encode CSR as JOSE Base-64 DER.
537
538              Return type
539                     unicode
540
541       josepy.json_util.encode_hex16(value)
542              Hexlify.
543
544              Parameters
545                     value (bytes) --
546
547              Return type
548                     unicode
549

JSON WEB ALGORITHMS

551       JSON Web Algorithms.
552
553       https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
554
555       class josepy.jwa.JWA
556              Bases: josepy.interfaces.JSONDeSerializable
557
558              JSON Web Algorithm.
559
560       class josepy.jwa.JWASignature(name)
561              Bases: josepy.jwa.JWA, collections.abc.Hashable
562
563              Base class for JSON Web Signature Algorithms.
564
565              classmethod from_json(jobj)
566                     Deserialize a decoded JSON document.
567
568                     Parameters
569                            jobj -- Python  object,  composed  of  only  other
570                            basic  data  types, as decoded from JSON document.
571                            Not  necessarily  dict  (as  decoded  from   "JSON
572                            object" document).
573
574                     Raises josepy.errors.DeserializationError  -- if decoding
575                            was unsuccessful, e.g. in case of unparseable X509
576                            certificate,  or  wrong  padding  in  JOSE  base64
577                            encoded string, etc.
578
579              classmethod register(signature_cls)
580                     Register class for JSON deserialization.
581
582              sign(key, msg)
583                     Sign the msg using key.
584
585              to_partial_json()
586                     Partially serialize.
587
588                     Following the example, partial  serialization  means  the
589                     following:
590
591                        assert isinstance(Bar().to_partial_json()[0], Foo)
592                        assert isinstance(Bar().to_partial_json()[1], Foo)
593
594                        # in particular...
595                        assert Bar().to_partial_json() != ['foo', 'foo']
596
597                     Raises josepy.errors.SerializationError -- in case of any
598                            serialization error.
599
600                     Returns
601                            Partially serializable object.
602
603              verify(key, msg, sig)
604                     Verify the msg and sig using key.
605
606       class josepy.jwa._JWAES(name)
607              Bases: josepy.jwa.JWASignature
608
609              sign(key, msg)
610                     Sign the msg using key.
611
612              verify(key, msg, sig)
613                     Verify the msg and sig using key.
614
615       class josepy.jwa._JWAHS(name, hash_)
616              Bases: josepy.jwa.JWASignature
617
618              kty    alias of josepy.jwk.JWKOct
619
620              sign(key, msg)
621                     Sign the msg using key.
622
623              verify(key, msg, sig)
624                     Verify the msg and sig using key.
625
626       class josepy.jwa._JWAPS(name, hash_)
627              Bases: josepy.jwa._JWARSA, josepy.jwa.JWASignature
628
629       class josepy.jwa._JWARS(name, hash_)
630              Bases: josepy.jwa._JWARSA, josepy.jwa.JWASignature
631

JSON WEB KEY

633       JSON Web Key.
634
635       class josepy.jwk.JWK(**kwargs)
636              Bases: josepy.json_util.TypedJSONObjectWithFields
637
638              JSON Web Key.
639
640              classmethod load(data, password=None, backend=None)
641                     Load serialized key as JWK.
642
643                     Parameters
644
645                            · data (str) -- Public or private  key  serialized
646                              as PEM or DER.
647
648                            · password (str) -- Optional password.
649
650                            · backend  -- A PEMSerializationBackend and DERSe‐
651                              rializationBackend provider.
652
653                     Raises errors.Error  --  if  unable  to  deserialize,  or
654                            unsupported JWK algorithm
655
656                     Returns
657                            JWK of an appropriate type.
658
659                     Return type
660                            JWK
661
662              public_key()
663                     Generate JWK with public key.
664
665                     For symmetric cryptosystems, this would return self.
666
667              thumbprint(hash_function=<class      'cryptography.hazmat.primi‐
668              tives.hashes.SHA256'>)
669                     Compute JWK Thumbprint.
670
671                     https://tools.ietf.org/html/rfc7638
672
673                     Returns
674                            bytes
675
676       class josepy.jwk.JWKES(**kwargs)
677              Bases: josepy.jwk.JWK
678
679              ES JWK.
680
681              WARNING:
682                 This is not yet implemented!
683
684              classmethod fields_from_json(jobj)
685                     Deserialize fields from JSON.
686
687              fields_to_partial_json()
688                     Serialize fields to JSON.
689
690              public_key()
691                     Generate JWK with public key.
692
693                     For symmetric cryptosystems, this would return self.
694
695       class josepy.jwk.JWKOct(**kwargs)
696              Bases: josepy.jwk.JWK
697
698              Symmetric JWK.
699
700              classmethod fields_from_json(jobj)
701                     Deserialize fields from JSON.
702
703              fields_to_partial_json()
704                     Serialize fields to JSON.
705
706              public_key()
707                     Generate JWK with public key.
708
709                     For symmetric cryptosystems, this would return self.
710
711       class josepy.jwk.JWKRSA(*args, **kwargs)
712              Bases: josepy.jwk.JWK
713
714              RSA JWK.
715
716              Variables
717                     key -- RSAPrivateKey or RSAPublicKey wrapped in  Compara‐
718                     bleRSAKey
719
720              classmethod _decode_param(data)
721                     Decode Base64urlUInt.
722
723              classmethod _encode_param(data)
724                     Encode Base64urlUInt.
725
726                     Return type
727                            unicode
728
729              classmethod fields_from_json(jobj)
730                     Deserialize fields from JSON.
731
732              fields_to_partial_json()
733                     Serialize fields to JSON.
734
735              public_key()
736                     Generate JWK with public key.
737
738                     For symmetric cryptosystems, this would return self.
739

JSON WEB SIGNATURE

741       JSON Web Signature.
742
743       class josepy.jws.CLI
744              Bases: object
745
746              JWS CLI.
747
748              classmethod run(args=None)
749                     Parse arguments and sign/verify.
750
751              classmethod sign(args)
752                     Sign.
753
754              classmethod verify(args)
755                     Verify.
756
757       class josepy.jws.Header(**kwargs)
758              Bases: josepy.json_util.JSONObjectWithFields
759
760              JOSE Header.
761
762              WARNING:
763                 This  class  supports  only Registered Header Parameter Names
764                 (as defined in section 4.1 of the protocol). If you need Pub‐
765                 lic  Header Parameter Names (4.2) or Private Header Parameter
766                 Names (4.3), you must subclass and override  from_json()  and
767                 to_partial_json() appropriately.
768
769              WARNING:
770                 This class does not support any extensions through the "crit"
771                 (Critical) Header Parameter  (4.1.11)  and  as  a  conforming
772                 implementation,  from_json()  treats  its  occurrence  as  an
773                 error. Please subclass if you seek for a different behaviour.
774
775              Variables
776
777                     · x5tS256 -- "x5t#S256"
778
779                     · typ (str) -- MIME Media Type, inc. MediaType.PREFIX.
780
781                     · cty (str) -- Content-Type, inc. MediaType.PREFIX.
782
783              find_key()
784                     Find key based on header.
785

TODO

787       Supports only "jwk" header parameter lookup.
788
789              Returns
790                     (Public) key found in the header.
791
792              Return type
793                     JWK
794
795              Raises josepy.errors.Error -- if key could not be found
796
797              not_omitted()
798                     Fields that would not be omitted in the JSON object.
799
800       class josepy.jws.JWS(**kwargs)
801              Bases: josepy.json_util.JSONObjectWithFields
802
803              JSON Web Signature.
804
805              Variables
806
807                     · payload (str) -- JWS Payload.
808
809                     · signature (str) -- JWS Signatures.
810
811              classmethod from_compact(compact)
812                     Compact deserialization.
813
814                     Parameters
815                            compact (bytes) --
816
817              classmethod from_json(jobj)
818                     Deserialize a decoded JSON document.
819
820                     Parameters
821                            jobj -- Python  object,  composed  of  only  other
822                            basic  data  types, as decoded from JSON document.
823                            Not  necessarily  dict  (as  decoded  from   "JSON
824                            object" document).
825
826                     Raises josepy.errors.DeserializationError  -- if decoding
827                            was unsuccessful, e.g. in case of unparseable X509
828                            certificate,  or  wrong  padding  in  JOSE  base64
829                            encoded string, etc.
830
831              classmethod sign(payload, **kwargs)
832                     Sign.
833
834              signature
835                     Get a singleton signature.
836
837                     Return type
838                            JWS.signature_cls
839
840              signature_cls
841                     alias of Signature
842
843              to_compact()
844                     Compact serialization.
845
846                     Return type
847                            bytes
848
849              to_partial_json(flat=True)
850                     Partially serialize.
851
852                     Following the example, partial  serialization  means  the
853                     following:
854
855                        assert isinstance(Bar().to_partial_json()[0], Foo)
856                        assert isinstance(Bar().to_partial_json()[1], Foo)
857
858                        # in particular...
859                        assert Bar().to_partial_json() != ['foo', 'foo']
860
861                     Raises josepy.errors.SerializationError -- in case of any
862                            serialization error.
863
864                     Returns
865                            Partially serializable object.
866
867              verify(key=None)
868                     Verify.
869
870       class josepy.jws.MediaType
871              Bases: object
872
873              MediaType field encoder/decoder.
874
875              classmethod decode(value)
876                     Decoder.
877
878              classmethod encode(value)
879                     Encoder.
880
881       class josepy.jws.Signature(**kwargs)
882              Bases: josepy.json_util.JSONObjectWithFields
883
884              JWS Signature.
885
886              Variables
887
888                     · combined -- Combined Header (protected and unprotected,
889                       Header).
890
891                     · protected  (unicode)  --  JWS  protected  header  (Jose
892                       Base-64 decoded).
893
894                     · header -- JWS Unprotected Header (Header).
895
896                     · signature (str) -- The signature.
897
898              classmethod fields_from_json(jobj)
899                     Deserialize fields from JSON.
900
901              fields_to_partial_json()
902                     Serialize fields to JSON.
903
904              header_cls
905                     alias of Header
906
907              classmethod  sign(payload,  key,  alg,  include_jwk=True,   pro‐
908              tect=frozenset(), **kwargs)
909                     Sign.
910
911                     Parameters
912                            key (JWK) -- Key for signature.
913
914              verify(payload, key=None)
915                     Verify.
916
917                     Parameters
918                            key (JWK) -- Key used for verification.
919

UTILITIES

921       JOSE utilities.
922
923       class josepy.util.ComparableKey(wrapped)
924              Bases: object
925
926              Comparable wrapper for cryptography keys.
927
928              See https://github.com/pyca/cryptography/issues/2122.
929
930              public_key()
931                     Get wrapped public key.
932
933       class josepy.util.ComparableRSAKey(wrapped)
934              Bases: josepy.util.ComparableKey
935
936              Wrapper for cryptography RSA keys.
937
938              Wraps around:
939
940              · RSAPrivateKey
941
942              · RSAPublicKey
943
944       class josepy.util.ComparableX509(wrapped)
945              Bases: object
946
947              Wrapper for OpenSSL.crypto.X509** objects that supports __eq__.
948
949              Variables
950                     wrapped -- Wrapped certificate or certificate request.
951
952              _dump(filetype=2)
953                     Dumps  the object into a buffer with the specified encod‐
954                     ing.
955
956                     Parameters
957                            filetype (int) -- The desired encoding. Should  be
958                            one        of        OpenSSL.crypto.FILETYPE_ASN1,
959                            OpenSSL.crypto.FILETYPE_PEM,                    or
960                            OpenSSL.crypto.FILETYPE_TEXT.
961
962                     Returns
963                            Encoded X509 object.
964
965                     Return type
966                            str
967
968       class josepy.util.ImmutableMap(**kwargs)
969              Bases: collections.abc.Mapping, collections.abc.Hashable
970
971              Immutable key to value mapping with attribute access.
972
973              update(**kwargs)
974                     Return updated map.
975
976       class josepy.util.abstractclassmethod(target)
977              Bases: classmethod
978
979              Descriptor for an abstract classmethod.
980
981              It augments the abc framework with an abstract classmethod. This
982              is implemented as abc.abstractclassmethod in the standard Python
983              library starting with version 3.2.
984
985              This  particular  implementation,  allegedly based on Python 3.3
986              source          code,          is          stolen           from
987              http://stackoverflow.com/questions/11217878/python-2-7-combine-abc-abstractmethod-and-classmethod.
988
989       class josepy.util.frozendict(*args, **kwargs)
990              Bases: collections.abc.Mapping, collections.abc.Hashable
991
992              Frozen dictionary.
993
994       · genindex
995
996       · modindex
997
998       · search
999

AUTHOR

1001       Let's Encrypt Project
1002
1004       2015-2017, Let's Encrypt Project
1005
1006
1007
1008
10091.1                              Feb 02, 2019                        JOSEPY(1)
Impressum