Skip to content

Architecture Principles

Daniel edited this page Feb 22, 2018 · 2 revisions

This page contains some loose principles that should guide the development of JOSESwift.

Modularity and Reusability

Logical independent components should be modular and promote reusability.

Example

Both JWS and JWE use the same compact serializer. The compact serializer does not need detailed information about the inner structure of these objects.

Exchangeability of Cryptographic Primitives

Cryptographic primitives should be replaceable.

Example

The crypto primitives of a JWS signer can be exchanged by replacing one source file.

Immutability

Objects are immutable. Properties of an object need to be set during initialization or have default values. Compute derived values as needed after initializing an object.

Example

The compact serialization of a JWS is derived from its immutable properties.

Where to do computing

Do computations needed to construct a valid object during initialization to ensure immutability.

Example

The signature of a JWS is computed during initialization. It is needed to construct a valid, immutable object.

Signatures are not validated when initializing a JWS from a serialization. Objects with an invalid signature are still syntactically correct objects.

Reasonable Defaults

Provide reasonable defaults additionally to full customizability.

Example

There should be a default signing algorithm so users only need to specify some data to construct a JWS. See #54 and #55.