piermesh/docs/Cryptography/WhaleSong.md

118 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Diffie hellman ephemeral
Fernet based encryption
==========================
### *class* Cryptography.WhaleSong.DHEFern(cache, nodeNickname, cLog)
#### cLog
Method reference to run.Node.cLog so we can log to the ui from here
#### loadedParams
In memory representations of cryptography parameters
* **Type:**
dict
#### loadedKeys
In memory representations of cryptography keys
* **Type:**
dict
#### nodeNickname
Name of node for isolating configs when running multiple nodes
* **Type:**
str
#### cache
Daisy cache for use in storing cryptography information
* **Type:**
Components.daisy.Cache
#### publicKey
Public key for node
#### privateKey
Private key for node
#### checkInMem(store: str, nodeID: str)
Check if parameters or keys are loaded for node of nodeID
* **Parameters:**
**store** (*str*) Whether to check loaded keys or parameters
#### decrypt(data, nodeID: str)
Decrypt bytes and return either str or dict (TODO: Check whether to msgpack load)
#### encrypt(data, nodeID: str, isDict: bool = True)
Do Fernet encryption
data
: Either bytes or dict to encrypt
isDict: bool
: Whether data is a dictionary
#### genKeyPair(paramsOverride=False, setSelf: bool = True)
Generate public and private keys from self.params (TODO: Gen from passed params)
paramsOverride
: False or parameters to use (TODO)
setSelf: bool
: Whether to set self.privateKey and self.publicKey
#### genParams()
Generate Diffie Hellman parameters
#### getParamsBytes()
Get bytes encoded from self.parameters (TODO: Encode from store)
#### getRecord(store: str, key: str)
Get record from store: store with key: key
#### getSalt()
Get random salt
#### initStore(store: str)
Initialize store: store
#### keyDerive(pubKey: bytes, salt: bytes, nodeID: str, params: bytes)
Derive shared key using Diffie Hellman
pubKey: bytes
: Public key
nodeID: str
: PierMesh node ID
params: bytes
: Encryption parameters
#### loadParamBytes(pemBytes: bytes)
Load parameters to self.params from given bytes (TODO: Load from store)
#### loadRecordToMem(store: str, nodeID: str)
Load record of nodeID from store to either keys or pameters